diff --git a/package.json b/package.json index c7c0790a1d..6300589356 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packages/contracts" ], "resolutions": { - "viem": "^2.21.12", + "viem": "^2.21.55", "typescript": "^5.5.3" }, "devDependencies": { diff --git a/packages/bots/liquidator/package.json b/packages/bots/liquidator/package.json index 9630d1452c..821ee3fd83 100644 --- a/packages/bots/liquidator/package.json +++ b/packages/bots/liquidator/package.json @@ -34,7 +34,7 @@ "dotenv": "^16.4.5", "pino": "^9.2.0", "pino-pretty": "^11.2.1", - "viem": "^2.21.12" + "viem": "^2.21.55" }, "devDependencies": { "eslint": "^8", diff --git a/packages/bots/liquidator/src/index.ts b/packages/bots/liquidator/src/index.ts index 8eb40a169a..7a89c8e1c5 100644 --- a/packages/bots/liquidator/src/index.ts +++ b/packages/bots/liquidator/src/index.ts @@ -1,6 +1,6 @@ import { APIGatewayEvent, APIGatewayProxyResult, Context } from "aws-lambda"; import axios from "axios"; -import { createPublicClient, createWalletClient, fallback, Hex, http } from "viem"; +import { createWalletClient, fallback, Hex, http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { mode } from "viem/chains"; import { BotType } from "@ionicprotocol/sdk"; @@ -9,6 +9,7 @@ import config from "./config"; import { liquidatePositions } from "./liquidatePositions"; import { logger } from "./logger"; import { setUpSdk } from "./utils"; +import { createIonicPublicClient } from "./utils/client"; const HEARTBEAT_API_URL: any = process.env.UPTIME_LIQUIDATOR_API; @@ -22,10 +23,7 @@ if (typeof HEARTBEAT_API_URL === "undefined") { export const account = privateKeyToAccount(config.adminPrivateKey as Hex); -export const client = createPublicClient({ - chain: mode, - transport: fallback(config.rpcUrls.map((url) => http(url))), -}); +export const client = createIonicPublicClient(mode, config.rpcUrls); export const walletClient = createWalletClient({ account, diff --git a/packages/bots/liquidator/src/justSubmit.ts b/packages/bots/liquidator/src/justSubmit.ts index 5a37b8e3cb..0c15331390 100644 --- a/packages/bots/liquidator/src/justSubmit.ts +++ b/packages/bots/liquidator/src/justSubmit.ts @@ -1,30 +1,19 @@ import { Client, OpportunityParams } from "@pythnetwork/express-relay-evm-js"; import { ionicLiquidatorAbi } from "@ionicprotocol/sdk"; -import { - createPublicClient, - createWalletClient, - encodeAbiParameters, - encodeFunctionData, - fallback, - Hex, - http, -} from "viem"; +import { createWalletClient, encodeAbiParameters, encodeFunctionData, fallback, Hex, http } from "viem"; import { mode } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; import config from "./config"; import { logger } from "./logger"; import { setUpSdk } from "./utils"; +import { createIonicPublicClient } from "./utils/client"; (BigInt.prototype as any).toJSON = function () { return this.toString(); }; const account = privateKeyToAccount(config.adminPrivateKey as Hex); -const publicClient = createPublicClient({ - batch: { multicall: { wait: 16 } }, - chain: mode, - transport: fallback(config.rpcUrls.map((url) => http(url))), -}); +const publicClient = createIonicPublicClient(mode, config.rpcUrls); const walletClient = createWalletClient({ account, chain: mode, diff --git a/packages/bots/liquidator/src/runPythLiquidator.ts b/packages/bots/liquidator/src/runPythLiquidator.ts index 5d46fea54b..1dfadb547f 100644 --- a/packages/bots/liquidator/src/runPythLiquidator.ts +++ b/packages/bots/liquidator/src/runPythLiquidator.ts @@ -8,6 +8,7 @@ import { fallback, Hex, http, + type PublicClientConfig, } from "viem"; import { mode } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; @@ -26,11 +27,14 @@ const startTime = Math.floor(new Date().getTime() / 1000); }; const account = privateKeyToAccount(config.adminPrivateKey as Hex); -const publicClient = createPublicClient({ +const clientConfig: PublicClientConfig = { batch: { multicall: { wait: 16 } }, chain: mode, transport: fallback(config.rpcUrls.map((url) => http(url))), -}); + cacheTime: 4_000, + pollingInterval: 4_000, +}; +const publicClient = createPublicClient(clientConfig); const walletClient = createWalletClient({ account, chain: mode, diff --git a/packages/bots/liquidator/src/utils/client.ts b/packages/bots/liquidator/src/utils/client.ts new file mode 100644 index 0000000000..c44a73cc9b --- /dev/null +++ b/packages/bots/liquidator/src/utils/client.ts @@ -0,0 +1,13 @@ +import { Chain, createPublicClient, fallback, http, PublicClientConfig } from "viem"; + +export function createIonicPublicClient(chain: Chain, rpcUrls: string[]) { + const config: PublicClientConfig = { + chain, + transport: fallback(rpcUrls.map((url) => http(url))), + batch: { multicall: { wait: 16 } }, + cacheTime: 4_000, + pollingInterval: 4_000, + }; + + return createPublicClient(config); +} diff --git a/packages/bots/pyth-updater/package.json b/packages/bots/pyth-updater/package.json index a93cc099ec..8783fca484 100644 --- a/packages/bots/pyth-updater/package.json +++ b/packages/bots/pyth-updater/package.json @@ -34,7 +34,7 @@ "pino": "^9.2.0", "pino-pretty": "^11.2.1", "ts-node-dev": "^2.0.0", - "viem": "^2.21.12" + "viem": "^2.21.55" }, "devDependencies": { "eslint": "^8", diff --git a/packages/chains/package.json b/packages/chains/package.json index 66183ccb9c..ff3501b291 100644 --- a/packages/chains/package.json +++ b/packages/chains/package.json @@ -26,7 +26,7 @@ "dependencies": { "@ionicprotocol/types": "workspace:*", "utf-8-validate": "^6.0.4", - "viem": "^2.21.12" + "viem": "^2.21.55" }, "devDependencies": { "eslint": "^8", diff --git a/packages/chains/src/common/docs.ts b/packages/chains/src/common/docs.ts index d363d9e403..6b856f8820 100644 --- a/packages/chains/src/common/docs.ts +++ b/packages/chains/src/common/docs.ts @@ -25,11 +25,15 @@ export const wrappedAssetDocs = (chainId: SupportedChains) => { swapAddress: "https://velodrome.finance/swap" }, [SupportedChains.fraxtal]: { - swapName: "Fraxtal", + swapName: "Velodrome", swapAddress: "https://app.frax.finance/swap/main" }, [SupportedChains.lisk]: { - swapName: "Lisk", + swapName: "Velodrome", + swapAddress: "https://velodrome.finance/swap" + }, + [SupportedChains.superseed]: { + swapName: "Velodrome", swapAddress: "https://velodrome.finance/swap" } }[chainId]; diff --git a/packages/chains/src/index.ts b/packages/chains/src/index.ts index 5e197f6325..c9def70a10 100644 --- a/packages/chains/src/index.ts +++ b/packages/chains/src/index.ts @@ -15,8 +15,20 @@ import { default as fraxtal } from "./fraxtal"; import { default as lisk } from "./lisk"; import { default as mode } from "./mode"; import { default as optimism } from "./optimism"; +import { default as superseed } from "./superseed"; -export { base, bob, lisk, mode, optimism, fraxtal }; +export { base, bob, lisk, mode, optimism, fraxtal, superseed }; + +const vSuperseed: Chain = { + id: 5330, + name: "Superseed", + nativeCurrency: { + name: "Ethereum", + symbol: "ETH", + decimals: 18 + }, + rpcUrls: { default: { http: ["https://rpc-superseed-mainnet-0.t.conduit.xyz"] } } +}; export const chainIdtoChain: { [chainId: number]: Chain } = { [mode.chainId]: vMode, @@ -24,7 +36,8 @@ export const chainIdtoChain: { [chainId: number]: Chain } = { [optimism.chainId]: vOptimism, [bob.chainId]: vBob, [fraxtal.chainId]: vFraxtal, - [lisk.chainId]: vLisk + [lisk.chainId]: vLisk, + [superseed.chainId]: vSuperseed }; export const chainIdToConfig: { [chainId: number]: ChainConfig } = { @@ -33,5 +46,6 @@ export const chainIdToConfig: { [chainId: number]: ChainConfig } = { [optimism.chainId]: optimism, [bob.chainId]: bob, [fraxtal.chainId]: fraxtal, - [lisk.chainId]: lisk + [lisk.chainId]: lisk, + [superseed.chainId]: superseed }; diff --git a/packages/chains/src/superseed/addresses.ts b/packages/chains/src/superseed/addresses.ts new file mode 100644 index 0000000000..441ffd9540 --- /dev/null +++ b/packages/chains/src/superseed/addresses.ts @@ -0,0 +1,22 @@ +import { assetSymbols, ChainAddresses, underlying } from "@ionicprotocol/types"; +import { zeroAddress } from "viem"; + +import { assets } from "./assets"; + +const chainAddresses: ChainAddresses = { + PAIR_INIT_HASH: "", // TODO is this used anywhere? + STABLE_TOKEN: zeroAddress, + UNISWAP_V2_ROUTER: zeroAddress, + UNISWAP_V2_FACTORY: zeroAddress, + UNISWAP_V3: { + FACTORY: zeroAddress, + PAIR_INIT_HASH: "", + QUOTER_V2: zeroAddress // unused + }, + UNISWAP_V3_ROUTER: zeroAddress, // universal router, need to check if this works + W_BTC_TOKEN: zeroAddress, // underlying(assets, assetSymbols.WBTC), + W_TOKEN: underlying(assets, assetSymbols.WETH), + W_TOKEN_USD_CHAINLINK_PRICE_FEED: zeroAddress +}; + +export default chainAddresses; diff --git a/packages/chains/src/superseed/assets.ts b/packages/chains/src/superseed/assets.ts new file mode 100644 index 0000000000..1158c9dbde --- /dev/null +++ b/packages/chains/src/superseed/assets.ts @@ -0,0 +1,22 @@ +import { assetSymbols, OracleTypes, SupportedAsset, SupportedChains } from "@ionicprotocol/types"; +import { parseEther } from "viem"; + +import { wrappedAssetDocs } from "../common"; + +export const WETH = "0x4200000000000000000000000000000000000006"; + +export const assets: SupportedAsset[] = [ + { + symbol: assetSymbols.WETH, + underlying: WETH, + name: "Wrapped Ether", + decimals: 18, + oracle: OracleTypes.FixedNativePriceOracle, + extraDocs: wrappedAssetDocs(SupportedChains.superseed), + initialBorrowCap: parseEther("100").toString(), + initialSupplyCap: parseEther("100").toString(), + initialCf: "0.5" + } +]; + +export default assets; diff --git a/packages/chains/src/superseed/fundingStrategies.ts b/packages/chains/src/superseed/fundingStrategies.ts new file mode 100644 index 0000000000..54c4ffeb9b --- /dev/null +++ b/packages/chains/src/superseed/fundingStrategies.ts @@ -0,0 +1,5 @@ +import { FundingStrategy } from "@ionicprotocol/types"; + +const fundingStrategies: FundingStrategy[] = []; + +export default fundingStrategies; diff --git a/packages/chains/src/superseed/index.ts b/packages/chains/src/superseed/index.ts new file mode 100644 index 0000000000..61a64b8ddb --- /dev/null +++ b/packages/chains/src/superseed/index.ts @@ -0,0 +1,31 @@ +import { ChainConfig, SupportedChains } from "@ionicprotocol/types"; + +import deployments from "../../../sdk/deployments/superseed.json"; + +import chainAddresses from "./addresses"; +import { assets } from "./assets"; +import fundingStrategies from "./fundingStrategies"; +import irms from "./irms"; +import leveragePairs from "./leveragePairs"; +import liquidationDefaults from "./liquidation"; +import oracles from "./oracles"; +import specificParams from "./params"; +import deployedPlugins from "./plugins"; +import redemptionStrategies from "./redemptionStrategies"; + +const chainConfig: ChainConfig = { + chainId: SupportedChains.superseed, + chainAddresses, + assets, + irms, + liquidationDefaults, + oracles, + specificParams, + deployedPlugins, + redemptionStrategies, + fundingStrategies, + chainDeployments: deployments.contracts, + leveragePairs +}; + +export default chainConfig; diff --git a/packages/chains/src/superseed/irms.ts b/packages/chains/src/superseed/irms.ts new file mode 100644 index 0000000000..8e6a3ac707 --- /dev/null +++ b/packages/chains/src/superseed/irms.ts @@ -0,0 +1,7 @@ +import { IrmTypes } from "@ionicprotocol/types"; + +const baseIrms = [IrmTypes.JumpRateModel]; + +const irms: IrmTypes[] = [...baseIrms]; + +export default irms; diff --git a/packages/chains/src/superseed/leveragePairs.ts b/packages/chains/src/superseed/leveragePairs.ts new file mode 100644 index 0000000000..aec608582f --- /dev/null +++ b/packages/chains/src/superseed/leveragePairs.ts @@ -0,0 +1,5 @@ +import { LeveragePoolConfig } from "@ionicprotocol/types"; + +const leveragePairs: LeveragePoolConfig[] = []; + +export default leveragePairs; diff --git a/packages/chains/src/superseed/liquidation.ts b/packages/chains/src/superseed/liquidation.ts new file mode 100644 index 0000000000..2830ff1446 --- /dev/null +++ b/packages/chains/src/superseed/liquidation.ts @@ -0,0 +1,19 @@ +import { LiquidationDefaults, LiquidationStrategy } from "@ionicprotocol/types"; +import { zeroAddress } from "viem"; + +import chainAddresses from "./addresses"; +import { WETH } from "./assets"; + +const liquidationDefaults: LiquidationDefaults = { + DEFAULT_ROUTER: chainAddresses.UNISWAP_V2_ROUTER, + ASSET_SPECIFIC_ROUTER: {}, + SUPPORTED_OUTPUT_CURRENCIES: [zeroAddress, WETH], + SUPPORTED_INPUT_CURRENCIES: [zeroAddress, WETH], + LIQUIDATION_STRATEGY: LiquidationStrategy.UNISWAP, + MINIMUM_PROFIT_NATIVE: 0n, + LIQUIDATION_INTERVAL_SECONDS: 20, + jarvisPools: [], + balancerPools: [] +}; + +export default liquidationDefaults; diff --git a/packages/chains/src/superseed/oracles.ts b/packages/chains/src/superseed/oracles.ts new file mode 100644 index 0000000000..50b1a18a6c --- /dev/null +++ b/packages/chains/src/superseed/oracles.ts @@ -0,0 +1,7 @@ +import { OracleTypes } from "@ionicprotocol/types"; + +const baseOracles = [OracleTypes.FixedNativePriceOracle, OracleTypes.MasterPriceOracle, OracleTypes.SimplePriceOracle]; + +const oracles: OracleTypes[] = [...baseOracles]; + +export default oracles; diff --git a/packages/chains/src/superseed/params.ts b/packages/chains/src/superseed/params.ts new file mode 100644 index 0000000000..536d51e5ba --- /dev/null +++ b/packages/chains/src/superseed/params.ts @@ -0,0 +1,40 @@ +import { assetSymbols, ChainParams } from "@ionicprotocol/types"; +import { Address } from "viem"; + +import chainAddresses from "./addresses"; + +const specificParams: ChainParams = { + blocksPerYear: BigInt(30 * 60 * 24 * 365), // 30 blocks per minute = 2 sec block time + cgId: "ethereum", + metadata: { + chainIdHex: "0x14d2", + name: "Superseed", + shortName: "Superseed", + uniswapV3Fees: {}, + img: "https://raw.githubusercontent.com/superseed-xyz/brand-kit/227ecaadf8da2ad9acb208428ff178a2cd345565/logos-wordmarks/logos/small-black.svg", + blockExplorerUrls: { default: { name: "superseed", url: "https://explorer-superseed-mainnet-0.t.conduit.xyz" } }, + rpcUrls: { + default: { + http: ["https://mainnet.superseed.xyz"] + }, + public: { + http: ["https://mainnet.superseed.xyz"] + } + }, + nativeCurrency: { + symbol: "ETH", + name: "ETH" + }, + wrappedNativeCurrency: { + symbol: assetSymbols.WETH, + address: chainAddresses.W_TOKEN as Address, + name: "WETH", + decimals: 18, + color: "#7A88A1", + overlayTextColor: "#fff", + logoURL: "https://d1912tcoux65lj.cloudfront.net/network/ethereum.png" + } + } +}; + +export default specificParams; diff --git a/packages/chains/src/superseed/plugins.ts b/packages/chains/src/superseed/plugins.ts new file mode 100644 index 0000000000..075787ef75 --- /dev/null +++ b/packages/chains/src/superseed/plugins.ts @@ -0,0 +1,5 @@ +import { DeployedPlugins } from "@ionicprotocol/types"; + +const deployedPlugins: DeployedPlugins = {}; + +export default deployedPlugins; diff --git a/packages/chains/src/superseed/redemptionStrategies.ts b/packages/chains/src/superseed/redemptionStrategies.ts new file mode 100644 index 0000000000..b995e6bd44 --- /dev/null +++ b/packages/chains/src/superseed/redemptionStrategies.ts @@ -0,0 +1,5 @@ +import { RedemptionStrategy } from "@ionicprotocol/types"; + +const redemptionStrategies: RedemptionStrategy[] = []; + +export default redemptionStrategies; diff --git a/packages/contracts/chainDeploy/helpers/liquidators/ionicLiquidator.ts b/packages/contracts/chainDeploy/helpers/liquidators/ionicLiquidator.ts index 7d8537c25e..12a2b84e81 100644 --- a/packages/contracts/chainDeploy/helpers/liquidators/ionicLiquidator.ts +++ b/packages/contracts/chainDeploy/helpers/liquidators/ionicLiquidator.ts @@ -81,8 +81,7 @@ export const deployIonicUniV3Liquidator = async ({ args: [deployConfig.wtoken, deployConfig.uniswap.uniswapV3Quoter] } }, - proxyContract: "OpenZeppelinTransparentProxy", - owner: multisig + proxyContract: "OpenZeppelinTransparentProxy" } }); if (uniV3Liquidator.transactionHash) diff --git a/packages/contracts/chainDeploy/index.ts b/packages/contracts/chainDeploy/index.ts index 62c5ab10a6..18b71162dd 100644 --- a/packages/contracts/chainDeploy/index.ts +++ b/packages/contracts/chainDeploy/index.ts @@ -5,6 +5,8 @@ import { deploy as deployMode, deployConfig as deployConfigMode } from "./mainne import { deploy as deployFrax, deployConfig as deployConfigFrax } from "./mainnets/fraxtal"; import { deploy as deployOptimism, deployConfig as deployConfigOptimism } from "./mainnets/optimism"; import { deploy as deployLisk, deployConfig as deployConfigLisk } from "./mainnets/lisk"; +import { deploy as deploySuperseed, deployConfig as deployConfigSuperseed } from "./mainnets/superseed"; +import { superseed } from "@ionicprotocol/chains"; export const chainDeployConfig: Record = { // mainnets @@ -12,7 +14,8 @@ export const chainDeployConfig: Record => { + const { deployer } = await getNamedAccounts(); + const publicClient = await viem.getPublicClient(); + + //// Uniswap V3 Liquidator Funder + const uniswapV3LiquidatorFunder = await deployments.deploy("UniswapV3LiquidatorFunder", { + from: deployer, + args: [], + log: true, + waitConfirmations: 1 + }); + console.log("UniswapV3LiquidatorFunder: ", uniswapV3LiquidatorFunder.address); +}; diff --git a/packages/contracts/deploy/01-deploy-fee-distributor.ts b/packages/contracts/deploy/01-deploy-fee-distributor.ts index a7454bd15b..962bc4ce08 100644 --- a/packages/contracts/deploy/01-deploy-fee-distributor.ts +++ b/packages/contracts/deploy/01-deploy-fee-distributor.ts @@ -1,5 +1,6 @@ import { DeployFunction } from "hardhat-deploy/types"; import { Address, formatUnits, parseEther, maxUint256, Hash } from "viem"; +import { chainIdtoChain } from "@ionicprotocol/chains"; import { ChainDeployConfig, chainDeployConfig } from "../chainDeploy"; import { getCgPrice } from "../chainDeploy/helpers/getCgPrice"; @@ -9,7 +10,7 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments, getCh console.log("chainId: ", chainId); const MIN_BORROW_USD = 0.1; - const publicClient = await viem.getPublicClient(); + const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] }); const { deployer, multisig } = await getNamedAccounts(); console.log("deployer: ", deployer); diff --git a/packages/contracts/deploy/11-deploy-liquidators.ts b/packages/contracts/deploy/11-deploy-liquidators.ts index b54c2bfc8e..7dac3c7c7f 100644 --- a/packages/contracts/deploy/11-deploy-liquidators.ts +++ b/packages/contracts/deploy/11-deploy-liquidators.ts @@ -47,23 +47,6 @@ const func: DeployFunction = async ({ run, viem, getNamedAccounts, deployments, chainId }); - // await configureIonicLiquidator({ - // contractName: liquidatorContractName, - // viem, - // getNamedAccounts, - // chainId, - // deployments - // }); - - liquidatorContractName = await deployIonicLiquidator({ - run, - viem, - getNamedAccounts, - deployments, - deployConfig: chainDeployParams, - chainId - }); - await configureIonicLiquidator({ contractName: liquidatorContractName, viem, @@ -71,6 +54,23 @@ const func: DeployFunction = async ({ run, viem, getNamedAccounts, deployments, chainId, deployments }); + + // liquidatorContractName = await deployIonicLiquidator({ + // run, + // viem, + // getNamedAccounts, + // deployments, + // deployConfig: chainDeployParams, + // chainId + // }); + + // await configureIonicLiquidator({ + // contractName: liquidatorContractName, + // viem, + // getNamedAccounts, + // chainId, + // deployments + // }); } }; diff --git a/packages/contracts/deployments/superseed/.chainId b/packages/contracts/deployments/superseed/.chainId new file mode 100644 index 0000000000..500b9b9697 --- /dev/null +++ b/packages/contracts/deployments/superseed/.chainId @@ -0,0 +1 @@ +5330 \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AddressesProvider.json b/packages/contracts/deployments/superseed/AddressesProvider.json new file mode 100644 index 0000000000..28dc144d8c --- /dev/null +++ b/packages/contracts/deployments/superseed/AddressesProvider.json @@ -0,0 +1,978 @@ +{ + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balancerPoolForTokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "curveSwapPoolsConfig", + "outputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "flywheelRewards", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "fundingStrategiesConfig", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "getAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "getBalancerPoolForTokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurveSwapPools", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address[]", + "name": "coins", + "type": "address[]" + } + ], + "internalType": "struct AddressesProvider.CurveSwapPool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getFundingStrategy", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "internalType": "struct AddressesProvider.FundingStrategy", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getJarvisPools", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "internalType": "struct AddressesProvider.JarvisPool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getRedemptionStrategy", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "internalType": "struct AddressesProvider.RedemptionStrategy", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "jarvisPoolsConfig", + "outputs": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "plugins", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesConfig", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "id", + "type": "string" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "setAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "setBalancerPoolForTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address[]", + "name": "coins", + "type": "address[]" + } + ], + "name": "setCurveSwapPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "flywheelRewardsModule", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "name": "setFlywheelRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "strategy", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "name": "setFundingStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "name": "setJarvisPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "plugin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "name": "setPlugin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "strategy", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "setRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "transactionIndex": 1, + "gasUsed": "772720", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000002000009000000000000000000000000000000000000020000000000000000000800001000800000000000000000000000400001000000000000000000000000000000000008000080000000000000c00000000000000000000000000200000400000000000000000000000000000000000000000060000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577", + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000007ea7bb80f3bbee9b52e6ed3775ba06c9c80d4154" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + } + ], + "blockNumber": 4135345, + "cumulativeGasUsed": "816598", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + "0x1155b614971f16758C92c4890eD338C9e3ede6b7" + ] + }, + "implementation": "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AddressesProvider_Implementation.json b/packages/contracts/deployments/superseed/AddressesProvider_Implementation.json new file mode 100644 index 0000000000..65b2352529 --- /dev/null +++ b/packages/contracts/deployments/superseed/AddressesProvider_Implementation.json @@ -0,0 +1,1202 @@ +{ + "address": "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balancerPoolForTokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "curveSwapPoolsConfig", + "outputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "flywheelRewards", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "fundingStrategiesConfig", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "id", + "type": "string" + } + ], + "name": "getAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "getBalancerPoolForTokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurveSwapPools", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address[]", + "name": "coins", + "type": "address[]" + } + ], + "internalType": "struct AddressesProvider.CurveSwapPool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getFundingStrategy", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "internalType": "struct AddressesProvider.FundingStrategy", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getJarvisPools", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "internalType": "struct AddressesProvider.JarvisPool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getRedemptionStrategy", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "internalType": "struct AddressesProvider.RedemptionStrategy", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "jarvisPoolsConfig", + "outputs": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "plugins", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesConfig", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "id", + "type": "string" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "name": "setAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "setBalancerPoolForTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address[]", + "name": "coins", + "type": "address[]" + } + ], + "name": "setCurveSwapPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "flywheelRewardsModule", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "name": "setFlywheelRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "strategy", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "inputToken", + "type": "address" + } + ], + "name": "setFundingStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "syntheticToken", + "type": "address" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidityPool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + } + ], + "name": "setJarvisPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "plugin", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + } + ], + "name": "setPlugin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "strategy", + "type": "address" + }, + { + "internalType": "string", + "name": "contractInterface", + "type": "string" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "setRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x46ea006549fe44994462d8571060befcd5f312ef79d536b3dc499ab0e14c0dfa", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154", + "transactionIndex": 1, + "gasUsed": "1564734", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x34ae5981a8b76bb65f0d85e05d074b6fd90c02b8fc3810e89371fe513cb0b307", + "transactionHash": "0x46ea006549fe44994462d8571060befcd5f312ef79d536b3dc499ab0e14c0dfa", + "logs": [], + "blockNumber": 4135342, + "cumulativeGasUsed": "1608612", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"NewPendingOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_acceptOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"_setPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balancerPoolForTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"curveSwapPoolsConfig\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"flywheelRewards\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fundingStrategiesConfig\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"id\",\"type\":\"string\"}],\"name\":\"getAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getBalancerPoolForTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurveSwapPools\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"coins\",\"type\":\"address[]\"}],\"internalType\":\"struct AddressesProvider.CurveSwapPool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getFundingStrategy\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"}],\"internalType\":\"struct AddressesProvider.FundingStrategy\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getJarvisPools\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"syntheticToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"liquidityPool\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"}],\"internalType\":\"struct AddressesProvider.JarvisPool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getRedemptionStrategy\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"internalType\":\"struct AddressesProvider.RedemptionStrategy\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"jarvisPoolsConfig\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"syntheticToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"liquidityPool\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"plugins\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesConfig\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"id\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"newAddress\",\"type\":\"address\"}],\"name\":\"setAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"pool\",\"type\":\"address\"}],\"name\":\"setBalancerPoolForTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"coins\",\"type\":\"address[]\"}],\"name\":\"setCurveSwapPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"flywheelRewardsModule\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"}],\"name\":\"setFlywheelRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"}],\"name\":\"setFundingStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"syntheticToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"liquidityPool\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"}],\"name\":\"setJarvisPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"plugin\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"}],\"name\":\"setPlugin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"contractInterface\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"setRedemptionStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Veliko Minkov \",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_acceptOwner()\":{\"details\":\"Owner function for pending owner to accept role and update owner\"},\"_setPendingOwner(address)\":{\"details\":\"Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\",\"params\":{\"newPendingOwner\":\"New pending owner.\"}},\"getAddress(string)\":{\"details\":\"Returns an address by id\",\"returns\":{\"_0\":\"The address\"}},\"initialize(address)\":{\"details\":\"Initializer to set the admin that can set and change contracts addresses\"},\"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.\"},\"setAddress(string,address)\":{\"details\":\"Sets an address for an id replacing the address saved in the addresses map\",\"params\":{\"id\":\"The id\",\"newAddress\":\"The address to set\"}},\"setFlywheelRewards(address,address,string)\":{\"details\":\"sets the address and contract interface ID of the flywheel for the reward token\",\"params\":{\"contractInterface\":\"a string that uniquely identifies the contract's interface\",\"flywheelRewardsModule\":\"the flywheel rewards module address\",\"rewardToken\":\"the reward token address\"}},\"setFundingStrategy(address,address,string,address)\":{\"details\":\"sets the address and contract interface ID of the funding strategy for the asset\",\"params\":{\"asset\":\"the asset address\",\"contractInterface\":\"a string that uniquely identifies the contract's interface\",\"strategy\":\"funding strategy address\"}},\"setJarvisPool(address,address,address,uint256)\":{\"details\":\"configures the Jarvis pool of a Jarvis synthetic token\",\"params\":{\"collateralToken\":\"the collateral token address\",\"expirationTime\":\"the operation expiration time\",\"liquidityPool\":\"the liquidity pool address\",\"syntheticToken\":\"the synthetic token address\"}},\"setPlugin(address,address,string)\":{\"details\":\"sets the address and contract interface ID of the ERC4626 plugin for the asset\",\"params\":{\"asset\":\"the asset address\",\"contractInterface\":\"a string that uniquely identifies the contract's interface\",\"plugin\":\"the ERC4626 plugin address\"}},\"setRedemptionStrategy(address,address,string,address)\":{\"details\":\"sets the address and contract interface ID of the redemption strategy for the asset\",\"params\":{\"asset\":\"the asset address\",\"contractInterface\":\"a string that uniquely identifies the contract's interface\",\"strategy\":\"redemption strategy address\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"AddressesProvider\",\"version\":1},\"userdoc\":{\"events\":{\"NewOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is accepted, which means owner is updated\"},\"NewPendingOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is changed\"}},\"kind\":\"user\",\"methods\":{\"_acceptOwner()\":{\"notice\":\"Accepts transfer of owner rights. msg.sender must be pendingOwner\"},\"_setPendingOwner(address)\":{\"notice\":\"Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\"},\"pendingOwner()\":{\"notice\":\"Pending owner of this contract\"}},\"notice\":\"The Addresses Provider serves as a central storage of system internal and external contract addresses that change between deploys and across chains\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/AddressesProvider.sol\":\"AddressesProvider\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50611b54806100206000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c8063959fc097116100f9578063bf40fac111610097578063cf78b30a11610071578063cf78b30a1461044c578063e30c39781461045f578063f2fde38b14610472578063fc4d33f91461048557600080fd5b8063bf40fac114610413578063c4d66de814610426578063ceb4e9431461043957600080fd5b8063a11b73a6116100d3578063a11b73a6146103ba578063a13449d6146103cd578063b40dc803146103ed578063b91975541461040057600080fd5b8063959fc0971461033b578063984d8655146103735780639b2ea4bd146103a757600080fd5b806362772c731161016657806377d792191161014057806377d79219146102a65780637930b9b0146102bb57806381bc3632146103035780638da5cb5b1461031657600080fd5b806362772c73146102785780636e96dfd71461028b578063715018a61461029e57600080fd5b8063316eb395116101a2578063316eb3951461020f5780634172e7f91461023157806344fca697146102525780634b12e6431461026557600080fd5b8063073d0b6c146101c95780631783a521146101de5780632cf3219c146101f1575b600080fd5b6101dc6101d7366004611462565b61048d565b005b6101dc6101ec366004611462565b610560565b6101f9610602565b60405161020691906114d8565b60405180910390f35b61022261021d366004611589565b6106ce565b604051610206939291906115f1565b61024461023f366004611589565b61078c565b604051610206929190611626565b6101dc610260366004611652565b61083b565b610244610273366004611589565b610950565b6101dc61028636600461169d565b61097c565b6101dc610299366004611589565b610a2e565b6101dc610a98565b6102ae610ae0565b6040516102069190611723565b6102ce6102c9366004611795565b610b68565b60405161020694939291906001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6101dc6103113660046117ae565b610bb2565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610206565b61032361034936600461180f565b6001600160a01b039182166000908152606d60209081526040808320938516835292905220541690565b61032361038136600461180f565b606d6020908152600092835260408084209091529082529020546001600160a01b031681565b6101dc6103b5366004611842565b610c5a565b6101dc6103c83660046117ae565b610ca9565b6103e06103db366004611589565b610d48565b60405161020691906118d7565b6102226103fb366004611589565b610e5e565b6101dc61040e3660046118ea565b610e8a565b610323610421366004611924565b610ecf565b6101dc610434366004611589565b610f04565b610323610447366004611795565b611013565b6103e061045a366004611589565b611042565b606554610323906001600160a01b031681565b6101dc610480366004611589565b6110bb565b6101dc61112c565b610495611240565b6040518060600160405280856001600160a01b0316815260200184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050506001600160a01b038481166020938401528881168252606a83526040909120835181546001600160a01b031916921691909117815590820151600182019061052f9082611a03565b5060409190910151600290910180546001600160a01b0319166001600160a01b039092169190911790555050505050565b610568611240565b6040518060600160405280856001600160a01b0316815260200184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050506001600160a01b038481166020938401528881168252606983526040909120835181546001600160a01b031916921691909117815590820151600182019061052f9082611a03565b6060606c805480602002602001604051908101604052809291908181526020016000905b828210156106c55760008481526020908190206040805180820182526002860290920180546001600160a01b031683526001810180548351818702810187019094528084529394919385830193928301828280156106ad57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161068f575b50505050508152505081526020019060010190610626565b50505050905090565b606a60205260009081526040902080546001820180546001600160a01b0390921692916106fa9061197c565b80601f01602080910402602001604051908101604052809291908181526020018280546107269061197c565b80156107735780601f1061074857610100808354040283529160200191610773565b820191906000526020600020905b81548152906001019060200180831161075657829003601f168201915b505050600290930154919250506001600160a01b031683565b606860205260009081526040902080546001820180546001600160a01b0390921692916107b89061197c565b80601f01602080910402602001604051908101604052809291908181526020018280546107e49061197c565b80156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905082565b610843611240565b604080516080810182526001600160a01b0395861681529385166020850190815292851690840190815260608401918252606b8054600181018255600091909152935160049094027fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b4810180549587166001600160a01b031996871617905592517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b584018054918716918616919091179055517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b68301805491909516931692909217909255517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b790910155565b606760205260009081526040902080546001820180546001600160a01b0390921692916107b89061197c565b610984611240565b606c6040518060400160405280856001600160a01b031681526020018484808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250939094525050835460018082018655948252602091829020845160029092020180546001600160a01b0319166001600160a01b0390921691909117815583820151805194959194610a269450918501920190611383565b505050505050565b610a36611240565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b610aa0611240565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064015b60405180910390fd5b6060606b805480602002602001604051908101604052809291908181526020016000905b828210156106c5576000848152602090819020604080516080810182526004860290920180546001600160a01b0390811684526001808301548216858701526002830154909116928401929092526003015460608301529083529092019101610b04565b606b8181548110610b7857600080fd5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b039283169450908216929091169084565b610bba611240565b6040518060400160405280846001600160a01b0316815260200183838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250506001600160a01b038781168252606760209081526040909220845181546001600160a01b0319169216919091178155908301519091506001820190610c519082611a03565b50505050505050565b610c62611240565b8060668484604051610c75929190611ac3565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055505050565b610cb1611240565b6040518060400160405280846001600160a01b0316815260200183838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250506001600160a01b038781168252606860209081526040909220845181546001600160a01b0319169216919091178155908301519091506001820190610c519082611a03565b610d7e604051806060016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681525090565b6001600160a01b038083166000908152606a60209081526040918290208251606081019093528054909316825260018301805492939291840191610dc19061197c565b80601f0160208091040260200160405190810160405280929190818152602001828054610ded9061197c565b8015610e3a5780601f10610e0f57610100808354040283529160200191610e3a565b820191906000526020600020905b815481529060010190602001808311610e1d57829003601f168201915b5050509183525050600291909101546001600160a01b031660209091015292915050565b606960205260009081526040902080546001820180546001600160a01b0390921692916106fa9061197c565b610e92611240565b6001600160a01b039283166000908152606d6020908152604080832094861683529390529190912080546001600160a01b03191691909216179055565b600060668383604051610ee3929190611ac3565b908152604051908190036020019020546001600160a01b0316905092915050565b600054610100900460ff1615808015610f245750600054600160ff909116105b80610f3e5750303b158015610f3e575060005460ff166001145b610fa15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ad7565b6000805460ff191660011790558015610fc4576000805461ff0019166101001790555b610fcd8261129c565b801561100f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610a8c565b5050565b606c818154811061102357600080fd5b60009182526020909120600290910201546001600160a01b0316905081565b611078604051806060016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681525090565b6001600160a01b038083166000908152606960209081526040918290208251606081019093528054909316825260018301805492939291840191610dc19061197c565b6110c3611240565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b0316331461117e5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b6044820152606401610ad7565b60006111926033546001600160a01b031690565b6065549091506001600160a01b03166111aa816112d7565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101610a8c565b6033546001600160a01b0316331461129a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ad7565b565b600054610100900460ff166112c35760405162461bcd60e51b8152600401610ad790611ad3565b6112cb611329565b6112d4816112d7565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166113505760405162461bcd60e51b8152600401610ad790611ad3565b61129a600054610100900460ff1661137a5760405162461bcd60e51b8152600401610ad790611ad3565b61129a336112d7565b8280548282559060005260206000209081019282156113d8579160200282015b828111156113d857825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113a3565b506113e49291506113e8565b5090565b5b808211156113e457600081556001016113e9565b80356001600160a01b038116811461141457600080fd5b919050565b60008083601f84011261142b57600080fd5b50813567ffffffffffffffff81111561144357600080fd5b60208301915083602082850101111561145b57600080fd5b9250929050565b60008060008060006080868803121561147a57600080fd5b611483866113fd565b9450611491602087016113fd565b9350604086013567ffffffffffffffff8111156114ad57600080fd5b6114b988828901611419565b90945092506114cc9050606087016113fd565b90509295509295909350565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b8481101561157a57898403603f19018652825180516001600160a01b039081168652908901518986018990528051898701819052908a0191849160608801905b8084101561156457845183168252938c019360019390930192908c0190611542565b50988b0198965050509288019250600101611502565b50919998505050505050505050565b60006020828403121561159b57600080fd5b6115a4826113fd565b9392505050565b6000815180845260005b818110156115d1576020818501810151868301820152016115b5565b506000602082860101526020601f19601f83011685010191505092915050565b600060018060a01b0380861683526060602084015261161360608401866115ab565b9150808416604084015250949350505050565b6001600160a01b038316815260406020820181905260009061164a908301846115ab565b949350505050565b6000806000806080858703121561166857600080fd5b611671856113fd565b935061167f602086016113fd565b925061168d604086016113fd565b9396929550929360600135925050565b6000806000604084860312156116b257600080fd5b6116bb846113fd565b9250602084013567ffffffffffffffff808211156116d857600080fd5b818601915086601f8301126116ec57600080fd5b8135818111156116fb57600080fd5b8760208260051b850101111561171057600080fd5b6020830194508093505050509250925092565b602080825282518282018190526000919060409081850190868401855b8281101561178857815180516001600160a01b039081168652878201518116888701528682015116868601526060908101519085015260809093019290850190600101611740565b5091979650505050505050565b6000602082840312156117a757600080fd5b5035919050565b600080600080606085870312156117c457600080fd5b6117cd856113fd565b93506117db602086016113fd565b9250604085013567ffffffffffffffff8111156117f757600080fd5b61180387828801611419565b95989497509550505050565b6000806040838503121561182257600080fd5b61182b836113fd565b9150611839602084016113fd565b90509250929050565b60008060006040848603121561185757600080fd5b833567ffffffffffffffff81111561186e57600080fd5b61187a86828701611419565b909450925061188d9050602085016113fd565b90509250925092565b600060018060a01b038083511684526020830151606060208601526118be60608601826115ab565b9050816040850151166040860152809250505092915050565b6020815260006115a46020830184611896565b6000806000606084860312156118ff57600080fd5b611908846113fd565b9250611916602085016113fd565b915061188d604085016113fd565b6000806020838503121561193757600080fd5b823567ffffffffffffffff81111561194e57600080fd5b61195a85828601611419565b90969095509350505050565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061199057607f821691505b6020821081036119b057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156119fe576000816000526020600020601f850160051c810160208610156119df5750805b601f850160051c820191505b81811015610a26578281556001016119eb565b505050565b815167ffffffffffffffff811115611a1d57611a1d611966565b611a3181611a2b845461197c565b846119b6565b602080601f831160018114611a665760008415611a4e5750858301515b600019600386901b1c1916600185901b178555610a26565b600085815260208120601f198616915b82811015611a9557888601518255948401946001909101908401611a76565b5085821015611ab35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8183823760009101908152919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220ab57bfc01d77f6b410512112473141bf372b82a8c1c0e21021005108ee72b18964736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101c45760003560e01c8063959fc097116100f9578063bf40fac111610097578063cf78b30a11610071578063cf78b30a1461044c578063e30c39781461045f578063f2fde38b14610472578063fc4d33f91461048557600080fd5b8063bf40fac114610413578063c4d66de814610426578063ceb4e9431461043957600080fd5b8063a11b73a6116100d3578063a11b73a6146103ba578063a13449d6146103cd578063b40dc803146103ed578063b91975541461040057600080fd5b8063959fc0971461033b578063984d8655146103735780639b2ea4bd146103a757600080fd5b806362772c731161016657806377d792191161014057806377d79219146102a65780637930b9b0146102bb57806381bc3632146103035780638da5cb5b1461031657600080fd5b806362772c73146102785780636e96dfd71461028b578063715018a61461029e57600080fd5b8063316eb395116101a2578063316eb3951461020f5780634172e7f91461023157806344fca697146102525780634b12e6431461026557600080fd5b8063073d0b6c146101c95780631783a521146101de5780632cf3219c146101f1575b600080fd5b6101dc6101d7366004611462565b61048d565b005b6101dc6101ec366004611462565b610560565b6101f9610602565b60405161020691906114d8565b60405180910390f35b61022261021d366004611589565b6106ce565b604051610206939291906115f1565b61024461023f366004611589565b61078c565b604051610206929190611626565b6101dc610260366004611652565b61083b565b610244610273366004611589565b610950565b6101dc61028636600461169d565b61097c565b6101dc610299366004611589565b610a2e565b6101dc610a98565b6102ae610ae0565b6040516102069190611723565b6102ce6102c9366004611795565b610b68565b60405161020694939291906001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6101dc6103113660046117ae565b610bb2565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610206565b61032361034936600461180f565b6001600160a01b039182166000908152606d60209081526040808320938516835292905220541690565b61032361038136600461180f565b606d6020908152600092835260408084209091529082529020546001600160a01b031681565b6101dc6103b5366004611842565b610c5a565b6101dc6103c83660046117ae565b610ca9565b6103e06103db366004611589565b610d48565b60405161020691906118d7565b6102226103fb366004611589565b610e5e565b6101dc61040e3660046118ea565b610e8a565b610323610421366004611924565b610ecf565b6101dc610434366004611589565b610f04565b610323610447366004611795565b611013565b6103e061045a366004611589565b611042565b606554610323906001600160a01b031681565b6101dc610480366004611589565b6110bb565b6101dc61112c565b610495611240565b6040518060600160405280856001600160a01b0316815260200184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050506001600160a01b038481166020938401528881168252606a83526040909120835181546001600160a01b031916921691909117815590820151600182019061052f9082611a03565b5060409190910151600290910180546001600160a01b0319166001600160a01b039092169190911790555050505050565b610568611240565b6040518060600160405280856001600160a01b0316815260200184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050506001600160a01b038481166020938401528881168252606983526040909120835181546001600160a01b031916921691909117815590820151600182019061052f9082611a03565b6060606c805480602002602001604051908101604052809291908181526020016000905b828210156106c55760008481526020908190206040805180820182526002860290920180546001600160a01b031683526001810180548351818702810187019094528084529394919385830193928301828280156106ad57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161068f575b50505050508152505081526020019060010190610626565b50505050905090565b606a60205260009081526040902080546001820180546001600160a01b0390921692916106fa9061197c565b80601f01602080910402602001604051908101604052809291908181526020018280546107269061197c565b80156107735780601f1061074857610100808354040283529160200191610773565b820191906000526020600020905b81548152906001019060200180831161075657829003601f168201915b505050600290930154919250506001600160a01b031683565b606860205260009081526040902080546001820180546001600160a01b0390921692916107b89061197c565b80601f01602080910402602001604051908101604052809291908181526020018280546107e49061197c565b80156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905082565b610843611240565b604080516080810182526001600160a01b0395861681529385166020850190815292851690840190815260608401918252606b8054600181018255600091909152935160049094027fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b4810180549587166001600160a01b031996871617905592517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b584018054918716918616919091179055517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b68301805491909516931692909217909255517fbd43cb8ece8cd1863bcd6082d65c5b0d25665b1ce17980f0da43c0ed545f98b790910155565b606760205260009081526040902080546001820180546001600160a01b0390921692916107b89061197c565b610984611240565b606c6040518060400160405280856001600160a01b031681526020018484808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250939094525050835460018082018655948252602091829020845160029092020180546001600160a01b0319166001600160a01b0390921691909117815583820151805194959194610a269450918501920190611383565b505050505050565b610a36611240565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b610aa0611240565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064015b60405180910390fd5b6060606b805480602002602001604051908101604052809291908181526020016000905b828210156106c5576000848152602090819020604080516080810182526004860290920180546001600160a01b0390811684526001808301548216858701526002830154909116928401929092526003015460608301529083529092019101610b04565b606b8181548110610b7857600080fd5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b039283169450908216929091169084565b610bba611240565b6040518060400160405280846001600160a01b0316815260200183838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250506001600160a01b038781168252606760209081526040909220845181546001600160a01b0319169216919091178155908301519091506001820190610c519082611a03565b50505050505050565b610c62611240565b8060668484604051610c75929190611ac3565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055505050565b610cb1611240565b6040518060400160405280846001600160a01b0316815260200183838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250506001600160a01b038781168252606860209081526040909220845181546001600160a01b0319169216919091178155908301519091506001820190610c519082611a03565b610d7e604051806060016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681525090565b6001600160a01b038083166000908152606a60209081526040918290208251606081019093528054909316825260018301805492939291840191610dc19061197c565b80601f0160208091040260200160405190810160405280929190818152602001828054610ded9061197c565b8015610e3a5780601f10610e0f57610100808354040283529160200191610e3a565b820191906000526020600020905b815481529060010190602001808311610e1d57829003601f168201915b5050509183525050600291909101546001600160a01b031660209091015292915050565b606960205260009081526040902080546001820180546001600160a01b0390921692916106fa9061197c565b610e92611240565b6001600160a01b039283166000908152606d6020908152604080832094861683529390529190912080546001600160a01b03191691909216179055565b600060668383604051610ee3929190611ac3565b908152604051908190036020019020546001600160a01b0316905092915050565b600054610100900460ff1615808015610f245750600054600160ff909116105b80610f3e5750303b158015610f3e575060005460ff166001145b610fa15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ad7565b6000805460ff191660011790558015610fc4576000805461ff0019166101001790555b610fcd8261129c565b801561100f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610a8c565b5050565b606c818154811061102357600080fd5b60009182526020909120600290910201546001600160a01b0316905081565b611078604051806060016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681525090565b6001600160a01b038083166000908152606960209081526040918290208251606081019093528054909316825260018301805492939291840191610dc19061197c565b6110c3611240565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b0316331461117e5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b6044820152606401610ad7565b60006111926033546001600160a01b031690565b6065549091506001600160a01b03166111aa816112d7565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101610a8c565b6033546001600160a01b0316331461129a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ad7565b565b600054610100900460ff166112c35760405162461bcd60e51b8152600401610ad790611ad3565b6112cb611329565b6112d4816112d7565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166113505760405162461bcd60e51b8152600401610ad790611ad3565b61129a600054610100900460ff1661137a5760405162461bcd60e51b8152600401610ad790611ad3565b61129a336112d7565b8280548282559060005260206000209081019282156113d8579160200282015b828111156113d857825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113a3565b506113e49291506113e8565b5090565b5b808211156113e457600081556001016113e9565b80356001600160a01b038116811461141457600080fd5b919050565b60008083601f84011261142b57600080fd5b50813567ffffffffffffffff81111561144357600080fd5b60208301915083602082850101111561145b57600080fd5b9250929050565b60008060008060006080868803121561147a57600080fd5b611483866113fd565b9450611491602087016113fd565b9350604086013567ffffffffffffffff8111156114ad57600080fd5b6114b988828901611419565b90945092506114cc9050606087016113fd565b90509295509295909350565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b8481101561157a57898403603f19018652825180516001600160a01b039081168652908901518986018990528051898701819052908a0191849160608801905b8084101561156457845183168252938c019360019390930192908c0190611542565b50988b0198965050509288019250600101611502565b50919998505050505050505050565b60006020828403121561159b57600080fd5b6115a4826113fd565b9392505050565b6000815180845260005b818110156115d1576020818501810151868301820152016115b5565b506000602082860101526020601f19601f83011685010191505092915050565b600060018060a01b0380861683526060602084015261161360608401866115ab565b9150808416604084015250949350505050565b6001600160a01b038316815260406020820181905260009061164a908301846115ab565b949350505050565b6000806000806080858703121561166857600080fd5b611671856113fd565b935061167f602086016113fd565b925061168d604086016113fd565b9396929550929360600135925050565b6000806000604084860312156116b257600080fd5b6116bb846113fd565b9250602084013567ffffffffffffffff808211156116d857600080fd5b818601915086601f8301126116ec57600080fd5b8135818111156116fb57600080fd5b8760208260051b850101111561171057600080fd5b6020830194508093505050509250925092565b602080825282518282018190526000919060409081850190868401855b8281101561178857815180516001600160a01b039081168652878201518116888701528682015116868601526060908101519085015260809093019290850190600101611740565b5091979650505050505050565b6000602082840312156117a757600080fd5b5035919050565b600080600080606085870312156117c457600080fd5b6117cd856113fd565b93506117db602086016113fd565b9250604085013567ffffffffffffffff8111156117f757600080fd5b61180387828801611419565b95989497509550505050565b6000806040838503121561182257600080fd5b61182b836113fd565b9150611839602084016113fd565b90509250929050565b60008060006040848603121561185757600080fd5b833567ffffffffffffffff81111561186e57600080fd5b61187a86828701611419565b909450925061188d9050602085016113fd565b90509250925092565b600060018060a01b038083511684526020830151606060208601526118be60608601826115ab565b9050816040850151166040860152809250505092915050565b6020815260006115a46020830184611896565b6000806000606084860312156118ff57600080fd5b611908846113fd565b9250611916602085016113fd565b915061188d604085016113fd565b6000806020838503121561193757600080fd5b823567ffffffffffffffff81111561194e57600080fd5b61195a85828601611419565b90969095509350505050565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061199057607f821691505b6020821081036119b057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156119fe576000816000526020600020601f850160051c810160208610156119df5750805b601f850160051c820191505b81811015610a26578281556001016119eb565b505050565b815167ffffffffffffffff811115611a1d57611a1d611966565b611a3181611a2b845461197c565b846119b6565b602080601f831160018114611a665760008415611a4e5750858301515b600019600386901b1c1916600185901b178555610a26565b600085815260208120601f198616915b82811015611a9557888601518255948401946001909101908401611a76565b5085821015611ab35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8183823760009101908152919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea2646970667358221220ab57bfc01d77f6b410512112473141bf372b82a8c1c0e21021005108ee72b18964736f6c63430008160033", + "devdoc": { + "author": "Veliko Minkov ", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_acceptOwner()": { + "details": "Owner function for pending owner to accept role and update owner" + }, + "_setPendingOwner(address)": { + "details": "Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.", + "params": { + "newPendingOwner": "New pending owner." + } + }, + "getAddress(string)": { + "details": "Returns an address by id", + "returns": { + "_0": "The address" + } + }, + "initialize(address)": { + "details": "Initializer to set the admin that can set and change contracts addresses" + }, + "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." + }, + "setAddress(string,address)": { + "details": "Sets an address for an id replacing the address saved in the addresses map", + "params": { + "id": "The id", + "newAddress": "The address to set" + } + }, + "setFlywheelRewards(address,address,string)": { + "details": "sets the address and contract interface ID of the flywheel for the reward token", + "params": { + "contractInterface": "a string that uniquely identifies the contract's interface", + "flywheelRewardsModule": "the flywheel rewards module address", + "rewardToken": "the reward token address" + } + }, + "setFundingStrategy(address,address,string,address)": { + "details": "sets the address and contract interface ID of the funding strategy for the asset", + "params": { + "asset": "the asset address", + "contractInterface": "a string that uniquely identifies the contract's interface", + "strategy": "funding strategy address" + } + }, + "setJarvisPool(address,address,address,uint256)": { + "details": "configures the Jarvis pool of a Jarvis synthetic token", + "params": { + "collateralToken": "the collateral token address", + "expirationTime": "the operation expiration time", + "liquidityPool": "the liquidity pool address", + "syntheticToken": "the synthetic token address" + } + }, + "setPlugin(address,address,string)": { + "details": "sets the address and contract interface ID of the ERC4626 plugin for the asset", + "params": { + "asset": "the asset address", + "contractInterface": "a string that uniquely identifies the contract's interface", + "plugin": "the ERC4626 plugin address" + } + }, + "setRedemptionStrategy(address,address,string,address)": { + "details": "sets the address and contract interface ID of the redemption strategy for the asset", + "params": { + "asset": "the asset address", + "contractInterface": "a string that uniquely identifies the contract's interface", + "strategy": "redemption strategy address" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "AddressesProvider", + "version": 1 + }, + "userdoc": { + "events": { + "NewOwner(address,address)": { + "notice": "Emitted when pendingOwner is accepted, which means owner is updated" + }, + "NewPendingOwner(address,address)": { + "notice": "Emitted when pendingOwner is changed" + } + }, + "kind": "user", + "methods": { + "_acceptOwner()": { + "notice": "Accepts transfer of owner rights. msg.sender must be pendingOwner" + }, + "_setPendingOwner(address)": { + "notice": "Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer." + }, + "pendingOwner()": { + "notice": "Pending owner of this contract" + } + }, + "notice": "The Addresses Provider serves as a central storage of system internal and external contract addresses that change between deploys and across chains", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 54261, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 51332, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "_addresses", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_string_memory_ptr,t_address)" + }, + { + "astId": 51337, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "plugins", + "offset": 0, + "slot": "103", + "type": "t_mapping(t_address,t_struct(Contract)51385_storage)" + }, + { + "astId": 51342, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "flywheelRewards", + "offset": 0, + "slot": "104", + "type": "t_mapping(t_address,t_struct(Contract)51385_storage)" + }, + { + "astId": 51347, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "redemptionStrategiesConfig", + "offset": 0, + "slot": "105", + "type": "t_mapping(t_address,t_struct(RedemptionStrategy)51392_storage)" + }, + { + "astId": 51352, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "fundingStrategiesConfig", + "offset": 0, + "slot": "106", + "type": "t_mapping(t_address,t_struct(FundingStrategy)51399_storage)" + }, + { + "astId": 51356, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "jarvisPoolsConfig", + "offset": 0, + "slot": "107", + "type": "t_array(t_struct(JarvisPool)51408_storage)dyn_storage" + }, + { + "astId": 51360, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "curveSwapPoolsConfig", + "offset": 0, + "slot": "108", + "type": "t_array(t_struct(CurveSwapPool)51414_storage)dyn_storage" + }, + { + "astId": 51366, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "balancerPoolForTokens", + "offset": 0, + "slot": "109", + "type": "t_mapping(t_address,t_mapping(t_address,t_address))" + } + ], + "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_struct(CurveSwapPool)51414_storage)dyn_storage": { + "base": "t_struct(CurveSwapPool)51414_storage", + "encoding": "dynamic_array", + "label": "struct AddressesProvider.CurveSwapPool[]", + "numberOfBytes": "32" + }, + "t_array(t_struct(JarvisPool)51408_storage)dyn_storage": { + "base": "t_struct(JarvisPool)51408_storage", + "encoding": "dynamic_array", + "label": "struct AddressesProvider.JarvisPool[]", + "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_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_mapping(t_address,t_address))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_address)" + }, + "t_mapping(t_address,t_struct(Contract)51385_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct AddressesProvider.Contract)", + "numberOfBytes": "32", + "value": "t_struct(Contract)51385_storage" + }, + "t_mapping(t_address,t_struct(FundingStrategy)51399_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct AddressesProvider.FundingStrategy)", + "numberOfBytes": "32", + "value": "t_struct(FundingStrategy)51399_storage" + }, + "t_mapping(t_address,t_struct(RedemptionStrategy)51392_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct AddressesProvider.RedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_struct(RedemptionStrategy)51392_storage" + }, + "t_mapping(t_string_memory_ptr,t_address)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(Contract)51385_storage": { + "encoding": "inplace", + "label": "struct AddressesProvider.Contract", + "members": [ + { + "astId": 51382, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "addr", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 51384, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "contractInterface", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(CurveSwapPool)51414_storage": { + "encoding": "inplace", + "label": "struct AddressesProvider.CurveSwapPool", + "members": [ + { + "astId": 51410, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "poolAddress", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 51413, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "coins", + "offset": 0, + "slot": "1", + "type": "t_array(t_address)dyn_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(FundingStrategy)51399_storage": { + "encoding": "inplace", + "label": "struct AddressesProvider.FundingStrategy", + "members": [ + { + "astId": 51394, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "addr", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 51396, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "contractInterface", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 51398, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "inputToken", + "offset": 0, + "slot": "2", + "type": "t_address" + } + ], + "numberOfBytes": "96" + }, + "t_struct(JarvisPool)51408_storage": { + "encoding": "inplace", + "label": "struct AddressesProvider.JarvisPool", + "members": [ + { + "astId": 51401, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "syntheticToken", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 51403, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "collateralToken", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 51405, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "liquidityPool", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 51407, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "expirationTime", + "offset": 0, + "slot": "3", + "type": "t_uint256" + } + ], + "numberOfBytes": "128" + }, + "t_struct(RedemptionStrategy)51392_storage": { + "encoding": "inplace", + "label": "struct AddressesProvider.RedemptionStrategy", + "members": [ + { + "astId": 51387, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "addr", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 51389, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "contractInterface", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 51391, + "contract": "contracts/ionic/AddressesProvider.sol:AddressesProvider", + "label": "outputToken", + "offset": 0, + "slot": "2", + "type": "t_address" + } + ], + "numberOfBytes": "96" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AddressesProvider_Proxy.json b/packages/contracts/deployments/superseed/AddressesProvider_Proxy.json new file mode 100644 index 0000000000..2e0b22ee9b --- /dev/null +++ b/packages/contracts/deployments/superseed/AddressesProvider_Proxy.json @@ -0,0 +1,275 @@ +{ + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "transactionIndex": 1, + "gasUsed": "772720", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000002000009000000000000000000000000000000000000020000000000000000000800001000800000000000000000000000400001000000000000000000000000000000000008000080000000000000c00000000000000000000000000200000400000000000000000000000000000000000000000060000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577", + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000007ea7bb80f3bbee9b52e6ed3775ba06c9c80d4154" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + }, + { + "transactionIndex": 1, + "blockNumber": 4135345, + "transactionHash": "0x3d99a6ef046c2cb7eba5531fcb84ffba575a5b35a4a7de271efc38cda4cdca63", + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x34b9a2471f80f9d000759a985465d1cb0c656569eddd72eff05b8dc2d86b4577" + } + ], + "blockNumber": 4135345, + "cumulativeGasUsed": "816598", + "status": 1, + "byzantium": true + }, + "args": [ + "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AuthoritiesRegistry.json b/packages/contracts/deployments/superseed/AuthoritiesRegistry.json new file mode 100644 index 0000000000..b7ef465c00 --- /dev/null +++ b/packages/contracts/deployments/superseed/AuthoritiesRegistry.json @@ -0,0 +1,636 @@ +{ + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "functionSig", + "type": "bytes4" + } + ], + "name": "canCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "createPoolAuthority", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "auth", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_leveredPositionsFactory", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "leveredPositionsFactory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "noAuthRequired", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolAuthLogic", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "poolsAuthorities", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "reconfigureAuthority", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_leveredPositionsFactory", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint8", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "setUserRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "transactionIndex": 1, + "gasUsed": "2343115", + "logsBloom": "0x00010000000000000000000000000000400010000000000001800000000200000000000000000000000010100000000000100000100000000008000000000004000000000000040000000000000002040401000000000000000000000000000400000000020000000000000000000800000000800000000000000000000000400000200000000000000080000000000000000000000080000000000000c00001000000002000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000020000000000000000000000000000000040000000000000", + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35", + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000522e808b99a89f0587906eb0a913675d35a936f6" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0x8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76", + "0x00000000000000000000000049fc77cac3066bde8effb717e43aa31b112a0ece", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": "0x", + "logIndex": 3, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0xa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b76389980198", + "0x00000000000000000000000049fc77cac3066bde8effb717e43aa31b112a0ece", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": "0x", + "logIndex": 4, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 5, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 6, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 7, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + } + ], + "blockNumber": 4159568, + "cumulativeGasUsed": "2386957", + "status": 1, + "byzantium": true + }, + "args": [ + "0x522E808b99a89F0587906eB0A913675D35a936f6", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000005d74800e977bfc8e14eca28c9405bacbd091738e" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + "0x5d74800e977bFc8E14Eca28C9405BacbD091738E" + ] + }, + "implementation": "0x522E808b99a89F0587906eB0A913675D35a936f6", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AuthoritiesRegistry_Implementation.json b/packages/contracts/deployments/superseed/AuthoritiesRegistry_Implementation.json new file mode 100644 index 0000000000..1d2488b3c6 --- /dev/null +++ b/packages/contracts/deployments/superseed/AuthoritiesRegistry_Implementation.json @@ -0,0 +1,523 @@ +{ + "address": "0x522E808b99a89F0587906eB0A913675D35a936f6", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "functionSig", + "type": "bytes4" + } + ], + "name": "canCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "createPoolAuthority", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "auth", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_leveredPositionsFactory", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "leveredPositionsFactory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "noAuthRequired", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolAuthLogic", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "poolsAuthorities", + "outputs": [ + { + "internalType": "contract PoolRolesAuthority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "reconfigureAuthority", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_leveredPositionsFactory", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint8", + "name": "role", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "setUserRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xce73164d9334dd04990782a5c55fa1fb3681694d976e7b3f30a58c41cca46223", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x522E808b99a89F0587906eB0A913675D35a936f6", + "transactionIndex": 1, + "gasUsed": "3606459", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2489807033993e05ad84796086bbfd5c9b06a1fd33aa9957028292df5606c325", + "transactionHash": "0xce73164d9334dd04990782a5c55fa1fb3681694d976e7b3f30a58c41cca46223", + "logs": [], + "blockNumber": 4159565, + "cumulativeGasUsed": "3650301", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"NewPendingOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_acceptOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"_setPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"functionSig\",\"type\":\"bytes4\"}],\"name\":\"canCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"pool\",\"type\":\"address\"}],\"name\":\"createPoolAuthority\",\"outputs\":[{\"internalType\":\"contract PoolRolesAuthority\",\"name\":\"auth\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_leveredPositionsFactory\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"leveredPositionsFactory\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"noAuthRequired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolAuthLogic\",\"outputs\":[{\"internalType\":\"contract PoolRolesAuthority\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"poolsAuthorities\",\"outputs\":[{\"internalType\":\"contract PoolRolesAuthority\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"reconfigureAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_leveredPositionsFactory\",\"type\":\"address\"}],\"name\":\"reinitialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"role\",\"type\":\"uint8\"},{\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"name\":\"setUserRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_acceptOwner()\":{\"details\":\"Owner function for pending owner to accept role and update owner\"},\"_setPendingOwner(address)\":{\"details\":\"Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\",\"params\":{\"newPendingOwner\":\"New pending owner.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"events\":{\"NewOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is accepted, which means owner is updated\"},\"NewPendingOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is changed\"}},\"kind\":\"user\",\"methods\":{\"_acceptOwner()\":{\"notice\":\"Accepts transfer of owner rights. msg.sender must be pendingOwner\"},\"_setPendingOwner(address)\":{\"notice\":\"Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\"},\"pendingOwner()\":{\"notice\":\"Pending owner of this contract\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/AuthoritiesRegistry.sol\":\"AuthoritiesRegistry\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50614053806100206000396000f3fe60806040523480156200001157600080fd5b5060043610620001155760003560e01c8063c4d66de811620000a3578063ec2ffdd1116200006e578063ec2ffdd11462000241578063f2fde38b146200026d578063f7e7d1fd1462000284578063fc4d33f9146200029b57600080fd5b8063c4d66de814620001e8578063ca224d9814620001ff578063df595cb81462000216578063e30c3978146200022d57600080fd5b80637a084dac11620000e45780637a084dac14620001855780638da5cb5b14620001ab57806395f14b1614620001bd578063a1a82b5614620001d157600080fd5b806354927fb8146200011a5780635a89ef51146200014b5780636e96dfd71462000164578063715018a6146200017b575b600080fd5b6067546200012e906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001626200015c36600462001297565b620002a5565b005b620001626200017536600462001297565b62000670565b62000162620006dc565b6068546200019a90600160a01b900460ff1681565b604051901515815260200162000142565b6033546001600160a01b03166200012e565b6068546200012e906001600160a01b031681565b6200012e620001e236600462001297565b62000722565b62000162620001f936600462001297565b620009ed565b6200016262000210366004620012dd565b62000b6d565b6200019a6200022736600462001342565b62000d71565b6065546200012e906001600160a01b031681565b6200012e6200025236600462001297565b6066602052600090815260409020546001600160a01b031681565b620001626200027e36600462001297565b62000e3a565b620001626200029536600462001297565b62000ead565b6200016262000ff6565b6001600160a01b038082166000818152606660205260409020548392169033141580620002da57506001600160a01b03811615155b156200066b576001600160a01b038116620003305760405162461bcd60e51b81526020600482015260116024820152706e6f207375636820617574686f7269747960781b60448201526064015b60405180910390fd5b6033546001600160a01b0316331480620003525750336001600160a01b038416145b620003945760405162461bcd60e51b81526020600482015260116024820152701b9bdd081bdddb995c881bdc881c1bdbdb607a1b604482015260640162000327565b806001600160a01b031663e347416d6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015620003d057600080fd5b505af1158015620003e5573d6000803e3d6000fd5b5050604051630c22644560e01b81526001600160a01b03858116600483015284169250630c2264459150602401600060405180830381600087803b1580156200042d57600080fd5b505af115801562000442573d6000803e3d6000fd5b5050604051630a4c60c560e41b81526001600160a01b0385811660048301528416925063a4c60c509150602401600060405180830381600087803b1580156200048a57600080fd5b505af11580156200049f573d6000803e3d6000fd5b5050604051637875b94560e01b81526001600160a01b03858116600483015284169250637875b9459150602401600060405180830381600087803b158015620004e757600080fd5b505af1158015620004fc573d6000803e3d6000fd5b505060405163387beb5760e11b81526001600160a01b038581166004830152841692506370f7d6ae9150602401600060405180830381600087803b1580156200054457600080fd5b505af115801562000559573d6000803e3d6000fd5b50505050620005706033546001600160a01b031690565b6001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620005b8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005de9190620013a8565b6001600160a01b0316146200066b57806001600160a01b03166313af40356200060f6033546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b1580156200065157600080fd5b505af115801562000666573d6000803e3d6000fd5b505050505b505050565b6200067a62001110565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b620006e662001110565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b604482015260640162000327565b60006200072e62001110565b6001600160a01b0382811660009081526066602052604090205416156200078a5760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e4818dc99585d1959608a1b604482015260640162000327565b6067546000906001600160a01b0316620007cb7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b604051620007d99062001265565b6001600160a01b03928316815291166020820152606060408201819052600090820152608001604051809103906000f0801580156200081c573d6000803e3d6000fd5b5060405163189acdbd60e31b81523060048201529092508291506001600160a01b0382169063c4d66de890602401600060405180830381600087803b1580156200086557600080fd5b505af11580156200087a573d6000803e3d6000fd5b505050506001600160a01b038381166000818152606660205260409081902080546001600160a01b0319169386169384179055516319883fc160e01b815260048101919091526319883fc190602401600060405180830381600087803b158015620008e457600080fd5b505af1158015620008f9573d6000803e3d6000fd5b50505050816001600160a01b03166367aff48430846001600160a01b03166342f1e8796040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200094c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009729190620013c8565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260ff16602482015260016044820152606401600060405180830381600087803b158015620009c357600080fd5b505af1158015620009d8573d6000803e3d6000fd5b50505050620009e783620002a5565b50919050565b600054610100900460ff161580801562000a0e5750600054600160ff909116105b8062000a2a5750303b15801562000a2a575060005460ff166001145b62000a8f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840162000327565b6000805460ff19166001179055801562000ab3576000805461ff0019166101001790555b62000abe336200116e565b606880546001600160a01b0319166001600160a01b03841617905560405162000ae79062001273565b604051809103906000f08015801562000b04573d6000803e3d6000fd5b50606780546001600160a01b0319166001600160a01b0392909216919091179055801562000b69576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001620006d0565b5050565b6001600160a01b03808516600090815260666020526040902054168062000bcd5760405162461bcd60e51b8152602060048201526013602482015272185d5d1a08191bd95cc81b9bdd08195e1a5cdd606a1b604482015260640162000327565b6033546001600160a01b031633148062000bf157506068546001600160a01b031633145b62000c365760405162461bcd60e51b81526020600482015260146024820152736e6f74206f776e6572206f7220666163746f727960601b604482015260640162000327565b6068546001600160a01b03163314158062000cba5750806001600160a01b0316633300183c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000c8b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000cb19190620013c8565b60ff168360ff16145b62000cfc5760405162461bcd60e51b81526020600482015260116024820152706f6e6c79206c657620706f7320726f6c6560781b604482015260640162000327565b6040516319ebfd2160e21b81526001600160a01b03858116600483015260ff8516602483015283151560448301528216906367aff48490606401600060405180830381600087803b15801562000d5157600080fd5b505af115801562000d66573d6000803e3d6000fd5b505050505050505050565b6001600160a01b038085166000908152606660205260408120549091168062000da9575050606854600160a01b900460ff1662000e32565b60405163b700961360e01b81526001600160a01b03868116600483015285811660248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa15801562000e08573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e2e9190620013e8565b9150505b949350505050565b62000e4462001110565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633148062000f7057600062000ef57fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b90506001600160a01b03811633148062000f6d5760405162461bcd60e51b815260206004820152603260248201527f4f776e61626c653a2063616c6c6572206973206e65697468657220746865206f6044820152713bb732b9103737b9103a34329030b236b4b760711b606482015260840162000327565b50505b606880546001600160a01b0319166001600160a01b03841617905560405162000f999062001273565b604051809103906000f08015801562000fb6573d6000803e3d6000fd5b50606780546001600160a01b0319166001600160a01b039290921691909117905550506068805460ff60a01b191646630e9ac0d614600160a01b02179055565b6065546001600160a01b031633146200104a5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b604482015260640162000327565b60006200105f6033546001600160a01b031690565b6065549091506001600160a01b03166200107981620011b0565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101620006d0565b6033546001600160a01b031633146200116c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000327565b565b600054610100900460ff16620011985760405162461bcd60e51b8152600401620003279062001408565b620011a262001202565b620011ad81620011b0565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166200122c5760405162461bcd60e51b8152600401620003279062001408565b6200116c600054610100900460ff166200125a5760405162461bcd60e51b8152600401620003279062001408565b6200116c33620011b0565b610dcf806200145483390190565b611dfb806200222383390190565b6001600160a01b0381168114620011ad57600080fd5b600060208284031215620012aa57600080fd5b8135620012b78162001281565b9392505050565b60ff81168114620011ad57600080fd5b8015158114620011ad57600080fd5b60008060008060808587031215620012f457600080fd5b8435620013018162001281565b93506020850135620013138162001281565b925060408501356200132581620012be565b915060608501356200133781620012ce565b939692955090935050565b600080600080608085870312156200135957600080fd5b8435620013668162001281565b93506020850135620013788162001281565b925060408501356200138a8162001281565b915060608501356001600160e01b0319811681146200133757600080fd5b600060208284031215620013bb57600080fd5b8151620012b78162001281565b600060208284031215620013db57600080fd5b8151620012b781620012be565b600060208284031215620013fb57600080fd5b8151620012b781620012ce565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe608060405260405162000dcf38038062000dcf833981016040819052620000269162000424565b828162000036828260006200004d565b50620000449050826200007f565b50505062000557565b6200005883620000f1565b600082511180620000665750805b156200007a5762000078838362000133565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000c160008051602062000d88833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000ee8162000162565b50565b620000fc8162000200565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200015b838360405180606001604052806027815260200162000da86027913962000297565b9392505050565b6001600160a01b038116620001cd5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b8060008051602062000d888339815191525b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b6200026f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401620001c4565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc620001df565b6060600080856001600160a01b031685604051620002b6919062000504565b600060405180830381855af49150503d8060008114620002f3576040519150601f19603f3d011682016040523d82523d6000602084013e620002f8565b606091505b5090925090506200030c8683838762000316565b9695505050505050565b606083156200038a57825160000362000382576001600160a01b0385163b620003825760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620001c4565b508162000396565b6200039683836200039e565b949350505050565b815115620003af5781518083602001fd5b8060405162461bcd60e51b8152600401620001c4919062000522565b80516001600160a01b0381168114620003e357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200041b57818101518382015260200162000401565b50506000910152565b6000806000606084860312156200043a57600080fd5b6200044584620003cb565b92506200045560208501620003cb565b60408501519092506001600160401b03808211156200047357600080fd5b818601915086601f8301126200048857600080fd5b8151818111156200049d576200049d620003e8565b604051601f8201601f19908116603f01168101908382118183101715620004c857620004c8620003e8565b81604052828152896020848701011115620004e257600080fd5b620004f5836020830160208801620003fe565b80955050505050509250925092565b6000825162000518818460208701620003fe565b9190910192915050565b602081526000825180602084015262000543816040850160208701620003fe565b601f01601f19169190910160400192915050565b61082180620005676000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106b3565b610118565b61005b6100933660046106ce565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106b3565b6101ed565b3480156100f557600080fd5b506100ad61020d565b61010661022e565b6101166101116102c3565b6102cd565b565b6101206102f1565b6001600160a01b0316330361014d5761014a81604051806020016040528060008152506000610324565b50565b61014a6100fe565b61015d6102f1565b6001600160a01b031633036101b4576101af8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610324915050565b505050565b6101af6100fe565b60006101c66102f1565b6001600160a01b031633036101e2576101dd6102c3565b905090565b6101ea6100fe565b90565b6101f56102f1565b6001600160a01b0316330361014d5761014a8161034f565b60006102176102f1565b6001600160a01b031633036101e2576101dd6102f1565b6102366102f1565b6001600160a01b031633036101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101dd6103a3565b3660008037600080366000845af43d6000803e8080156102ec573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61032d836103cb565b60008251118061033a5750805b156101af57610349838361040b565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103786102f1565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610437565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610315565b6103d4816104e0565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061043083836040518060600160405280602781526020016107c560279139610574565b9392505050565b6001600160a01b03811661049c5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084016102ba565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b61054d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016102ba565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6104bf565b6060600080856001600160a01b0316856040516105919190610775565b600060405180830381855af49150503d80600081146105cc576040519150601f19603f3d011682016040523d82523d6000602084013e6105d1565b606091505b50915091506105e2868383876105ec565b9695505050505050565b6060831561065b578251600003610654576001600160a01b0385163b6106545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102ba565b5081610665565b610665838361066d565b949350505050565b81511561067d5781518083602001fd5b8060405162461bcd60e51b81526004016102ba9190610791565b80356001600160a01b03811681146106ae57600080fd5b919050565b6000602082840312156106c557600080fd5b61043082610697565b6000806000604084860312156106e357600080fd5b6106ec84610697565b9250602084013567ffffffffffffffff8082111561070957600080fd5b818601915086601f83011261071d57600080fd5b81358181111561072c57600080fd5b87602082850101111561073e57600080fd5b6020830194508093505050509250925092565b60005b8381101561076c578181015183820152602001610754565b50506000910152565b60008251610787818460208701610751565b9190910192915050565b60208152600082518060208401526107b0816040850160208701610751565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122049fbb9e275f9555a5ebeb3eac5556056919978cd556ae751be1e8df612684db664736f6c63430008160033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564608060405234801561001057600080fd5b50600080546001600160a01b03199081168255600180549091169055604051819081908190819033907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908390a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a3505050506100a66100ab60201b60201c565b61016b565b600554610100900460ff16156101175760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60055460ff9081161015610169576005805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b611c818061017a6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80637875b94511610104578063b4bad06a116100a2578063c6b0263e11610071578063c6b0263e14610441578063d8e708cd14610454578063e347416d14610467578063ea7ca2761461046f57600080fd5b8063b4bad06a146103bb578063b700961314610408578063bf7e214f1461041b578063c4d66de81461042e57600080fd5b80637d40583d116100de5780637d40583d146103625780638da5cb5b14610375578063a29508fc146103a0578063a4c60c50146103a857600080fd5b80637875b945146103115780637917b794146103245780637a9e5e4b1461034f57600080fd5b80632f47571f116101715780633c0689751161014b5780633c068975146102d057806342f1e879146102e357806367aff484146102eb57806370f7d6ae146102fe57600080fd5b80632f47571f1461027757806332c9c4d8146102b55780633300183c146102c857600080fd5b806313af4035116101ad57806313af40351461023657806313e27f8b1461024957806316d8887a1461025c57806319883fc11461026457600080fd5b806306a36aee146101d45780630c226445146102075780630e7b949e1461021c575b600080fd5b6101f46101e23660046118bf565b60026020526000908152604090205481565b6040519081526020015b60405180910390f35b61021a6102153660046118bf565b6104a6565b005b610224600281565b60405160ff90911681526020016101fe565b61021a6102443660046118bf565b6104ef565b61021a6102573660046118bf565b61056c565b610224600381565b61021a6102723660046118bf565b6105a9565b6102a5610285366004611900565b600360209081526000928352604080842090915290825290205460ff1681565b60405190151581526020016101fe565b61021a6102c33660046118bf565b6105e6565b610224600481565b61021a6102de3660046118bf565b610762565b610224600081565b61021a6102f9366004611954565b61079f565b61021a61030c3660046118bf565b610874565b61021a61031f3660046118bf565b610ab4565b6101f4610332366004611900565b600460209081526000928352604080842090915290825290205481565b61021a61035d3660046118bf565b610be6565b61021a61037036600461199d565b610cd0565b600054610388906001600160a01b031681565b6040516001600160a01b0390911681526020016101fe565b610224600181565b61021a6103b63660046118bf565b610ddb565b6102a56103c93660046119f5565b6001600160a01b039190911660009081526004602090815260408083206001600160e01b031990941683529290522054600160ff929092161c16151590565b6102a5610416366004611a3a565b610f1e565b600154610388906001600160a01b031681565b61021a61043c3660046118bf565b610f9d565b61021a61044f366004611a5a565b6110d0565b61021a6104623660046118bf565b611171565b61021a6111ae565b6102a561047d366004611a88565b6001600160a01b0391909116600090815260026020526040902054600160ff9092161c16151590565b6104bc336000356001600160e01b031916611275565b6104e15760405162461bcd60e51b81526004016104d890611ab4565b60405180910390fd5b6104ec81600161131e565b50565b610505336000356001600160e01b031916611275565b6105215760405162461bcd60e51b81526004016104d890611ab4565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b610582336000356001600160e01b031916611275565b61059e5760405162461bcd60e51b81526004016104d890611ab4565b6104ec81600161142b565b6105bf336000356001600160e01b031916611275565b6105db5760405162461bcd60e51b81526004016104d890611ab4565b6104ec8160016115a9565b6105fc336000356001600160e01b031916611275565b6106185760405162461bcd60e51b81526004016104d890611ab4565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610658573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106809190810190611afb565b905060005b815181101561075d576106cf8282815181106106a3576106a3611bc0565b60200260200101518383815181106106bd576106bd611bc0565b50637af1e23160e11b905060006110d0565b61071260038383815181106106e6576106e6611bc0565b602002602001015184848151811061070057610700611bc0565b50637af1e23160e11b90506001610cd0565b610755600383838151811061072957610729611bc0565b602002602001015184848151811061074357610743611bc0565b5063db006a7560e01b90506001610cd0565b600101610685565b505050565b610778336000356001600160e01b031916611275565b6107945760405162461bcd60e51b81526004016104d890611ab4565b6104ec81600061142b565b6107b5336000356001600160e01b031916611275565b6107d15760405162461bcd60e51b81526004016104d890611ab4565b8015610800576001600160a01b03831660009081526002602052604090208054600160ff85161b179055610826565b6001600160a01b03831660009081526002602052604090208054600160ff85161b191690555b8160ff16836001600160a01b03167f4c9bdd0c8e073eb5eda2250b18d8e5121ff27b62064fbeeeed4869bb99bc5bf283604051610867911515815260200190565b60405180910390a3505050565b61088a336000356001600160e01b031916611275565b6108a65760405162461bcd60e51b81526004016104d890611ab4565b6108bb600482631853304760e31b6001610cd0565b6108d0600482630ede4edd60e41b6001610cd0565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610910573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109389190810190611afb565b905060005b815181101561075d57610989600483838151811061095d5761095d611bc0565b602002602001015184848151811061097757610977611bc0565b5063140e25ad60e31b90506001610cd0565b6109a0600483838151811061072957610729611bc0565b6109e360048383815181106109b7576109b7611bc0565b60200260200101518484815181106109d1576109d1611bc0565b5063852a12e360e01b90506001610cd0565b610a2660048383815181106109fa576109fa611bc0565b6020026020010151848481518110610a1457610a14611bc0565b5063317afabb60e21b90506001610cd0565b610a696004838381518110610a3d57610a3d611bc0565b6020026020010151848481518110610a5757610a57611bc0565b5063073a938160e11b90506001610cd0565b610aac6004838381518110610a8057610a80611bc0565b6020026020010151848481518110610a9a57610a9a611bc0565b50633c3b4b8960e01b90506001610cd0565b60010161093d565b610aca336000356001600160e01b031916611275565b610ae65760405162461bcd60e51b81526004016104d890611ab4565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b26573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b4e9190810190611afb565b905060005b815181101561075d57610b9d828281518110610b7157610b71611bc0565b6020026020010151838381518110610b8b57610b8b611bc0565b50637af1e23160e11b905060016110d0565b610bde828281518110610bb257610bb2611bc0565b6020026020010151838381518110610bcc57610bcc611bc0565b5063db006a7560e01b905060016110d0565b600101610b53565b6000546001600160a01b0316331480610c7b575060015460405163b700961360e01b81526001600160a01b039091169063b700961390610c3a90339030906001600160e01b03196000351690600401611bd6565b602060405180830381865afa158015610c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7b9190611c03565b610c8457600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b610ce6336000356001600160e01b031916611275565b610d025760405162461bcd60e51b81526004016104d890611ab4565b8015610d46576001600160a01b03831660009081526004602090815260408083206001600160e01b03198616845290915290208054600160ff87161b179055610d81565b6001600160a01b03831660009081526004602090815260408083206001600160e01b03198616845290915290208054600160ff87161b191690555b816001600160e01b031916836001600160a01b03168560ff167fa52ea92e6e955aa8ac66420b86350f7139959adfcc7e6a14eee1bd116d09860e84604051610dcd911515815260200190565b60405180910390a450505050565b610df1336000356001600160e01b031916611275565b610e0d5760405162461bcd60e51b81526004016104d890611ab4565b610e1881600261131e565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e58573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e809190810190611afb565b905060005b815181101561075d57610ea560028383815181106109fa576109fa611bc0565b610ebc6002838381518110610a3d57610a3d611bc0565b610eff6002838381518110610ed357610ed3611bc0565b6020026020010151848481518110610eed57610eed611bc0565b506304c11f0360e31b90506001610cd0565b610f166002838381518110610a8057610a80611bc0565b600101610e85565b6001600160a01b03821660009081526003602090815260408083206001600160e01b03198516845290915281205460ff1680610f9557506001600160a01b0380841660009081526004602090815260408083206001600160e01b031987168452825280832054938816835260029091529020541615155b949350505050565b600554610100900460ff1615808015610fbd5750600554600160ff909116105b80610fd75750303b158015610fd7575060055460ff166001145b61103a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104d8565b6005805460ff19166001179055801561105d576005805461ff0019166101001790555b600080546001600160a01b0384166001600160a01b031991821617909155600180549091163017905580156110cc576005805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6110e6336000356001600160e01b031916611275565b6111025760405162461bcd60e51b81526004016104d890611ab4565b6001600160a01b03831660008181526003602090815260408083206001600160e01b0319871680855290835292819020805460ff191686151590811790915590519081529192917f950a343f5d10445e82a71036d3f4fb3016180a25805141932543b83e2078a93e9101610867565b611187336000356001600160e01b031916611275565b6111a35760405162461bcd60e51b81526004016104d890611ab4565b6104ec8160006115a9565b6111c4336000356001600160e01b031916611275565b6111e05760405162461bcd60e51b81526004016104d890611ab4565b6111f560003063e347416d60e01b6001610cd0565b61120a600030630c22644560e01b6001610cd0565b61121f600030630a4c60c560e41b6001610cd0565b611234600030630659389b60e31b6001610cd0565b611249600030637875b94560e01b6001610cd0565b61125e60003063387beb5760e11b6001610cd0565b6112736000306319ebfd2160e21b6001610cd0565b565b6001546000906001600160a01b031680158015906112ff575060405163b700961360e01b81526001600160a01b0382169063b7009613906112be90879030908890600401611bd6565b602060405180830381865afa1580156112db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ff9190611c03565b80610f9557506000546001600160a01b03858116911614949350505050565b6113328183631853304760e31b6001610cd0565b6113468183630ede4edd60e41b6001610cd0565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611386573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113ae9190810190611afb565b905060005b81518110156114255760006113c66116aa565b905060005b815181101561141b57611413858585815181106113ea576113ea611bc0565b602002602001015184848151811061140457611404611bc0565b60200260200101516001610cd0565b6001016113cb565b50506001016113b3565b50505050565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561146b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114939190810190611afb565b905060005b8151811015611425576114e18282815181106114b6576114b6611bc0565b60200260200101518383815181106114d0576114d0611bc0565b5063317afabb60e21b9050856110d0565b6115218282815181106114f6576114f6611bc0565b602002602001015183838151811061151057611510611bc0565b5063073a938160e11b9050856110d0565b61156182828151811061153657611536611bc0565b602002602001015183838151811061155057611550611bc0565b506304c11f0360e31b9050856110d0565b6115a182828151811061157657611576611bc0565b602002602001015183838151811061159057611590611bc0565b50633c3b4b8960e01b9050856110d0565b600101611498565b6115bb82631853304760e31b836110d0565b6115cd82630ede4edd60e41b836110d0565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561160d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116359190810190611afb565b905060005b815181101561142557600061164d6116aa565b905060005b81518110156116a05761169884848151811061167057611670611bc0565b602002602001015183838151811061168a5761168a611bc0565b6020026020010151876110d0565b600101611652565b505060010161163a565b60408051600680825260e0820190925260609190816020820160c08036833701905050915063140e25ad60e31b826116e183611c20565b92508260ff16815181106116f7576116f7611bc0565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8261172283611c20565b92508260ff168151811061173857611738611bc0565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b8261176383611c20565b92508260ff168151811061177957611779611bc0565b6001600160e01b03199092166020928302919091019091015263a9059cbb60e01b826117a483611c20565b92508260ff16815181106117ba576117ba611bc0565b6001600160e01b0319909216602092830291909101909101526323b872dd60e01b826117e583611c20565b92508260ff16815181106117fb576117fb611bc0565b6001600160e01b03199092166020928302919091019091015263095ea7b360e01b8261182683611c20565b92508260ff168151811061183c5761183c611bc0565b6001600160e01b03199092166020928302919091019091015260ff8116156118a65760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104d8565b5090565b6001600160a01b03811681146104ec57600080fd5b6000602082840312156118d157600080fd5b81356118dc816118aa565b9392505050565b80356001600160e01b0319811681146118fb57600080fd5b919050565b6000806040838503121561191357600080fd5b823561191e816118aa565b915061192c602084016118e3565b90509250929050565b803560ff811681146118fb57600080fd5b80151581146104ec57600080fd5b60008060006060848603121561196957600080fd5b8335611974816118aa565b925061198260208501611935565b9150604084013561199281611946565b809150509250925092565b600080600080608085870312156119b357600080fd5b6119bc85611935565b935060208501356119cc816118aa565b92506119da604086016118e3565b915060608501356119ea81611946565b939692955090935050565b600080600060608486031215611a0a57600080fd5b611a1384611935565b92506020840135611a23816118aa565b9150611a31604085016118e3565b90509250925092565b600080600060608486031215611a4f57600080fd5b8335611a13816118aa565b600080600060608486031215611a6f57600080fd5b8335611a7a816118aa565b9250611982602085016118e3565b60008060408385031215611a9b57600080fd5b8235611aa6816118aa565b915061192c60208401611935565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b80516118fb816118aa565b60006020808385031215611b0e57600080fd5b825167ffffffffffffffff80821115611b2657600080fd5b818501915085601f830112611b3a57600080fd5b815181811115611b4c57611b4c611ada565b8060051b604051601f19603f83011681018181108582111715611b7157611b71611ada565b604052918252848201925083810185019188831115611b8f57600080fd5b938501935b82851015611bb457611ba585611af0565b84529385019392850192611b94565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215611c1557600080fd5b81516118dc81611946565b600060ff821680611c4157634e487b7160e01b600052601160045260246000fd5b600019019291505056fea26469706673582212203697c5df093fecfe51293170c70e50ad0107abeb49f1b472c2dbd8ba10eda86664736f6c63430008160033a26469706673582212205b3dc4126764b77dcb499e6a312479c947b4c178b4b1d7fbb61bd60e1b35b3d564736f6c63430008160033", + "deployedBytecode": "0x60806040523480156200001157600080fd5b5060043610620001155760003560e01c8063c4d66de811620000a3578063ec2ffdd1116200006e578063ec2ffdd11462000241578063f2fde38b146200026d578063f7e7d1fd1462000284578063fc4d33f9146200029b57600080fd5b8063c4d66de814620001e8578063ca224d9814620001ff578063df595cb81462000216578063e30c3978146200022d57600080fd5b80637a084dac11620000e45780637a084dac14620001855780638da5cb5b14620001ab57806395f14b1614620001bd578063a1a82b5614620001d157600080fd5b806354927fb8146200011a5780635a89ef51146200014b5780636e96dfd71462000164578063715018a6146200017b575b600080fd5b6067546200012e906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001626200015c36600462001297565b620002a5565b005b620001626200017536600462001297565b62000670565b62000162620006dc565b6068546200019a90600160a01b900460ff1681565b604051901515815260200162000142565b6033546001600160a01b03166200012e565b6068546200012e906001600160a01b031681565b6200012e620001e236600462001297565b62000722565b62000162620001f936600462001297565b620009ed565b6200016262000210366004620012dd565b62000b6d565b6200019a6200022736600462001342565b62000d71565b6065546200012e906001600160a01b031681565b6200012e6200025236600462001297565b6066602052600090815260409020546001600160a01b031681565b620001626200027e36600462001297565b62000e3a565b620001626200029536600462001297565b62000ead565b6200016262000ff6565b6001600160a01b038082166000818152606660205260409020548392169033141580620002da57506001600160a01b03811615155b156200066b576001600160a01b038116620003305760405162461bcd60e51b81526020600482015260116024820152706e6f207375636820617574686f7269747960781b60448201526064015b60405180910390fd5b6033546001600160a01b0316331480620003525750336001600160a01b038416145b620003945760405162461bcd60e51b81526020600482015260116024820152701b9bdd081bdddb995c881bdc881c1bdbdb607a1b604482015260640162000327565b806001600160a01b031663e347416d6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015620003d057600080fd5b505af1158015620003e5573d6000803e3d6000fd5b5050604051630c22644560e01b81526001600160a01b03858116600483015284169250630c2264459150602401600060405180830381600087803b1580156200042d57600080fd5b505af115801562000442573d6000803e3d6000fd5b5050604051630a4c60c560e41b81526001600160a01b0385811660048301528416925063a4c60c509150602401600060405180830381600087803b1580156200048a57600080fd5b505af11580156200049f573d6000803e3d6000fd5b5050604051637875b94560e01b81526001600160a01b03858116600483015284169250637875b9459150602401600060405180830381600087803b158015620004e757600080fd5b505af1158015620004fc573d6000803e3d6000fd5b505060405163387beb5760e11b81526001600160a01b038581166004830152841692506370f7d6ae9150602401600060405180830381600087803b1580156200054457600080fd5b505af115801562000559573d6000803e3d6000fd5b50505050620005706033546001600160a01b031690565b6001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620005b8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005de9190620013a8565b6001600160a01b0316146200066b57806001600160a01b03166313af40356200060f6033546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b1580156200065157600080fd5b505af115801562000666573d6000803e3d6000fd5b505050505b505050565b6200067a62001110565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b620006e662001110565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b604482015260640162000327565b60006200072e62001110565b6001600160a01b0382811660009081526066602052604090205416156200078a5760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e4818dc99585d1959608a1b604482015260640162000327565b6067546000906001600160a01b0316620007cb7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b604051620007d99062001265565b6001600160a01b03928316815291166020820152606060408201819052600090820152608001604051809103906000f0801580156200081c573d6000803e3d6000fd5b5060405163189acdbd60e31b81523060048201529092508291506001600160a01b0382169063c4d66de890602401600060405180830381600087803b1580156200086557600080fd5b505af11580156200087a573d6000803e3d6000fd5b505050506001600160a01b038381166000818152606660205260409081902080546001600160a01b0319169386169384179055516319883fc160e01b815260048101919091526319883fc190602401600060405180830381600087803b158015620008e457600080fd5b505af1158015620008f9573d6000803e3d6000fd5b50505050816001600160a01b03166367aff48430846001600160a01b03166342f1e8796040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200094c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009729190620013c8565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260ff16602482015260016044820152606401600060405180830381600087803b158015620009c357600080fd5b505af1158015620009d8573d6000803e3d6000fd5b50505050620009e783620002a5565b50919050565b600054610100900460ff161580801562000a0e5750600054600160ff909116105b8062000a2a5750303b15801562000a2a575060005460ff166001145b62000a8f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840162000327565b6000805460ff19166001179055801562000ab3576000805461ff0019166101001790555b62000abe336200116e565b606880546001600160a01b0319166001600160a01b03841617905560405162000ae79062001273565b604051809103906000f08015801562000b04573d6000803e3d6000fd5b50606780546001600160a01b0319166001600160a01b0392909216919091179055801562000b69576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001620006d0565b5050565b6001600160a01b03808516600090815260666020526040902054168062000bcd5760405162461bcd60e51b8152602060048201526013602482015272185d5d1a08191bd95cc81b9bdd08195e1a5cdd606a1b604482015260640162000327565b6033546001600160a01b031633148062000bf157506068546001600160a01b031633145b62000c365760405162461bcd60e51b81526020600482015260146024820152736e6f74206f776e6572206f7220666163746f727960601b604482015260640162000327565b6068546001600160a01b03163314158062000cba5750806001600160a01b0316633300183c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000c8b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000cb19190620013c8565b60ff168360ff16145b62000cfc5760405162461bcd60e51b81526020600482015260116024820152706f6e6c79206c657620706f7320726f6c6560781b604482015260640162000327565b6040516319ebfd2160e21b81526001600160a01b03858116600483015260ff8516602483015283151560448301528216906367aff48490606401600060405180830381600087803b15801562000d5157600080fd5b505af115801562000d66573d6000803e3d6000fd5b505050505050505050565b6001600160a01b038085166000908152606660205260408120549091168062000da9575050606854600160a01b900460ff1662000e32565b60405163b700961360e01b81526001600160a01b03868116600483015285811660248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa15801562000e08573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e2e9190620013e8565b9150505b949350505050565b62000e4462001110565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633148062000f7057600062000ef57fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b90506001600160a01b03811633148062000f6d5760405162461bcd60e51b815260206004820152603260248201527f4f776e61626c653a2063616c6c6572206973206e65697468657220746865206f6044820152713bb732b9103737b9103a34329030b236b4b760711b606482015260840162000327565b50505b606880546001600160a01b0319166001600160a01b03841617905560405162000f999062001273565b604051809103906000f08015801562000fb6573d6000803e3d6000fd5b50606780546001600160a01b0319166001600160a01b039290921691909117905550506068805460ff60a01b191646630e9ac0d614600160a01b02179055565b6065546001600160a01b031633146200104a5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b604482015260640162000327565b60006200105f6033546001600160a01b031690565b6065549091506001600160a01b03166200107981620011b0565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101620006d0565b6033546001600160a01b031633146200116c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000327565b565b600054610100900460ff16620011985760405162461bcd60e51b8152600401620003279062001408565b620011a262001202565b620011ad81620011b0565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166200122c5760405162461bcd60e51b8152600401620003279062001408565b6200116c600054610100900460ff166200125a5760405162461bcd60e51b8152600401620003279062001408565b6200116c33620011b0565b610dcf806200145483390190565b611dfb806200222383390190565b6001600160a01b0381168114620011ad57600080fd5b600060208284031215620012aa57600080fd5b8135620012b78162001281565b9392505050565b60ff81168114620011ad57600080fd5b8015158114620011ad57600080fd5b60008060008060808587031215620012f457600080fd5b8435620013018162001281565b93506020850135620013138162001281565b925060408501356200132581620012be565b915060608501356200133781620012ce565b939692955090935050565b600080600080608085870312156200135957600080fd5b8435620013668162001281565b93506020850135620013788162001281565b925060408501356200138a8162001281565b915060608501356001600160e01b0319811681146200133757600080fd5b600060208284031215620013bb57600080fd5b8151620012b78162001281565b600060208284031215620013db57600080fd5b8151620012b781620012be565b600060208284031215620013fb57600080fd5b8151620012b781620012ce565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe608060405260405162000dcf38038062000dcf833981016040819052620000269162000424565b828162000036828260006200004d565b50620000449050826200007f565b50505062000557565b6200005883620000f1565b600082511180620000665750805b156200007a5762000078838362000133565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000c160008051602062000d88833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000ee8162000162565b50565b620000fc8162000200565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200015b838360405180606001604052806027815260200162000da86027913962000297565b9392505050565b6001600160a01b038116620001cd5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b8060008051602062000d888339815191525b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b6200026f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401620001c4565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc620001df565b6060600080856001600160a01b031685604051620002b6919062000504565b600060405180830381855af49150503d8060008114620002f3576040519150601f19603f3d011682016040523d82523d6000602084013e620002f8565b606091505b5090925090506200030c8683838762000316565b9695505050505050565b606083156200038a57825160000362000382576001600160a01b0385163b620003825760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620001c4565b508162000396565b6200039683836200039e565b949350505050565b815115620003af5781518083602001fd5b8060405162461bcd60e51b8152600401620001c4919062000522565b80516001600160a01b0381168114620003e357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200041b57818101518382015260200162000401565b50506000910152565b6000806000606084860312156200043a57600080fd5b6200044584620003cb565b92506200045560208501620003cb565b60408501519092506001600160401b03808211156200047357600080fd5b818601915086601f8301126200048857600080fd5b8151818111156200049d576200049d620003e8565b604051601f8201601f19908116603f01168101908382118183101715620004c857620004c8620003e8565b81604052828152896020848701011115620004e257600080fd5b620004f5836020830160208801620003fe565b80955050505050509250925092565b6000825162000518818460208701620003fe565b9190910192915050565b602081526000825180602084015262000543816040850160208701620003fe565b601f01601f19169190910160400192915050565b61082180620005676000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106b3565b610118565b61005b6100933660046106ce565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106b3565b6101ed565b3480156100f557600080fd5b506100ad61020d565b61010661022e565b6101166101116102c3565b6102cd565b565b6101206102f1565b6001600160a01b0316330361014d5761014a81604051806020016040528060008152506000610324565b50565b61014a6100fe565b61015d6102f1565b6001600160a01b031633036101b4576101af8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610324915050565b505050565b6101af6100fe565b60006101c66102f1565b6001600160a01b031633036101e2576101dd6102c3565b905090565b6101ea6100fe565b90565b6101f56102f1565b6001600160a01b0316330361014d5761014a8161034f565b60006102176102f1565b6001600160a01b031633036101e2576101dd6102f1565b6102366102f1565b6001600160a01b031633036101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101dd6103a3565b3660008037600080366000845af43d6000803e8080156102ec573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61032d836103cb565b60008251118061033a5750805b156101af57610349838361040b565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103786102f1565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610437565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610315565b6103d4816104e0565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061043083836040518060600160405280602781526020016107c560279139610574565b9392505050565b6001600160a01b03811661049c5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084016102ba565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b0381163b61054d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016102ba565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6104bf565b6060600080856001600160a01b0316856040516105919190610775565b600060405180830381855af49150503d80600081146105cc576040519150601f19603f3d011682016040523d82523d6000602084013e6105d1565b606091505b50915091506105e2868383876105ec565b9695505050505050565b6060831561065b578251600003610654576001600160a01b0385163b6106545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102ba565b5081610665565b610665838361066d565b949350505050565b81511561067d5781518083602001fd5b8060405162461bcd60e51b81526004016102ba9190610791565b80356001600160a01b03811681146106ae57600080fd5b919050565b6000602082840312156106c557600080fd5b61043082610697565b6000806000604084860312156106e357600080fd5b6106ec84610697565b9250602084013567ffffffffffffffff8082111561070957600080fd5b818601915086601f83011261071d57600080fd5b81358181111561072c57600080fd5b87602082850101111561073e57600080fd5b6020830194508093505050509250925092565b60005b8381101561076c578181015183820152602001610754565b50506000910152565b60008251610787818460208701610751565b9190910192915050565b60208152600082518060208401526107b0816040850160208701610751565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122049fbb9e275f9555a5ebeb3eac5556056919978cd556ae751be1e8df612684db664736f6c63430008160033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564608060405234801561001057600080fd5b50600080546001600160a01b03199081168255600180549091169055604051819081908190819033907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908390a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a3505050506100a66100ab60201b60201c565b61016b565b600554610100900460ff16156101175760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60055460ff9081161015610169576005805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b611c818061017a6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80637875b94511610104578063b4bad06a116100a2578063c6b0263e11610071578063c6b0263e14610441578063d8e708cd14610454578063e347416d14610467578063ea7ca2761461046f57600080fd5b8063b4bad06a146103bb578063b700961314610408578063bf7e214f1461041b578063c4d66de81461042e57600080fd5b80637d40583d116100de5780637d40583d146103625780638da5cb5b14610375578063a29508fc146103a0578063a4c60c50146103a857600080fd5b80637875b945146103115780637917b794146103245780637a9e5e4b1461034f57600080fd5b80632f47571f116101715780633c0689751161014b5780633c068975146102d057806342f1e879146102e357806367aff484146102eb57806370f7d6ae146102fe57600080fd5b80632f47571f1461027757806332c9c4d8146102b55780633300183c146102c857600080fd5b806313af4035116101ad57806313af40351461023657806313e27f8b1461024957806316d8887a1461025c57806319883fc11461026457600080fd5b806306a36aee146101d45780630c226445146102075780630e7b949e1461021c575b600080fd5b6101f46101e23660046118bf565b60026020526000908152604090205481565b6040519081526020015b60405180910390f35b61021a6102153660046118bf565b6104a6565b005b610224600281565b60405160ff90911681526020016101fe565b61021a6102443660046118bf565b6104ef565b61021a6102573660046118bf565b61056c565b610224600381565b61021a6102723660046118bf565b6105a9565b6102a5610285366004611900565b600360209081526000928352604080842090915290825290205460ff1681565b60405190151581526020016101fe565b61021a6102c33660046118bf565b6105e6565b610224600481565b61021a6102de3660046118bf565b610762565b610224600081565b61021a6102f9366004611954565b61079f565b61021a61030c3660046118bf565b610874565b61021a61031f3660046118bf565b610ab4565b6101f4610332366004611900565b600460209081526000928352604080842090915290825290205481565b61021a61035d3660046118bf565b610be6565b61021a61037036600461199d565b610cd0565b600054610388906001600160a01b031681565b6040516001600160a01b0390911681526020016101fe565b610224600181565b61021a6103b63660046118bf565b610ddb565b6102a56103c93660046119f5565b6001600160a01b039190911660009081526004602090815260408083206001600160e01b031990941683529290522054600160ff929092161c16151590565b6102a5610416366004611a3a565b610f1e565b600154610388906001600160a01b031681565b61021a61043c3660046118bf565b610f9d565b61021a61044f366004611a5a565b6110d0565b61021a6104623660046118bf565b611171565b61021a6111ae565b6102a561047d366004611a88565b6001600160a01b0391909116600090815260026020526040902054600160ff9092161c16151590565b6104bc336000356001600160e01b031916611275565b6104e15760405162461bcd60e51b81526004016104d890611ab4565b60405180910390fd5b6104ec81600161131e565b50565b610505336000356001600160e01b031916611275565b6105215760405162461bcd60e51b81526004016104d890611ab4565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b610582336000356001600160e01b031916611275565b61059e5760405162461bcd60e51b81526004016104d890611ab4565b6104ec81600161142b565b6105bf336000356001600160e01b031916611275565b6105db5760405162461bcd60e51b81526004016104d890611ab4565b6104ec8160016115a9565b6105fc336000356001600160e01b031916611275565b6106185760405162461bcd60e51b81526004016104d890611ab4565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610658573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106809190810190611afb565b905060005b815181101561075d576106cf8282815181106106a3576106a3611bc0565b60200260200101518383815181106106bd576106bd611bc0565b50637af1e23160e11b905060006110d0565b61071260038383815181106106e6576106e6611bc0565b602002602001015184848151811061070057610700611bc0565b50637af1e23160e11b90506001610cd0565b610755600383838151811061072957610729611bc0565b602002602001015184848151811061074357610743611bc0565b5063db006a7560e01b90506001610cd0565b600101610685565b505050565b610778336000356001600160e01b031916611275565b6107945760405162461bcd60e51b81526004016104d890611ab4565b6104ec81600061142b565b6107b5336000356001600160e01b031916611275565b6107d15760405162461bcd60e51b81526004016104d890611ab4565b8015610800576001600160a01b03831660009081526002602052604090208054600160ff85161b179055610826565b6001600160a01b03831660009081526002602052604090208054600160ff85161b191690555b8160ff16836001600160a01b03167f4c9bdd0c8e073eb5eda2250b18d8e5121ff27b62064fbeeeed4869bb99bc5bf283604051610867911515815260200190565b60405180910390a3505050565b61088a336000356001600160e01b031916611275565b6108a65760405162461bcd60e51b81526004016104d890611ab4565b6108bb600482631853304760e31b6001610cd0565b6108d0600482630ede4edd60e41b6001610cd0565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610910573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109389190810190611afb565b905060005b815181101561075d57610989600483838151811061095d5761095d611bc0565b602002602001015184848151811061097757610977611bc0565b5063140e25ad60e31b90506001610cd0565b6109a0600483838151811061072957610729611bc0565b6109e360048383815181106109b7576109b7611bc0565b60200260200101518484815181106109d1576109d1611bc0565b5063852a12e360e01b90506001610cd0565b610a2660048383815181106109fa576109fa611bc0565b6020026020010151848481518110610a1457610a14611bc0565b5063317afabb60e21b90506001610cd0565b610a696004838381518110610a3d57610a3d611bc0565b6020026020010151848481518110610a5757610a57611bc0565b5063073a938160e11b90506001610cd0565b610aac6004838381518110610a8057610a80611bc0565b6020026020010151848481518110610a9a57610a9a611bc0565b50633c3b4b8960e01b90506001610cd0565b60010161093d565b610aca336000356001600160e01b031916611275565b610ae65760405162461bcd60e51b81526004016104d890611ab4565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b26573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b4e9190810190611afb565b905060005b815181101561075d57610b9d828281518110610b7157610b71611bc0565b6020026020010151838381518110610b8b57610b8b611bc0565b50637af1e23160e11b905060016110d0565b610bde828281518110610bb257610bb2611bc0565b6020026020010151838381518110610bcc57610bcc611bc0565b5063db006a7560e01b905060016110d0565b600101610b53565b6000546001600160a01b0316331480610c7b575060015460405163b700961360e01b81526001600160a01b039091169063b700961390610c3a90339030906001600160e01b03196000351690600401611bd6565b602060405180830381865afa158015610c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7b9190611c03565b610c8457600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b610ce6336000356001600160e01b031916611275565b610d025760405162461bcd60e51b81526004016104d890611ab4565b8015610d46576001600160a01b03831660009081526004602090815260408083206001600160e01b03198616845290915290208054600160ff87161b179055610d81565b6001600160a01b03831660009081526004602090815260408083206001600160e01b03198616845290915290208054600160ff87161b191690555b816001600160e01b031916836001600160a01b03168560ff167fa52ea92e6e955aa8ac66420b86350f7139959adfcc7e6a14eee1bd116d09860e84604051610dcd911515815260200190565b60405180910390a450505050565b610df1336000356001600160e01b031916611275565b610e0d5760405162461bcd60e51b81526004016104d890611ab4565b610e1881600261131e565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e58573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e809190810190611afb565b905060005b815181101561075d57610ea560028383815181106109fa576109fa611bc0565b610ebc6002838381518110610a3d57610a3d611bc0565b610eff6002838381518110610ed357610ed3611bc0565b6020026020010151848481518110610eed57610eed611bc0565b506304c11f0360e31b90506001610cd0565b610f166002838381518110610a8057610a80611bc0565b600101610e85565b6001600160a01b03821660009081526003602090815260408083206001600160e01b03198516845290915281205460ff1680610f9557506001600160a01b0380841660009081526004602090815260408083206001600160e01b031987168452825280832054938816835260029091529020541615155b949350505050565b600554610100900460ff1615808015610fbd5750600554600160ff909116105b80610fd75750303b158015610fd7575060055460ff166001145b61103a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104d8565b6005805460ff19166001179055801561105d576005805461ff0019166101001790555b600080546001600160a01b0384166001600160a01b031991821617909155600180549091163017905580156110cc576005805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6110e6336000356001600160e01b031916611275565b6111025760405162461bcd60e51b81526004016104d890611ab4565b6001600160a01b03831660008181526003602090815260408083206001600160e01b0319871680855290835292819020805460ff191686151590811790915590519081529192917f950a343f5d10445e82a71036d3f4fb3016180a25805141932543b83e2078a93e9101610867565b611187336000356001600160e01b031916611275565b6111a35760405162461bcd60e51b81526004016104d890611ab4565b6104ec8160006115a9565b6111c4336000356001600160e01b031916611275565b6111e05760405162461bcd60e51b81526004016104d890611ab4565b6111f560003063e347416d60e01b6001610cd0565b61120a600030630c22644560e01b6001610cd0565b61121f600030630a4c60c560e41b6001610cd0565b611234600030630659389b60e31b6001610cd0565b611249600030637875b94560e01b6001610cd0565b61125e60003063387beb5760e11b6001610cd0565b6112736000306319ebfd2160e21b6001610cd0565b565b6001546000906001600160a01b031680158015906112ff575060405163b700961360e01b81526001600160a01b0382169063b7009613906112be90879030908890600401611bd6565b602060405180830381865afa1580156112db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ff9190611c03565b80610f9557506000546001600160a01b03858116911614949350505050565b6113328183631853304760e31b6001610cd0565b6113468183630ede4edd60e41b6001610cd0565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611386573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113ae9190810190611afb565b905060005b81518110156114255760006113c66116aa565b905060005b815181101561141b57611413858585815181106113ea576113ea611bc0565b602002602001015184848151811061140457611404611bc0565b60200260200101516001610cd0565b6001016113cb565b50506001016113b3565b50505050565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561146b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114939190810190611afb565b905060005b8151811015611425576114e18282815181106114b6576114b6611bc0565b60200260200101518383815181106114d0576114d0611bc0565b5063317afabb60e21b9050856110d0565b6115218282815181106114f6576114f6611bc0565b602002602001015183838151811061151057611510611bc0565b5063073a938160e11b9050856110d0565b61156182828151811061153657611536611bc0565b602002602001015183838151811061155057611550611bc0565b506304c11f0360e31b9050856110d0565b6115a182828151811061157657611576611bc0565b602002602001015183838151811061159057611590611bc0565b50633c3b4b8960e01b9050856110d0565b600101611498565b6115bb82631853304760e31b836110d0565b6115cd82630ede4edd60e41b836110d0565b6000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561160d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116359190810190611afb565b905060005b815181101561142557600061164d6116aa565b905060005b81518110156116a05761169884848151811061167057611670611bc0565b602002602001015183838151811061168a5761168a611bc0565b6020026020010151876110d0565b600101611652565b505060010161163a565b60408051600680825260e0820190925260609190816020820160c08036833701905050915063140e25ad60e31b826116e183611c20565b92508260ff16815181106116f7576116f7611bc0565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8261172283611c20565b92508260ff168151811061173857611738611bc0565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b8261176383611c20565b92508260ff168151811061177957611779611bc0565b6001600160e01b03199092166020928302919091019091015263a9059cbb60e01b826117a483611c20565b92508260ff16815181106117ba576117ba611bc0565b6001600160e01b0319909216602092830291909101909101526323b872dd60e01b826117e583611c20565b92508260ff16815181106117fb576117fb611bc0565b6001600160e01b03199092166020928302919091019091015263095ea7b360e01b8261182683611c20565b92508260ff168151811061183c5761183c611bc0565b6001600160e01b03199092166020928302919091019091015260ff8116156118a65760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104d8565b5090565b6001600160a01b03811681146104ec57600080fd5b6000602082840312156118d157600080fd5b81356118dc816118aa565b9392505050565b80356001600160e01b0319811681146118fb57600080fd5b919050565b6000806040838503121561191357600080fd5b823561191e816118aa565b915061192c602084016118e3565b90509250929050565b803560ff811681146118fb57600080fd5b80151581146104ec57600080fd5b60008060006060848603121561196957600080fd5b8335611974816118aa565b925061198260208501611935565b9150604084013561199281611946565b809150509250925092565b600080600080608085870312156119b357600080fd5b6119bc85611935565b935060208501356119cc816118aa565b92506119da604086016118e3565b915060608501356119ea81611946565b939692955090935050565b600080600060608486031215611a0a57600080fd5b611a1384611935565b92506020840135611a23816118aa565b9150611a31604085016118e3565b90509250925092565b600080600060608486031215611a4f57600080fd5b8335611a13816118aa565b600080600060608486031215611a6f57600080fd5b8335611a7a816118aa565b9250611982602085016118e3565b60008060408385031215611a9b57600080fd5b8235611aa6816118aa565b915061192c60208401611935565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b80516118fb816118aa565b60006020808385031215611b0e57600080fd5b825167ffffffffffffffff80821115611b2657600080fd5b818501915085601f830112611b3a57600080fd5b815181811115611b4c57611b4c611ada565b8060051b604051601f19603f83011681018181108582111715611b7157611b71611ada565b604052918252848201925083810185019188831115611b8f57600080fd5b938501935b82851015611bb457611ba585611af0565b84529385019392850192611b94565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215611c1557600080fd5b81516118dc81611946565b600060ff821680611c4157634e487b7160e01b600052601160045260246000fd5b600019019291505056fea26469706673582212203697c5df093fecfe51293170c70e50ad0107abeb49f1b472c2dbd8ba10eda86664736f6c63430008160033a26469706673582212205b3dc4126764b77dcb499e6a312479c947b4c178b4b1d7fbb61bd60e1b35b3d564736f6c63430008160033", + "devdoc": { + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_acceptOwner()": { + "details": "Owner function for pending owner to accept role and update owner" + }, + "_setPendingOwner(address)": { + "details": "Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.", + "params": { + "newPendingOwner": "New pending owner." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "NewOwner(address,address)": { + "notice": "Emitted when pendingOwner is accepted, which means owner is updated" + }, + "NewPendingOwner(address,address)": { + "notice": "Emitted when pendingOwner is changed" + } + }, + "kind": "user", + "methods": { + "_acceptOwner()": { + "notice": "Accepts transfer of owner rights. msg.sender must be pendingOwner" + }, + "_setPendingOwner(address)": { + "notice": "Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer." + }, + "pendingOwner()": { + "notice": "Pending owner of this contract" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 54261, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 51684, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "poolsAuthorities", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_address,t_contract(PoolRolesAuthority)54097)" + }, + { + "astId": 51687, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "poolAuthLogic", + "offset": 0, + "slot": "103", + "type": "t_contract(PoolRolesAuthority)54097" + }, + { + "astId": 51689, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "leveredPositionsFactory", + "offset": 0, + "slot": "104", + "type": "t_address" + }, + { + "astId": 51691, + "contract": "contracts/ionic/AuthoritiesRegistry.sol:AuthoritiesRegistry", + "label": "noAuthRequired", + "offset": 20, + "slot": "104", + "type": "t_bool" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "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_contract(PoolRolesAuthority)54097": { + "encoding": "inplace", + "label": "contract PoolRolesAuthority", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_contract(PoolRolesAuthority)54097)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract PoolRolesAuthority)", + "numberOfBytes": "32", + "value": "t_contract(PoolRolesAuthority)54097" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/AuthoritiesRegistry_Proxy.json b/packages/contracts/deployments/superseed/AuthoritiesRegistry_Proxy.json new file mode 100644 index 0000000000..22aed937f6 --- /dev/null +++ b/packages/contracts/deployments/superseed/AuthoritiesRegistry_Proxy.json @@ -0,0 +1,315 @@ +{ + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "transactionIndex": 1, + "gasUsed": "2343115", + "logsBloom": "0x00010000000000000000000000000000400010000000000001800000000200000000000000000000000010100000000000100000100000000008000000000004000000000000040000000000000002040401000000000000000000000000000400000000020000000000000000000800000000800000000000000000000000400000200000000000000080000000000000000000000080000000000000c00001000000002000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000020000000000000000000000000000000040000000000000", + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35", + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000522e808b99a89f0587906eb0a913675d35a936f6" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0x8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76", + "0x00000000000000000000000049fc77cac3066bde8effb717e43aa31b112a0ece", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": "0x", + "logIndex": 3, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0xa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b76389980198", + "0x00000000000000000000000049fc77cac3066bde8effb717e43aa31b112a0ece", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "data": "0x", + "logIndex": 4, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0xBFE9BC0Aa91E477Dd07FFFC96D15cBf947A5DF4F", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", + "logIndex": 5, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 6, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + }, + { + "transactionIndex": 1, + "blockNumber": 4159568, + "transactionHash": "0xaeb47a4f638e295ed031ec5fa5b5e931bc87603b94cc343072a3b55688b64995", + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 7, + "blockHash": "0x3ab0dedd5fcddcb13f49a7363224803dfa7335aebdaa084f944e5e3e3ba0cd35" + } + ], + "blockNumber": 4159568, + "cumulativeGasUsed": "2386957", + "status": 1, + "byzantium": true + }, + "args": [ + "0x522E808b99a89F0587906eB0A913675D35a936f6", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000005d74800e977bfc8e14eca28c9405bacbd091738e" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/CErc20Delegate.json b/packages/contracts/deployments/superseed/CErc20Delegate.json new file mode 100644 index 0000000000..ad80ff585c --- /dev/null +++ b/packages/contracts/deployments/superseed/CErc20Delegate.json @@ -0,0 +1,1535 @@ +{ + "address": "0xE1A3006be645a80F206311d9f18C866c204bA02f", + "abi": [ + { + "inputs": [], + "name": "CallerIsNotEOA", + "type": "error" + }, + { + "inputs": [], + "name": "InteractionNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldAdminFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFeeMantissa", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldIonicFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newIonicFeeMantissa", + "type": "uint256" + } + ], + "name": "NewIonicFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "benefactor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "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": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "_becomeImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract IonicComptroller", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractType", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "delegateType", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "feeSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xce50965cf1617080ea1630d860e63ab98a0aa8cb12055f148331547ff6040340", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xE1A3006be645a80F206311d9f18C866c204bA02f", + "transactionIndex": 1, + "gasUsed": "5030224", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xffb061cda50175d543af31074b66e210bde994f3bffe6efd8614a4d7fbdb11d6", + "transactionHash": "0xce50965cf1617080ea1630d860e63ab98a0aa8cb12055f148331547ff6040340", + "logs": [], + "blockNumber": 4134607, + "cumulativeGasUsed": "5085290", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CallerIsNotEOA\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InteractionNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cashPrior\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"interestAccumulated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"AccrueInterest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"Borrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"LiquidateBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintTokens\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAdminFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldIonicFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newIonicFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewIonicFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"oldInterestRateModel\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"newInterestRateModel\",\"type\":\"address\"}],\"name\":\"NewMarketInterestRateModel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReserveFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewReserveFactor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"Redeem\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"payer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"RepayBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"benefactor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"addAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reduceAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesReduced\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"_becomeImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accrualBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"}],\"name\":\"borrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractType\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"delegateType\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interestRateModel\",\"outputs\":[{\"internalType\":\"contract InterestRateModel\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"}],\"name\":\"liquidateBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"}],\"name\":\"redeemUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrowBehalf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"seize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferIn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBorrows\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalReserves\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underlying\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Compound\",\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"functionSelectors\":\"a list of all the function selectors that this logic extension exposes\"}},\"_withdrawAdminFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_withdrawIonicFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"borrow(uint256)\":{\"params\":{\"borrowAmount\":\"The amount of the underlying asset to borrow\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"getCash()\":{\"returns\":{\"_0\":\"The quantity of underlying asset owned by this contract\"}},\"liquidateBorrow(address,uint256,address)\":{\"params\":{\"borrower\":\"The borrower of this cToken to be liquidated\",\"cTokenCollateral\":\"The market in which to seize collateral from the borrower\",\"repayAmount\":\"The amount of the underlying borrowed asset to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"mint(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"mintAmount\":\"The amount of the underlying asset to supply\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeem(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemTokens\":\"The number of cTokens to redeem into underlying\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeemUnderlying(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemAmount\":\"The amount of underlying to redeem\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrow(uint256)\":{\"params\":{\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrowBehalf(address,uint256)\":{\"params\":{\"borrower\":\"the account with the debt being payed off\",\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"seize(address,address,uint256)\":{\"details\":\"Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\",\"params\":{\"borrower\":\"The account having collateral seized\",\"liquidator\":\"The account receiving seized collateral\",\"seizeTokens\":\"The number of cTokens to seize\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}}},\"title\":\"Compound's CErc20Delegate Contract\",\"version\":1},\"userdoc\":{\"events\":{\"AccrueInterest(uint256,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when interest is accrued\"},\"Approval(address,address,uint256)\":{\"notice\":\"EIP20 Approval event\"},\"Borrow(address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when underlying is borrowed\"},\"LiquidateBorrow(address,address,uint256,address,uint256)\":{\"notice\":\"Event emitted when a borrow is liquidated\"},\"Mint(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are minted\"},\"NewAdminFee(uint256,uint256)\":{\"notice\":\"Event emitted when the admin fee is changed\"},\"NewIonicFee(uint256,uint256)\":{\"notice\":\"Event emitted when the Ionic fee is changed\"},\"NewMarketInterestRateModel(address,address)\":{\"notice\":\"Event emitted when interestRateModel is changed\"},\"NewReserveFactor(uint256,uint256)\":{\"notice\":\"Event emitted when the reserve factor is changed\"},\"Redeem(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are redeemed\"},\"RepayBorrow(address,address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when a borrow is repaid\"},\"ReservesAdded(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are added\"},\"ReservesReduced(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are reduced\"},\"Transfer(address,address,uint256)\":{\"notice\":\"EIP20 Transfer event\"}},\"kind\":\"user\",\"methods\":{\"_becomeImplementation(bytes)\":{\"notice\":\"Called by the delegator on a delegate to initialize it for duty\"},\"_withdrawAdminFees(uint256)\":{\"notice\":\"Accrues interest and reduces admin fees by transferring to admin\"},\"_withdrawIonicFees(uint256)\":{\"notice\":\"Accrues interest and reduces Ionic fees by transferring to Ionic\"},\"accrualBlockNumber()\":{\"notice\":\"Block number that interest was last accrued at\"},\"adminFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for admin fees\"},\"ap()\":{\"notice\":\"Addresses Provider\"},\"borrow(uint256)\":{\"notice\":\"Sender borrows assets from the protocol to their own address\"},\"borrowIndex()\":{\"notice\":\"Accumulator of the total earned interest rate since the opening of the market\"},\"comptroller()\":{\"notice\":\"Contract which oversees inter-cToken operations\"},\"decimals()\":{\"notice\":\"EIP-20 token decimals for this token\"},\"getCash()\":{\"notice\":\"Get cash balance of this cToken in the underlying asset\"},\"interestRateModel()\":{\"notice\":\"Model which tells what the current interest rate should be\"},\"ionicFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for Ionic fees\"},\"liquidateBorrow(address,uint256,address)\":{\"notice\":\"The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator.\"},\"mint(uint256)\":{\"notice\":\"Sender supplies assets into the market and receives cTokens in exchange\"},\"name()\":{\"notice\":\"EIP-20 token name for this token\"},\"redeem(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for the underlying asset\"},\"redeemUnderlying(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for a specified amount of underlying asset\"},\"repayBorrow(uint256)\":{\"notice\":\"Sender repays their own borrow\"},\"repayBorrowBehalf(address,uint256)\":{\"notice\":\"Sender repays a borrow belonging to borrower\"},\"reserveFactorMantissa()\":{\"notice\":\"Fraction of interest currently set aside for reserves\"},\"seize(address,address,uint256)\":{\"notice\":\"Transfers collateral tokens (this market) to the liquidator.\"},\"symbol()\":{\"notice\":\"EIP-20 token symbol for this token\"},\"totalAdminFees()\":{\"notice\":\"Total amount of admin fees of the underlying held in this market\"},\"totalBorrows()\":{\"notice\":\"Total amount of outstanding borrows of the underlying in this market\"},\"totalIonicFees()\":{\"notice\":\"Total amount of Ionic fees of the underlying held in this market\"},\"totalReserves()\":{\"notice\":\"Total amount of reserves of the underlying held in this market\"},\"totalSupply()\":{\"notice\":\"Total number of tokens in circulation\"},\"underlying()\":{\"notice\":\"Underlying asset for this CToken\"}},\"notice\":\"CTokens which wrap an EIP-20 underlying and are delegated to\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/CErc20Delegate.sol\":\"CErc20Delegate\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicUniV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV3FlashCallback.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV3Pool.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\nimport { IUniswapV3Quoter } from \\\"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"./ionic/IFlashLoanReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicUniV3Liquidator\\n * @author Veliko Minkov (https://github.com/vminkov)\\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\\n */\\ncontract IonicUniV3Liquidator is\\n OwnableUpgradeable,\\n ILiquidator,\\n IUniswapV3FlashCallback,\\n IExpressRelayFeeReceiver,\\n IFlashLoanReceiver\\n{\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n\\n address public W_NATIVE_ADDRESS;\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n IUniswapV3Quoter public quoter;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(address _wtoken, address _quoter) external initializer {\\n __Ownable_init();\\n W_NATIVE_ADDRESS = _wtoken;\\n quoter = IUniswapV3Quoter(_quoter);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n underlying.approve(address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateToTokensWithFlashLoan(\\n LiquidateToTokensWithFlashSwapVars calldata vars\\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\\n flashSwapPool.flash(\\n address(this),\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n\\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(\\n LiquidateToTokensWithFlashSwapVars memory vars,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\\n uint256 flashSwapReturnAmount = _flashSwapAmount;\\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\\n flashSwapReturnAmount += fee0;\\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\\n flashSwapReturnAmount += fee1;\\n } else {\\n revert(\\\"wrong pool or _flashSwapToken\\\");\\n }\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay the borrowed asset directly\\n collateralRequired = flashSwapReturnAmount;\\n\\n // Repay flashloan\\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\\n } else {\\n // TODO swap within the same pool and then repay the FL to the pool\\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\\n\\n {\\n collateralRequired = quoter.quoteExactOutputSingle(\\n zeroForOne ? pool.token0() : pool.token1(),\\n zeroForOne ? pool.token1() : pool.token0(),\\n pool.fee(),\\n _flashSwapAmount,\\n 0 // sqrtPriceLimitX96\\n );\\n }\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n\\n // Repay flashloan\\n pool.swap(\\n address(pool),\\n zeroForOne,\\n int256(collateralRequired),\\n 0, // sqrtPriceLimitX96\\n \\\"\\\"\\n );\\n }\\n\\n return address(underlyingCollateral);\\n } else {\\n revert(\\\"the redemptions strategy did not swap to the flash swapped pool assets\\\");\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n bool[] calldata whitelisted\\n ) external onlyOwner {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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\":\"0x03ad15c5d4e63fbc8d4df554ce3172f4e0611843a326a8e29ec39870e5ddbd72\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20Delegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CToken.sol\\\";\\n\\n/**\\n * @title Compound's CErc20Delegate Contract\\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\\n * @author Compound\\n */\\ncontract CErc20Delegate is CErc20 {\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 3;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n */\\n function _becomeImplementation(bytes memory) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 1;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20Delegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x64f72d66ae0f29c8400dd922cf2d5f453c1de98a72d7041fa8b39ec2aba25402\",\"license\":\"UNLICENSED\"},\"contracts/compound/CToken.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { CTokenSecondExtensionBase, ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { TokenErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { CTokenOracleProtected } from \\\"./CTokenOracleProtected.sol\\\";\\n\\nimport { DiamondExtension, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { PoolLens } from \\\"../PoolLens.sol\\\";\\nimport { IonicUniV3Liquidator } from \\\"../IonicUniV3Liquidator.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\n/**\\n * @title Compound's CErc20 Contract\\n * @notice CTokens which wrap an EIP-20 underlying\\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\\n * @author Compound\\n */\\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\\n modifier isAuthorized() {\\n require(\\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\\n \\\"not authorized\\\"\\n );\\n _;\\n }\\n\\n modifier isMinHFThresholdExceeded(address borrower) {\\n PoolLens lens = PoolLens(ap.getAddress(\\\"PoolLens\\\"));\\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\\\"IonicUniV3Liquidator\\\")));\\n\\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\\n require(msg.sender == address(liquidator), \\\"Health factor not low enough for non-permissioned liquidations\\\");\\n _;\\n } else {\\n _;\\n }\\n }\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 13;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.mint.selector;\\n functionSelectors[--fnsCount] = this.redeem.selector;\\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\\n functionSelectors[--fnsCount] = this.borrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\\n functionSelectors[--fnsCount] = this.getCash.selector;\\n functionSelectors[--fnsCount] = this.seize.selector;\\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*** User Interface ***/\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = mintInternal(mintAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemInternal(redeemTokens);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to redeem\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemUnderlyingInternal(redeemAmount);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return borrowInternal(borrowAmount);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowInternal(repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\\n return err;\\n }\\n\\n /**\\n * @notice Get cash balance of this cToken in the underlying asset\\n * @return The quantity of underlying asset owned by this contract\\n */\\n function getCash() external view override returns (uint256) {\\n return getCashInternal();\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Will fail unless called by another cToken during the process of liquidation.\\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\\n }\\n\\n function selfTransferOut(address to, uint256 amount) external override {\\n require(msg.sender == address(this), \\\"!self\\\");\\n doTransferOut(to, amount);\\n }\\n\\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\\n require(msg.sender == address(this), \\\"!self\\\");\\n return doTransferIn(from, amount);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\\n }\\n\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalIonicFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\\n totalIonicFees = totalIonicFeesNew;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(address(ionicAdmin), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces admin fees by transferring to admin\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\\n }\\n\\n // Fail gracefully if protocol has insufficient underlying cash\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalAdminFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n totalAdminFees = totalAdminFees - withdrawAmount;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of this contract in terms of the underlying\\n * @dev This excludes the value of the current message, if any\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view virtual returns (uint256) {\\n return EIP20Interface(underlying).balanceOf(address(this));\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\\n * This will revert due to insufficient balance or insufficient allowance.\\n * This function returns the actual amount received,\\n * which may be less than `amount` if there is a fee attached to the transfer.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\\n \\\"TOKEN_TRANSFER_IN_FAILED\\\"\\n );\\n\\n // Calculate the amount that was *actually* transferred\\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\\n require(balanceAfter >= balanceBefore, \\\"TOKEN_TRANSFER_IN_OVERFLOW\\\");\\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\\n * it is >= amount, this should not revert in normal conditions.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferOut(address to, uint256 amount) internal virtual {\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\\n \\\"TOKEN_TRANSFER_OUT_FAILED\\\"\\n );\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\\n }\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\\n return mintFresh(msg.sender, mintAmount);\\n }\\n\\n struct MintLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 mintTokens;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n uint256 actualMintAmount;\\n }\\n\\n /**\\n * @notice User supplies assets into the market and receives cTokens in exchange\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param minter The address of the account which is supplying the assets\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\\n /* Fail if mint not allowed */\\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\\n }\\n\\n MintLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n // Check max supply\\n // unused function\\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n } */\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call `doTransferIn` for the minter and the mintAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\\n * side-effects occurred. The function returns the amount actually transferred,\\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\\n * of cash.\\n */\\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\\n\\n /*\\n * We get the current exchange rate and calculate the number of cTokens to be minted:\\n * mintTokens = actualMintAmount / exchangeRate\\n */\\n\\n // mintTokens is rounded down here - correct\\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\\n vars.actualMintAmount,\\n Exp({ mantissa: vars.exchangeRateMantissa })\\n );\\n require(vars.mathErr == MathError.NO_ERROR, \\\"MINT_EXCHANGE_CALCULATION_FAILED\\\");\\n require(vars.mintTokens > 0, \\\"MINT_ZERO_CTOKENS_REJECTED\\\");\\n\\n /*\\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\\n * totalSupplyNew = totalSupply + mintTokens\\n * accountTokensNew = accountTokens[minter] + mintTokens\\n */\\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\\n\\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[minter] = vars.accountTokensNew;\\n\\n /* We emit a Mint event, and a Transfer event */\\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\\n emit Transfer(address(this), minter, vars.mintTokens);\\n\\n /* We call the defense hook */\\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\\n\\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, redeemTokens, 0);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, 0, redeemAmount);\\n }\\n\\n struct RedeemLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 redeemTokens;\\n uint256 redeemAmount;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n }\\n\\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\\n res = (x * 1e18) / y;\\n if (x % y != 0) res += 1;\\n }\\n\\n /**\\n * @notice User redeems cTokens in exchange for the underlying asset\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param redeemer The address of the account which is redeeming the tokens\\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemFresh(\\n address redeemer,\\n uint256 redeemTokensIn,\\n uint256 redeemAmountIn\\n ) internal returns (uint256) {\\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \\\"!redeem tokens or amount\\\");\\n\\n RedeemLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n if (redeemTokensIn > 0) {\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\\n\\n /*\\n * We calculate the exchange rate and the amount of underlying to be redeemed:\\n * redeemTokens = redeemTokensIn\\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\\n */\\n vars.redeemTokens = redeemTokensIn;\\n\\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n redeemTokensIn\\n );\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n } else {\\n if (redeemAmountIn == type(uint256).max) {\\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\\n }\\n\\n // don't allow dust tokens/assets to be left after\\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\\n\\n /*\\n * We get the current exchange rate and calculate the amount to be redeemed:\\n * redeemTokens = redeemAmountIn / exchangeRate\\n * redeemAmount = redeemAmountIn\\n */\\n\\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\\n\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\\n\\n vars.redeemAmount = redeemAmountIn;\\n }\\n\\n /* Fail if redeem not allowed */\\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\\n }\\n\\n /*\\n * We calculate the new total supply and redeemer balance, checking for underflow:\\n * totalSupplyNew = totalSupply - redeemTokens\\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\\n */\\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /* Fail gracefully if protocol has insufficient cash */\\n if (getCashInternal() < vars.redeemAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[redeemer] = vars.accountTokensNew;\\n\\n /*\\n * We invoke doTransferOut for the redeemer and the redeemAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken has redeemAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(redeemer, vars.redeemAmount);\\n\\n /* We emit a Transfer event, and a Redeem event */\\n emit Transfer(redeemer, address(this), vars.redeemTokens);\\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n /* We call the defense hook */\\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\\n return borrowFresh(msg.sender, borrowAmount);\\n }\\n\\n struct BorrowLocalVars {\\n MathError mathErr;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n }\\n\\n /**\\n * @notice Users borrow assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\\n /* Fail if borrow not allowed */\\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\\n }\\n\\n /* Fail gracefully if protocol has insufficient underlying cash */\\n uint256 cashPrior = getCashInternal();\\n\\n if (cashPrior < borrowAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\\n }\\n\\n BorrowLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on overflow:\\n * accountBorrowsNew = accountBorrows + borrowAmount\\n * totalBorrowsNew = totalBorrows + borrowAmount\\n */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(\\n Error.MATH_ERROR,\\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n uint256(vars.mathErr)\\n );\\n }\\n\\n // Check min borrow for this user for this asset\\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /*\\n * We invoke doTransferOut for the borrower and the borrowAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken borrowAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(borrower, borrowAmount);\\n\\n /* We emit a Borrow event */\\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\\n internal\\n nonReentrant(false)\\n returns (uint256, uint256)\\n {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\\n }\\n\\n struct RepayBorrowLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 repayAmount;\\n uint256 borrowerIndex;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n uint256 actualRepayAmount;\\n }\\n\\n /**\\n * @notice Borrows are repaid by another user (possibly the borrower).\\n * @param payer the account paying off the borrow\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount the amount of undelrying tokens being returned\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowFresh(\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) internal returns (uint256, uint256) {\\n /* Fail if repayBorrow not allowed */\\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\\n }\\n\\n RepayBorrowLocalVars memory vars;\\n\\n /* We remember the original borrowerIndex for verification purposes */\\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\\n\\n /* We fetch the amount the borrower owes, with accumulated interest */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n /* If repayAmount == -1, repayAmount = accountBorrows */\\n if (repayAmount == type(uint256).max) {\\n vars.repayAmount = vars.accountBorrows;\\n } else {\\n vars.repayAmount = repayAmount;\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call doTransferIn for the payer and the repayAmount\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken holds an additional repayAmount of cash.\\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n * it returns the amount actually transferred, in case of a fee.\\n */\\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on underflow:\\n * accountBorrowsNew = accountBorrows - actualRepayAmount\\n * totalBorrowsNew = totalBorrows - actualRepayAmount\\n */\\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\\\");\\n\\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\\\");\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /* We emit a RepayBorrow event */\\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\\n\\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowInternal(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n ICErc20(cTokenCollateral).accrueInterest();\\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\\n }\\n\\n /**\\n * @notice The liquidator liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param liquidator The address repaying the borrow and seizing collateral\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowFresh(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal returns (uint256, uint256) {\\n /* Fail if liquidate not allowed */\\n uint256 allowed = comptroller.liquidateBorrowAllowed(\\n address(this),\\n cTokenCollateral,\\n liquidator,\\n borrower,\\n repayAmount\\n );\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Verify cTokenCollateral market's block number equals current block number */\\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\\n }\\n\\n /* Fail if repayAmount = 0 */\\n if (repayAmount == 0) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\\n }\\n\\n /* Fail if repayAmount = -1 */\\n if (repayAmount == type(uint256).max) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\\n }\\n\\n /* Fail if repayBorrow fails */\\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We calculate the number of collateral tokens that will be seized */\\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\\n address(this),\\n cTokenCollateral,\\n actualRepayAmount\\n );\\n require(amountSeizeError == uint256(Error.NO_ERROR), \\\"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\\\");\\n\\n /* Revert if borrower collateral token balance < seizeTokens */\\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \\\"LIQUIDATE_SEIZE_TOO_MUCH\\\");\\n\\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\\n uint256 seizeError;\\n if (cTokenCollateral == address(this)) {\\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\\n } else {\\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\\n }\\n\\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\\n require(seizeError == uint256(Error.NO_ERROR), \\\"!seize\\\");\\n\\n /* We emit a LiquidateBorrow event */\\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\\n\\n return (uint256(Error.NO_ERROR), actualRepayAmount);\\n }\\n\\n struct SeizeInternalLocalVars {\\n MathError mathErr;\\n uint256 borrowerTokensNew;\\n uint256 liquidatorTokensNew;\\n uint256 liquidatorSeizeTokens;\\n uint256 protocolSeizeTokens;\\n uint256 protocolSeizeAmount;\\n uint256 exchangeRateMantissa;\\n uint256 totalReservesNew;\\n uint256 totalIonicFeeNew;\\n uint256 totalSupplyNew;\\n uint256 feeSeizeTokens;\\n uint256 feeSeizeAmount;\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seizeInternal(\\n address seizerToken,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) internal returns (uint256) {\\n /* Fail if seize not allowed */\\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\\n }\\n\\n SeizeInternalLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\\n */\\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n vars.protocolSeizeAmount = mul_ScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n vars.protocolSeizeTokens\\n );\\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\\n\\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\\n\\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n totalReserves = vars.totalReservesNew;\\n totalSupply = vars.totalSupplyNew;\\n totalIonicFees = vars.totalIonicFeeNew;\\n\\n accountTokens[borrower] = vars.borrowerTokensNew;\\n accountTokens[liquidator] = vars.liquidatorTokensNew;\\n\\n /* Emit a Transfer event */\\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function asCTokenExtension() internal view returns (ICErc20) {\\n return ICErc20(address(this));\\n }\\n\\n /*** Reentrancy Guard ***/\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant(bool localOnly) {\\n _beforeNonReentrant(localOnly);\\n _;\\n _afterNonReentrant(localOnly);\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\\n */\\n function _beforeNonReentrant(bool localOnly) private {\\n require(_notEntered, \\\"re-entered\\\");\\n if (!localOnly) comptroller._beforeNonReentrant();\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\\n */\\n function _afterNonReentrant(bool localOnly) private {\\n _notEntered = true; // get a gas-refund post-Istanbul\\n if (!localOnly) comptroller._afterNonReentrant();\\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 * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\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 * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n}\\n\",\"keccak256\":\"0x308ca2ce334910ef9ece96a98a4a899eaa802051051dc89bf6f8732242000b7b\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenOracleProtected.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.22;\\n\\nimport { CErc20Storage } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenOracleProtected is CErc20Storage {\\n error InteractionNotAllowed();\\n error CallerIsNotEOA();\\n\\n modifier onlyOracleApproved() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyOracleApprovedAllowEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n if (tx.origin == msg.sender) {\\n _;\\n return;\\n }\\n\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyNotBlacklistedEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n if (msg.sender != tx.origin) {\\n revert CallerIsNotEOA();\\n }\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x42b99e4fbc5880f64a6f1d8b02f3b061b0d3a6c312f47d83e88593eefaf71304\",\"license\":\"Unlicense\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/EIP20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ERC 20 Token Standard Interface\\n * https://eips.ethereum.org/EIPS/eip-20\\n */\\ninterface EIP20Interface {\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n /**\\n * @notice Get the total number of tokens in circulation\\n * @return uint256 The supply of tokens\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @notice Gets the balance of the specified address\\n * @param owner The address from which the balance will be retrieved\\n * @return balance uint256 The balance\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transfer(address dst, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Transfer `amount` tokens from `src` to `dst`\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool success);\\n\\n /**\\n * @notice Approve `spender` to transfer up to `amount` from `src`\\n * @dev This will overwrite the approval amount for `spender`\\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\\n * @param spender The address of the account which may transfer tokens\\n * @param amount The number of tokens that are approved (-1 means infinite)\\n * @return success bool Whether or not the approval succeeded\\n */\\n function approve(address spender, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Get the current allowance from `owner` for `spender`\\n * @param owner The address of the account which owns the tokens to be spent\\n * @param spender The address of the account which may transfer tokens\\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\\n */\\n function allowance(address owner, address spender) external view returns (uint256 remaining);\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n}\\n\",\"keccak256\":\"0xcea1d290397e1c8eac89c96738e7ec55259a575f878152eeccf33c0cf6d008e5\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV3FlashCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#flash\\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\\ninterface IUniswapV3FlashCallback {\\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\\n function uniswapV3FlashCallback(\\n uint256 fee0,\\n uint256 fee1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc26730db16259a49c30bd7bd880bb7e48ad94853087a373ba787e406ca969f3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50615a0780620000216000396000f3fe608060405234801561001057600080fd5b50600436106102275760003560e01c8063852a12e311610130578063b0d58e49116100b8578063c91a424f1161007c578063c91a424f1461043f578063cb2ef6f714610452578063db006a751461047c578063f3fdb15a1461048f578063f5e3c462146104a257600080fd5b8063b0d58e49146103ee578063b2a02ff114610401578063be99f11914610414578063c3bf11cd14610423578063c5ebeaec1461042c57600080fd5b806395d89b41116100ff57806395d89b41146103ae5780639826394b146103b6578063a0712d68146103bf578063a7b820df146103d2578063aa5af0fd146103e557600080fd5b8063852a12e31461037457806389f8132e146103875780638d02d9a11461039c5780638f840ddd146103a557600080fd5b80633b1d21a2116101b35780635fe3b567116101825780635fe3b5671461032957806361feacff146103415780636752e7021461034a5780636c540baf146103585780636f307dc31461036157600080fd5b80633b1d21a2146102da5780633c4f743c146102e257806347bd37181461030d57806356e677281461031657600080fd5b8063173b9904116101fa578063173b99041461029357806318160ddd1461029c5780632608f818146102a55780632c436e5b146102b8578063313ce567146102cd57600080fd5b8063067db1b31461022c57806306fdde03146102415780630e7527021461025f578063135f133414610280575b600080fd5b61023f61023a366004615465565b6104b5565b005b6102496104ff565b60405161025691906154b5565b60405180910390f35b61027261026d3660046154e8565b61058d565b604051908152602001610256565b61027261028e366004615465565b6107ad565b61027260085481565b610272600f5481565b6102726102b3366004615465565b6107f9565b60015b60405160ff9091168152602001610256565b6003546102bb9060ff1681565b610272610a29565b6014546102f5906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b610272600b5481565b61023f610324366004615517565b610a38565b6003546102f59061010090046001600160a01b031681565b610272600d5481565b610272666379da05b6000081565b61027260095481565b6013546102f5906001600160a01b031681565b6102726103823660046154e8565b610a8a565b61038f610ca0565b60405161025691906155c8565b61027260065481565b610272600c5481565b610249610e9e565b610272600e5481565b6102726103cd3660046154e8565b610eab565b6102726103e03660046154e8565b6110b8565b610272600a5481565b6102726103fc3660046154e8565b611446565b61027261040f366004615616565b611705565b61027267016345785d8a000081565b61027260075481565b61027261043a3660046154e8565b61189f565b6000546102f5906001600160a01b031681565b60408051808201909152600e81526d43457263323044656c656761746560901b6020820152610249565b61027261048a3660046154e8565b611aa6565b6004546102f5906001600160a01b031681565b6102726104b0366004615657565b611cad565b3330146104f15760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b6104fb828261250c565b5050565b6001805461050c90615699565b80601f016020809104026020016040519081016040528092919081815260200182805461053890615699565b80156105855780601f1061055a57610100808354040283529160200191610585565b820191906000526020600020905b81548152906001019060200180831161056857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926105da9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa1580156105f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061b9190615700565b6106375760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906106669060040161574a565b602060405180830381865afa158015610683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a79190615776565b90506001600160a01b0381166106cb5760006106c28461258d565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561070e57600080fd5b505af1158015610722573d6000803e3d6000fd5b50503332039150610744905057600061073a8561258d565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107729032903390600401615793565b60006040518083038186803b15801561078a57600080fd5b505afa15801561079e573d6000803e3d6000fd5b50505050600061073a8561258d565b60003330146107e65760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064016104e8565b6107f0838361261e565b90505b92915050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926108469261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610863573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108879190615700565b6108a35760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906108d29060040161574a565b602060405180830381865afa1580156108ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109139190615776565b90506001600160a01b03811661093957600061092f85856127f1565b50925050506107f3565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561097c57600080fd5b505af1158015610990573d6000803e3d6000fd5b505033320391506109b490505760006109a986866127f1565b5093505050506107f3565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906109e29032903390600401615793565b60006040518083038186803b1580156109fa57600080fd5b505afa158015610a0e573d6000803e3d6000fd5b505050506000610a1e86866127f1565b509695505050505050565b6000610a33612884565b905090565b33301480610a495750610a496128f1565b610a875760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b60448201526064016104e8565b50565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610ad79261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b189190615700565b610b345760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610b639060040161574a565b602060405180830381865afa158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba49190615776565b90506001600160a01b038116610bc457610bbd83612a6e565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610c0757600080fd5b505af1158015610c1b573d6000803e3d6000fd5b50503332039150610c39905057610c3184612a6e565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610c679032903390600401615793565b60006040518083038186803b158015610c7f57600080fd5b505afa158015610c93573d6000803e3d6000fd5b50505050610c3184612a6e565b606060036000610cae612af6565b90508160ff168151610cc091906157c3565b67ffffffffffffffff811115610cd857610cd8615501565b604051908082528060200260200182016040528015610d01578160200160208202803683370190505b50925060005b8151811015610d5d57818181518110610d2257610d226157d6565b6020026020010151848281518110610d3c57610d3c6157d6565b6001600160e01b031990921660209283029190910190910152600101610d07565b50805163cb2ef6f760e01b908490610d74856157ec565b9450610d839060ff86166157c3565b81518110610d9357610d936157d6565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b908490610dc2856157ec565b9450610dd19060ff86166157c3565b81518110610de157610de16157d6565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b908490610e10856157ec565b9450610e1f9060ff86166157c3565b81518110610e2f57610e2f6157d6565b6001600160e01b03199092166020928302919091019091015260ff821615610e995760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104e8565b505090565b6002805461050c90615699565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610ef89261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f399190615700565b610f555760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610f849060040161574a565b602060405180830381865afa158015610fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc59190615776565b90506001600160a01b038116610fe05760006106c284612ebe565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561102357600080fd5b505af1158015611037573d6000803e3d6000fd5b5050333203915061104f905057600061073a85612ebe565b604051633108c13b60e01b81526001600160a01b03821690633108c13b9061107d9032903390600401615793565b60006040518083038186803b15801561109557600080fd5b505afa1580156110a9573d6000803e3d6000fd5b50505050600061073a85612ebe565b6000806110c481612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906110f39060040161574a565b602060405180830381865afa158015611110573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111349190615776565b90506001600160a01b03811661128c57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611184573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a89190615809565b5043600954146111c5576111be600a6039612fff565b9250611286565b836111ce612884565b10156111e0576111be600e6038612fff565b600d548411156111f6576111be6002603a612fff565b83600d546112049190615822565b600d55600354604080516303e1469160e61b815290516112819261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127b9190615776565b8561250c565b600092505b50611437565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906112bc9032903390600401615793565b60006040518083038186803b1580156112d457600080fd5b505afa1580156112e8573d6000803e3d6000fd5b505050506112f33090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611332573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113569190615809565b5043600954146113735761136c600a6039612fff565b9350611434565b8461137c612884565b101561138e5761136c600e6038612fff565b600d548511156113a45761136c6002603a612fff565b84600d546113b29190615822565b600d55600354604080516303e1469160e61b8152905161142f9261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611405573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114299190615776565b8661250c565b600093505b50505b61144081613078565b50919050565b60008061145281612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906114819060040161574a565b602060405180830381865afa15801561149e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c29190615776565b90506001600160a01b0381166115b657306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611512573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115369190615809565b50436009541461154c576111be600a6035612fff565b83611555612884565b1015611567576111be600e6034612fff565b600e5484111561157d576111be60026036612fff565b600084600e5461158d9190615822565b600e8190556000549091506115ab906001600160a01b03168661250c565b600093505050611437565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906115e69032903390600401615793565b60006040518083038186803b1580156115fe57600080fd5b505afa158015611612573d6000803e3d6000fd5b5050505061161d3090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561165c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116809190615809565b5043600954146116965761136c600a6035612fff565b8461169f612884565b10156116b15761136c600e6034612fff565b600e548511156116c75761136c60026036612fff565b600085600e546116d79190615822565b600e8190556000549091506116f5906001600160a01b03168761250c565b6000945050505061144081613078565b6000600161171281612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906117419060040161574a565b602060405180830381865afa15801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190615776565b90506001600160a01b0381166117a65761179e338787876130fb565b92505061188e565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156117e957600080fd5b505af11580156117fd573d6000803e3d6000fd5b5050333203915061181f905057611816338888886130fb565b9350505061188e565b604051633108c13b60e01b81526001600160a01b03821690633108c13b9061184d9032903390600401615793565b60006040518083038186803b15801561186557600080fd5b505afa158015611879573d6000803e3d6000fd5b50505050611889338888886130fb565b935050505b61189781613078565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926118ec9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611909573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192d9190615700565b6119495760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906119789060040161574a565b602060405180830381865afa158015611995573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b99190615776565b90506001600160a01b0381166119d257610bbd836135e3565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611a1557600080fd5b505af1158015611a29573d6000803e3d6000fd5b50503332039150611a3f905057610c31846135e3565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611a6d9032903390600401615793565b60006040518083038186803b158015611a8557600080fd5b505afa158015611a99573d6000803e3d6000fd5b50505050610c31846135e3565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611af39261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611b10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b349190615700565b611b505760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611b7f9060040161574a565b602060405180830381865afa158015611b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc09190615776565b90506001600160a01b038116611bd957610bbd8361365e565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611c1c57600080fd5b505af1158015611c30573d6000803e3d6000fd5b50503332039150611c46905057610c318461365e565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611c749032903390600401615793565b60006040518083038186803b158015611c8c57600080fd5b505afa158015611ca0573d6000803e3d6000fd5b50505050610c318461365e565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611cfa9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3b9190615700565b611d575760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611d869060040161574a565b602060405180830381865afa158015611da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc79190615776565b90506001600160a01b038116611ffc5760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac190611e0a9060040161584b565b602060405180830381865afa158015611e27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4b9190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac190611e7f9060040161586d565b602060405180830381865afa158015611e9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec09190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f249190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d92611f5b92899261010090041690600401615793565b602060405180830381865afa158015611f78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9c9190615809565b1115611fe157336001600160a01b03821614611fca5760405162461bcd60e51b81526004016104e89061589b565b6000611fd78989896136db565b509550611ff39050565b6000611fee8989896136db565b509550505b50505050610bbd565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561203f57600080fd5b505af1158015612053573d6000803e3d6000fd5b5050333203915061228690505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac1906120939060040161584b565b602060405180830381865afa1580156120b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d49190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906121089060040161586d565b602060405180830381865afa158015612125573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121499190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926121e492899261010090041690600401615793565b602060405180830381865afa158015612201573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122259190615809565b111561226a57336001600160a01b038216146122535760405162461bcd60e51b81526004016104e89061589b565b60006122608a8a8a6136db565b50965061227c9050565b60006122778a8a8a6136db565b509650505b5050505050610bbd565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906122b49032903390600401615793565b60006040518083038186803b1580156122cc57600080fd5b505afa1580156122e0573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac1906123179060040161584b565b602060405180830381865afa158015612334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123589190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061238c9060040161586d565b602060405180830381865afa1580156123a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123cd9190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561240d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124319190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261246892899261010090041690600401615793565b602060405180830381865afa158015612485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a99190615809565b11156124ee57336001600160a01b038216146124d75760405162461bcd60e51b81526004016104e89061589b565b60006124e48a8a8a6136db565b5096506125009050565b60006124fb8a8a8a6136db565b509650505b50505050509392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091018252602080820180516001600160e01b031663a9059cbb60e01b1790528251808401909352601983527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000908301526104fb916137d5565b600080600061259b81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156125db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ff9190615809565b5061260b333386613833565b9250925061261881613078565b50915091565b6013546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561266b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268f9190615809565b905061271f6323b872dd60e01b8530866040516024016126b1939291906158f8565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280601881526020017f544f4b454e5f5452414e534645525f494e5f4641494c454400000000000000008152506137d5565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278c9190615809565b9050818110156127de5760405162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f5700000000000060448201526064016104e8565b6127e88282615822565b95945050505050565b60008060006127ff81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561283f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128639190615809565b5061286f338686613833565b9250925061287c81613078565b509250929050565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156128cd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a339190615809565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561294a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061296e9190615776565b6001600160a01b0316336001600160a01b03161480156129eb5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129eb9190615700565b80612a6857506000546001600160a01b031633148015612a685750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a689190615700565b91505090565b600080612a7a81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ade9190615809565b50612aeb33600085613c40565b915061144081613078565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b81612b32846157ec565b93508360ff1681518110612b4857612b486157d6565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b81612b73846157ec565b93508360ff1681518110612b8957612b896157d6565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b81612bb4846157ec565b93508360ff1681518110612bca57612bca6157d6565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b81612bf5846157ec565b93508360ff1681518110612c0b57612c0b6157d6565b6001600160e01b03199092166020928302919091019091015263073a938160e11b81612c36846157ec565b93508360ff1681518110612c4c57612c4c6157d6565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b81612c77846157ec565b93508360ff1681518110612c8d57612c8d6157d6565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b81612cb8846157ec565b93508360ff1681518110612cce57612cce6157d6565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b81612cf9846157ec565b93508360ff1681518110612d0f57612d0f6157d6565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b81612d3a846157ec565b93508360ff1681518110612d5057612d506157d6565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b81612d7b846157ec565b93508360ff1681518110612d9157612d916157d6565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b81612dbc846157ec565b93508360ff1681518110612dd257612dd26157d6565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b81612dfd846157ec565b93508360ff1681518110612e1357612e136157d6565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b81612e3e846157ec565b93508360ff1681518110612e5457612e546157d6565b6001600160e01b03199092166020928302919091019091015260ff8216156107f35760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104e8565b6000806000612ecc81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f309190615809565b5061260b3385614287565b600054600160a01b900460ff16612f815760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b60448201526064016104e8565b80612fef57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612fd657600080fd5b505af1158015612fea573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601181111561303457613034615835565b83606181111561304657613046615835565b60408051928352602083019190915260009082015260600160405180910390a18260118111156107f0576107f0615835565b6000805460ff60a01b1916600160a01b17905580610a8757600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130e057600080fd5b505af11580156130f4573d6000803e3d6000fd5b5050505050565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af115801561316f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131939190615809565b905080156131b0576131a86003601d83614692565b915050610c31565b846001600160a01b0316846001600160a01b0316036131d5576131a86006601e612fff565b61323a604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03851660009081526010602052604090205461325d9085614734565b602083018190528282600381111561327757613277615835565b600381111561328857613288615835565b90525060009050815160038111156132a2576132a2615835565b146132d2576132c96009601c836000015160038111156132c4576132c4615835565b614692565b92505050610c31565b6132f1846040518060200160405280666379da05b6000081525061475f565b6080820152604080516020810190915267016345785d8a0000815261331790859061475f565b6101408201819052608082015161332e9086615822565b6133389190615822565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561337b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339f9190615809565b60c0820190815260408051602081019091529051815260808201516133c49190614782565b60a0820152604080516020810190915260c082015181526101408201516133eb9190614782565b61016082015260a0810151600c5461340391906157c3565b60e08201526101408101516080820151600f546134209190615822565b61342a9190615822565b610120820152610160810151600e5461344391906157c3565b6101008201526001600160a01b0386166000908152601060205260409020546060820151613471919061479a565b604083018190528282600381111561348b5761348b615835565b600381111561349c5761349c615835565b90525060009050815160038111156134b6576134b6615835565b146134d8576132c96009601b836000015160038111156132c4576132c4615835565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b16808252908490209290925560608501519251928352909290916000805160206159b2833981519152910160405180910390a3306001600160a01b0316856001600160a01b03166000805160206159b2833981519152836080015160405161358591815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b6000806135ef81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561362f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136539190615809565b50612aeb33846147c0565b60008061366a81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156136aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ce9190615809565b50612aeb33846000613c40565b60008060006136e981612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061374d9190615809565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561378e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b29190615809565b506137bf33878787614b5b565b925092506137cc81613078565b50935093915050565b6013546000906137ef906001600160a01b03168484615018565b80519091501561382e578080602001905181019061380d9190615700565b829061382c5760405162461bcd60e51b81526004016104e891906154b5565b505b505050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af11580156138a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c59190615809565b905080156138e6576138da6003604383614692565b60009250925050613c38565b43600954146138fb576138da600a6044612fff565b6139446040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa1580156139ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d29190615809565b6080820152600185016139ee57608081015160408201526139f6565b604081018590525b613a0487826040015161261e565b60e082018190526080820151613a1991614734565b60a0830181905260208301826003811115613a3657613a36615835565b6003811115613a4757613a47615835565b9052506000905081602001516003811115613a6457613a64615835565b14613ad75760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c454400000000000060648201526084016104e8565b613ae7600b548260e00151614734565b60c0830181905260208301826003811115613b0457613b04615835565b6003811115613b1557613b15615835565b9052506000905081602001516003811115613b3257613b32615835565b14613b995760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b60648201526084016104e8565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613c4d575081155b613c995760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e74000000000000000060448201526064016104e8565b613cda6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3c9190615809565b60408201528315613dff5761138884600f54613d589190615822565b1015613d6457600f5493505b6060810184905260408051602081018252908201518152613d8590856150ab565b6080830181905260208301826003811115613da257613da2615835565b6003811115613db357613db3615835565b9052506000905081602001516003811115613dd057613dd0615835565b14613dfa57613df26009602c836020015160038111156132c4576132c4615835565b915050610bbd565b613f46565b6000198303613e8c57600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e899190615809565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ecc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ef09190615809565b90506103e8613eff8583615822565b1015613f09578093505b613f178483604001516150fd565b60608301819052600f546103e891613f2e91615822565b1015613f3d57600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d9191613f849130918b91906004016158f8565b6020604051808303816000875af1158015613fa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc79190615809565b90508015613fe557613fdc6003602b83614692565b92505050610bbd565b4360095414613ffa57613fdc600a602f612fff565b61400a600f548360600151614734565b60a084018190526020840182600381111561402757614027615835565b600381111561403857614038615835565b905250600090508260200151600381111561405557614055615835565b1461407757613fdc60096031846020015160038111156132c4576132c4615835565b6001600160a01b038616600090815260106020526040902054606083015161409f9190614734565b60c08401819052602084018260038111156140bc576140bc615835565b60038111156140cd576140cd615835565b90525060009050826020015160038111156140ea576140ea615835565b1461410c57613fdc60096030846020015160038111156132c4576132c4615835565b8160800151614119612884565b101561412b57613fdc600e6032612fff565b60a0820151600f5560c08201516001600160a01b038716600090815260106020526040902055608082015161416190879061250c565b306001600160a01b0316866001600160a01b03166000805160206159b2833981519152846060015160405161419891815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b15801561425c57600080fd5b505af1158015614270573d6000803e3d6000fd5b506000925061427d915050565b9695505050505050565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e1906142c5903090899089906004016158f8565b6020604051808303816000875af11580156142e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143089190615809565b905080156143295761431d6003602183614692565b6000925092505061468b565b436009541461433e5761431d600a6024612fff565b61437f6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143e19190615809565b60408201526143f0868661261e565b60c08201819052604080516020810182529083015181526144119190615138565b606083018190526020830182600381111561442e5761442e615835565b600381111561443f5761443f615835565b905250600090508160200151600381111561445c5761445c615835565b146144a95760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016104e8565b60008160600151116144fd5760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a454354454400000000000060448201526064016104e8565b8060600151600f5461450f91906157c3565b608082015260608101516001600160a01b03871660009081526010602052604090205461453c91906157c3565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b03166000805160206159b283398151915283606001516040516145eb91815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b15801561465e57600080fd5b505af1158015614672573d6000803e3d6000fd5b506000925061467f915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08460118111156146c7576146c7615835565b8460618111156146d9576146d9615835565b604080519283526020830191909152810184905260600160405180910390a1600384601181111561470c5761470c615835565b146147285783601181111561472357614723615835565b610c31565b610c31826103e86157c3565b60008083831161475357600061474a8486615822565b9150915061468b565b5060039050600061468b565b6000670de0b6b3a7640000614778848460000151615148565b6107f09190615932565b60008061478f848461518a565b9050610c31816151bb565b6000808383018481106147b25760009250905061468b565b60026000925092505061468b565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c906147fd903090889088906004016158f8565b6020604051808303816000875af115801561481c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148409190615809565b9050801561485d576148556003601083614692565b9150506107f3565b436009541461487257614855600a600c612fff565b600061487c612884565b90508381101561489b57614892600e600b612fff565b925050506107f3565b6148c7604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614910573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149349190615809565b60208201819052614945908661479a565b604083018190528282600381111561495f5761495f615835565b600381111561497057614970615835565b905250600090508151600381111561498a5761498a615835565b146149b6576149ac6009600e836000015160038111156132c4576132c4615835565b93505050506107f3565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a339190615809565b92508215614a48576149ac6003601085614692565b614a54600b548661479a565b6060830181905282826003811115614a6e57614a6e615835565b6003811115614a7f57614a7f615835565b9052506000905081516003811115614a9957614a99615835565b14614abb576149ac6009600d836000015160038111156132c4576132c4615835565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b55614af7868661250c565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af1158015614bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bf59190615809565b90508015614c1657614c0a6003601483614692565b6000925092505061500f565b4360095414614c2b57614c0a600a6018612fff565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c8e9190615809565b14614c9f57614c0a600a6013612fff565b866001600160a01b0316866001600160a01b031603614cc457614c0a60066019612fff565b84600003614cd857614c0a60076017612fff565b6000198503614ced57614c0a60076016612fff565b600080614cfb898989613833565b90925090508115614d3057614d22826011811115614d1b57614d1b615835565b601a612fff565b60009450945050505061500f565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b90614d6d9030908c9088906004016158f8565b6040805180830381865afa158015614d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dad9190615946565b90925090508115614e1c5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016104e8565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa158015614e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e899190615809565b1015614ed75760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d554348000000000000000060448201526064016104e8565b6000306001600160a01b038a1603614efc57614ef5308d8d856130fb565b9050614f72565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190614f2c908f908f9087906004016158f8565b6020604051808303816000875af1158015614f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f6f9190615809565b90505b8015614fa95760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b60448201526064016104e8565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6060600080856001600160a01b031685604051615035919061596a565b6000604051808303816000865af19150503d8060008114615072576040519150601f19603f3d011682016040523d82523d6000602084013e615077565b606091505b5091509150816127e8578051156150915780518082602001fd5b8360405162461bcd60e51b81526004016104e891906154b5565b6000806000806150bb86866151d3565b909250905060008260038111156150d4576150d4615835565b146150e5575091506000905061468b565b60006150f0826151bb565b9350935050509250929050565b60008161511284670de0b6b3a7640000615986565b61511c9190615932565b9050615128828461599d565b156107f3576107f06001826157c3565b6000806000806150bb868661524f565b60006107f083836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f770000000000000000008152506152c2565b60408051602081019091526000815260405180602001604052806151b2856000015185615148565b90529392505050565b80516000906107f390670de0b6b3a764000090615932565b60006151eb6040518060200160405280600081525090565b6000806151fc866000015186615315565b9092509050600082600381111561521557615215615835565b146152345750604080516020810190915260008152909250905061468b565b60408051602081019091529081526000969095509350505050565b60006152676040518060200160405280600081525090565b60008061527c670de0b6b3a764000087615315565b9092509050600082600381111561529557615295615835565b146152b45750604080516020810190915260008152909250905061468b565b6150f0818660000151615357565b60008315806152cf575082155b156152dc57506000610bbd565b60006152e88486615986565b9050836152f58683615932565b1483906106c25760405162461bcd60e51b81526004016104e891906154b5565b6000808360000361532b5750600090508061468b565b838302836153398683615932565b1461534c5760026000925092505061468b565b60009250905061468b565b600061536f6040518060200160405280600081525090565b60008061538486670de0b6b3a7640000615315565b9092509050600082600381111561539d5761539d615835565b146153bc5750604080516020810190915260008152909250905061468b565b6000806153c98388615422565b909250905060008260038111156153e2576153e2615835565b14615405578160405180602001604052806000815250955095505050505061468b565b604080516020810190915290815260009890975095505050505050565b60008082600003615439575060019050600061468b565b60006154458486615932565b915091509250929050565b6001600160a01b0381168114610a8757600080fd5b6000806040838503121561547857600080fd5b823561548381615450565b946020939093013593505050565b60005b838110156154ac578181015183820152602001615494565b50506000910152565b60208152600082518060208401526154d4816040850160208701615491565b601f01601f19169190910160400192915050565b6000602082840312156154fa57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561552957600080fd5b813567ffffffffffffffff8082111561554157600080fd5b818401915084601f83011261555557600080fd5b81358181111561556757615567615501565b604051601f8201601f19908116603f0116810190838211818310171561558f5761558f615501565b816040528281528760208487010111156155a857600080fd5b826020860160208301376000928101602001929092525095945050505050565b6020808252825182820181905260009190848201906040850190845b8181101561560a5783516001600160e01b031916835292840192918401916001016155e4565b50909695505050505050565b60008060006060848603121561562b57600080fd5b833561563681615450565b9250602084013561564681615450565b929592945050506040919091013590565b60008060006060848603121561566c57600080fd5b833561567781615450565b925060208401359150604084013561568e81615450565b809150509250925092565b600181811c908216806156ad57607f821691505b60208210810361144057634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561571257600080fd5b81518015158114610bbd57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b60006020828403121561578857600080fd5b8151610bbd81615450565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052601160045260246000fd5b808201808211156107f3576107f36157ad565b634e487b7160e01b600052603260045260246000fd5b600060ff8216806157ff576157ff6157ad565b6000190192915050565b60006020828403121561581b57600080fd5b5051919050565b818103818111156107f3576107f36157ad565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b6000826159415761594161591c565b500490565b6000806040838503121561595957600080fd5b505080516020909101519092909150565b6000825161597c818460208701615491565b9190910192915050565b80820281158282048414176107f3576107f36157ad565b6000826159ac576159ac61591c565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202bab04d2112709d0e3e12f449d5a32fb8b6cbbf72f35bc7f7599fd174357e26664736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106102275760003560e01c8063852a12e311610130578063b0d58e49116100b8578063c91a424f1161007c578063c91a424f1461043f578063cb2ef6f714610452578063db006a751461047c578063f3fdb15a1461048f578063f5e3c462146104a257600080fd5b8063b0d58e49146103ee578063b2a02ff114610401578063be99f11914610414578063c3bf11cd14610423578063c5ebeaec1461042c57600080fd5b806395d89b41116100ff57806395d89b41146103ae5780639826394b146103b6578063a0712d68146103bf578063a7b820df146103d2578063aa5af0fd146103e557600080fd5b8063852a12e31461037457806389f8132e146103875780638d02d9a11461039c5780638f840ddd146103a557600080fd5b80633b1d21a2116101b35780635fe3b567116101825780635fe3b5671461032957806361feacff146103415780636752e7021461034a5780636c540baf146103585780636f307dc31461036157600080fd5b80633b1d21a2146102da5780633c4f743c146102e257806347bd37181461030d57806356e677281461031657600080fd5b8063173b9904116101fa578063173b99041461029357806318160ddd1461029c5780632608f818146102a55780632c436e5b146102b8578063313ce567146102cd57600080fd5b8063067db1b31461022c57806306fdde03146102415780630e7527021461025f578063135f133414610280575b600080fd5b61023f61023a366004615465565b6104b5565b005b6102496104ff565b60405161025691906154b5565b60405180910390f35b61027261026d3660046154e8565b61058d565b604051908152602001610256565b61027261028e366004615465565b6107ad565b61027260085481565b610272600f5481565b6102726102b3366004615465565b6107f9565b60015b60405160ff9091168152602001610256565b6003546102bb9060ff1681565b610272610a29565b6014546102f5906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b610272600b5481565b61023f610324366004615517565b610a38565b6003546102f59061010090046001600160a01b031681565b610272600d5481565b610272666379da05b6000081565b61027260095481565b6013546102f5906001600160a01b031681565b6102726103823660046154e8565b610a8a565b61038f610ca0565b60405161025691906155c8565b61027260065481565b610272600c5481565b610249610e9e565b610272600e5481565b6102726103cd3660046154e8565b610eab565b6102726103e03660046154e8565b6110b8565b610272600a5481565b6102726103fc3660046154e8565b611446565b61027261040f366004615616565b611705565b61027267016345785d8a000081565b61027260075481565b61027261043a3660046154e8565b61189f565b6000546102f5906001600160a01b031681565b60408051808201909152600e81526d43457263323044656c656761746560901b6020820152610249565b61027261048a3660046154e8565b611aa6565b6004546102f5906001600160a01b031681565b6102726104b0366004615657565b611cad565b3330146104f15760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b6104fb828261250c565b5050565b6001805461050c90615699565b80601f016020809104026020016040519081016040528092919081815260200182805461053890615699565b80156105855780601f1061055a57610100808354040283529160200191610585565b820191906000526020600020905b81548152906001019060200180831161056857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926105da9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa1580156105f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061b9190615700565b6106375760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906106669060040161574a565b602060405180830381865afa158015610683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a79190615776565b90506001600160a01b0381166106cb5760006106c28461258d565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561070e57600080fd5b505af1158015610722573d6000803e3d6000fd5b50503332039150610744905057600061073a8561258d565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107729032903390600401615793565b60006040518083038186803b15801561078a57600080fd5b505afa15801561079e573d6000803e3d6000fd5b50505050600061073a8561258d565b60003330146107e65760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064016104e8565b6107f0838361261e565b90505b92915050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926108469261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610863573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108879190615700565b6108a35760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906108d29060040161574a565b602060405180830381865afa1580156108ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109139190615776565b90506001600160a01b03811661093957600061092f85856127f1565b50925050506107f3565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561097c57600080fd5b505af1158015610990573d6000803e3d6000fd5b505033320391506109b490505760006109a986866127f1565b5093505050506107f3565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906109e29032903390600401615793565b60006040518083038186803b1580156109fa57600080fd5b505afa158015610a0e573d6000803e3d6000fd5b505050506000610a1e86866127f1565b509695505050505050565b6000610a33612884565b905090565b33301480610a495750610a496128f1565b610a875760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b60448201526064016104e8565b50565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610ad79261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b189190615700565b610b345760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610b639060040161574a565b602060405180830381865afa158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba49190615776565b90506001600160a01b038116610bc457610bbd83612a6e565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610c0757600080fd5b505af1158015610c1b573d6000803e3d6000fd5b50503332039150610c39905057610c3184612a6e565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610c679032903390600401615793565b60006040518083038186803b158015610c7f57600080fd5b505afa158015610c93573d6000803e3d6000fd5b50505050610c3184612a6e565b606060036000610cae612af6565b90508160ff168151610cc091906157c3565b67ffffffffffffffff811115610cd857610cd8615501565b604051908082528060200260200182016040528015610d01578160200160208202803683370190505b50925060005b8151811015610d5d57818181518110610d2257610d226157d6565b6020026020010151848281518110610d3c57610d3c6157d6565b6001600160e01b031990921660209283029190910190910152600101610d07565b50805163cb2ef6f760e01b908490610d74856157ec565b9450610d839060ff86166157c3565b81518110610d9357610d936157d6565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b908490610dc2856157ec565b9450610dd19060ff86166157c3565b81518110610de157610de16157d6565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b908490610e10856157ec565b9450610e1f9060ff86166157c3565b81518110610e2f57610e2f6157d6565b6001600160e01b03199092166020928302919091019091015260ff821615610e995760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104e8565b505090565b6002805461050c90615699565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610ef89261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015610f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f399190615700565b610f555760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610f849060040161574a565b602060405180830381865afa158015610fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc59190615776565b90506001600160a01b038116610fe05760006106c284612ebe565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561102357600080fd5b505af1158015611037573d6000803e3d6000fd5b5050333203915061104f905057600061073a85612ebe565b604051633108c13b60e01b81526001600160a01b03821690633108c13b9061107d9032903390600401615793565b60006040518083038186803b15801561109557600080fd5b505afa1580156110a9573d6000803e3d6000fd5b50505050600061073a85612ebe565b6000806110c481612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906110f39060040161574a565b602060405180830381865afa158015611110573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111349190615776565b90506001600160a01b03811661128c57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611184573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a89190615809565b5043600954146111c5576111be600a6039612fff565b9250611286565b836111ce612884565b10156111e0576111be600e6038612fff565b600d548411156111f6576111be6002603a612fff565b83600d546112049190615822565b600d55600354604080516303e1469160e61b815290516112819261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127b9190615776565b8561250c565b600092505b50611437565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906112bc9032903390600401615793565b60006040518083038186803b1580156112d457600080fd5b505afa1580156112e8573d6000803e3d6000fd5b505050506112f33090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611332573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113569190615809565b5043600954146113735761136c600a6039612fff565b9350611434565b8461137c612884565b101561138e5761136c600e6038612fff565b600d548511156113a45761136c6002603a612fff565b84600d546113b29190615822565b600d55600354604080516303e1469160e61b8152905161142f9261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611405573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114299190615776565b8661250c565b600093505b50505b61144081613078565b50919050565b60008061145281612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906114819060040161574a565b602060405180830381865afa15801561149e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c29190615776565b90506001600160a01b0381166115b657306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611512573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115369190615809565b50436009541461154c576111be600a6035612fff565b83611555612884565b1015611567576111be600e6034612fff565b600e5484111561157d576111be60026036612fff565b600084600e5461158d9190615822565b600e8190556000549091506115ab906001600160a01b03168661250c565b600093505050611437565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906115e69032903390600401615793565b60006040518083038186803b1580156115fe57600080fd5b505afa158015611612573d6000803e3d6000fd5b5050505061161d3090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561165c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116809190615809565b5043600954146116965761136c600a6035612fff565b8461169f612884565b10156116b15761136c600e6034612fff565b600e548511156116c75761136c60026036612fff565b600085600e546116d79190615822565b600e8190556000549091506116f5906001600160a01b03168761250c565b6000945050505061144081613078565b6000600161171281612f3b565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906117419060040161574a565b602060405180830381865afa15801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190615776565b90506001600160a01b0381166117a65761179e338787876130fb565b92505061188e565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156117e957600080fd5b505af11580156117fd573d6000803e3d6000fd5b5050333203915061181f905057611816338888886130fb565b9350505061188e565b604051633108c13b60e01b81526001600160a01b03821690633108c13b9061184d9032903390600401615793565b60006040518083038186803b15801561186557600080fd5b505afa158015611879573d6000803e3d6000fd5b50505050611889338888886130fb565b935050505b61189781613078565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926118ec9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611909573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192d9190615700565b6119495760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906119789060040161574a565b602060405180830381865afa158015611995573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b99190615776565b90506001600160a01b0381166119d257610bbd836135e3565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611a1557600080fd5b505af1158015611a29573d6000803e3d6000fd5b50503332039150611a3f905057610c31846135e3565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611a6d9032903390600401615793565b60006040518083038186803b158015611a8557600080fd5b505afa158015611a99573d6000803e3d6000fd5b50505050610c31846135e3565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611af39261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611b10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b349190615700565b611b505760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611b7f9060040161574a565b602060405180830381865afa158015611b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc09190615776565b90506001600160a01b038116611bd957610bbd8361365e565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611c1c57600080fd5b505af1158015611c30573d6000803e3d6000fd5b50503332039150611c46905057610c318461365e565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611c749032903390600401615793565b60006040518083038186803b158015611c8c57600080fd5b505afa158015611ca0573d6000803e3d6000fd5b50505050610c318461365e565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611cfa9261010090910490911690339030906001600160e01b0319883516906004016156cd565b602060405180830381865afa158015611d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3b9190615700565b611d575760405162461bcd60e51b81526004016104e890615722565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611d869060040161574a565b602060405180830381865afa158015611da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc79190615776565b90506001600160a01b038116611ffc5760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac190611e0a9060040161584b565b602060405180830381865afa158015611e27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4b9190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac190611e7f9060040161586d565b602060405180830381865afa158015611e9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec09190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f249190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d92611f5b92899261010090041690600401615793565b602060405180830381865afa158015611f78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9c9190615809565b1115611fe157336001600160a01b03821614611fca5760405162461bcd60e51b81526004016104e89061589b565b6000611fd78989896136db565b509550611ff39050565b6000611fee8989896136db565b509550505b50505050610bbd565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561203f57600080fd5b505af1158015612053573d6000803e3d6000fd5b5050333203915061228690505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac1906120939060040161584b565b602060405180830381865afa1580156120b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d49190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906121089060040161586d565b602060405180830381865afa158015612125573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121499190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926121e492899261010090041690600401615793565b602060405180830381865afa158015612201573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122259190615809565b111561226a57336001600160a01b038216146122535760405162461bcd60e51b81526004016104e89061589b565b60006122608a8a8a6136db565b50965061227c9050565b60006122778a8a8a6136db565b509650505b5050505050610bbd565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906122b49032903390600401615793565b60006040518083038186803b1580156122cc57600080fd5b505afa1580156122e0573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac1906123179060040161584b565b602060405180830381865afa158015612334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123589190615776565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061238c9060040161586d565b602060405180830381865afa1580156123a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123cd9190615776565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561240d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124319190615809565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261246892899261010090041690600401615793565b602060405180830381865afa158015612485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a99190615809565b11156124ee57336001600160a01b038216146124d75760405162461bcd60e51b81526004016104e89061589b565b60006124e48a8a8a6136db565b5096506125009050565b60006124fb8a8a8a6136db565b509650505b50505050509392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091018252602080820180516001600160e01b031663a9059cbb60e01b1790528251808401909352601983527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000908301526104fb916137d5565b600080600061259b81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156125db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ff9190615809565b5061260b333386613833565b9250925061261881613078565b50915091565b6013546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561266b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268f9190615809565b905061271f6323b872dd60e01b8530866040516024016126b1939291906158f8565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280601881526020017f544f4b454e5f5452414e534645525f494e5f4641494c454400000000000000008152506137d5565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278c9190615809565b9050818110156127de5760405162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f5700000000000060448201526064016104e8565b6127e88282615822565b95945050505050565b60008060006127ff81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561283f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128639190615809565b5061286f338686613833565b9250925061287c81613078565b509250929050565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156128cd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a339190615809565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561294a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061296e9190615776565b6001600160a01b0316336001600160a01b03161480156129eb5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129eb9190615700565b80612a6857506000546001600160a01b031633148015612a685750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a689190615700565b91505090565b600080612a7a81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ade9190615809565b50612aeb33600085613c40565b915061144081613078565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b81612b32846157ec565b93508360ff1681518110612b4857612b486157d6565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b81612b73846157ec565b93508360ff1681518110612b8957612b896157d6565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b81612bb4846157ec565b93508360ff1681518110612bca57612bca6157d6565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b81612bf5846157ec565b93508360ff1681518110612c0b57612c0b6157d6565b6001600160e01b03199092166020928302919091019091015263073a938160e11b81612c36846157ec565b93508360ff1681518110612c4c57612c4c6157d6565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b81612c77846157ec565b93508360ff1681518110612c8d57612c8d6157d6565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b81612cb8846157ec565b93508360ff1681518110612cce57612cce6157d6565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b81612cf9846157ec565b93508360ff1681518110612d0f57612d0f6157d6565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b81612d3a846157ec565b93508360ff1681518110612d5057612d506157d6565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b81612d7b846157ec565b93508360ff1681518110612d9157612d916157d6565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b81612dbc846157ec565b93508360ff1681518110612dd257612dd26157d6565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b81612dfd846157ec565b93508360ff1681518110612e1357612e136157d6565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b81612e3e846157ec565b93508360ff1681518110612e5457612e546157d6565b6001600160e01b03199092166020928302919091019091015260ff8216156107f35760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e6774680000000060448201526064016104e8565b6000806000612ecc81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f309190615809565b5061260b3385614287565b600054600160a01b900460ff16612f815760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b60448201526064016104e8565b80612fef57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612fd657600080fd5b505af1158015612fea573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601181111561303457613034615835565b83606181111561304657613046615835565b60408051928352602083019190915260009082015260600160405180910390a18260118111156107f0576107f0615835565b6000805460ff60a01b1916600160a01b17905580610a8757600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130e057600080fd5b505af11580156130f4573d6000803e3d6000fd5b5050505050565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af115801561316f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131939190615809565b905080156131b0576131a86003601d83614692565b915050610c31565b846001600160a01b0316846001600160a01b0316036131d5576131a86006601e612fff565b61323a604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03851660009081526010602052604090205461325d9085614734565b602083018190528282600381111561327757613277615835565b600381111561328857613288615835565b90525060009050815160038111156132a2576132a2615835565b146132d2576132c96009601c836000015160038111156132c4576132c4615835565b614692565b92505050610c31565b6132f1846040518060200160405280666379da05b6000081525061475f565b6080820152604080516020810190915267016345785d8a0000815261331790859061475f565b6101408201819052608082015161332e9086615822565b6133389190615822565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561337b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339f9190615809565b60c0820190815260408051602081019091529051815260808201516133c49190614782565b60a0820152604080516020810190915260c082015181526101408201516133eb9190614782565b61016082015260a0810151600c5461340391906157c3565b60e08201526101408101516080820151600f546134209190615822565b61342a9190615822565b610120820152610160810151600e5461344391906157c3565b6101008201526001600160a01b0386166000908152601060205260409020546060820151613471919061479a565b604083018190528282600381111561348b5761348b615835565b600381111561349c5761349c615835565b90525060009050815160038111156134b6576134b6615835565b146134d8576132c96009601b836000015160038111156132c4576132c4615835565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b16808252908490209290925560608501519251928352909290916000805160206159b2833981519152910160405180910390a3306001600160a01b0316856001600160a01b03166000805160206159b2833981519152836080015160405161358591815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b6000806135ef81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561362f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136539190615809565b50612aeb33846147c0565b60008061366a81612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156136aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ce9190615809565b50612aeb33846000613c40565b60008060006136e981612f3b565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061374d9190615809565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561378e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b29190615809565b506137bf33878787614b5b565b925092506137cc81613078565b50935093915050565b6013546000906137ef906001600160a01b03168484615018565b80519091501561382e578080602001905181019061380d9190615700565b829061382c5760405162461bcd60e51b81526004016104e891906154b5565b505b505050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af11580156138a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c59190615809565b905080156138e6576138da6003604383614692565b60009250925050613c38565b43600954146138fb576138da600a6044612fff565b6139446040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa1580156139ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d29190615809565b6080820152600185016139ee57608081015160408201526139f6565b604081018590525b613a0487826040015161261e565b60e082018190526080820151613a1991614734565b60a0830181905260208301826003811115613a3657613a36615835565b6003811115613a4757613a47615835565b9052506000905081602001516003811115613a6457613a64615835565b14613ad75760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c454400000000000060648201526084016104e8565b613ae7600b548260e00151614734565b60c0830181905260208301826003811115613b0457613b04615835565b6003811115613b1557613b15615835565b9052506000905081602001516003811115613b3257613b32615835565b14613b995760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b60648201526084016104e8565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613c4d575081155b613c995760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e74000000000000000060448201526064016104e8565b613cda6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3c9190615809565b60408201528315613dff5761138884600f54613d589190615822565b1015613d6457600f5493505b6060810184905260408051602081018252908201518152613d8590856150ab565b6080830181905260208301826003811115613da257613da2615835565b6003811115613db357613db3615835565b9052506000905081602001516003811115613dd057613dd0615835565b14613dfa57613df26009602c836020015160038111156132c4576132c4615835565b915050610bbd565b613f46565b6000198303613e8c57600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e899190615809565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ecc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ef09190615809565b90506103e8613eff8583615822565b1015613f09578093505b613f178483604001516150fd565b60608301819052600f546103e891613f2e91615822565b1015613f3d57600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d9191613f849130918b91906004016158f8565b6020604051808303816000875af1158015613fa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc79190615809565b90508015613fe557613fdc6003602b83614692565b92505050610bbd565b4360095414613ffa57613fdc600a602f612fff565b61400a600f548360600151614734565b60a084018190526020840182600381111561402757614027615835565b600381111561403857614038615835565b905250600090508260200151600381111561405557614055615835565b1461407757613fdc60096031846020015160038111156132c4576132c4615835565b6001600160a01b038616600090815260106020526040902054606083015161409f9190614734565b60c08401819052602084018260038111156140bc576140bc615835565b60038111156140cd576140cd615835565b90525060009050826020015160038111156140ea576140ea615835565b1461410c57613fdc60096030846020015160038111156132c4576132c4615835565b8160800151614119612884565b101561412b57613fdc600e6032612fff565b60a0820151600f5560c08201516001600160a01b038716600090815260106020526040902055608082015161416190879061250c565b306001600160a01b0316866001600160a01b03166000805160206159b2833981519152846060015160405161419891815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b15801561425c57600080fd5b505af1158015614270573d6000803e3d6000fd5b506000925061427d915050565b9695505050505050565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e1906142c5903090899089906004016158f8565b6020604051808303816000875af11580156142e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143089190615809565b905080156143295761431d6003602183614692565b6000925092505061468b565b436009541461433e5761431d600a6024612fff565b61437f6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156143bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143e19190615809565b60408201526143f0868661261e565b60c08201819052604080516020810182529083015181526144119190615138565b606083018190526020830182600381111561442e5761442e615835565b600381111561443f5761443f615835565b905250600090508160200151600381111561445c5761445c615835565b146144a95760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016104e8565b60008160600151116144fd5760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a454354454400000000000060448201526064016104e8565b8060600151600f5461450f91906157c3565b608082015260608101516001600160a01b03871660009081526010602052604090205461453c91906157c3565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b03166000805160206159b283398151915283606001516040516145eb91815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b15801561465e57600080fd5b505af1158015614672573d6000803e3d6000fd5b506000925061467f915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08460118111156146c7576146c7615835565b8460618111156146d9576146d9615835565b604080519283526020830191909152810184905260600160405180910390a1600384601181111561470c5761470c615835565b146147285783601181111561472357614723615835565b610c31565b610c31826103e86157c3565b60008083831161475357600061474a8486615822565b9150915061468b565b5060039050600061468b565b6000670de0b6b3a7640000614778848460000151615148565b6107f09190615932565b60008061478f848461518a565b9050610c31816151bb565b6000808383018481106147b25760009250905061468b565b60026000925092505061468b565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c906147fd903090889088906004016158f8565b6020604051808303816000875af115801561481c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148409190615809565b9050801561485d576148556003601083614692565b9150506107f3565b436009541461487257614855600a600c612fff565b600061487c612884565b90508381101561489b57614892600e600b612fff565b925050506107f3565b6148c7604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614910573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149349190615809565b60208201819052614945908661479a565b604083018190528282600381111561495f5761495f615835565b600381111561497057614970615835565b905250600090508151600381111561498a5761498a615835565b146149b6576149ac6009600e836000015160038111156132c4576132c4615835565b93505050506107f3565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a339190615809565b92508215614a48576149ac6003601085614692565b614a54600b548661479a565b6060830181905282826003811115614a6e57614a6e615835565b6003811115614a7f57614a7f615835565b9052506000905081516003811115614a9957614a99615835565b14614abb576149ac6009600d836000015160038111156132c4576132c4615835565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b55614af7868661250c565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af1158015614bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bf59190615809565b90508015614c1657614c0a6003601483614692565b6000925092505061500f565b4360095414614c2b57614c0a600a6018612fff565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c8e9190615809565b14614c9f57614c0a600a6013612fff565b866001600160a01b0316866001600160a01b031603614cc457614c0a60066019612fff565b84600003614cd857614c0a60076017612fff565b6000198503614ced57614c0a60076016612fff565b600080614cfb898989613833565b90925090508115614d3057614d22826011811115614d1b57614d1b615835565b601a612fff565b60009450945050505061500f565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b90614d6d9030908c9088906004016158f8565b6040805180830381865afa158015614d89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dad9190615946565b90925090508115614e1c5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016104e8565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa158015614e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e899190615809565b1015614ed75760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d554348000000000000000060448201526064016104e8565b6000306001600160a01b038a1603614efc57614ef5308d8d856130fb565b9050614f72565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190614f2c908f908f9087906004016158f8565b6020604051808303816000875af1158015614f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f6f9190615809565b90505b8015614fa95760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b60448201526064016104e8565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6060600080856001600160a01b031685604051615035919061596a565b6000604051808303816000865af19150503d8060008114615072576040519150601f19603f3d011682016040523d82523d6000602084013e615077565b606091505b5091509150816127e8578051156150915780518082602001fd5b8360405162461bcd60e51b81526004016104e891906154b5565b6000806000806150bb86866151d3565b909250905060008260038111156150d4576150d4615835565b146150e5575091506000905061468b565b60006150f0826151bb565b9350935050509250929050565b60008161511284670de0b6b3a7640000615986565b61511c9190615932565b9050615128828461599d565b156107f3576107f06001826157c3565b6000806000806150bb868661524f565b60006107f083836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f770000000000000000008152506152c2565b60408051602081019091526000815260405180602001604052806151b2856000015185615148565b90529392505050565b80516000906107f390670de0b6b3a764000090615932565b60006151eb6040518060200160405280600081525090565b6000806151fc866000015186615315565b9092509050600082600381111561521557615215615835565b146152345750604080516020810190915260008152909250905061468b565b60408051602081019091529081526000969095509350505050565b60006152676040518060200160405280600081525090565b60008061527c670de0b6b3a764000087615315565b9092509050600082600381111561529557615295615835565b146152b45750604080516020810190915260008152909250905061468b565b6150f0818660000151615357565b60008315806152cf575082155b156152dc57506000610bbd565b60006152e88486615986565b9050836152f58683615932565b1483906106c25760405162461bcd60e51b81526004016104e891906154b5565b6000808360000361532b5750600090508061468b565b838302836153398683615932565b1461534c5760026000925092505061468b565b60009250905061468b565b600061536f6040518060200160405280600081525090565b60008061538486670de0b6b3a7640000615315565b9092509050600082600381111561539d5761539d615835565b146153bc5750604080516020810190915260008152909250905061468b565b6000806153c98388615422565b909250905060008260038111156153e2576153e2615835565b14615405578160405180602001604052806000815250955095505050505061468b565b604080516020810190915290815260009890975095505050505050565b60008082600003615439575060019050600061468b565b60006154458486615932565b915091509250929050565b6001600160a01b0381168114610a8757600080fd5b6000806040838503121561547857600080fd5b823561548381615450565b946020939093013593505050565b60005b838110156154ac578181015183820152602001615494565b50506000910152565b60208152600082518060208401526154d4816040850160208701615491565b601f01601f19169190910160400192915050565b6000602082840312156154fa57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561552957600080fd5b813567ffffffffffffffff8082111561554157600080fd5b818401915084601f83011261555557600080fd5b81358181111561556757615567615501565b604051601f8201601f19908116603f0116810190838211818310171561558f5761558f615501565b816040528281528760208487010111156155a857600080fd5b826020860160208301376000928101602001929092525095945050505050565b6020808252825182820181905260009190848201906040850190845b8181101561560a5783516001600160e01b031916835292840192918401916001016155e4565b50909695505050505050565b60008060006060848603121561562b57600080fd5b833561563681615450565b9250602084013561564681615450565b929592945050506040919091013590565b60008060006060848603121561566c57600080fd5b833561567781615450565b925060208401359150604084013561568e81615450565b809150509250925092565b600181811c908216806156ad57607f821691505b60208210810361144057634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561571257600080fd5b81518015158114610bbd57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b60006020828403121561578857600080fd5b8151610bbd81615450565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052601160045260246000fd5b808201808211156107f3576107f36157ad565b634e487b7160e01b600052603260045260246000fd5b600060ff8216806157ff576157ff6157ad565b6000190192915050565b60006020828403121561581b57600080fd5b5051919050565b818103818111156107f3576107f36157ad565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b6000826159415761594161591c565b500490565b6000806040838503121561595957600080fd5b505080516020909101519092909150565b6000825161597c818460208701615491565b9190910192915050565b80820281158282048414176107f3576107f36157ad565b6000826159ac576159ac61591c565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202bab04d2112709d0e3e12f449d5a32fb8b6cbbf72f35bc7f7599fd174357e26664736f6c63430008160033", + "devdoc": { + "author": "Compound", + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "functionSelectors": "a list of all the function selectors that this logic extension exposes" + } + }, + "_withdrawAdminFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_withdrawIonicFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "borrow(uint256)": { + "params": { + "borrowAmount": "The amount of the underlying asset to borrow" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "getCash()": { + "returns": { + "_0": "The quantity of underlying asset owned by this contract" + } + }, + "liquidateBorrow(address,uint256,address)": { + "params": { + "borrower": "The borrower of this cToken to be liquidated", + "cTokenCollateral": "The market in which to seize collateral from the borrower", + "repayAmount": "The amount of the underlying borrowed asset to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "mint(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "mintAmount": "The amount of the underlying asset to supply" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeem(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemTokens": "The number of cTokens to redeem into underlying" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeemUnderlying(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemAmount": "The amount of underlying to redeem" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrow(uint256)": { + "params": { + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrowBehalf(address,uint256)": { + "params": { + "borrower": "the account with the debt being payed off", + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "seize(address,address,uint256)": { + "details": "Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.", + "params": { + "borrower": "The account having collateral seized", + "liquidator": "The account receiving seized collateral", + "seizeTokens": "The number of cTokens to seize" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + } + }, + "title": "Compound's CErc20Delegate Contract", + "version": 1 + }, + "userdoc": { + "events": { + "AccrueInterest(uint256,uint256,uint256,uint256)": { + "notice": "Event emitted when interest is accrued" + }, + "Approval(address,address,uint256)": { + "notice": "EIP20 Approval event" + }, + "Borrow(address,uint256,uint256,uint256)": { + "notice": "Event emitted when underlying is borrowed" + }, + "LiquidateBorrow(address,address,uint256,address,uint256)": { + "notice": "Event emitted when a borrow is liquidated" + }, + "Mint(address,uint256,uint256)": { + "notice": "Event emitted when tokens are minted" + }, + "NewAdminFee(uint256,uint256)": { + "notice": "Event emitted when the admin fee is changed" + }, + "NewIonicFee(uint256,uint256)": { + "notice": "Event emitted when the Ionic fee is changed" + }, + "NewMarketInterestRateModel(address,address)": { + "notice": "Event emitted when interestRateModel is changed" + }, + "NewReserveFactor(uint256,uint256)": { + "notice": "Event emitted when the reserve factor is changed" + }, + "Redeem(address,uint256,uint256)": { + "notice": "Event emitted when tokens are redeemed" + }, + "RepayBorrow(address,address,uint256,uint256,uint256)": { + "notice": "Event emitted when a borrow is repaid" + }, + "ReservesAdded(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are added" + }, + "ReservesReduced(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are reduced" + }, + "Transfer(address,address,uint256)": { + "notice": "EIP20 Transfer event" + } + }, + "kind": "user", + "methods": { + "_becomeImplementation(bytes)": { + "notice": "Called by the delegator on a delegate to initialize it for duty" + }, + "_withdrawAdminFees(uint256)": { + "notice": "Accrues interest and reduces admin fees by transferring to admin" + }, + "_withdrawIonicFees(uint256)": { + "notice": "Accrues interest and reduces Ionic fees by transferring to Ionic" + }, + "accrualBlockNumber()": { + "notice": "Block number that interest was last accrued at" + }, + "adminFeeMantissa()": { + "notice": "Fraction of interest currently set aside for admin fees" + }, + "ap()": { + "notice": "Addresses Provider" + }, + "borrow(uint256)": { + "notice": "Sender borrows assets from the protocol to their own address" + }, + "borrowIndex()": { + "notice": "Accumulator of the total earned interest rate since the opening of the market" + }, + "comptroller()": { + "notice": "Contract which oversees inter-cToken operations" + }, + "decimals()": { + "notice": "EIP-20 token decimals for this token" + }, + "getCash()": { + "notice": "Get cash balance of this cToken in the underlying asset" + }, + "interestRateModel()": { + "notice": "Model which tells what the current interest rate should be" + }, + "ionicFeeMantissa()": { + "notice": "Fraction of interest currently set aside for Ionic fees" + }, + "liquidateBorrow(address,uint256,address)": { + "notice": "The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator." + }, + "mint(uint256)": { + "notice": "Sender supplies assets into the market and receives cTokens in exchange" + }, + "name()": { + "notice": "EIP-20 token name for this token" + }, + "redeem(uint256)": { + "notice": "Sender redeems cTokens in exchange for the underlying asset" + }, + "redeemUnderlying(uint256)": { + "notice": "Sender redeems cTokens in exchange for a specified amount of underlying asset" + }, + "repayBorrow(uint256)": { + "notice": "Sender repays their own borrow" + }, + "repayBorrowBehalf(address,uint256)": { + "notice": "Sender repays a borrow belonging to borrower" + }, + "reserveFactorMantissa()": { + "notice": "Fraction of interest currently set aside for reserves" + }, + "seize(address,address,uint256)": { + "notice": "Transfers collateral tokens (this market) to the liquidator." + }, + "symbol()": { + "notice": "EIP-20 token symbol for this token" + }, + "totalAdminFees()": { + "notice": "Total amount of admin fees of the underlying held in this market" + }, + "totalBorrows()": { + "notice": "Total amount of outstanding borrows of the underlying in this market" + }, + "totalIonicFees()": { + "notice": "Total amount of Ionic fees of the underlying held in this market" + }, + "totalReserves()": { + "notice": "Total amount of reserves of the underlying held in this market" + }, + "totalSupply()": { + "notice": "Total number of tokens in circulation" + }, + "underlying()": { + "notice": "Underlying asset for this CToken" + } + }, + "notice": "CTokens which wrap an EIP-20 underlying and are delegated to", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 17997, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 18003, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "_notEntered", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 18006, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "name", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 18009, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "symbol", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 18012, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "decimals", + "offset": 0, + "slot": "3", + "type": "t_uint8" + }, + { + "astId": 18022, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "comptroller", + "offset": 1, + "slot": "3", + "type": "t_contract(IonicComptroller)25652" + }, + { + "astId": 18026, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "interestRateModel", + "offset": 0, + "slot": "4", + "type": "t_contract(InterestRateModel)28313" + }, + { + "astId": 18028, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "initialExchangeRateMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 18031, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "adminFeeMantissa", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 18034, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "ionicFeeMantissa", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 18037, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "reserveFactorMantissa", + "offset": 0, + "slot": "8", + "type": "t_uint256" + }, + { + "astId": 18040, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "accrualBlockNumber", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 18043, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "borrowIndex", + "offset": 0, + "slot": "10", + "type": "t_uint256" + }, + { + "astId": 18046, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "totalBorrows", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 18049, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "totalReserves", + "offset": 0, + "slot": "12", + "type": "t_uint256" + }, + { + "astId": 18052, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "totalAdminFees", + "offset": 0, + "slot": "13", + "type": "t_uint256" + }, + { + "astId": 18055, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "totalIonicFees", + "offset": 0, + "slot": "14", + "type": "t_uint256" + }, + { + "astId": 18058, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "totalSupply", + "offset": 0, + "slot": "15", + "type": "t_uint256" + }, + { + "astId": 18062, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "accountTokens", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 18068, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "transferAllowances", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 18079, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "accountBorrows", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_struct(BorrowSnapshot)18074_storage)" + }, + { + "astId": 18088, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "underlying", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 18092, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "ap", + "offset": 0, + "slot": "20", + "type": "t_contract(AddressesProvider)37930" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(AddressesProvider)37930": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(InterestRateModel)28313": { + "encoding": "inplace", + "label": "contract InterestRateModel", + "numberOfBytes": "20" + }, + "t_contract(IonicComptroller)25652": { + "encoding": "inplace", + "label": "contract IonicComptroller", + "numberOfBytes": "20" + }, + "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_struct(BorrowSnapshot)18074_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct CErc20Storage.BorrowSnapshot)", + "numberOfBytes": "32", + "value": "t_struct(BorrowSnapshot)18074_storage" + }, + "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_struct(BorrowSnapshot)18074_storage": { + "encoding": "inplace", + "label": "struct CErc20Storage.BorrowSnapshot", + "members": [ + { + "astId": 18071, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "principal", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 18073, + "contract": "contracts/compound/CErc20Delegate.sol:CErc20Delegate", + "label": "interestIndex", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/CErc20PluginDelegate.json b/packages/contracts/deployments/superseed/CErc20PluginDelegate.json new file mode 100644 index 0000000000..255f443bfe --- /dev/null +++ b/packages/contracts/deployments/superseed/CErc20PluginDelegate.json @@ -0,0 +1,1609 @@ +{ + "address": "0x8C58ECb9C0050824177f4e1Cd71C335421d4aeA2", + "abi": [ + { + "inputs": [], + "name": "CallerIsNotEOA", + "type": "error" + }, + { + "inputs": [], + "name": "InteractionNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldAdminFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFeeMantissa", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldIonicFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newIonicFeeMantissa", + "type": "uint256" + } + ], + "name": "NewIonicFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldImpl", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newImpl", + "type": "address" + } + ], + "name": "NewPluginImplementation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "benefactor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "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": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "_becomeImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_plugin", + "type": "address" + } + ], + "name": "_updatePlugin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract IonicComptroller", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractType", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "delegateType", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "feeSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "plugin", + "outputs": [ + { + "internalType": "contract IERC4626", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x8d6a82a6bfb4bcecdbac2e5e450bc4c028b47ed1feb82fbefa5ca1015b6e4e7a", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x8C58ECb9C0050824177f4e1Cd71C335421d4aeA2", + "transactionIndex": 1, + "gasUsed": "5282316", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x12f6568a42465fd4501e00ced4e91ef6f702c71c627ecaa6434d46f3726275d3", + "transactionHash": "0x8d6a82a6bfb4bcecdbac2e5e450bc4c028b47ed1feb82fbefa5ca1015b6e4e7a", + "logs": [], + "blockNumber": 4134610, + "cumulativeGasUsed": "5326194", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CallerIsNotEOA\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InteractionNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cashPrior\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"interestAccumulated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"AccrueInterest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"Borrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"LiquidateBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintTokens\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAdminFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldIonicFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newIonicFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewIonicFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"oldInterestRateModel\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"newInterestRateModel\",\"type\":\"address\"}],\"name\":\"NewMarketInterestRateModel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImpl\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImpl\",\"type\":\"address\"}],\"name\":\"NewPluginImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReserveFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewReserveFactor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"Redeem\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"payer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"RepayBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"benefactor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"addAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reduceAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesReduced\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"_becomeImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_plugin\",\"type\":\"address\"}],\"name\":\"_updatePlugin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accrualBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"}],\"name\":\"borrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractType\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"delegateType\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interestRateModel\",\"outputs\":[{\"internalType\":\"contract InterestRateModel\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"}],\"name\":\"liquidateBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"plugin\",\"outputs\":[{\"internalType\":\"contract IERC4626\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"}],\"name\":\"redeemUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrowBehalf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"seize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferIn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBorrows\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalReserves\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underlying\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Joey Santoro CErc20PluginDelegate deposits and withdraws from a plugin contract It is also capable of delegating reward functionality to a PluginRewardsDistributor\",\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_becomeImplementation(bytes)\":{\"params\":{\"data\":\"The encoded arguments for becoming\"}},\"_getExtensionFunctions()\":{\"returns\":{\"functionSelectors\":\"a list of all the function selectors that this logic extension exposes\"}},\"_updatePlugin(address)\":{\"params\":{\"_plugin\":\"The address of the plugin implementation to use\"}},\"_withdrawAdminFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_withdrawIonicFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"borrow(uint256)\":{\"params\":{\"borrowAmount\":\"The amount of the underlying asset to borrow\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"getCash()\":{\"returns\":{\"_0\":\"The quantity of underlying asset owned by this contract\"}},\"liquidateBorrow(address,uint256,address)\":{\"params\":{\"borrower\":\"The borrower of this cToken to be liquidated\",\"cTokenCollateral\":\"The market in which to seize collateral from the borrower\",\"repayAmount\":\"The amount of the underlying borrowed asset to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"mint(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"mintAmount\":\"The amount of the underlying asset to supply\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeem(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemTokens\":\"The number of cTokens to redeem into underlying\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeemUnderlying(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemAmount\":\"The amount of underlying to redeem\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrow(uint256)\":{\"params\":{\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrowBehalf(address,uint256)\":{\"params\":{\"borrower\":\"the account with the debt being payed off\",\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"seize(address,address,uint256)\":{\"details\":\"Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\",\"params\":{\"borrower\":\"The account having collateral seized\",\"liquidator\":\"The account receiving seized collateral\",\"seizeTokens\":\"The number of cTokens to seize\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}}},\"title\":\"Rari's CErc20Plugin's Contract\",\"version\":1},\"userdoc\":{\"events\":{\"AccrueInterest(uint256,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when interest is accrued\"},\"Approval(address,address,uint256)\":{\"notice\":\"EIP20 Approval event\"},\"Borrow(address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when underlying is borrowed\"},\"LiquidateBorrow(address,address,uint256,address,uint256)\":{\"notice\":\"Event emitted when a borrow is liquidated\"},\"Mint(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are minted\"},\"NewAdminFee(uint256,uint256)\":{\"notice\":\"Event emitted when the admin fee is changed\"},\"NewIonicFee(uint256,uint256)\":{\"notice\":\"Event emitted when the Ionic fee is changed\"},\"NewMarketInterestRateModel(address,address)\":{\"notice\":\"Event emitted when interestRateModel is changed\"},\"NewReserveFactor(uint256,uint256)\":{\"notice\":\"Event emitted when the reserve factor is changed\"},\"Redeem(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are redeemed\"},\"RepayBorrow(address,address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when a borrow is repaid\"},\"ReservesAdded(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are added\"},\"ReservesReduced(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are reduced\"},\"Transfer(address,address,uint256)\":{\"notice\":\"EIP20 Transfer event\"}},\"kind\":\"user\",\"methods\":{\"_becomeImplementation(bytes)\":{\"notice\":\"Delegate interface to become the implementation\"},\"_updatePlugin(address)\":{\"notice\":\"Update the plugin implementation to a whitelisted implementation\"},\"_withdrawAdminFees(uint256)\":{\"notice\":\"Accrues interest and reduces admin fees by transferring to admin\"},\"_withdrawIonicFees(uint256)\":{\"notice\":\"Accrues interest and reduces Ionic fees by transferring to Ionic\"},\"accrualBlockNumber()\":{\"notice\":\"Block number that interest was last accrued at\"},\"adminFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for admin fees\"},\"ap()\":{\"notice\":\"Addresses Provider\"},\"borrow(uint256)\":{\"notice\":\"Sender borrows assets from the protocol to their own address\"},\"borrowIndex()\":{\"notice\":\"Accumulator of the total earned interest rate since the opening of the market\"},\"comptroller()\":{\"notice\":\"Contract which oversees inter-cToken operations\"},\"decimals()\":{\"notice\":\"EIP-20 token decimals for this token\"},\"getCash()\":{\"notice\":\"Get cash balance of this cToken in the underlying asset\"},\"interestRateModel()\":{\"notice\":\"Model which tells what the current interest rate should be\"},\"ionicFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for Ionic fees\"},\"liquidateBorrow(address,uint256,address)\":{\"notice\":\"The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator.\"},\"mint(uint256)\":{\"notice\":\"Sender supplies assets into the market and receives cTokens in exchange\"},\"name()\":{\"notice\":\"EIP-20 token name for this token\"},\"plugin()\":{\"notice\":\"Plugin address\"},\"redeem(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for the underlying asset\"},\"redeemUnderlying(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for a specified amount of underlying asset\"},\"repayBorrow(uint256)\":{\"notice\":\"Sender repays their own borrow\"},\"repayBorrowBehalf(address,uint256)\":{\"notice\":\"Sender repays a borrow belonging to borrower\"},\"reserveFactorMantissa()\":{\"notice\":\"Fraction of interest currently set aside for reserves\"},\"seize(address,address,uint256)\":{\"notice\":\"Transfers collateral tokens (this market) to the liquidator.\"},\"symbol()\":{\"notice\":\"EIP-20 token symbol for this token\"},\"totalAdminFees()\":{\"notice\":\"Total amount of admin fees of the underlying held in this market\"},\"totalBorrows()\":{\"notice\":\"Total amount of outstanding borrows of the underlying in this market\"},\"totalIonicFees()\":{\"notice\":\"Total amount of Ionic fees of the underlying held in this market\"},\"totalReserves()\":{\"notice\":\"Total amount of reserves of the underlying held in this market\"},\"totalSupply()\":{\"notice\":\"Total number of tokens in circulation\"},\"underlying()\":{\"notice\":\"Underlying asset for this CToken\"}},\"notice\":\"CToken which outsources token logic to a plugin\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/CErc20PluginDelegate.sol\":\"CErc20PluginDelegate\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicUniV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV3FlashCallback.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV3Pool.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\nimport { IUniswapV3Quoter } from \\\"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"./ionic/IFlashLoanReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicUniV3Liquidator\\n * @author Veliko Minkov (https://github.com/vminkov)\\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\\n */\\ncontract IonicUniV3Liquidator is\\n OwnableUpgradeable,\\n ILiquidator,\\n IUniswapV3FlashCallback,\\n IExpressRelayFeeReceiver,\\n IFlashLoanReceiver\\n{\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n\\n address public W_NATIVE_ADDRESS;\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n IUniswapV3Quoter public quoter;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(address _wtoken, address _quoter) external initializer {\\n __Ownable_init();\\n W_NATIVE_ADDRESS = _wtoken;\\n quoter = IUniswapV3Quoter(_quoter);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n underlying.approve(address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateToTokensWithFlashLoan(\\n LiquidateToTokensWithFlashSwapVars calldata vars\\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\\n flashSwapPool.flash(\\n address(this),\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n\\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(\\n LiquidateToTokensWithFlashSwapVars memory vars,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\\n uint256 flashSwapReturnAmount = _flashSwapAmount;\\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\\n flashSwapReturnAmount += fee0;\\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\\n flashSwapReturnAmount += fee1;\\n } else {\\n revert(\\\"wrong pool or _flashSwapToken\\\");\\n }\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay the borrowed asset directly\\n collateralRequired = flashSwapReturnAmount;\\n\\n // Repay flashloan\\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\\n } else {\\n // TODO swap within the same pool and then repay the FL to the pool\\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\\n\\n {\\n collateralRequired = quoter.quoteExactOutputSingle(\\n zeroForOne ? pool.token0() : pool.token1(),\\n zeroForOne ? pool.token1() : pool.token0(),\\n pool.fee(),\\n _flashSwapAmount,\\n 0 // sqrtPriceLimitX96\\n );\\n }\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n\\n // Repay flashloan\\n pool.swap(\\n address(pool),\\n zeroForOne,\\n int256(collateralRequired),\\n 0, // sqrtPriceLimitX96\\n \\\"\\\"\\n );\\n }\\n\\n return address(underlyingCollateral);\\n } else {\\n revert(\\\"the redemptions strategy did not swap to the flash swapped pool assets\\\");\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n bool[] calldata whitelisted\\n ) external onlyOwner {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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\":\"0x03ad15c5d4e63fbc8d4df554ce3172f4e0611843a326a8e29ec39870e5ddbd72\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20Delegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CToken.sol\\\";\\n\\n/**\\n * @title Compound's CErc20Delegate Contract\\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\\n * @author Compound\\n */\\ncontract CErc20Delegate is CErc20 {\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 3;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n */\\n function _becomeImplementation(bytes memory) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 1;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20Delegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x64f72d66ae0f29c8400dd922cf2d5f453c1de98a72d7041fa8b39ec2aba25402\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20PluginDelegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CErc20Delegate.sol\\\";\\nimport \\\"./EIP20Interface.sol\\\";\\nimport \\\"./IERC4626.sol\\\";\\nimport \\\"../external/uniswap/IUniswapV2Pair.sol\\\";\\n\\n/**\\n * @title Rari's CErc20Plugin's Contract\\n * @notice CToken which outsources token logic to a plugin\\n * @author Joey Santoro\\n *\\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\\n */\\ncontract CErc20PluginDelegate is CErc20Delegate {\\n event NewPluginImplementation(address oldImpl, address newImpl);\\n\\n /**\\n * @notice Plugin address\\n */\\n IERC4626 public plugin;\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 2;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Delegate interface to become the implementation\\n * @param data The encoded arguments for becoming\\n */\\n function _becomeImplementation(bytes memory data) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"only self and admins can call _becomeImplementation\\\");\\n\\n address _plugin = abi.decode(data, (address));\\n\\n if (_plugin == address(0) && address(plugin) != address(0)) {\\n // if no new plugin address is given, use the latest implementation\\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\\n }\\n\\n if (_plugin != address(0) && _plugin != address(plugin)) {\\n _updatePlugin(_plugin);\\n }\\n }\\n\\n /**\\n * @notice Update the plugin implementation to a whitelisted implementation\\n * @param _plugin The address of the plugin implementation to use\\n */\\n function _updatePlugin(address _plugin) public {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"only self and admins can call _updatePlugin\\\");\\n\\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\\n\\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\\n }\\n\\n plugin = IERC4626(_plugin);\\n\\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\\n\\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\\n if (amount != 0) {\\n deposit(amount);\\n }\\n\\n emit NewPluginImplementation(oldImplementation, _plugin);\\n }\\n\\n /*** CToken Overrides ***/\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of the plugin in terms of the underlying\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view override returns (uint256) {\\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\\n }\\n\\n /**\\n * @notice Transfer the underlying to the cToken and trigger a deposit\\n * @param from Address to transfer funds from\\n * @param amount Amount of underlying to transfer\\n * @return The actual amount that is transferred\\n */\\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\\n // Perform the EIP-20 transfer in\\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \\\"send\\\");\\n\\n deposit(amount);\\n return amount;\\n }\\n\\n function deposit(uint256 amount) internal {\\n plugin.deposit(amount, address(this));\\n }\\n\\n /**\\n * @notice Transfer the underlying from plugin to destination\\n * @param to Address to transfer funds to\\n * @param amount Amount of underlying to transfer\\n */\\n function doTransferOut(address to, uint256 amount) internal override {\\n plugin.withdraw(amount, to, address(this));\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 2;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20PluginDelegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x095cc54097ac06a9b6232222c5197df72c4cc4a0f2c69261bf22ebba2dfead3f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CToken.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { CTokenSecondExtensionBase, ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { TokenErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { CTokenOracleProtected } from \\\"./CTokenOracleProtected.sol\\\";\\n\\nimport { DiamondExtension, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { PoolLens } from \\\"../PoolLens.sol\\\";\\nimport { IonicUniV3Liquidator } from \\\"../IonicUniV3Liquidator.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\n/**\\n * @title Compound's CErc20 Contract\\n * @notice CTokens which wrap an EIP-20 underlying\\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\\n * @author Compound\\n */\\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\\n modifier isAuthorized() {\\n require(\\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\\n \\\"not authorized\\\"\\n );\\n _;\\n }\\n\\n modifier isMinHFThresholdExceeded(address borrower) {\\n PoolLens lens = PoolLens(ap.getAddress(\\\"PoolLens\\\"));\\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\\\"IonicUniV3Liquidator\\\")));\\n\\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\\n require(msg.sender == address(liquidator), \\\"Health factor not low enough for non-permissioned liquidations\\\");\\n _;\\n } else {\\n _;\\n }\\n }\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 13;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.mint.selector;\\n functionSelectors[--fnsCount] = this.redeem.selector;\\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\\n functionSelectors[--fnsCount] = this.borrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\\n functionSelectors[--fnsCount] = this.getCash.selector;\\n functionSelectors[--fnsCount] = this.seize.selector;\\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*** User Interface ***/\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = mintInternal(mintAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemInternal(redeemTokens);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to redeem\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemUnderlyingInternal(redeemAmount);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return borrowInternal(borrowAmount);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowInternal(repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\\n return err;\\n }\\n\\n /**\\n * @notice Get cash balance of this cToken in the underlying asset\\n * @return The quantity of underlying asset owned by this contract\\n */\\n function getCash() external view override returns (uint256) {\\n return getCashInternal();\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Will fail unless called by another cToken during the process of liquidation.\\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\\n }\\n\\n function selfTransferOut(address to, uint256 amount) external override {\\n require(msg.sender == address(this), \\\"!self\\\");\\n doTransferOut(to, amount);\\n }\\n\\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\\n require(msg.sender == address(this), \\\"!self\\\");\\n return doTransferIn(from, amount);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\\n }\\n\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalIonicFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\\n totalIonicFees = totalIonicFeesNew;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(address(ionicAdmin), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces admin fees by transferring to admin\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\\n }\\n\\n // Fail gracefully if protocol has insufficient underlying cash\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalAdminFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n totalAdminFees = totalAdminFees - withdrawAmount;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of this contract in terms of the underlying\\n * @dev This excludes the value of the current message, if any\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view virtual returns (uint256) {\\n return EIP20Interface(underlying).balanceOf(address(this));\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\\n * This will revert due to insufficient balance or insufficient allowance.\\n * This function returns the actual amount received,\\n * which may be less than `amount` if there is a fee attached to the transfer.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\\n \\\"TOKEN_TRANSFER_IN_FAILED\\\"\\n );\\n\\n // Calculate the amount that was *actually* transferred\\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\\n require(balanceAfter >= balanceBefore, \\\"TOKEN_TRANSFER_IN_OVERFLOW\\\");\\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\\n * it is >= amount, this should not revert in normal conditions.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferOut(address to, uint256 amount) internal virtual {\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\\n \\\"TOKEN_TRANSFER_OUT_FAILED\\\"\\n );\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\\n }\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\\n return mintFresh(msg.sender, mintAmount);\\n }\\n\\n struct MintLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 mintTokens;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n uint256 actualMintAmount;\\n }\\n\\n /**\\n * @notice User supplies assets into the market and receives cTokens in exchange\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param minter The address of the account which is supplying the assets\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\\n /* Fail if mint not allowed */\\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\\n }\\n\\n MintLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n // Check max supply\\n // unused function\\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n } */\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call `doTransferIn` for the minter and the mintAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\\n * side-effects occurred. The function returns the amount actually transferred,\\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\\n * of cash.\\n */\\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\\n\\n /*\\n * We get the current exchange rate and calculate the number of cTokens to be minted:\\n * mintTokens = actualMintAmount / exchangeRate\\n */\\n\\n // mintTokens is rounded down here - correct\\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\\n vars.actualMintAmount,\\n Exp({ mantissa: vars.exchangeRateMantissa })\\n );\\n require(vars.mathErr == MathError.NO_ERROR, \\\"MINT_EXCHANGE_CALCULATION_FAILED\\\");\\n require(vars.mintTokens > 0, \\\"MINT_ZERO_CTOKENS_REJECTED\\\");\\n\\n /*\\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\\n * totalSupplyNew = totalSupply + mintTokens\\n * accountTokensNew = accountTokens[minter] + mintTokens\\n */\\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\\n\\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[minter] = vars.accountTokensNew;\\n\\n /* We emit a Mint event, and a Transfer event */\\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\\n emit Transfer(address(this), minter, vars.mintTokens);\\n\\n /* We call the defense hook */\\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\\n\\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, redeemTokens, 0);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, 0, redeemAmount);\\n }\\n\\n struct RedeemLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 redeemTokens;\\n uint256 redeemAmount;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n }\\n\\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\\n res = (x * 1e18) / y;\\n if (x % y != 0) res += 1;\\n }\\n\\n /**\\n * @notice User redeems cTokens in exchange for the underlying asset\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param redeemer The address of the account which is redeeming the tokens\\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemFresh(\\n address redeemer,\\n uint256 redeemTokensIn,\\n uint256 redeemAmountIn\\n ) internal returns (uint256) {\\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \\\"!redeem tokens or amount\\\");\\n\\n RedeemLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n if (redeemTokensIn > 0) {\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\\n\\n /*\\n * We calculate the exchange rate and the amount of underlying to be redeemed:\\n * redeemTokens = redeemTokensIn\\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\\n */\\n vars.redeemTokens = redeemTokensIn;\\n\\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n redeemTokensIn\\n );\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n } else {\\n if (redeemAmountIn == type(uint256).max) {\\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\\n }\\n\\n // don't allow dust tokens/assets to be left after\\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\\n\\n /*\\n * We get the current exchange rate and calculate the amount to be redeemed:\\n * redeemTokens = redeemAmountIn / exchangeRate\\n * redeemAmount = redeemAmountIn\\n */\\n\\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\\n\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\\n\\n vars.redeemAmount = redeemAmountIn;\\n }\\n\\n /* Fail if redeem not allowed */\\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\\n }\\n\\n /*\\n * We calculate the new total supply and redeemer balance, checking for underflow:\\n * totalSupplyNew = totalSupply - redeemTokens\\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\\n */\\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /* Fail gracefully if protocol has insufficient cash */\\n if (getCashInternal() < vars.redeemAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[redeemer] = vars.accountTokensNew;\\n\\n /*\\n * We invoke doTransferOut for the redeemer and the redeemAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken has redeemAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(redeemer, vars.redeemAmount);\\n\\n /* We emit a Transfer event, and a Redeem event */\\n emit Transfer(redeemer, address(this), vars.redeemTokens);\\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n /* We call the defense hook */\\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\\n return borrowFresh(msg.sender, borrowAmount);\\n }\\n\\n struct BorrowLocalVars {\\n MathError mathErr;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n }\\n\\n /**\\n * @notice Users borrow assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\\n /* Fail if borrow not allowed */\\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\\n }\\n\\n /* Fail gracefully if protocol has insufficient underlying cash */\\n uint256 cashPrior = getCashInternal();\\n\\n if (cashPrior < borrowAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\\n }\\n\\n BorrowLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on overflow:\\n * accountBorrowsNew = accountBorrows + borrowAmount\\n * totalBorrowsNew = totalBorrows + borrowAmount\\n */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(\\n Error.MATH_ERROR,\\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n uint256(vars.mathErr)\\n );\\n }\\n\\n // Check min borrow for this user for this asset\\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /*\\n * We invoke doTransferOut for the borrower and the borrowAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken borrowAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(borrower, borrowAmount);\\n\\n /* We emit a Borrow event */\\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\\n internal\\n nonReentrant(false)\\n returns (uint256, uint256)\\n {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\\n }\\n\\n struct RepayBorrowLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 repayAmount;\\n uint256 borrowerIndex;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n uint256 actualRepayAmount;\\n }\\n\\n /**\\n * @notice Borrows are repaid by another user (possibly the borrower).\\n * @param payer the account paying off the borrow\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount the amount of undelrying tokens being returned\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowFresh(\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) internal returns (uint256, uint256) {\\n /* Fail if repayBorrow not allowed */\\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\\n }\\n\\n RepayBorrowLocalVars memory vars;\\n\\n /* We remember the original borrowerIndex for verification purposes */\\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\\n\\n /* We fetch the amount the borrower owes, with accumulated interest */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n /* If repayAmount == -1, repayAmount = accountBorrows */\\n if (repayAmount == type(uint256).max) {\\n vars.repayAmount = vars.accountBorrows;\\n } else {\\n vars.repayAmount = repayAmount;\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call doTransferIn for the payer and the repayAmount\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken holds an additional repayAmount of cash.\\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n * it returns the amount actually transferred, in case of a fee.\\n */\\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on underflow:\\n * accountBorrowsNew = accountBorrows - actualRepayAmount\\n * totalBorrowsNew = totalBorrows - actualRepayAmount\\n */\\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\\\");\\n\\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\\\");\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /* We emit a RepayBorrow event */\\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\\n\\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowInternal(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n ICErc20(cTokenCollateral).accrueInterest();\\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\\n }\\n\\n /**\\n * @notice The liquidator liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param liquidator The address repaying the borrow and seizing collateral\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowFresh(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal returns (uint256, uint256) {\\n /* Fail if liquidate not allowed */\\n uint256 allowed = comptroller.liquidateBorrowAllowed(\\n address(this),\\n cTokenCollateral,\\n liquidator,\\n borrower,\\n repayAmount\\n );\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Verify cTokenCollateral market's block number equals current block number */\\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\\n }\\n\\n /* Fail if repayAmount = 0 */\\n if (repayAmount == 0) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\\n }\\n\\n /* Fail if repayAmount = -1 */\\n if (repayAmount == type(uint256).max) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\\n }\\n\\n /* Fail if repayBorrow fails */\\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We calculate the number of collateral tokens that will be seized */\\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\\n address(this),\\n cTokenCollateral,\\n actualRepayAmount\\n );\\n require(amountSeizeError == uint256(Error.NO_ERROR), \\\"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\\\");\\n\\n /* Revert if borrower collateral token balance < seizeTokens */\\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \\\"LIQUIDATE_SEIZE_TOO_MUCH\\\");\\n\\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\\n uint256 seizeError;\\n if (cTokenCollateral == address(this)) {\\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\\n } else {\\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\\n }\\n\\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\\n require(seizeError == uint256(Error.NO_ERROR), \\\"!seize\\\");\\n\\n /* We emit a LiquidateBorrow event */\\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\\n\\n return (uint256(Error.NO_ERROR), actualRepayAmount);\\n }\\n\\n struct SeizeInternalLocalVars {\\n MathError mathErr;\\n uint256 borrowerTokensNew;\\n uint256 liquidatorTokensNew;\\n uint256 liquidatorSeizeTokens;\\n uint256 protocolSeizeTokens;\\n uint256 protocolSeizeAmount;\\n uint256 exchangeRateMantissa;\\n uint256 totalReservesNew;\\n uint256 totalIonicFeeNew;\\n uint256 totalSupplyNew;\\n uint256 feeSeizeTokens;\\n uint256 feeSeizeAmount;\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seizeInternal(\\n address seizerToken,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) internal returns (uint256) {\\n /* Fail if seize not allowed */\\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\\n }\\n\\n SeizeInternalLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\\n */\\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n vars.protocolSeizeAmount = mul_ScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n vars.protocolSeizeTokens\\n );\\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\\n\\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\\n\\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n totalReserves = vars.totalReservesNew;\\n totalSupply = vars.totalSupplyNew;\\n totalIonicFees = vars.totalIonicFeeNew;\\n\\n accountTokens[borrower] = vars.borrowerTokensNew;\\n accountTokens[liquidator] = vars.liquidatorTokensNew;\\n\\n /* Emit a Transfer event */\\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function asCTokenExtension() internal view returns (ICErc20) {\\n return ICErc20(address(this));\\n }\\n\\n /*** Reentrancy Guard ***/\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant(bool localOnly) {\\n _beforeNonReentrant(localOnly);\\n _;\\n _afterNonReentrant(localOnly);\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\\n */\\n function _beforeNonReentrant(bool localOnly) private {\\n require(_notEntered, \\\"re-entered\\\");\\n if (!localOnly) comptroller._beforeNonReentrant();\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\\n */\\n function _afterNonReentrant(bool localOnly) private {\\n _notEntered = true; // get a gas-refund post-Istanbul\\n if (!localOnly) comptroller._afterNonReentrant();\\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 * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\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 * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n}\\n\",\"keccak256\":\"0x308ca2ce334910ef9ece96a98a4a899eaa802051051dc89bf6f8732242000b7b\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenOracleProtected.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.22;\\n\\nimport { CErc20Storage } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenOracleProtected is CErc20Storage {\\n error InteractionNotAllowed();\\n error CallerIsNotEOA();\\n\\n modifier onlyOracleApproved() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyOracleApprovedAllowEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n if (tx.origin == msg.sender) {\\n _;\\n return;\\n }\\n\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyNotBlacklistedEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n if (msg.sender != tx.origin) {\\n revert CallerIsNotEOA();\\n }\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x42b99e4fbc5880f64a6f1d8b02f3b061b0d3a6c312f47d83e88593eefaf71304\",\"license\":\"Unlicense\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/EIP20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ERC 20 Token Standard Interface\\n * https://eips.ethereum.org/EIPS/eip-20\\n */\\ninterface EIP20Interface {\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n /**\\n * @notice Get the total number of tokens in circulation\\n * @return uint256 The supply of tokens\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @notice Gets the balance of the specified address\\n * @param owner The address from which the balance will be retrieved\\n * @return balance uint256 The balance\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transfer(address dst, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Transfer `amount` tokens from `src` to `dst`\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool success);\\n\\n /**\\n * @notice Approve `spender` to transfer up to `amount` from `src`\\n * @dev This will overwrite the approval amount for `spender`\\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\\n * @param spender The address of the account which may transfer tokens\\n * @param amount The number of tokens that are approved (-1 means infinite)\\n * @return success bool Whether or not the approval succeeded\\n */\\n function approve(address spender, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Get the current allowance from `owner` for `spender`\\n * @param owner The address of the account which owns the tokens to be spent\\n * @param spender The address of the account which may transfer tokens\\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\\n */\\n function allowance(address owner, address spender) external view returns (uint256 remaining);\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n}\\n\",\"keccak256\":\"0xcea1d290397e1c8eac89c96738e7ec55259a575f878152eeccf33c0cf6d008e5\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IERC4626.sol\":{\"content\":\"pragma solidity >=0.8.0;\\npragma experimental ABIEncoderV2;\\n\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\n\\ninterface IERC4626 is EIP20Interface {\\n /*----------------------------------------------------------------\\n Events\\n ----------------------------------------------------------------*/\\n\\n event Deposit(address indexed from, address indexed to, uint256 value);\\n\\n event Withdraw(address indexed from, address indexed to, uint256 value);\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n /**\\n @notice Deposit a specific amount of underlying tokens.\\n @param underlyingAmount The amount of the underlying token to deposit.\\n @param to The address to receive shares corresponding to the deposit\\n @return shares The shares in the vault credited to `to`\\n */\\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\\n\\n /**\\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\\n @param shareAmount The amount of vault shares to mint.\\n @param to The address to receive shares corresponding to the mint.\\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\\n */\\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\\n\\n /**\\n @notice Withdraw a specific amount of underlying tokens.\\n @param underlyingAmount The amount of the underlying token to withdraw.\\n @param to The address to receive underlying corresponding to the withdrawal.\\n @param from The address to burn shares from corresponding to the withdrawal.\\n @return shares The shares in the vault burned from sender\\n */\\n function withdraw(\\n uint256 underlyingAmount,\\n address to,\\n address from\\n ) external returns (uint256 shares);\\n\\n /**\\n @notice Redeem a specific amount of shares for underlying tokens.\\n @param shareAmount The amount of shares to redeem.\\n @param to The address to receive underlying corresponding to the redemption.\\n @param from The address to burn shares from corresponding to the redemption.\\n @return value The underlying amount transferred to `to`.\\n */\\n function redeem(\\n uint256 shareAmount,\\n address to,\\n address from\\n ) external returns (uint256 value);\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n /** \\n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n @return the address of the asset\\n */\\n function asset() external view returns (address);\\n\\n /** \\n @notice Returns a user's Vault balance in underlying tokens.\\n @param user The user to get the underlying balance of.\\n @return balance The user's Vault balance in underlying tokens.\\n */\\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\\n\\n /** \\n @notice Calculates the total amount of underlying tokens the Vault manages.\\n @return The total amount of underlying tokens the Vault manages.\\n */\\n function totalAssets() external view returns (uint256);\\n\\n /** \\n @notice Returns the value in underlying terms of one vault token. \\n */\\n function exchangeRate() external view returns (uint256);\\n\\n /**\\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\\n @param underlyingAmount the input amount of underlying tokens\\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\\n */\\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\\n\\n /**\\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\\n @param shareAmount the amount of shares from a mint call.\\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\\n */\\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\\n\\n /**\\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\\n @param underlyingAmount the input amount of underlying tokens\\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\\n */\\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\\n\\n /**\\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\\n @param shareAmount the amount of shares from a redeem call.\\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\\n */\\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\\n}\\n\",\"keccak256\":\"0x1dc7b6dc2f1202ca16bff4eb488bb5bfcd6a48202996663a7220a888b261d7cb\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3FlashCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#flash\\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\\ninterface IUniswapV3FlashCallback {\\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\\n function uniswapV3FlashCallback(\\n uint256 fee0,\\n uint256 fee1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc26730db16259a49c30bd7bd880bb7e48ad94853087a373ba787e406ca969f3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50615e9480620000216000396000f3fe608060405234801561001057600080fd5b506004361061023d5760003560e01c8063852a12e31161013b578063b2a02ff1116100b8578063cb2ef6f71161007c578063cb2ef6f71461047b578063db006a75146104ab578063ef01df4f146104be578063f3fdb15a146104d1578063f5e3c462146104e457600080fd5b8063b2a02ff11461042a578063be99f1191461043d578063c3bf11cd1461044c578063c5ebeaec14610455578063c91a424f1461046857600080fd5b80639826394b116100ff5780639826394b146103df578063a0712d68146103e8578063a7b820df146103fb578063aa5af0fd1461040e578063b0d58e491461041757600080fd5b8063852a12e31461039d57806389f8132e146103b05780638d02d9a1146103c55780638f840ddd146103ce57806395d89b41146103d757600080fd5b8063313ce567116101c95780635fe3b5671161018d5780635fe3b5671461035257806361feacff1461036a5780636752e702146103735780636c540baf146103815780636f307dc31461038a57600080fd5b8063313ce567146102f65780633b1d21a2146103035780633c4f743c1461030b57806347bd37181461033657806356e677281461033f57600080fd5b8063173b990411610210578063173b9904146102a957806318160ddd146102b257806319f496c8146102bb5780632608f818146102ce5780632c436e5b146102e157600080fd5b8063067db1b31461024257806306fdde03146102575780630e75270214610275578063135f133414610296575b600080fd5b6102556102503660046158f9565b6104f7565b005b61025f610541565b60405161026c9190615925565b60405180910390f35b610288610283366004615974565b6105cf565b60405190815260200161026c565b6102886102a43660046158f9565b6107ef565b61028860085481565b610288600f5481565b6102556102c936600461598d565b61083b565b6102886102dc3660046158f9565b610b8f565b60025b60405160ff909116815260200161026c565b6003546102e49060ff1681565b610288610dbf565b60145461031e906001600160a01b031681565b6040516001600160a01b03909116815260200161026c565b610288600b5481565b61025561034d3660046159c0565b610dce565b60035461031e9061010090046001600160a01b031681565b610288600d5481565b610288666379da05b6000081565b61028860095481565b60135461031e906001600160a01b031681565b6102886103ab366004615974565b610f2c565b6103b8611142565b60405161026c9190615a71565b61028860065481565b610288600c5481565b61025f6112f2565b610288600e5481565b6102886103f6366004615974565b6112ff565b610288610409366004615974565b61150c565b610288600a5481565b610288610425366004615974565b61189a565b610288610438366004615abf565b611b59565b61028867016345785d8a000081565b61028860075481565b610288610463366004615974565b611cf3565b60005461031e906001600160a01b031681565b604080518082019091526014815273434572633230506c7567696e44656c656761746560601b602082015261025f565b6102886104b9366004615974565b611efa565b60155461031e906001600160a01b031681565b60045461031e906001600160a01b031681565b6102886104f2366004615b00565b612101565b3330146105335760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b61053d8282612960565b5050565b6001805461054e90615b42565b80601f016020809104026020016040519081016040528092919081815260200182805461057a90615b42565b80156105c75780601f1061059c576101008083540402835291602001916105c7565b820191906000526020600020905b8154815290600101906020018083116105aa57829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261061c9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065d9190615ba9565b6106795760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906106a890600401615bf3565b602060405180830381865afa1580156106c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e99190615c1f565b90506001600160a01b03811661070d576000610704846129e2565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561075057600080fd5b505af1158015610764573d6000803e3d6000fd5b50503332039150610786905057600061077c856129e2565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107b49032903390600401615c3c565b60006040518083038186803b1580156107cc57600080fd5b505afa1580156107e0573d6000803e3d6000fd5b50505050600061077c856129e2565b60003330146108285760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b604482015260640161052a565b6108328383612a73565b90505b92915050565b3330148061084c575061084c612b29565b6108ac5760405162461bcd60e51b815260206004820152602b60248201527f6f6e6c792073656c6620616e642061646d696e732063616e2063616c6c205f7560448201526a383230ba32a8363ab3b4b760a91b606482015260840161052a565b6015546000906001600160a01b03166108c557816108d2565b6015546001600160a01b03165b6015549091506001600160a01b03161580159061095957506015546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610932573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109569190615c56565b15155b15610a43576015546040516370a0823160e01b81523060048201526001600160a01b039091169063ba0876529082906370a0823190602401602060405180830381865afa1580156109ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d29190615c56565b6040516001600160e01b031960e084901b1681526004810191909152306024820181905260448201526064016020604051808303816000875af1158015610a1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a419190615c56565b505b601580546001600160a01b0319166001600160a01b0384811691821790925560135460405163095ea7b360e01b8152600481019290925260001960248301529091169063095ea7b3906044016020604051808303816000875af1158015610aae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad29190615ba9565b506013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b409190615c56565b90508015610b5157610b5181612ca6565b7fb32957d2794aaec3ea2c8852833af2192fe9fb518777de1f883e9e821781da758284604051610b82929190615c3c565b60405180910390a1505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610bdc9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1d9190615ba9565b610c395760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610c6890600401615bf3565b602060405180830381865afa158015610c85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca99190615c1f565b90506001600160a01b038116610ccf576000610cc58585612d1b565b5092505050610835565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610d1257600080fd5b505af1158015610d26573d6000803e3d6000fd5b50503332039150610d4a9050576000610d3f8686612d1b565b509350505050610835565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610d789032903390600401615c3c565b60006040518083038186803b158015610d9057600080fd5b505afa158015610da4573d6000803e3d6000fd5b505050506000610db48686612d1b565b509695505050505050565b6000610dc9612dae565b905090565b33301480610ddf5750610ddf612b29565b610e475760405162461bcd60e51b815260206004820152603360248201527f6f6e6c792073656c6620616e642061646d696e732063616e2063616c6c205f6260448201527232b1b7b6b2a4b6b83632b6b2b73a30ba34b7b760691b606482015260840161052a565b600081806020019051810190610e5d9190615c1f565b90506001600160a01b038116158015610e8057506015546001600160a01b031615155b15610ef8576000546015546040516381218ea960e01b81526001600160a01b0391821660048201529116906381218ea990602401602060405180830381865afa158015610ed1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef59190615c1f565b90505b6001600160a01b03811615801590610f1e57506015546001600160a01b03828116911614155b1561053d5761053d8161083b565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610f799261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fba9190615ba9565b610fd65760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061100590600401615bf3565b602060405180830381865afa158015611022573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110469190615c1f565b90506001600160a01b0381166110665761105f83612e82565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156110a957600080fd5b505af11580156110bd573d6000803e3d6000fd5b505033320391506110db9050576110d384612e82565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906111099032903390600401615c3c565b60006040518083038186803b15801561112157600080fd5b505afa158015611135573d6000803e3d6000fd5b505050506110d384612e82565b606060026000611150612f0a565b90508160ff1681516111629190615c85565b67ffffffffffffffff81111561117a5761117a6159aa565b6040519080825280602002602001820160405280156111a3578160200160208202803683370190505b50925060005b81518110156111ff578181815181106111c4576111c4615c98565b60200260200101518482815181106111de576111de615c98565b6001600160e01b0319909216602092830291909101909101526001016111a9565b50805163ef01df4f60e01b90849061121685615cae565b94506112259060ff8616615c85565b8151811061123557611235615c98565b6001600160e01b031990921660209283029190910190910152805163033e92d960e31b90849061126485615cae565b94506112739060ff8616615c85565b8151811061128357611283615c98565b6001600160e01b03199092166020928302919091019091015260ff8216156112ed5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161052a565b505090565b6002805461054e90615b42565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261134c9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611369573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138d9190615ba9565b6113a95760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906113d890600401615bf3565b602060405180830381865afa1580156113f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114199190615c1f565b90506001600160a01b0381166114345760006107048461307a565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561147757600080fd5b505af115801561148b573d6000803e3d6000fd5b505033320391506114a3905057600061077c8561307a565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906114d19032903390600401615c3c565b60006040518083038186803b1580156114e957600080fd5b505afa1580156114fd573d6000803e3d6000fd5b50505050600061077c8561307a565b600080611518816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061154790600401615bf3565b602060405180830381865afa158015611564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115889190615c1f565b90506001600160a01b0381166116e057306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156115d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115fc9190615c56565b50436009541461161957611612600a60396131bb565b92506116da565b83611622612dae565b101561163457611612600e60386131bb565b600d5484111561164a576116126002603a6131bb565b83600d546116589190615ccb565b600d55600354604080516303e1469160e61b815290516116d59261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190615c1f565b85612960565b600092505b5061188b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906117109032903390600401615c3c565b60006040518083038186803b15801561172857600080fd5b505afa15801561173c573d6000803e3d6000fd5b505050506117473090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611786573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117aa9190615c56565b5043600954146117c7576117c0600a60396131bb565b9350611888565b846117d0612dae565b10156117e2576117c0600e60386131bb565b600d548511156117f8576117c06002603a6131bb565b84600d546118069190615ccb565b600d55600354604080516303e1469160e61b815290516118839261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611859573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187d9190615c1f565b86612960565b600093505b50505b61189481613234565b50919050565b6000806118a6816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906118d590600401615bf3565b602060405180830381865afa1580156118f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119169190615c1f565b90506001600160a01b038116611a0a57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198a9190615c56565b5043600954146119a057611612600a60356131bb565b836119a9612dae565b10156119bb57611612600e60346131bb565b600e548411156119d157611612600260366131bb565b600084600e546119e19190615ccb565b600e8190556000549091506119ff906001600160a01b031686612960565b60009350505061188b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b90611a3a9032903390600401615c3c565b60006040518083038186803b158015611a5257600080fd5b505afa158015611a66573d6000803e3d6000fd5b50505050611a713090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad49190615c56565b504360095414611aea576117c0600a60356131bb565b84611af3612dae565b1015611b05576117c0600e60346131bb565b600e54851115611b1b576117c0600260366131bb565b600085600e54611b2b9190615ccb565b600e819055600054909150611b49906001600160a01b031687612960565b6000945050505061189481613234565b60006001611b66816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611b9590600401615bf3565b602060405180830381865afa158015611bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd69190615c1f565b90506001600160a01b038116611bfa57611bf2338787876132b8565b925050611ce2565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611c3d57600080fd5b505af1158015611c51573d6000803e3d6000fd5b50503332039150611c73905057611c6a338888886132b8565b93505050611ce2565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611ca19032903390600401615c3c565b60006040518083038186803b158015611cb957600080fd5b505afa158015611ccd573d6000803e3d6000fd5b50505050611cdd338888886132b8565b935050505b611ceb81613234565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611d409261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d819190615ba9565b611d9d5760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611dcc90600401615bf3565b602060405180830381865afa158015611de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0d9190615c1f565b90506001600160a01b038116611e265761105f836137a0565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611e6957600080fd5b505af1158015611e7d573d6000803e3d6000fd5b50503332039150611e939050576110d3846137a0565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611ec19032903390600401615c3c565b60006040518083038186803b158015611ed957600080fd5b505afa158015611eed573d6000803e3d6000fd5b505050506110d3846137a0565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611f479261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f889190615ba9565b611fa45760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611fd390600401615bf3565b602060405180830381865afa158015611ff0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120149190615c1f565b90506001600160a01b03811661202d5761105f8361381b565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561207057600080fd5b505af1158015612084573d6000803e3d6000fd5b5050333203915061209a9050576110d38461381b565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906120c89032903390600401615c3c565b60006040518083038186803b1580156120e057600080fd5b505afa1580156120f4573d6000803e3d6000fd5b505050506110d38461381b565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261214e9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa15801561216b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218f9190615ba9565b6121ab5760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906121da90600401615bf3565b602060405180830381865afa1580156121f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221b9190615c1f565b90506001600160a01b0381166124505760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac19061225e90600401615cf4565b602060405180830381865afa15801561227b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229f9190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906122d390600401615d16565b602060405180830381865afa1580156122f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123149190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123789190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926123af92899261010090041690600401615c3c565b602060405180830381865afa1580156123cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f09190615c56565b111561243557336001600160a01b0382161461241e5760405162461bcd60e51b815260040161052a90615d44565b600061242b898989613898565b5095506124479050565b6000612442898989613898565b509550505b5050505061105f565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561249357600080fd5b505af11580156124a7573d6000803e3d6000fd5b505033320391506126da90505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac1906124e790600401615cf4565b602060405180830381865afa158015612504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125289190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061255c90600401615d16565b602060405180830381865afa158015612579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259d9190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126019190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261263892899261010090041690600401615c3c565b602060405180830381865afa158015612655573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126799190615c56565b11156126be57336001600160a01b038216146126a75760405162461bcd60e51b815260040161052a90615d44565b60006126b48a8a8a613898565b5096506126d09050565b60006126cb8a8a8a613898565b509650505b505050505061105f565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906127089032903390600401615c3c565b60006040518083038186803b15801561272057600080fd5b505afa158015612734573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac19061276b90600401615cf4565b602060405180830381865afa158015612788573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ac9190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906127e090600401615d16565b602060405180830381865afa1580156127fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128219190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128859190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926128bc92899261010090041690600401615c3c565b602060405180830381865afa1580156128d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128fd9190615c56565b111561294257336001600160a01b0382161461292b5760405162461bcd60e51b815260040161052a90615d44565b60006129388a8a8a613898565b5096506129549050565b600061294f8a8a8a613898565b509650505b50505050509392505050565b601554604051632d182be560e21b8152600481018390526001600160a01b0384811660248301523060448301529091169063b460af94906064016020604051808303816000875af11580156129b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129dd9190615c56565b505050565b60008060006129f0816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612a30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a549190615c56565b50612a60333386613992565b92509250612a6d81613234565b50915091565b6013546040516323b872dd60e01b81526000916001600160a01b0316906323b872dd90612aa890869030908790600401615da1565b6020604051808303816000875af1158015612ac7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aeb9190615ba9565b612b205760405162461bcd60e51b815260040161052a906020808252600490820152631cd95b9960e21b604082015260600190565b61189482612ca6565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba69190615c1f565b6001600160a01b0316336001600160a01b0316148015612c235750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190615ba9565b80612ca057506000546001600160a01b031633148015612ca05750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca09190615ba9565b91505090565b601554604051636e553f6560e01b8152600481018390523060248201526001600160a01b0390911690636e553f65906044016020604051808303816000875af1158015612cf7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053d9190615c56565b6000806000612d29816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8d9190615c56565b50612d99338686613992565b92509250612da681613234565b509250929050565b6015546040516370a0823160e01b81523060048201526000916001600160a01b031690634cdad5069082906370a0823190602401602060405180830381865afa158015612dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e239190615c56565b6040518263ffffffff1660e01b8152600401612e4191815260200190565b602060405180830381865afa158015612e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc99190615c56565b600080612e8e816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef29190615c56565b50612eff33600085613d9f565b915061189481613234565b606060036000612f186143e6565b90508160ff168151612f2a9190615c85565b67ffffffffffffffff811115612f4257612f426159aa565b604051908082528060200260200182016040528015612f6b578160200160208202803683370190505b50925060005b8151811015612fc757818181518110612f8c57612f8c615c98565b6020026020010151848281518110612fa657612fa6615c98565b6001600160e01b031990921660209283029190910190910152600101612f71565b50805163cb2ef6f760e01b908490612fde85615cae565b9450612fed9060ff8616615c85565b81518110612ffd57612ffd615c98565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b90849061302c85615cae565b945061303b9060ff8616615c85565b8151811061304b5761304b615c98565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b90849061126485615cae565b6000806000613088816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156130c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ec9190615c56565b50612a6033856147ae565b600054600160a01b900460ff1661313d5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015260640161052a565b806131ab57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561319257600080fd5b505af11580156131a6573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360118111156131f0576131f0615cde565b83606181111561320257613202615cde565b60408051928352602083019190915260009082015260600160405180910390a182601181111561083257610832615cde565b6000805460ff60a01b1916600160a01b179055806132b557600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561329c57600080fd5b505af11580156132b0573d6000803e3d6000fd5b505050505b50565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af115801561332c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133509190615c56565b9050801561336d576133656003601d83614bb9565b9150506110d3565b846001600160a01b0316846001600160a01b031603613392576133656006601e6131bb565b6133f7604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03851660009081526010602052604090205461341a9085614c5b565b602083018190528282600381111561343457613434615cde565b600381111561344557613445615cde565b905250600090508151600381111561345f5761345f615cde565b1461348f576134866009601c8360000151600381111561348157613481615cde565b614bb9565b925050506110d3565b6134ae846040518060200160405280666379da05b60000815250614c86565b6080820152604080516020810190915267016345785d8a000081526134d4908590614c86565b610140820181905260808201516134eb9086615ccb565b6134f59190615ccb565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355c9190615c56565b60c0820190815260408051602081019091529051815260808201516135819190614ca9565b60a0820152604080516020810190915260c082015181526101408201516135a89190614ca9565b61016082015260a0810151600c546135c09190615c85565b60e08201526101408101516080820151600f546135dd9190615ccb565b6135e79190615ccb565b610120820152610160810151600e546136009190615c85565b6101008201526001600160a01b038616600090815260106020526040902054606082015161362e9190614cc1565b604083018190528282600381111561364857613648615cde565b600381111561365957613659615cde565b905250600090508151600381111561367357613673615cde565b14613695576134866009601b8360000151600381111561348157613481615cde565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615e3f833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615e3f833981519152836080015160405161374291815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b6000806137ac816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156137ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138109190615c56565b50612eff3384614ce7565b600080613827816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613867573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388b9190615c56565b50612eff33846000613d9f565b60008060006138a6816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156138e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061390a9190615c56565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561394b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396f9190615c56565b5061397c33878787615082565b9250925061398981613234565b50935093915050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af1158015613a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a249190615c56565b90508015613a4557613a396003604383614bb9565b60009250925050613d97565b4360095414613a5a57613a39600a60446131bb565b613aa36040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015613b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b319190615c56565b608082015260018501613b4d5760808101516040820152613b55565b604081018590525b613b63878260400151612a73565b60e082018190526080820151613b7891614c5b565b60a0830181905260208301826003811115613b9557613b95615cde565b6003811115613ba657613ba6615cde565b9052506000905081602001516003811115613bc357613bc3615cde565b14613c365760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c4544000000000000606482015260840161052a565b613c46600b548260e00151614c5b565b60c0830181905260208301826003811115613c6357613c63615cde565b6003811115613c7457613c74615cde565b9052506000905081602001516003811115613c9157613c91615cde565b14613cf85760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b606482015260840161052a565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613dac575081155b613df85760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e740000000000000000604482015260640161052a565b613e396040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e9b9190615c56565b60408201528315613f5e5761138884600f54613eb79190615ccb565b1015613ec357600f5493505b6060810184905260408051602081018252908201518152613ee4908561553f565b6080830181905260208301826003811115613f0157613f01615cde565b6003811115613f1257613f12615cde565b9052506000905081602001516003811115613f2f57613f2f615cde565b14613f5957613f516009602c8360200151600381111561348157613481615cde565b91505061105f565b6140a5565b6000198303613feb57600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe89190615c56565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561402b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061404f9190615c56565b90506103e861405e8583615ccb565b1015614068578093505b614076848360400151615591565b60608301819052600f546103e89161408d91615ccb565b101561409c57600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d91916140e39130918b9190600401615da1565b6020604051808303816000875af1158015614102573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141269190615c56565b905080156141445761413b6003602b83614bb9565b9250505061105f565b43600954146141595761413b600a602f6131bb565b614169600f548360600151614c5b565b60a084018190526020840182600381111561418657614186615cde565b600381111561419757614197615cde565b90525060009050826020015160038111156141b4576141b4615cde565b146141d65761413b600960318460200151600381111561348157613481615cde565b6001600160a01b03861660009081526010602052604090205460608301516141fe9190614c5b565b60c084018190526020840182600381111561421b5761421b615cde565b600381111561422c5761422c615cde565b905250600090508260200151600381111561424957614249615cde565b1461426b5761413b600960308460200151600381111561348157613481615cde565b8160800151614278612dae565b101561428a5761413b600e60326131bb565b60a0820151600f5560c08201516001600160a01b03871660009081526010602052604090205560808201516142c0908790612960565b306001600160a01b0316866001600160a01b0316600080516020615e3f83398151915284606001516040516142f791815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b1580156143bb57600080fd5b505af11580156143cf573d6000803e3d6000fd5b50600092506143dc915050565b9695505050505050565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b8161442284615cae565b93508360ff168151811061443857614438615c98565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8161446384615cae565b93508360ff168151811061447957614479615c98565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b816144a484615cae565b93508360ff16815181106144ba576144ba615c98565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b816144e584615cae565b93508360ff16815181106144fb576144fb615c98565b6001600160e01b03199092166020928302919091019091015263073a938160e11b8161452684615cae565b93508360ff168151811061453c5761453c615c98565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b8161456784615cae565b93508360ff168151811061457d5761457d615c98565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b816145a884615cae565b93508360ff16815181106145be576145be615c98565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b816145e984615cae565b93508360ff16815181106145ff576145ff615c98565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b8161462a84615cae565b93508360ff168151811061464057614640615c98565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b8161466b84615cae565b93508360ff168151811061468157614681615c98565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b816146ac84615cae565b93508360ff16815181106146c2576146c2615c98565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b816146ed84615cae565b93508360ff168151811061470357614703615c98565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b8161472e84615cae565b93508360ff168151811061474457614744615c98565b6001600160e01b03199092166020928302919091019091015260ff8216156108355760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161052a565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e1906147ec90309089908990600401615da1565b6020604051808303816000875af115801561480b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482f9190615c56565b90508015614850576148446003602183614bb9565b60009250925050614bb2565b436009541461486557614844600a60246131bb565b6148a66040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149089190615c56565b60408201526149178686612a73565b60c082018190526040805160208101825290830151815261493891906155cc565b606083018190526020830182600381111561495557614955615cde565b600381111561496657614966615cde565b905250600090508160200151600381111561498357614983615cde565b146149d05760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015260640161052a565b6000816060015111614a245760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a4543544544000000000000604482015260640161052a565b8060600151600f54614a369190615c85565b608082015260608101516001600160a01b038716600090815260106020526040902054614a639190615c85565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b0316600080516020615e3f8339815191528360600151604051614b1291815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b158015614b8557600080fd5b505af1158015614b99573d6000803e3d6000fd5b5060009250614ba6915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846011811115614bee57614bee615cde565b846061811115614c0057614c00615cde565b604080519283526020830191909152810184905260600160405180910390a16003846011811115614c3357614c33615cde565b14614c4f57836011811115614c4a57614c4a615cde565b6110d3565b6110d3826103e8615c85565b600080838311614c7a576000614c718486615ccb565b91509150614bb2565b50600390506000614bb2565b6000670de0b6b3a7640000614c9f8484600001516155dc565b6108329190615ddb565b600080614cb6848461561e565b90506110d38161564f565b600080838301848110614cd957600092509050614bb2565b600260009250925050614bb2565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c90614d2490309088908890600401615da1565b6020604051808303816000875af1158015614d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d679190615c56565b90508015614d8457614d7c6003601083614bb9565b915050610835565b4360095414614d9957614d7c600a600c6131bb565b6000614da3612dae565b905083811015614dc257614db9600e600b6131bb565b92505050610835565b614dee604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e5b9190615c56565b60208201819052614e6c9086614cc1565b6040830181905282826003811115614e8657614e86615cde565b6003811115614e9757614e97615cde565b9052506000905081516003811115614eb157614eb1615cde565b14614edd57614ed36009600e8360000151600381111561348157613481615cde565b9350505050610835565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614f36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f5a9190615c56565b92508215614f6f57614ed36003601085614bb9565b614f7b600b5486614cc1565b6060830181905282826003811115614f9557614f95615cde565b6003811115614fa657614fa6615cde565b9052506000905081516003811115614fc057614fc0615cde565b14614fe257614ed36009600d8360000151600381111561348157613481615cde565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b5561501e8686612960565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af11580156150f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061511c9190615c56565b9050801561513d576151316003601483614bb9565b60009250925050615536565b436009541461515257615131600a60186131bb565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015615191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151b59190615c56565b146151c657615131600a60136131bb565b866001600160a01b0316866001600160a01b0316036151eb57615131600660196131bb565b846000036151ff57615131600760176131bb565b600019850361521457615131600760166131bb565b600080615222898989613992565b909250905081156152575761524982601181111561524257615242615cde565b601a6131bb565b600094509450505050615536565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b906152949030908c908890600401615da1565b6040805180830381865afa1580156152b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152d49190615def565b909250905081156153435760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b606482015260840161052a565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa15801561538c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153b09190615c56565b10156153fe5760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d5543480000000000000000604482015260640161052a565b6000306001600160a01b038a16036154235761541c308d8d856132b8565b9050615499565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190615453908f908f908790600401615da1565b6020604051808303816000875af1158015615472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906154969190615c56565b90505b80156154d05760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b604482015260640161052a565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b60008060008061554f8686615667565b9092509050600082600381111561556857615568615cde565b146155795750915060009050614bb2565b60006155848261564f565b9350935050509250929050565b6000816155a684670de0b6b3a7640000615e13565b6155b09190615ddb565b90506155bc8284615e2a565b1561083557610832600182615c85565b60008060008061554f86866156e3565b600061083283836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615756565b60408051602081019091526000815260405180602001604052806156468560000151856155dc565b90529392505050565b805160009061083590670de0b6b3a764000090615ddb565b600061567f6040518060200160405280600081525090565b6000806156908660000151866157a9565b909250905060008260038111156156a9576156a9615cde565b146156c857506040805160208101909152600081529092509050614bb2565b60408051602081019091529081526000969095509350505050565b60006156fb6040518060200160405280600081525090565b600080615710670de0b6b3a7640000876157a9565b9092509050600082600381111561572957615729615cde565b1461574857506040805160208101909152600081529092509050614bb2565b6155848186600001516157eb565b6000831580615763575082155b156157705750600061105f565b600061577c8486615e13565b9050836157898683615ddb565b1483906107045760405162461bcd60e51b815260040161052a9190615925565b600080836000036157bf57506000905080614bb2565b838302836157cd8683615ddb565b146157e057600260009250925050614bb2565b600092509050614bb2565b60006158036040518060200160405280600081525090565b60008061581886670de0b6b3a76400006157a9565b9092509050600082600381111561583157615831615cde565b1461585057506040805160208101909152600081529092509050614bb2565b60008061585d83886158b6565b9092509050600082600381111561587657615876615cde565b146158995781604051806020016040528060008152509550955050505050614bb2565b604080516020810190915290815260009890975095505050505050565b600080826000036158cd5750600190506000614bb2565b60006158d98486615ddb565b915091509250929050565b6001600160a01b03811681146132b557600080fd5b6000806040838503121561590c57600080fd5b8235615917816158e4565b946020939093013593505050565b60006020808352835180602085015260005b8181101561595357858101830151858201604001528201615937565b506000604082860101526040601f19601f8301168501019250505092915050565b60006020828403121561598657600080fd5b5035919050565b60006020828403121561599f57600080fd5b813561105f816158e4565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156159d257600080fd5b813567ffffffffffffffff808211156159ea57600080fd5b818401915084601f8301126159fe57600080fd5b813581811115615a1057615a106159aa565b604051601f8201601f19908116603f01168101908382118183101715615a3857615a386159aa565b81604052828152876020848701011115615a5157600080fd5b826020860160208301376000928101602001929092525095945050505050565b6020808252825182820181905260009190848201906040850190845b81811015615ab35783516001600160e01b03191683529284019291840191600101615a8d565b50909695505050505050565b600080600060608486031215615ad457600080fd5b8335615adf816158e4565b92506020840135615aef816158e4565b929592945050506040919091013590565b600080600060608486031215615b1557600080fd5b8335615b20816158e4565b9250602084013591506040840135615b37816158e4565b809150509250925092565b600181811c90821680615b5657607f821691505b60208210810361189457634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b600060208284031215615bbb57600080fd5b8151801515811461105f57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b600060208284031215615c3157600080fd5b815161105f816158e4565b6001600160a01b0392831681529116602082015260400190565b600060208284031215615c6857600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561083557610835615c6f565b634e487b7160e01b600052603260045260246000fd5b600060ff821680615cc157615cc1615c6f565b6000190192915050565b8181038181111561083557610835615c6f565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b600082615dea57615dea615dc5565b500490565b60008060408385031215615e0257600080fd5b505080516020909101519092909150565b808202811582820484141761083557610835615c6f565b600082615e3957615e39615dc5565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202b9014d02cf451c4a158c1796e57da55ad5383226679ce0300ea4ebdf7c477ca64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061023d5760003560e01c8063852a12e31161013b578063b2a02ff1116100b8578063cb2ef6f71161007c578063cb2ef6f71461047b578063db006a75146104ab578063ef01df4f146104be578063f3fdb15a146104d1578063f5e3c462146104e457600080fd5b8063b2a02ff11461042a578063be99f1191461043d578063c3bf11cd1461044c578063c5ebeaec14610455578063c91a424f1461046857600080fd5b80639826394b116100ff5780639826394b146103df578063a0712d68146103e8578063a7b820df146103fb578063aa5af0fd1461040e578063b0d58e491461041757600080fd5b8063852a12e31461039d57806389f8132e146103b05780638d02d9a1146103c55780638f840ddd146103ce57806395d89b41146103d757600080fd5b8063313ce567116101c95780635fe3b5671161018d5780635fe3b5671461035257806361feacff1461036a5780636752e702146103735780636c540baf146103815780636f307dc31461038a57600080fd5b8063313ce567146102f65780633b1d21a2146103035780633c4f743c1461030b57806347bd37181461033657806356e677281461033f57600080fd5b8063173b990411610210578063173b9904146102a957806318160ddd146102b257806319f496c8146102bb5780632608f818146102ce5780632c436e5b146102e157600080fd5b8063067db1b31461024257806306fdde03146102575780630e75270214610275578063135f133414610296575b600080fd5b6102556102503660046158f9565b6104f7565b005b61025f610541565b60405161026c9190615925565b60405180910390f35b610288610283366004615974565b6105cf565b60405190815260200161026c565b6102886102a43660046158f9565b6107ef565b61028860085481565b610288600f5481565b6102556102c936600461598d565b61083b565b6102886102dc3660046158f9565b610b8f565b60025b60405160ff909116815260200161026c565b6003546102e49060ff1681565b610288610dbf565b60145461031e906001600160a01b031681565b6040516001600160a01b03909116815260200161026c565b610288600b5481565b61025561034d3660046159c0565b610dce565b60035461031e9061010090046001600160a01b031681565b610288600d5481565b610288666379da05b6000081565b61028860095481565b60135461031e906001600160a01b031681565b6102886103ab366004615974565b610f2c565b6103b8611142565b60405161026c9190615a71565b61028860065481565b610288600c5481565b61025f6112f2565b610288600e5481565b6102886103f6366004615974565b6112ff565b610288610409366004615974565b61150c565b610288600a5481565b610288610425366004615974565b61189a565b610288610438366004615abf565b611b59565b61028867016345785d8a000081565b61028860075481565b610288610463366004615974565b611cf3565b60005461031e906001600160a01b031681565b604080518082019091526014815273434572633230506c7567696e44656c656761746560601b602082015261025f565b6102886104b9366004615974565b611efa565b60155461031e906001600160a01b031681565b60045461031e906001600160a01b031681565b6102886104f2366004615b00565b612101565b3330146105335760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b61053d8282612960565b5050565b6001805461054e90615b42565b80601f016020809104026020016040519081016040528092919081815260200182805461057a90615b42565b80156105c75780601f1061059c576101008083540402835291602001916105c7565b820191906000526020600020905b8154815290600101906020018083116105aa57829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261061c9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065d9190615ba9565b6106795760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906106a890600401615bf3565b602060405180830381865afa1580156106c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e99190615c1f565b90506001600160a01b03811661070d576000610704846129e2565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561075057600080fd5b505af1158015610764573d6000803e3d6000fd5b50503332039150610786905057600061077c856129e2565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107b49032903390600401615c3c565b60006040518083038186803b1580156107cc57600080fd5b505afa1580156107e0573d6000803e3d6000fd5b50505050600061077c856129e2565b60003330146108285760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b604482015260640161052a565b6108328383612a73565b90505b92915050565b3330148061084c575061084c612b29565b6108ac5760405162461bcd60e51b815260206004820152602b60248201527f6f6e6c792073656c6620616e642061646d696e732063616e2063616c6c205f7560448201526a383230ba32a8363ab3b4b760a91b606482015260840161052a565b6015546000906001600160a01b03166108c557816108d2565b6015546001600160a01b03165b6015549091506001600160a01b03161580159061095957506015546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610932573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109569190615c56565b15155b15610a43576015546040516370a0823160e01b81523060048201526001600160a01b039091169063ba0876529082906370a0823190602401602060405180830381865afa1580156109ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d29190615c56565b6040516001600160e01b031960e084901b1681526004810191909152306024820181905260448201526064016020604051808303816000875af1158015610a1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a419190615c56565b505b601580546001600160a01b0319166001600160a01b0384811691821790925560135460405163095ea7b360e01b8152600481019290925260001960248301529091169063095ea7b3906044016020604051808303816000875af1158015610aae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad29190615ba9565b506013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b409190615c56565b90508015610b5157610b5181612ca6565b7fb32957d2794aaec3ea2c8852833af2192fe9fb518777de1f883e9e821781da758284604051610b82929190615c3c565b60405180910390a1505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610bdc9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1d9190615ba9565b610c395760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610c6890600401615bf3565b602060405180830381865afa158015610c85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca99190615c1f565b90506001600160a01b038116610ccf576000610cc58585612d1b565b5092505050610835565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610d1257600080fd5b505af1158015610d26573d6000803e3d6000fd5b50503332039150610d4a9050576000610d3f8686612d1b565b509350505050610835565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610d789032903390600401615c3c565b60006040518083038186803b158015610d9057600080fd5b505afa158015610da4573d6000803e3d6000fd5b505050506000610db48686612d1b565b509695505050505050565b6000610dc9612dae565b905090565b33301480610ddf5750610ddf612b29565b610e475760405162461bcd60e51b815260206004820152603360248201527f6f6e6c792073656c6620616e642061646d696e732063616e2063616c6c205f6260448201527232b1b7b6b2a4b6b83632b6b2b73a30ba34b7b760691b606482015260840161052a565b600081806020019051810190610e5d9190615c1f565b90506001600160a01b038116158015610e8057506015546001600160a01b031615155b15610ef8576000546015546040516381218ea960e01b81526001600160a01b0391821660048201529116906381218ea990602401602060405180830381865afa158015610ed1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef59190615c1f565b90505b6001600160a01b03811615801590610f1e57506015546001600160a01b03828116911614155b1561053d5761053d8161083b565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610f799261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fba9190615ba9565b610fd65760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061100590600401615bf3565b602060405180830381865afa158015611022573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110469190615c1f565b90506001600160a01b0381166110665761105f83612e82565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156110a957600080fd5b505af11580156110bd573d6000803e3d6000fd5b505033320391506110db9050576110d384612e82565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906111099032903390600401615c3c565b60006040518083038186803b15801561112157600080fd5b505afa158015611135573d6000803e3d6000fd5b505050506110d384612e82565b606060026000611150612f0a565b90508160ff1681516111629190615c85565b67ffffffffffffffff81111561117a5761117a6159aa565b6040519080825280602002602001820160405280156111a3578160200160208202803683370190505b50925060005b81518110156111ff578181815181106111c4576111c4615c98565b60200260200101518482815181106111de576111de615c98565b6001600160e01b0319909216602092830291909101909101526001016111a9565b50805163ef01df4f60e01b90849061121685615cae565b94506112259060ff8616615c85565b8151811061123557611235615c98565b6001600160e01b031990921660209283029190910190910152805163033e92d960e31b90849061126485615cae565b94506112739060ff8616615c85565b8151811061128357611283615c98565b6001600160e01b03199092166020928302919091019091015260ff8216156112ed5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161052a565b505090565b6002805461054e90615b42565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261134c9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611369573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138d9190615ba9565b6113a95760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906113d890600401615bf3565b602060405180830381865afa1580156113f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114199190615c1f565b90506001600160a01b0381166114345760006107048461307a565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561147757600080fd5b505af115801561148b573d6000803e3d6000fd5b505033320391506114a3905057600061077c8561307a565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906114d19032903390600401615c3c565b60006040518083038186803b1580156114e957600080fd5b505afa1580156114fd573d6000803e3d6000fd5b50505050600061077c8561307a565b600080611518816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061154790600401615bf3565b602060405180830381865afa158015611564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115889190615c1f565b90506001600160a01b0381166116e057306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156115d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115fc9190615c56565b50436009541461161957611612600a60396131bb565b92506116da565b83611622612dae565b101561163457611612600e60386131bb565b600d5484111561164a576116126002603a6131bb565b83600d546116589190615ccb565b600d55600354604080516303e1469160e61b815290516116d59261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190615c1f565b85612960565b600092505b5061188b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906117109032903390600401615c3c565b60006040518083038186803b15801561172857600080fd5b505afa15801561173c573d6000803e3d6000fd5b505050506117473090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611786573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117aa9190615c56565b5043600954146117c7576117c0600a60396131bb565b9350611888565b846117d0612dae565b10156117e2576117c0600e60386131bb565b600d548511156117f8576117c06002603a6131bb565b84600d546118069190615ccb565b600d55600354604080516303e1469160e61b815290516118839261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa158015611859573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187d9190615c1f565b86612960565b600093505b50505b61189481613234565b50919050565b6000806118a6816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906118d590600401615bf3565b602060405180830381865afa1580156118f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119169190615c1f565b90506001600160a01b038116611a0a57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198a9190615c56565b5043600954146119a057611612600a60356131bb565b836119a9612dae565b10156119bb57611612600e60346131bb565b600e548411156119d157611612600260366131bb565b600084600e546119e19190615ccb565b600e8190556000549091506119ff906001600160a01b031686612960565b60009350505061188b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b90611a3a9032903390600401615c3c565b60006040518083038186803b158015611a5257600080fd5b505afa158015611a66573d6000803e3d6000fd5b50505050611a713090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad49190615c56565b504360095414611aea576117c0600a60356131bb565b84611af3612dae565b1015611b05576117c0600e60346131bb565b600e54851115611b1b576117c0600260366131bb565b600085600e54611b2b9190615ccb565b600e819055600054909150611b49906001600160a01b031687612960565b6000945050505061189481613234565b60006001611b66816130f7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611b9590600401615bf3565b602060405180830381865afa158015611bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd69190615c1f565b90506001600160a01b038116611bfa57611bf2338787876132b8565b925050611ce2565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611c3d57600080fd5b505af1158015611c51573d6000803e3d6000fd5b50503332039150611c73905057611c6a338888886132b8565b93505050611ce2565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611ca19032903390600401615c3c565b60006040518083038186803b158015611cb957600080fd5b505afa158015611ccd573d6000803e3d6000fd5b50505050611cdd338888886132b8565b935050505b611ceb81613234565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611d409261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d819190615ba9565b611d9d5760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611dcc90600401615bf3565b602060405180830381865afa158015611de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0d9190615c1f565b90506001600160a01b038116611e265761105f836137a0565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611e6957600080fd5b505af1158015611e7d573d6000803e3d6000fd5b50503332039150611e939050576110d3846137a0565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611ec19032903390600401615c3c565b60006040518083038186803b158015611ed957600080fd5b505afa158015611eed573d6000803e3d6000fd5b505050506110d3846137a0565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611f479261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa158015611f64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f889190615ba9565b611fa45760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611fd390600401615bf3565b602060405180830381865afa158015611ff0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120149190615c1f565b90506001600160a01b03811661202d5761105f8361381b565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561207057600080fd5b505af1158015612084573d6000803e3d6000fd5b5050333203915061209a9050576110d38461381b565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906120c89032903390600401615c3c565b60006040518083038186803b1580156120e057600080fd5b505afa1580156120f4573d6000803e3d6000fd5b505050506110d38461381b565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261214e9261010090910490911690339030906001600160e01b031988351690600401615b76565b602060405180830381865afa15801561216b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218f9190615ba9565b6121ab5760405162461bcd60e51b815260040161052a90615bcb565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906121da90600401615bf3565b602060405180830381865afa1580156121f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221b9190615c1f565b90506001600160a01b0381166124505760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac19061225e90600401615cf4565b602060405180830381865afa15801561227b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229f9190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906122d390600401615d16565b602060405180830381865afa1580156122f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123149190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123789190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926123af92899261010090041690600401615c3c565b602060405180830381865afa1580156123cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f09190615c56565b111561243557336001600160a01b0382161461241e5760405162461bcd60e51b815260040161052a90615d44565b600061242b898989613898565b5095506124479050565b6000612442898989613898565b509550505b5050505061105f565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561249357600080fd5b505af11580156124a7573d6000803e3d6000fd5b505033320391506126da90505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac1906124e790600401615cf4565b602060405180830381865afa158015612504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125289190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061255c90600401615d16565b602060405180830381865afa158015612579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259d9190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126019190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261263892899261010090041690600401615c3c565b602060405180830381865afa158015612655573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126799190615c56565b11156126be57336001600160a01b038216146126a75760405162461bcd60e51b815260040161052a90615d44565b60006126b48a8a8a613898565b5096506126d09050565b60006126cb8a8a8a613898565b509650505b505050505061105f565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906127089032903390600401615c3c565b60006040518083038186803b15801561272057600080fd5b505afa158015612734573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac19061276b90600401615cf4565b602060405180830381865afa158015612788573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ac9190615c1f565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906127e090600401615d16565b602060405180830381865afa1580156127fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128219190615c1f565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128859190615c56565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926128bc92899261010090041690600401615c3c565b602060405180830381865afa1580156128d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128fd9190615c56565b111561294257336001600160a01b0382161461292b5760405162461bcd60e51b815260040161052a90615d44565b60006129388a8a8a613898565b5096506129549050565b600061294f8a8a8a613898565b509650505b50505050509392505050565b601554604051632d182be560e21b8152600481018390526001600160a01b0384811660248301523060448301529091169063b460af94906064016020604051808303816000875af11580156129b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129dd9190615c56565b505050565b60008060006129f0816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612a30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a549190615c56565b50612a60333386613992565b92509250612a6d81613234565b50915091565b6013546040516323b872dd60e01b81526000916001600160a01b0316906323b872dd90612aa890869030908790600401615da1565b6020604051808303816000875af1158015612ac7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aeb9190615ba9565b612b205760405162461bcd60e51b815260040161052a906020808252600490820152631cd95b9960e21b604082015260600190565b61189482612ca6565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba69190615c1f565b6001600160a01b0316336001600160a01b0316148015612c235750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190615ba9565b80612ca057506000546001600160a01b031633148015612ca05750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca09190615ba9565b91505090565b601554604051636e553f6560e01b8152600481018390523060248201526001600160a01b0390911690636e553f65906044016020604051808303816000875af1158015612cf7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053d9190615c56565b6000806000612d29816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8d9190615c56565b50612d99338686613992565b92509250612da681613234565b509250929050565b6015546040516370a0823160e01b81523060048201526000916001600160a01b031690634cdad5069082906370a0823190602401602060405180830381865afa158015612dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e239190615c56565b6040518263ffffffff1660e01b8152600401612e4191815260200190565b602060405180830381865afa158015612e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc99190615c56565b600080612e8e816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef29190615c56565b50612eff33600085613d9f565b915061189481613234565b606060036000612f186143e6565b90508160ff168151612f2a9190615c85565b67ffffffffffffffff811115612f4257612f426159aa565b604051908082528060200260200182016040528015612f6b578160200160208202803683370190505b50925060005b8151811015612fc757818181518110612f8c57612f8c615c98565b6020026020010151848281518110612fa657612fa6615c98565b6001600160e01b031990921660209283029190910190910152600101612f71565b50805163cb2ef6f760e01b908490612fde85615cae565b9450612fed9060ff8616615c85565b81518110612ffd57612ffd615c98565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b90849061302c85615cae565b945061303b9060ff8616615c85565b8151811061304b5761304b615c98565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b90849061126485615cae565b6000806000613088816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156130c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ec9190615c56565b50612a6033856147ae565b600054600160a01b900460ff1661313d5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015260640161052a565b806131ab57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561319257600080fd5b505af11580156131a6573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360118111156131f0576131f0615cde565b83606181111561320257613202615cde565b60408051928352602083019190915260009082015260600160405180910390a182601181111561083257610832615cde565b6000805460ff60a01b1916600160a01b179055806132b557600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561329c57600080fd5b505af11580156132b0573d6000803e3d6000fd5b505050505b50565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af115801561332c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133509190615c56565b9050801561336d576133656003601d83614bb9565b9150506110d3565b846001600160a01b0316846001600160a01b031603613392576133656006601e6131bb565b6133f7604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03851660009081526010602052604090205461341a9085614c5b565b602083018190528282600381111561343457613434615cde565b600381111561344557613445615cde565b905250600090508151600381111561345f5761345f615cde565b1461348f576134866009601c8360000151600381111561348157613481615cde565b614bb9565b925050506110d3565b6134ae846040518060200160405280666379da05b60000815250614c86565b6080820152604080516020810190915267016345785d8a000081526134d4908590614c86565b610140820181905260808201516134eb9086615ccb565b6134f59190615ccb565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355c9190615c56565b60c0820190815260408051602081019091529051815260808201516135819190614ca9565b60a0820152604080516020810190915260c082015181526101408201516135a89190614ca9565b61016082015260a0810151600c546135c09190615c85565b60e08201526101408101516080820151600f546135dd9190615ccb565b6135e79190615ccb565b610120820152610160810151600e546136009190615c85565b6101008201526001600160a01b038616600090815260106020526040902054606082015161362e9190614cc1565b604083018190528282600381111561364857613648615cde565b600381111561365957613659615cde565b905250600090508151600381111561367357613673615cde565b14613695576134866009601b8360000151600381111561348157613481615cde565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615e3f833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615e3f833981519152836080015160405161374291815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b6000806137ac816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156137ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138109190615c56565b50612eff3384614ce7565b600080613827816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613867573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388b9190615c56565b50612eff33846000613d9f565b60008060006138a6816130f7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156138e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061390a9190615c56565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561394b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396f9190615c56565b5061397c33878787615082565b9250925061398981613234565b50935093915050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af1158015613a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a249190615c56565b90508015613a4557613a396003604383614bb9565b60009250925050613d97565b4360095414613a5a57613a39600a60446131bb565b613aa36040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015613b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b319190615c56565b608082015260018501613b4d5760808101516040820152613b55565b604081018590525b613b63878260400151612a73565b60e082018190526080820151613b7891614c5b565b60a0830181905260208301826003811115613b9557613b95615cde565b6003811115613ba657613ba6615cde565b9052506000905081602001516003811115613bc357613bc3615cde565b14613c365760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c4544000000000000606482015260840161052a565b613c46600b548260e00151614c5b565b60c0830181905260208301826003811115613c6357613c63615cde565b6003811115613c7457613c74615cde565b9052506000905081602001516003811115613c9157613c91615cde565b14613cf85760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b606482015260840161052a565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613dac575081155b613df85760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e740000000000000000604482015260640161052a565b613e396040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e9b9190615c56565b60408201528315613f5e5761138884600f54613eb79190615ccb565b1015613ec357600f5493505b6060810184905260408051602081018252908201518152613ee4908561553f565b6080830181905260208301826003811115613f0157613f01615cde565b6003811115613f1257613f12615cde565b9052506000905081602001516003811115613f2f57613f2f615cde565b14613f5957613f516009602c8360200151600381111561348157613481615cde565b91505061105f565b6140a5565b6000198303613feb57600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe89190615c56565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561402b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061404f9190615c56565b90506103e861405e8583615ccb565b1015614068578093505b614076848360400151615591565b60608301819052600f546103e89161408d91615ccb565b101561409c57600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d91916140e39130918b9190600401615da1565b6020604051808303816000875af1158015614102573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141269190615c56565b905080156141445761413b6003602b83614bb9565b9250505061105f565b43600954146141595761413b600a602f6131bb565b614169600f548360600151614c5b565b60a084018190526020840182600381111561418657614186615cde565b600381111561419757614197615cde565b90525060009050826020015160038111156141b4576141b4615cde565b146141d65761413b600960318460200151600381111561348157613481615cde565b6001600160a01b03861660009081526010602052604090205460608301516141fe9190614c5b565b60c084018190526020840182600381111561421b5761421b615cde565b600381111561422c5761422c615cde565b905250600090508260200151600381111561424957614249615cde565b1461426b5761413b600960308460200151600381111561348157613481615cde565b8160800151614278612dae565b101561428a5761413b600e60326131bb565b60a0820151600f5560c08201516001600160a01b03871660009081526010602052604090205560808201516142c0908790612960565b306001600160a01b0316866001600160a01b0316600080516020615e3f83398151915284606001516040516142f791815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b1580156143bb57600080fd5b505af11580156143cf573d6000803e3d6000fd5b50600092506143dc915050565b9695505050505050565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b8161442284615cae565b93508360ff168151811061443857614438615c98565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8161446384615cae565b93508360ff168151811061447957614479615c98565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b816144a484615cae565b93508360ff16815181106144ba576144ba615c98565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b816144e584615cae565b93508360ff16815181106144fb576144fb615c98565b6001600160e01b03199092166020928302919091019091015263073a938160e11b8161452684615cae565b93508360ff168151811061453c5761453c615c98565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b8161456784615cae565b93508360ff168151811061457d5761457d615c98565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b816145a884615cae565b93508360ff16815181106145be576145be615c98565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b816145e984615cae565b93508360ff16815181106145ff576145ff615c98565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b8161462a84615cae565b93508360ff168151811061464057614640615c98565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b8161466b84615cae565b93508360ff168151811061468157614681615c98565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b816146ac84615cae565b93508360ff16815181106146c2576146c2615c98565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b816146ed84615cae565b93508360ff168151811061470357614703615c98565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b8161472e84615cae565b93508360ff168151811061474457614744615c98565b6001600160e01b03199092166020928302919091019091015260ff8216156108355760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161052a565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e1906147ec90309089908990600401615da1565b6020604051808303816000875af115801561480b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482f9190615c56565b90508015614850576148446003602183614bb9565b60009250925050614bb2565b436009541461486557614844600a60246131bb565b6148a66040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149089190615c56565b60408201526149178686612a73565b60c082018190526040805160208101825290830151815261493891906155cc565b606083018190526020830182600381111561495557614955615cde565b600381111561496657614966615cde565b905250600090508160200151600381111561498357614983615cde565b146149d05760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015260640161052a565b6000816060015111614a245760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a4543544544000000000000604482015260640161052a565b8060600151600f54614a369190615c85565b608082015260608101516001600160a01b038716600090815260106020526040902054614a639190615c85565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b0316600080516020615e3f8339815191528360600151604051614b1291815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b158015614b8557600080fd5b505af1158015614b99573d6000803e3d6000fd5b5060009250614ba6915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846011811115614bee57614bee615cde565b846061811115614c0057614c00615cde565b604080519283526020830191909152810184905260600160405180910390a16003846011811115614c3357614c33615cde565b14614c4f57836011811115614c4a57614c4a615cde565b6110d3565b6110d3826103e8615c85565b600080838311614c7a576000614c718486615ccb565b91509150614bb2565b50600390506000614bb2565b6000670de0b6b3a7640000614c9f8484600001516155dc565b6108329190615ddb565b600080614cb6848461561e565b90506110d38161564f565b600080838301848110614cd957600092509050614bb2565b600260009250925050614bb2565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c90614d2490309088908890600401615da1565b6020604051808303816000875af1158015614d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d679190615c56565b90508015614d8457614d7c6003601083614bb9565b915050610835565b4360095414614d9957614d7c600a600c6131bb565b6000614da3612dae565b905083811015614dc257614db9600e600b6131bb565b92505050610835565b614dee604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e5b9190615c56565b60208201819052614e6c9086614cc1565b6040830181905282826003811115614e8657614e86615cde565b6003811115614e9757614e97615cde565b9052506000905081516003811115614eb157614eb1615cde565b14614edd57614ed36009600e8360000151600381111561348157613481615cde565b9350505050610835565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614f36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f5a9190615c56565b92508215614f6f57614ed36003601085614bb9565b614f7b600b5486614cc1565b6060830181905282826003811115614f9557614f95615cde565b6003811115614fa657614fa6615cde565b9052506000905081516003811115614fc057614fc0615cde565b14614fe257614ed36009600d8360000151600381111561348157613481615cde565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b5561501e8686612960565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af11580156150f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061511c9190615c56565b9050801561513d576151316003601483614bb9565b60009250925050615536565b436009541461515257615131600a60186131bb565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015615191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151b59190615c56565b146151c657615131600a60136131bb565b866001600160a01b0316866001600160a01b0316036151eb57615131600660196131bb565b846000036151ff57615131600760176131bb565b600019850361521457615131600760166131bb565b600080615222898989613992565b909250905081156152575761524982601181111561524257615242615cde565b601a6131bb565b600094509450505050615536565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b906152949030908c908890600401615da1565b6040805180830381865afa1580156152b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152d49190615def565b909250905081156153435760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b606482015260840161052a565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa15801561538c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153b09190615c56565b10156153fe5760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d5543480000000000000000604482015260640161052a565b6000306001600160a01b038a16036154235761541c308d8d856132b8565b9050615499565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190615453908f908f908790600401615da1565b6020604051808303816000875af1158015615472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906154969190615c56565b90505b80156154d05760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b604482015260640161052a565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b60008060008061554f8686615667565b9092509050600082600381111561556857615568615cde565b146155795750915060009050614bb2565b60006155848261564f565b9350935050509250929050565b6000816155a684670de0b6b3a7640000615e13565b6155b09190615ddb565b90506155bc8284615e2a565b1561083557610832600182615c85565b60008060008061554f86866156e3565b600061083283836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615756565b60408051602081019091526000815260405180602001604052806156468560000151856155dc565b90529392505050565b805160009061083590670de0b6b3a764000090615ddb565b600061567f6040518060200160405280600081525090565b6000806156908660000151866157a9565b909250905060008260038111156156a9576156a9615cde565b146156c857506040805160208101909152600081529092509050614bb2565b60408051602081019091529081526000969095509350505050565b60006156fb6040518060200160405280600081525090565b600080615710670de0b6b3a7640000876157a9565b9092509050600082600381111561572957615729615cde565b1461574857506040805160208101909152600081529092509050614bb2565b6155848186600001516157eb565b6000831580615763575082155b156157705750600061105f565b600061577c8486615e13565b9050836157898683615ddb565b1483906107045760405162461bcd60e51b815260040161052a9190615925565b600080836000036157bf57506000905080614bb2565b838302836157cd8683615ddb565b146157e057600260009250925050614bb2565b600092509050614bb2565b60006158036040518060200160405280600081525090565b60008061581886670de0b6b3a76400006157a9565b9092509050600082600381111561583157615831615cde565b1461585057506040805160208101909152600081529092509050614bb2565b60008061585d83886158b6565b9092509050600082600381111561587657615876615cde565b146158995781604051806020016040528060008152509550955050505050614bb2565b604080516020810190915290815260009890975095505050505050565b600080826000036158cd5750600190506000614bb2565b60006158d98486615ddb565b915091509250929050565b6001600160a01b03811681146132b557600080fd5b6000806040838503121561590c57600080fd5b8235615917816158e4565b946020939093013593505050565b60006020808352835180602085015260005b8181101561595357858101830151858201604001528201615937565b506000604082860101526040601f19601f8301168501019250505092915050565b60006020828403121561598657600080fd5b5035919050565b60006020828403121561599f57600080fd5b813561105f816158e4565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156159d257600080fd5b813567ffffffffffffffff808211156159ea57600080fd5b818401915084601f8301126159fe57600080fd5b813581811115615a1057615a106159aa565b604051601f8201601f19908116603f01168101908382118183101715615a3857615a386159aa565b81604052828152876020848701011115615a5157600080fd5b826020860160208301376000928101602001929092525095945050505050565b6020808252825182820181905260009190848201906040850190845b81811015615ab35783516001600160e01b03191683529284019291840191600101615a8d565b50909695505050505050565b600080600060608486031215615ad457600080fd5b8335615adf816158e4565b92506020840135615aef816158e4565b929592945050506040919091013590565b600080600060608486031215615b1557600080fd5b8335615b20816158e4565b9250602084013591506040840135615b37816158e4565b809150509250925092565b600181811c90821680615b5657607f821691505b60208210810361189457634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b600060208284031215615bbb57600080fd5b8151801515811461105f57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b600060208284031215615c3157600080fd5b815161105f816158e4565b6001600160a01b0392831681529116602082015260400190565b600060208284031215615c6857600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561083557610835615c6f565b634e487b7160e01b600052603260045260246000fd5b600060ff821680615cc157615cc1615c6f565b6000190192915050565b8181038181111561083557610835615c6f565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b600082615dea57615dea615dc5565b500490565b60008060408385031215615e0257600080fd5b505080516020909101519092909150565b808202811582820484141761083557610835615c6f565b600082615e3957615e39615dc5565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202b9014d02cf451c4a158c1796e57da55ad5383226679ce0300ea4ebdf7c477ca64736f6c63430008160033", + "devdoc": { + "author": "Joey Santoro CErc20PluginDelegate deposits and withdraws from a plugin contract It is also capable of delegating reward functionality to a PluginRewardsDistributor", + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_becomeImplementation(bytes)": { + "params": { + "data": "The encoded arguments for becoming" + } + }, + "_getExtensionFunctions()": { + "returns": { + "functionSelectors": "a list of all the function selectors that this logic extension exposes" + } + }, + "_updatePlugin(address)": { + "params": { + "_plugin": "The address of the plugin implementation to use" + } + }, + "_withdrawAdminFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_withdrawIonicFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "borrow(uint256)": { + "params": { + "borrowAmount": "The amount of the underlying asset to borrow" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "getCash()": { + "returns": { + "_0": "The quantity of underlying asset owned by this contract" + } + }, + "liquidateBorrow(address,uint256,address)": { + "params": { + "borrower": "The borrower of this cToken to be liquidated", + "cTokenCollateral": "The market in which to seize collateral from the borrower", + "repayAmount": "The amount of the underlying borrowed asset to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "mint(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "mintAmount": "The amount of the underlying asset to supply" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeem(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemTokens": "The number of cTokens to redeem into underlying" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeemUnderlying(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemAmount": "The amount of underlying to redeem" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrow(uint256)": { + "params": { + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrowBehalf(address,uint256)": { + "params": { + "borrower": "the account with the debt being payed off", + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "seize(address,address,uint256)": { + "details": "Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.", + "params": { + "borrower": "The account having collateral seized", + "liquidator": "The account receiving seized collateral", + "seizeTokens": "The number of cTokens to seize" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + } + }, + "title": "Rari's CErc20Plugin's Contract", + "version": 1 + }, + "userdoc": { + "events": { + "AccrueInterest(uint256,uint256,uint256,uint256)": { + "notice": "Event emitted when interest is accrued" + }, + "Approval(address,address,uint256)": { + "notice": "EIP20 Approval event" + }, + "Borrow(address,uint256,uint256,uint256)": { + "notice": "Event emitted when underlying is borrowed" + }, + "LiquidateBorrow(address,address,uint256,address,uint256)": { + "notice": "Event emitted when a borrow is liquidated" + }, + "Mint(address,uint256,uint256)": { + "notice": "Event emitted when tokens are minted" + }, + "NewAdminFee(uint256,uint256)": { + "notice": "Event emitted when the admin fee is changed" + }, + "NewIonicFee(uint256,uint256)": { + "notice": "Event emitted when the Ionic fee is changed" + }, + "NewMarketInterestRateModel(address,address)": { + "notice": "Event emitted when interestRateModel is changed" + }, + "NewReserveFactor(uint256,uint256)": { + "notice": "Event emitted when the reserve factor is changed" + }, + "Redeem(address,uint256,uint256)": { + "notice": "Event emitted when tokens are redeemed" + }, + "RepayBorrow(address,address,uint256,uint256,uint256)": { + "notice": "Event emitted when a borrow is repaid" + }, + "ReservesAdded(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are added" + }, + "ReservesReduced(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are reduced" + }, + "Transfer(address,address,uint256)": { + "notice": "EIP20 Transfer event" + } + }, + "kind": "user", + "methods": { + "_becomeImplementation(bytes)": { + "notice": "Delegate interface to become the implementation" + }, + "_updatePlugin(address)": { + "notice": "Update the plugin implementation to a whitelisted implementation" + }, + "_withdrawAdminFees(uint256)": { + "notice": "Accrues interest and reduces admin fees by transferring to admin" + }, + "_withdrawIonicFees(uint256)": { + "notice": "Accrues interest and reduces Ionic fees by transferring to Ionic" + }, + "accrualBlockNumber()": { + "notice": "Block number that interest was last accrued at" + }, + "adminFeeMantissa()": { + "notice": "Fraction of interest currently set aside for admin fees" + }, + "ap()": { + "notice": "Addresses Provider" + }, + "borrow(uint256)": { + "notice": "Sender borrows assets from the protocol to their own address" + }, + "borrowIndex()": { + "notice": "Accumulator of the total earned interest rate since the opening of the market" + }, + "comptroller()": { + "notice": "Contract which oversees inter-cToken operations" + }, + "decimals()": { + "notice": "EIP-20 token decimals for this token" + }, + "getCash()": { + "notice": "Get cash balance of this cToken in the underlying asset" + }, + "interestRateModel()": { + "notice": "Model which tells what the current interest rate should be" + }, + "ionicFeeMantissa()": { + "notice": "Fraction of interest currently set aside for Ionic fees" + }, + "liquidateBorrow(address,uint256,address)": { + "notice": "The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator." + }, + "mint(uint256)": { + "notice": "Sender supplies assets into the market and receives cTokens in exchange" + }, + "name()": { + "notice": "EIP-20 token name for this token" + }, + "plugin()": { + "notice": "Plugin address" + }, + "redeem(uint256)": { + "notice": "Sender redeems cTokens in exchange for the underlying asset" + }, + "redeemUnderlying(uint256)": { + "notice": "Sender redeems cTokens in exchange for a specified amount of underlying asset" + }, + "repayBorrow(uint256)": { + "notice": "Sender repays their own borrow" + }, + "repayBorrowBehalf(address,uint256)": { + "notice": "Sender repays a borrow belonging to borrower" + }, + "reserveFactorMantissa()": { + "notice": "Fraction of interest currently set aside for reserves" + }, + "seize(address,address,uint256)": { + "notice": "Transfers collateral tokens (this market) to the liquidator." + }, + "symbol()": { + "notice": "EIP-20 token symbol for this token" + }, + "totalAdminFees()": { + "notice": "Total amount of admin fees of the underlying held in this market" + }, + "totalBorrows()": { + "notice": "Total amount of outstanding borrows of the underlying in this market" + }, + "totalIonicFees()": { + "notice": "Total amount of Ionic fees of the underlying held in this market" + }, + "totalReserves()": { + "notice": "Total amount of reserves of the underlying held in this market" + }, + "totalSupply()": { + "notice": "Total number of tokens in circulation" + }, + "underlying()": { + "notice": "Underlying asset for this CToken" + } + }, + "notice": "CToken which outsources token logic to a plugin", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 17997, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 18003, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "_notEntered", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 18006, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "name", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 18009, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "symbol", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 18012, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "decimals", + "offset": 0, + "slot": "3", + "type": "t_uint8" + }, + { + "astId": 18022, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "comptroller", + "offset": 1, + "slot": "3", + "type": "t_contract(IonicComptroller)25652" + }, + { + "astId": 18026, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "interestRateModel", + "offset": 0, + "slot": "4", + "type": "t_contract(InterestRateModel)28313" + }, + { + "astId": 18028, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "initialExchangeRateMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 18031, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "adminFeeMantissa", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 18034, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "ionicFeeMantissa", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 18037, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "reserveFactorMantissa", + "offset": 0, + "slot": "8", + "type": "t_uint256" + }, + { + "astId": 18040, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "accrualBlockNumber", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 18043, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "borrowIndex", + "offset": 0, + "slot": "10", + "type": "t_uint256" + }, + { + "astId": 18046, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "totalBorrows", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 18049, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "totalReserves", + "offset": 0, + "slot": "12", + "type": "t_uint256" + }, + { + "astId": 18052, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "totalAdminFees", + "offset": 0, + "slot": "13", + "type": "t_uint256" + }, + { + "astId": 18055, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "totalIonicFees", + "offset": 0, + "slot": "14", + "type": "t_uint256" + }, + { + "astId": 18058, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "totalSupply", + "offset": 0, + "slot": "15", + "type": "t_uint256" + }, + { + "astId": 18062, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "accountTokens", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 18068, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "transferAllowances", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 18079, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "accountBorrows", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_struct(BorrowSnapshot)18074_storage)" + }, + { + "astId": 18088, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "underlying", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 18092, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "ap", + "offset": 0, + "slot": "20", + "type": "t_contract(AddressesProvider)37930" + }, + { + "astId": 12640, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "plugin", + "offset": 0, + "slot": "21", + "type": "t_contract(IERC4626)28185" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(AddressesProvider)37930": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(IERC4626)28185": { + "encoding": "inplace", + "label": "contract IERC4626", + "numberOfBytes": "20" + }, + "t_contract(InterestRateModel)28313": { + "encoding": "inplace", + "label": "contract InterestRateModel", + "numberOfBytes": "20" + }, + "t_contract(IonicComptroller)25652": { + "encoding": "inplace", + "label": "contract IonicComptroller", + "numberOfBytes": "20" + }, + "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_struct(BorrowSnapshot)18074_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct CErc20Storage.BorrowSnapshot)", + "numberOfBytes": "32", + "value": "t_struct(BorrowSnapshot)18074_storage" + }, + "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_struct(BorrowSnapshot)18074_storage": { + "encoding": "inplace", + "label": "struct CErc20Storage.BorrowSnapshot", + "members": [ + { + "astId": 18071, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "principal", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 18073, + "contract": "contracts/compound/CErc20PluginDelegate.sol:CErc20PluginDelegate", + "label": "interestIndex", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/CErc20RewardsDelegate.json b/packages/contracts/deployments/superseed/CErc20RewardsDelegate.json new file mode 100644 index 0000000000..6fbdfec9a8 --- /dev/null +++ b/packages/contracts/deployments/superseed/CErc20RewardsDelegate.json @@ -0,0 +1,1563 @@ +{ + "address": "0xb3788b3C421348E43beEa88551acC16d2f6a6332", + "abi": [ + { + "inputs": [], + "name": "CallerIsNotEOA", + "type": "error" + }, + { + "inputs": [], + "name": "InteractionNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "LiquidateBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldAdminFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFeeMantissa", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldIonicFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newIonicFeeMantissa", + "type": "uint256" + } + ], + "name": "NewIonicFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "Redeem", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "accountBorrows", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "RepayBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "benefactor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "addAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reduceAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTotalReserves", + "type": "uint256" + } + ], + "name": "ReservesReduced", + "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": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "_becomeImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "_withdrawIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "address", + "name": "_spender", + "type": "address" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract IonicComptroller", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractType", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "delegateType", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "feeSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + } + ], + "name": "liquidateBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + } + ], + "name": "redeemUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowBehalf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "selfTransferOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xd3763471492ae6c46518fba2b2369816eff3776a7c8fbb5723e664f4fe18c0ae", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xb3788b3C421348E43beEa88551acC16d2f6a6332", + "transactionIndex": 1, + "gasUsed": "5171297", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2d9c5496afa1484e702f7040dce7700e8dc4824ab53aecf462321abc6cc67ec4", + "transactionHash": "0xd3763471492ae6c46518fba2b2369816eff3776a7c8fbb5723e664f4fe18c0ae", + "logs": [], + "blockNumber": 4135294, + "cumulativeGasUsed": "5215175", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CallerIsNotEOA\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InteractionNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cashPrior\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"interestAccumulated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"AccrueInterest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"Borrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"LiquidateBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintTokens\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAdminFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldIonicFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newIonicFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewIonicFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"oldInterestRateModel\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"newInterestRateModel\",\"type\":\"address\"}],\"name\":\"NewMarketInterestRateModel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReserveFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewReserveFactor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"Redeem\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"payer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"accountBorrows\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"RepayBorrow\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"benefactor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"addAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reduceAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTotalReserves\",\"type\":\"uint256\"}],\"name\":\"ReservesReduced\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"_becomeImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"_withdrawIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accrualBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"}],\"name\":\"borrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractType\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"delegateType\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interestRateModel\",\"outputs\":[{\"internalType\":\"contract InterestRateModel\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"}],\"name\":\"liquidateBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"}],\"name\":\"redeemUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrowBehalf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"seize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferIn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"selfTransferOut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBorrows\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalReserves\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underlying\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"functionSelectors\":\"a list of all the function selectors that this logic extension exposes\"}},\"_withdrawAdminFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_withdrawIonicFees(uint256)\":{\"params\":{\"withdrawAmount\":\"Amount of fees to withdraw\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"borrow(uint256)\":{\"params\":{\"borrowAmount\":\"The amount of the underlying asset to borrow\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"getCash()\":{\"returns\":{\"_0\":\"The quantity of underlying asset owned by this contract\"}},\"liquidateBorrow(address,uint256,address)\":{\"params\":{\"borrower\":\"The borrower of this cToken to be liquidated\",\"cTokenCollateral\":\"The market in which to seize collateral from the borrower\",\"repayAmount\":\"The amount of the underlying borrowed asset to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"mint(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"mintAmount\":\"The amount of the underlying asset to supply\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeem(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemTokens\":\"The number of cTokens to redeem into underlying\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"redeemUnderlying(uint256)\":{\"details\":\"Accrues interest whether or not the operation succeeds, unless reverted\",\"params\":{\"redeemAmount\":\"The amount of underlying to redeem\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrow(uint256)\":{\"params\":{\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"repayBorrowBehalf(address,uint256)\":{\"params\":{\"borrower\":\"the account with the debt being payed off\",\"repayAmount\":\"The amount to repay\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"seize(address,address,uint256)\":{\"details\":\"Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\",\"params\":{\"borrower\":\"The account having collateral seized\",\"liquidator\":\"The account receiving seized collateral\",\"seizeTokens\":\"The number of cTokens to seize\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}}},\"version\":1},\"userdoc\":{\"events\":{\"AccrueInterest(uint256,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when interest is accrued\"},\"Approval(address,address,uint256)\":{\"notice\":\"EIP20 Approval event\"},\"Borrow(address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when underlying is borrowed\"},\"LiquidateBorrow(address,address,uint256,address,uint256)\":{\"notice\":\"Event emitted when a borrow is liquidated\"},\"Mint(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are minted\"},\"NewAdminFee(uint256,uint256)\":{\"notice\":\"Event emitted when the admin fee is changed\"},\"NewIonicFee(uint256,uint256)\":{\"notice\":\"Event emitted when the Ionic fee is changed\"},\"NewMarketInterestRateModel(address,address)\":{\"notice\":\"Event emitted when interestRateModel is changed\"},\"NewReserveFactor(uint256,uint256)\":{\"notice\":\"Event emitted when the reserve factor is changed\"},\"Redeem(address,uint256,uint256)\":{\"notice\":\"Event emitted when tokens are redeemed\"},\"RepayBorrow(address,address,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when a borrow is repaid\"},\"ReservesAdded(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are added\"},\"ReservesReduced(address,uint256,uint256)\":{\"notice\":\"Event emitted when the reserves are reduced\"},\"Transfer(address,address,uint256)\":{\"notice\":\"EIP20 Transfer event\"}},\"kind\":\"user\",\"methods\":{\"_becomeImplementation(bytes)\":{\"notice\":\"Called by the delegator on a delegate to initialize it for duty\"},\"_withdrawAdminFees(uint256)\":{\"notice\":\"Accrues interest and reduces admin fees by transferring to admin\"},\"_withdrawIonicFees(uint256)\":{\"notice\":\"Accrues interest and reduces Ionic fees by transferring to Ionic\"},\"accrualBlockNumber()\":{\"notice\":\"Block number that interest was last accrued at\"},\"adminFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for admin fees\"},\"ap()\":{\"notice\":\"Addresses Provider\"},\"approve(address,address)\":{\"notice\":\"token approval function\"},\"borrow(uint256)\":{\"notice\":\"Sender borrows assets from the protocol to their own address\"},\"borrowIndex()\":{\"notice\":\"Accumulator of the total earned interest rate since the opening of the market\"},\"claim()\":{\"notice\":\"A reward token claim function to be overridden for use cases where rewardToken needs to be pulled in\"},\"comptroller()\":{\"notice\":\"Contract which oversees inter-cToken operations\"},\"decimals()\":{\"notice\":\"EIP-20 token decimals for this token\"},\"getCash()\":{\"notice\":\"Get cash balance of this cToken in the underlying asset\"},\"interestRateModel()\":{\"notice\":\"Model which tells what the current interest rate should be\"},\"ionicFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for Ionic fees\"},\"liquidateBorrow(address,uint256,address)\":{\"notice\":\"The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator.\"},\"mint(uint256)\":{\"notice\":\"Sender supplies assets into the market and receives cTokens in exchange\"},\"name()\":{\"notice\":\"EIP-20 token name for this token\"},\"redeem(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for the underlying asset\"},\"redeemUnderlying(uint256)\":{\"notice\":\"Sender redeems cTokens in exchange for a specified amount of underlying asset\"},\"repayBorrow(uint256)\":{\"notice\":\"Sender repays their own borrow\"},\"repayBorrowBehalf(address,uint256)\":{\"notice\":\"Sender repays a borrow belonging to borrower\"},\"reserveFactorMantissa()\":{\"notice\":\"Fraction of interest currently set aside for reserves\"},\"seize(address,address,uint256)\":{\"notice\":\"Transfers collateral tokens (this market) to the liquidator.\"},\"symbol()\":{\"notice\":\"EIP-20 token symbol for this token\"},\"totalAdminFees()\":{\"notice\":\"Total amount of admin fees of the underlying held in this market\"},\"totalBorrows()\":{\"notice\":\"Total amount of outstanding borrows of the underlying in this market\"},\"totalIonicFees()\":{\"notice\":\"Total amount of Ionic fees of the underlying held in this market\"},\"totalReserves()\":{\"notice\":\"Total amount of reserves of the underlying held in this market\"},\"totalSupply()\":{\"notice\":\"Total number of tokens in circulation\"},\"underlying()\":{\"notice\":\"Underlying asset for this CToken\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/CErc20RewardsDelegate.sol\":\"CErc20RewardsDelegate\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicUniV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV3FlashCallback.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV3Pool.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\nimport { IUniswapV3Quoter } from \\\"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"./ionic/IFlashLoanReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicUniV3Liquidator\\n * @author Veliko Minkov (https://github.com/vminkov)\\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\\n */\\ncontract IonicUniV3Liquidator is\\n OwnableUpgradeable,\\n ILiquidator,\\n IUniswapV3FlashCallback,\\n IExpressRelayFeeReceiver,\\n IFlashLoanReceiver\\n{\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n\\n address public W_NATIVE_ADDRESS;\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n IUniswapV3Quoter public quoter;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(address _wtoken, address _quoter) external initializer {\\n __Ownable_init();\\n W_NATIVE_ADDRESS = _wtoken;\\n quoter = IUniswapV3Quoter(_quoter);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n underlying.approve(address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateToTokensWithFlashLoan(\\n LiquidateToTokensWithFlashSwapVars calldata vars\\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\\n flashSwapPool.flash(\\n address(this),\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n\\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(\\n LiquidateToTokensWithFlashSwapVars memory vars,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\\n uint256 flashSwapReturnAmount = _flashSwapAmount;\\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\\n flashSwapReturnAmount += fee0;\\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\\n flashSwapReturnAmount += fee1;\\n } else {\\n revert(\\\"wrong pool or _flashSwapToken\\\");\\n }\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay the borrowed asset directly\\n collateralRequired = flashSwapReturnAmount;\\n\\n // Repay flashloan\\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\\n } else {\\n // TODO swap within the same pool and then repay the FL to the pool\\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\\n\\n {\\n collateralRequired = quoter.quoteExactOutputSingle(\\n zeroForOne ? pool.token0() : pool.token1(),\\n zeroForOne ? pool.token1() : pool.token0(),\\n pool.fee(),\\n _flashSwapAmount,\\n 0 // sqrtPriceLimitX96\\n );\\n }\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n\\n // Repay flashloan\\n pool.swap(\\n address(pool),\\n zeroForOne,\\n int256(collateralRequired),\\n 0, // sqrtPriceLimitX96\\n \\\"\\\"\\n );\\n }\\n\\n return address(underlyingCollateral);\\n } else {\\n revert(\\\"the redemptions strategy did not swap to the flash swapped pool assets\\\");\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n bool[] calldata whitelisted\\n ) external onlyOwner {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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\":\"0x03ad15c5d4e63fbc8d4df554ce3172f4e0611843a326a8e29ec39870e5ddbd72\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20Delegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CToken.sol\\\";\\n\\n/**\\n * @title Compound's CErc20Delegate Contract\\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\\n * @author Compound\\n */\\ncontract CErc20Delegate is CErc20 {\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 3;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n */\\n function _becomeImplementation(bytes memory) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 1;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20Delegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x64f72d66ae0f29c8400dd922cf2d5f453c1de98a72d7041fa8b39ec2aba25402\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20RewardsDelegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CErc20Delegate.sol\\\";\\nimport \\\"./EIP20Interface.sol\\\";\\n\\ncontract CErc20RewardsDelegate is CErc20Delegate {\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 2;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n \\n /// @notice A reward token claim function\\n /// to be overridden for use cases where rewardToken needs to be pulled in\\n function claim() external {}\\n\\n /// @notice token approval function\\n function approve(address _token, address _spender) external {\\n require(hasAdminRights(), \\\"!admin\\\");\\n require(_token != underlying, \\\"!underlying\\\");\\n\\n EIP20Interface(_token).approve(_spender, type(uint256).max);\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 3;\\n }\\n\\n function contractType() external pure override returns (string memory) {\\n return \\\"CErc20RewardsDelegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0xa91654fca77ebeedce1c4cf3e343beee602427377190f57a35021641ab66ed0d\",\"license\":\"UNLICENSED\"},\"contracts/compound/CToken.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { CTokenSecondExtensionBase, ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { TokenErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { CTokenOracleProtected } from \\\"./CTokenOracleProtected.sol\\\";\\n\\nimport { DiamondExtension, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { PoolLens } from \\\"../PoolLens.sol\\\";\\nimport { IonicUniV3Liquidator } from \\\"../IonicUniV3Liquidator.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\n/**\\n * @title Compound's CErc20 Contract\\n * @notice CTokens which wrap an EIP-20 underlying\\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\\n * @author Compound\\n */\\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\\n modifier isAuthorized() {\\n require(\\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\\n \\\"not authorized\\\"\\n );\\n _;\\n }\\n\\n modifier isMinHFThresholdExceeded(address borrower) {\\n PoolLens lens = PoolLens(ap.getAddress(\\\"PoolLens\\\"));\\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\\\"IonicUniV3Liquidator\\\")));\\n\\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\\n require(msg.sender == address(liquidator), \\\"Health factor not low enough for non-permissioned liquidations\\\");\\n _;\\n } else {\\n _;\\n }\\n }\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 13;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.mint.selector;\\n functionSelectors[--fnsCount] = this.redeem.selector;\\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\\n functionSelectors[--fnsCount] = this.borrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\\n functionSelectors[--fnsCount] = this.getCash.selector;\\n functionSelectors[--fnsCount] = this.seize.selector;\\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*** User Interface ***/\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = mintInternal(mintAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemInternal(redeemTokens);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to redeem\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemUnderlyingInternal(redeemAmount);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return borrowInternal(borrowAmount);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowInternal(repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\\n return err;\\n }\\n\\n /**\\n * @notice Get cash balance of this cToken in the underlying asset\\n * @return The quantity of underlying asset owned by this contract\\n */\\n function getCash() external view override returns (uint256) {\\n return getCashInternal();\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Will fail unless called by another cToken during the process of liquidation.\\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\\n }\\n\\n function selfTransferOut(address to, uint256 amount) external override {\\n require(msg.sender == address(this), \\\"!self\\\");\\n doTransferOut(to, amount);\\n }\\n\\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\\n require(msg.sender == address(this), \\\"!self\\\");\\n return doTransferIn(from, amount);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\\n }\\n\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalIonicFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\\n totalIonicFees = totalIonicFeesNew;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(address(ionicAdmin), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces admin fees by transferring to admin\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\\n }\\n\\n // Fail gracefully if protocol has insufficient underlying cash\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalAdminFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n totalAdminFees = totalAdminFees - withdrawAmount;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of this contract in terms of the underlying\\n * @dev This excludes the value of the current message, if any\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view virtual returns (uint256) {\\n return EIP20Interface(underlying).balanceOf(address(this));\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\\n * This will revert due to insufficient balance or insufficient allowance.\\n * This function returns the actual amount received,\\n * which may be less than `amount` if there is a fee attached to the transfer.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\\n \\\"TOKEN_TRANSFER_IN_FAILED\\\"\\n );\\n\\n // Calculate the amount that was *actually* transferred\\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\\n require(balanceAfter >= balanceBefore, \\\"TOKEN_TRANSFER_IN_OVERFLOW\\\");\\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\\n * it is >= amount, this should not revert in normal conditions.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferOut(address to, uint256 amount) internal virtual {\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\\n \\\"TOKEN_TRANSFER_OUT_FAILED\\\"\\n );\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\\n }\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\\n return mintFresh(msg.sender, mintAmount);\\n }\\n\\n struct MintLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 mintTokens;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n uint256 actualMintAmount;\\n }\\n\\n /**\\n * @notice User supplies assets into the market and receives cTokens in exchange\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param minter The address of the account which is supplying the assets\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\\n /* Fail if mint not allowed */\\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\\n }\\n\\n MintLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n // Check max supply\\n // unused function\\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n } */\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call `doTransferIn` for the minter and the mintAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\\n * side-effects occurred. The function returns the amount actually transferred,\\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\\n * of cash.\\n */\\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\\n\\n /*\\n * We get the current exchange rate and calculate the number of cTokens to be minted:\\n * mintTokens = actualMintAmount / exchangeRate\\n */\\n\\n // mintTokens is rounded down here - correct\\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\\n vars.actualMintAmount,\\n Exp({ mantissa: vars.exchangeRateMantissa })\\n );\\n require(vars.mathErr == MathError.NO_ERROR, \\\"MINT_EXCHANGE_CALCULATION_FAILED\\\");\\n require(vars.mintTokens > 0, \\\"MINT_ZERO_CTOKENS_REJECTED\\\");\\n\\n /*\\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\\n * totalSupplyNew = totalSupply + mintTokens\\n * accountTokensNew = accountTokens[minter] + mintTokens\\n */\\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\\n\\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[minter] = vars.accountTokensNew;\\n\\n /* We emit a Mint event, and a Transfer event */\\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\\n emit Transfer(address(this), minter, vars.mintTokens);\\n\\n /* We call the defense hook */\\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\\n\\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, redeemTokens, 0);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, 0, redeemAmount);\\n }\\n\\n struct RedeemLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 redeemTokens;\\n uint256 redeemAmount;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n }\\n\\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\\n res = (x * 1e18) / y;\\n if (x % y != 0) res += 1;\\n }\\n\\n /**\\n * @notice User redeems cTokens in exchange for the underlying asset\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param redeemer The address of the account which is redeeming the tokens\\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemFresh(\\n address redeemer,\\n uint256 redeemTokensIn,\\n uint256 redeemAmountIn\\n ) internal returns (uint256) {\\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \\\"!redeem tokens or amount\\\");\\n\\n RedeemLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n if (redeemTokensIn > 0) {\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\\n\\n /*\\n * We calculate the exchange rate and the amount of underlying to be redeemed:\\n * redeemTokens = redeemTokensIn\\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\\n */\\n vars.redeemTokens = redeemTokensIn;\\n\\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n redeemTokensIn\\n );\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n } else {\\n if (redeemAmountIn == type(uint256).max) {\\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\\n }\\n\\n // don't allow dust tokens/assets to be left after\\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\\n\\n /*\\n * We get the current exchange rate and calculate the amount to be redeemed:\\n * redeemTokens = redeemAmountIn / exchangeRate\\n * redeemAmount = redeemAmountIn\\n */\\n\\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\\n\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\\n\\n vars.redeemAmount = redeemAmountIn;\\n }\\n\\n /* Fail if redeem not allowed */\\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\\n }\\n\\n /*\\n * We calculate the new total supply and redeemer balance, checking for underflow:\\n * totalSupplyNew = totalSupply - redeemTokens\\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\\n */\\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /* Fail gracefully if protocol has insufficient cash */\\n if (getCashInternal() < vars.redeemAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[redeemer] = vars.accountTokensNew;\\n\\n /*\\n * We invoke doTransferOut for the redeemer and the redeemAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken has redeemAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(redeemer, vars.redeemAmount);\\n\\n /* We emit a Transfer event, and a Redeem event */\\n emit Transfer(redeemer, address(this), vars.redeemTokens);\\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n /* We call the defense hook */\\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\\n return borrowFresh(msg.sender, borrowAmount);\\n }\\n\\n struct BorrowLocalVars {\\n MathError mathErr;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n }\\n\\n /**\\n * @notice Users borrow assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\\n /* Fail if borrow not allowed */\\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\\n }\\n\\n /* Fail gracefully if protocol has insufficient underlying cash */\\n uint256 cashPrior = getCashInternal();\\n\\n if (cashPrior < borrowAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\\n }\\n\\n BorrowLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on overflow:\\n * accountBorrowsNew = accountBorrows + borrowAmount\\n * totalBorrowsNew = totalBorrows + borrowAmount\\n */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(\\n Error.MATH_ERROR,\\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n uint256(vars.mathErr)\\n );\\n }\\n\\n // Check min borrow for this user for this asset\\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /*\\n * We invoke doTransferOut for the borrower and the borrowAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken borrowAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(borrower, borrowAmount);\\n\\n /* We emit a Borrow event */\\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\\n internal\\n nonReentrant(false)\\n returns (uint256, uint256)\\n {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\\n }\\n\\n struct RepayBorrowLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 repayAmount;\\n uint256 borrowerIndex;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n uint256 actualRepayAmount;\\n }\\n\\n /**\\n * @notice Borrows are repaid by another user (possibly the borrower).\\n * @param payer the account paying off the borrow\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount the amount of undelrying tokens being returned\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowFresh(\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) internal returns (uint256, uint256) {\\n /* Fail if repayBorrow not allowed */\\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\\n }\\n\\n RepayBorrowLocalVars memory vars;\\n\\n /* We remember the original borrowerIndex for verification purposes */\\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\\n\\n /* We fetch the amount the borrower owes, with accumulated interest */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n /* If repayAmount == -1, repayAmount = accountBorrows */\\n if (repayAmount == type(uint256).max) {\\n vars.repayAmount = vars.accountBorrows;\\n } else {\\n vars.repayAmount = repayAmount;\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call doTransferIn for the payer and the repayAmount\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken holds an additional repayAmount of cash.\\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n * it returns the amount actually transferred, in case of a fee.\\n */\\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on underflow:\\n * accountBorrowsNew = accountBorrows - actualRepayAmount\\n * totalBorrowsNew = totalBorrows - actualRepayAmount\\n */\\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\\\");\\n\\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\\\");\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /* We emit a RepayBorrow event */\\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\\n\\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowInternal(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n ICErc20(cTokenCollateral).accrueInterest();\\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\\n }\\n\\n /**\\n * @notice The liquidator liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param liquidator The address repaying the borrow and seizing collateral\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowFresh(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal returns (uint256, uint256) {\\n /* Fail if liquidate not allowed */\\n uint256 allowed = comptroller.liquidateBorrowAllowed(\\n address(this),\\n cTokenCollateral,\\n liquidator,\\n borrower,\\n repayAmount\\n );\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Verify cTokenCollateral market's block number equals current block number */\\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\\n }\\n\\n /* Fail if repayAmount = 0 */\\n if (repayAmount == 0) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\\n }\\n\\n /* Fail if repayAmount = -1 */\\n if (repayAmount == type(uint256).max) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\\n }\\n\\n /* Fail if repayBorrow fails */\\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We calculate the number of collateral tokens that will be seized */\\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\\n address(this),\\n cTokenCollateral,\\n actualRepayAmount\\n );\\n require(amountSeizeError == uint256(Error.NO_ERROR), \\\"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\\\");\\n\\n /* Revert if borrower collateral token balance < seizeTokens */\\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \\\"LIQUIDATE_SEIZE_TOO_MUCH\\\");\\n\\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\\n uint256 seizeError;\\n if (cTokenCollateral == address(this)) {\\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\\n } else {\\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\\n }\\n\\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\\n require(seizeError == uint256(Error.NO_ERROR), \\\"!seize\\\");\\n\\n /* We emit a LiquidateBorrow event */\\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\\n\\n return (uint256(Error.NO_ERROR), actualRepayAmount);\\n }\\n\\n struct SeizeInternalLocalVars {\\n MathError mathErr;\\n uint256 borrowerTokensNew;\\n uint256 liquidatorTokensNew;\\n uint256 liquidatorSeizeTokens;\\n uint256 protocolSeizeTokens;\\n uint256 protocolSeizeAmount;\\n uint256 exchangeRateMantissa;\\n uint256 totalReservesNew;\\n uint256 totalIonicFeeNew;\\n uint256 totalSupplyNew;\\n uint256 feeSeizeTokens;\\n uint256 feeSeizeAmount;\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seizeInternal(\\n address seizerToken,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) internal returns (uint256) {\\n /* Fail if seize not allowed */\\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\\n }\\n\\n SeizeInternalLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\\n */\\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n vars.protocolSeizeAmount = mul_ScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n vars.protocolSeizeTokens\\n );\\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\\n\\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\\n\\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n totalReserves = vars.totalReservesNew;\\n totalSupply = vars.totalSupplyNew;\\n totalIonicFees = vars.totalIonicFeeNew;\\n\\n accountTokens[borrower] = vars.borrowerTokensNew;\\n accountTokens[liquidator] = vars.liquidatorTokensNew;\\n\\n /* Emit a Transfer event */\\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function asCTokenExtension() internal view returns (ICErc20) {\\n return ICErc20(address(this));\\n }\\n\\n /*** Reentrancy Guard ***/\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant(bool localOnly) {\\n _beforeNonReentrant(localOnly);\\n _;\\n _afterNonReentrant(localOnly);\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\\n */\\n function _beforeNonReentrant(bool localOnly) private {\\n require(_notEntered, \\\"re-entered\\\");\\n if (!localOnly) comptroller._beforeNonReentrant();\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\\n */\\n function _afterNonReentrant(bool localOnly) private {\\n _notEntered = true; // get a gas-refund post-Istanbul\\n if (!localOnly) comptroller._afterNonReentrant();\\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 * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\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 * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n}\\n\",\"keccak256\":\"0x308ca2ce334910ef9ece96a98a4a899eaa802051051dc89bf6f8732242000b7b\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenOracleProtected.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.22;\\n\\nimport { CErc20Storage } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenOracleProtected is CErc20Storage {\\n error InteractionNotAllowed();\\n error CallerIsNotEOA();\\n\\n modifier onlyOracleApproved() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyOracleApprovedAllowEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n if (tx.origin == msg.sender) {\\n _;\\n return;\\n }\\n\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyNotBlacklistedEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n if (msg.sender != tx.origin) {\\n revert CallerIsNotEOA();\\n }\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x42b99e4fbc5880f64a6f1d8b02f3b061b0d3a6c312f47d83e88593eefaf71304\",\"license\":\"Unlicense\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/EIP20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ERC 20 Token Standard Interface\\n * https://eips.ethereum.org/EIPS/eip-20\\n */\\ninterface EIP20Interface {\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n /**\\n * @notice Get the total number of tokens in circulation\\n * @return uint256 The supply of tokens\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @notice Gets the balance of the specified address\\n * @param owner The address from which the balance will be retrieved\\n * @return balance uint256 The balance\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transfer(address dst, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Transfer `amount` tokens from `src` to `dst`\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool success);\\n\\n /**\\n * @notice Approve `spender` to transfer up to `amount` from `src`\\n * @dev This will overwrite the approval amount for `spender`\\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\\n * @param spender The address of the account which may transfer tokens\\n * @param amount The number of tokens that are approved (-1 means infinite)\\n * @return success bool Whether or not the approval succeeded\\n */\\n function approve(address spender, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Get the current allowance from `owner` for `spender`\\n * @param owner The address of the account which owns the tokens to be spent\\n * @param spender The address of the account which may transfer tokens\\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\\n */\\n function allowance(address owner, address spender) external view returns (uint256 remaining);\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n}\\n\",\"keccak256\":\"0xcea1d290397e1c8eac89c96738e7ec55259a575f878152eeccf33c0cf6d008e5\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV3FlashCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#flash\\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\\ninterface IUniswapV3FlashCallback {\\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\\n function uniswapV3FlashCallback(\\n uint256 fee0,\\n uint256 fee1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc26730db16259a49c30bd7bd880bb7e48ad94853087a373ba787e406ca969f3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50615c9380620000216000396000f3fe608060405234801561001057600080fd5b506004361061023d5760003560e01c80637e5465ba1161013b578063b0d58e49116100b8578063c91a424f1161007c578063c91a424f14610468578063cb2ef6f71461047b578063db006a75146104ac578063f3fdb15a146104bf578063f5e3c462146104d257600080fd5b8063b0d58e4914610417578063b2a02ff11461042a578063be99f1191461043d578063c3bf11cd1461044c578063c5ebeaec1461045557600080fd5b806395d89b41116100ff57806395d89b41146103d75780639826394b146103df578063a0712d68146103e8578063a7b820df146103fb578063aa5af0fd1461040e57600080fd5b80637e5465ba1461038a578063852a12e31461039d57806389f8132e146103b05780638d02d9a1146103c55780638f840ddd146103ce57600080fd5b80633b1d21a2116101c95780635fe3b5671161018d5780635fe3b5671461033f57806361feacff146103575780636752e702146103605780636c540baf1461036e5780636f307dc31461037757600080fd5b80633b1d21a2146102f05780633c4f743c146102f857806347bd3718146103235780634e71d92d1461025557806356e677281461032c57600080fd5b8063173b990411610210578063173b9904146102a957806318160ddd146102b25780632608f818146102bb5780632c436e5b146102ce578063313ce567146102e357600080fd5b8063067db1b31461024257806306fdde03146102575780630e75270214610275578063135f133414610296575b600080fd5b6102556102503660046156b8565b6104e5565b005b61025f61052f565b60405161026c9190615708565b60405180910390f35b61028861028336600461573b565b6105bd565b60405190815260200161026c565b6102886102a43660046156b8565b6107dd565b61028860085481565b610288600f5481565b6102886102c93660046156b8565b610829565b60035b60405160ff909116815260200161026c565b6003546102d19060ff1681565b610288610a59565b60145461030b906001600160a01b031681565b6040516001600160a01b03909116815260200161026c565b610288600b5481565b61025561033a36600461576a565b610a68565b60035461030b9061010090046001600160a01b031681565b610288600d5481565b610288666379da05b6000081565b61028860095481565b60135461030b906001600160a01b031681565b61025561039836600461581b565b610aba565b6102886103ab36600461573b565b610bbc565b6103b8610dd2565b60405161026c9190615854565b61028860065481565b610288600c5481565b61025f610f82565b610288600e5481565b6102886103f636600461573b565b610f8f565b61028861040936600461573b565b61119c565b610288600a5481565b61028861042536600461573b565b61152a565b6102886104383660046158a2565b6117e9565b61028867016345785d8a000081565b61028860075481565b61028861046336600461573b565b611983565b60005461030b906001600160a01b031681565b6040805180820190915260158152744345726332305265776172647344656c656761746560581b602082015261025f565b6102886104ba36600461573b565b611b8a565b60045461030b906001600160a01b031681565b6102886104e03660046158e3565b611d91565b3330146105215760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b61052b82826125f0565b5050565b6001805461053c90615925565b80601f016020809104026020016040519081016040528092919081815260200182805461056890615925565b80156105b55780601f1061058a576101008083540402835291602001916105b5565b820191906000526020600020905b81548152906001019060200180831161059857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261060a9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064b919061598c565b6106675760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610696906004016159d6565b602060405180830381865afa1580156106b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d79190615a02565b90506001600160a01b0381166106fb5760006106f284612671565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561073e57600080fd5b505af1158015610752573d6000803e3d6000fd5b50503332039150610774905057600061076a85612671565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107a29032903390600401615a1f565b60006040518083038186803b1580156107ba57600080fd5b505afa1580156107ce573d6000803e3d6000fd5b50505050600061076a85612671565b60003330146108165760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b6044820152606401610518565b6108208383612702565b90505b92915050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926108769261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b7919061598c565b6108d35760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610902906004016159d6565b602060405180830381865afa15801561091f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109439190615a02565b90506001600160a01b03811661096957600061095f85856128d5565b5092505050610823565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156109ac57600080fd5b505af11580156109c0573d6000803e3d6000fd5b505033320391506109e490505760006109d986866128d5565b509350505050610823565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610a129032903390600401615a1f565b60006040518083038186803b158015610a2a57600080fd5b505afa158015610a3e573d6000803e3d6000fd5b505050506000610a4e86866128d5565b509695505050505050565b6000610a63612968565b905090565b33301480610a795750610a796129d5565b610ab75760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b6044820152606401610518565b50565b610ac26129d5565b610af75760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610518565b6013546001600160a01b0390811690831603610b435760405162461bcd60e51b815260206004820152600b60248201526a21756e6465726c79696e6760a81b6044820152606401610518565b60405163095ea7b360e01b81526001600160a01b038281166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1158015610b93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb7919061598c565b505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610c099261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061598c565b610c665760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610c95906004016159d6565b602060405180830381865afa158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd69190615a02565b90506001600160a01b038116610cf657610cef83612b52565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50503332039150610d6b905057610d6384612b52565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610d999032903390600401615a1f565b60006040518083038186803b158015610db157600080fd5b505afa158015610dc5573d6000803e3d6000fd5b50505050610d6384612b52565b606060026000610de0612bda565b90508160ff168151610df29190615a4f565b67ffffffffffffffff811115610e0a57610e0a615754565b604051908082528060200260200182016040528015610e33578160200160208202803683370190505b50925060005b8151811015610e8f57818181518110610e5457610e54615a62565b6020026020010151848281518110610e6e57610e6e615a62565b6001600160e01b031990921660209283029190910190910152600101610e39565b508051634e71d92d60e01b908490610ea685615a78565b9450610eb59060ff8616615a4f565b81518110610ec557610ec5615a62565b6001600160e01b0319909216602092830291909101909101528051633f2a32dd60e11b908490610ef485615a78565b9450610f039060ff8616615a4f565b81518110610f1357610f13615a62565b6001600160e01b03199092166020928302919091019091015260ff821615610f7d5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610518565b505090565b6002805461053c90615925565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610fdc9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610ff9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101d919061598c565b6110395760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611068906004016159d6565b602060405180830381865afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190615a02565b90506001600160a01b0381166110c45760006106f284612d4a565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561110757600080fd5b505af115801561111b573d6000803e3d6000fd5b50503332039150611133905057600061076a85612d4a565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906111619032903390600401615a1f565b60006040518083038186803b15801561117957600080fd5b505afa15801561118d573d6000803e3d6000fd5b50505050600061076a85612d4a565b6000806111a881612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906111d7906004016159d6565b602060405180830381865afa1580156111f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112189190615a02565b90506001600160a01b03811661137057306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611268573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128c9190615a95565b5043600954146112a9576112a2600a6039612e8b565b925061136a565b836112b2612968565b10156112c4576112a2600e6038612e8b565b600d548411156112da576112a26002603a612e8b565b83600d546112e89190615aae565b600d55600354604080516303e1469160e61b815290516113659261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa15801561133b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135f9190615a02565b856125f0565b600092505b5061151b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906113a09032903390600401615a1f565b60006040518083038186803b1580156113b857600080fd5b505afa1580156113cc573d6000803e3d6000fd5b505050506113d73090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611416573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143a9190615a95565b50436009541461145757611450600a6039612e8b565b9350611518565b84611460612968565b101561147257611450600e6038612e8b565b600d54851115611488576114506002603a612e8b565b84600d546114969190615aae565b600d55600354604080516303e1469160e61b815290516115139261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa1580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150d9190615a02565b866125f0565b600093505b50505b61152481612f04565b50919050565b60008061153681612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611565906004016159d6565b602060405180830381865afa158015611582573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a69190615a02565b90506001600160a01b03811661169a57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156115f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161a9190615a95565b504360095414611630576112a2600a6035612e8b565b83611639612968565b101561164b576112a2600e6034612e8b565b600e54841115611661576112a260026036612e8b565b600084600e546116719190615aae565b600e81905560005490915061168f906001600160a01b0316866125f0565b60009350505061151b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906116ca9032903390600401615a1f565b60006040518083038186803b1580156116e257600080fd5b505afa1580156116f6573d6000803e3d6000fd5b505050506117013090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117649190615a95565b50436009541461177a57611450600a6035612e8b565b84611783612968565b101561179557611450600e6034612e8b565b600e548511156117ab5761145060026036612e8b565b600085600e546117bb9190615aae565b600e8190556000549091506117d9906001600160a01b0316876125f0565b6000945050505061152481612f04565b600060016117f681612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611825906004016159d6565b602060405180830381865afa158015611842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118669190615a02565b90506001600160a01b03811661188a5761188233878787612f87565b925050611972565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156118cd57600080fd5b505af11580156118e1573d6000803e3d6000fd5b505033320391506119039050576118fa33888888612f87565b93505050611972565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906119319032903390600401615a1f565b60006040518083038186803b15801561194957600080fd5b505afa15801561195d573d6000803e3d6000fd5b5050505061196d33888888612f87565b935050505b61197b81612f04565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926119d09261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa1580156119ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a11919061598c565b611a2d5760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611a5c906004016159d6565b602060405180830381865afa158015611a79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9d9190615a02565b90506001600160a01b038116611ab657610cef8361346f565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611af957600080fd5b505af1158015611b0d573d6000803e3d6000fd5b50503332039150611b23905057610d638461346f565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611b519032903390600401615a1f565b60006040518083038186803b158015611b6957600080fd5b505afa158015611b7d573d6000803e3d6000fd5b50505050610d638461346f565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611bd79261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015611bf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c18919061598c565b611c345760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611c63906004016159d6565b602060405180830381865afa158015611c80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca49190615a02565b90506001600160a01b038116611cbd57610cef836134ea565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611d0057600080fd5b505af1158015611d14573d6000803e3d6000fd5b50503332039150611d2a905057610d63846134ea565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611d589032903390600401615a1f565b60006040518083038186803b158015611d7057600080fd5b505afa158015611d84573d6000803e3d6000fd5b50505050610d63846134ea565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611dde9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015611dfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1f919061598c565b611e3b5760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611e6a906004016159d6565b602060405180830381865afa158015611e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eab9190615a02565b90506001600160a01b0381166120e05760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac190611eee90600401615ad7565b602060405180830381865afa158015611f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2f9190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac190611f6390600401615af9565b602060405180830381865afa158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa49190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fe4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120089190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261203f92899261010090041690600401615a1f565b602060405180830381865afa15801561205c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120809190615a95565b11156120c557336001600160a01b038216146120ae5760405162461bcd60e51b815260040161051890615b27565b60006120bb898989613567565b5095506120d79050565b60006120d2898989613567565b509550505b50505050610cef565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561212357600080fd5b505af1158015612137573d6000803e3d6000fd5b5050333203915061236a90505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac19061217790600401615ad7565b602060405180830381865afa158015612194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b89190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906121ec90600401615af9565b602060405180830381865afa158015612209573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222d9190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561226d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122919190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926122c892899261010090041690600401615a1f565b602060405180830381865afa1580156122e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123099190615a95565b111561234e57336001600160a01b038216146123375760405162461bcd60e51b815260040161051890615b27565b60006123448a8a8a613567565b5096506123609050565b600061235b8a8a8a613567565b509650505b5050505050610cef565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906123989032903390600401615a1f565b60006040518083038186803b1580156123b057600080fd5b505afa1580156123c4573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac1906123fb90600401615ad7565b602060405180830381865afa158015612418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243c9190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061247090600401615af9565b602060405180830381865afa15801561248d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124b19190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125159190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261254c92899261010090041690600401615a1f565b602060405180830381865afa158015612569573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258d9190615a95565b11156125d257336001600160a01b038216146125bb5760405162461bcd60e51b815260040161051890615b27565b60006125c88a8a8a613567565b5096506125e49050565b60006125df8a8a8a613567565b509650505b50505050509392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091018252602080820180516001600160e01b031663a9059cbb60e01b1790528251808401909352601983527f544f4b454e5f5452414e534645525f4f55545f4641494c4544000000000000009083015261052b91613661565b600080600061267f81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156126bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e39190615a95565b506126ef3333866136be565b925092506126fc81612f04565b50915091565b6013546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561274f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127739190615a95565b90506128036323b872dd60e01b85308660405160240161279593929190615b84565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280601881526020017f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000815250613661565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561284c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128709190615a95565b9050818110156128c25760405162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f570000000000006044820152606401610518565b6128cc8282615aae565b95945050505050565b60008060006128e381612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612923573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129479190615a95565b506129533386866136be565b9250925061296081612f04565b509250929050565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156129b1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a639190615a95565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a529190615a02565b6001600160a01b0316336001600160a01b0316148015612acf5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612acf919061598c565b80612b4c57506000546001600160a01b031633148015612b4c5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4c919061598c565b91505090565b600080612b5e81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc29190615a95565b50612bcf33600085613acb565b915061152481612f04565b606060036000612be8614112565b90508160ff168151612bfa9190615a4f565b67ffffffffffffffff811115612c1257612c12615754565b604051908082528060200260200182016040528015612c3b578160200160208202803683370190505b50925060005b8151811015612c9757818181518110612c5c57612c5c615a62565b6020026020010151848281518110612c7657612c76615a62565b6001600160e01b031990921660209283029190910190910152600101612c41565b50805163cb2ef6f760e01b908490612cae85615a78565b9450612cbd9060ff8616615a4f565b81518110612ccd57612ccd615a62565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b908490612cfc85615a78565b9450612d0b9060ff8616615a4f565b81518110612d1b57612d1b615a62565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b908490610ef485615a78565b6000806000612d5881612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dbc9190615a95565b506126ef33856144da565b600054600160a01b900460ff16612e0d5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610518565b80612e7b57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612e6257600080fd5b505af1158015612e76573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836011811115612ec057612ec0615ac1565b836061811115612ed257612ed2615ac1565b60408051928352602083019190915260009082015260600160405180910390a182601181111561082057610820615ac1565b6000805460ff60a01b1916600160a01b17905580610ab757600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612f6c57600080fd5b505af1158015612f80573d6000803e3d6000fd5b5050505050565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af1158015612ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301f9190615a95565b9050801561303c576130346003601d836148e5565b915050610d63565b846001600160a01b0316846001600160a01b031603613061576130346006601e612e8b565b6130c6604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152601060205260409020546130e99085614987565b602083018190528282600381111561310357613103615ac1565b600381111561311457613114615ac1565b905250600090508151600381111561312e5761312e615ac1565b1461315e576131556009601c8360000151600381111561315057613150615ac1565b6148e5565b92505050610d63565b61317d846040518060200160405280666379da05b600008152506149b2565b6080820152604080516020810190915267016345785d8a000081526131a39085906149b2565b610140820181905260808201516131ba9086615aae565b6131c49190615aae565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322b9190615a95565b60c08201908152604080516020810190915290518152608082015161325091906149d5565b60a0820152604080516020810190915260c0820151815261014082015161327791906149d5565b61016082015260a0810151600c5461328f9190615a4f565b60e08201526101408101516080820151600f546132ac9190615aae565b6132b69190615aae565b610120820152610160810151600e546132cf9190615a4f565b6101008201526001600160a01b03861660009081526010602052604090205460608201516132fd91906149ed565b604083018190528282600381111561331757613317615ac1565b600381111561332857613328615ac1565b905250600090508151600381111561334257613342615ac1565b14613364576131556009601b8360000151600381111561315057613150615ac1565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615c3e833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615c3e833981519152836080015160405161341191815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b60008061347b81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156134bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134df9190615a95565b50612bcf3384614a13565b6000806134f681612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355a9190615a95565b50612bcf33846000613acb565b600080600061357581612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d99190615a95565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561361a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363e9190615a95565b5061364b33878787614dae565b9250925061365881612f04565b50935093915050565b60135460009061367b906001600160a01b0316848461526b565b805190915015610bb75780806020019051810190613699919061598c565b82906136b85760405162461bcd60e51b81526004016105189190615708565b50505050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af115801561372c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137509190615a95565b905080156137715761376560036043836148e5565b60009250925050613ac3565b436009541461378657613765600a6044612e8b565b6137cf6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015613839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385d9190615a95565b6080820152600185016138795760808101516040820152613881565b604081018590525b61388f878260400151612702565b60e0820181905260808201516138a491614987565b60a08301819052602083018260038111156138c1576138c1615ac1565b60038111156138d2576138d2615ac1565b90525060009050816020015160038111156138ef576138ef615ac1565b146139625760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c45440000000000006064820152608401610518565b613972600b548260e00151614987565b60c083018190526020830182600381111561398f5761398f615ac1565b60038111156139a0576139a0615ac1565b90525060009050816020015160038111156139bd576139bd615ac1565b14613a245760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b6064820152608401610518565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613ad8575081155b613b245760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e7400000000000000006044820152606401610518565b613b656040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bc79190615a95565b60408201528315613c8a5761138884600f54613be39190615aae565b1015613bef57600f5493505b6060810184905260408051602081018252908201518152613c1090856152fe565b6080830181905260208301826003811115613c2d57613c2d615ac1565b6003811115613c3e57613c3e615ac1565b9052506000905081602001516003811115613c5b57613c5b615ac1565b14613c8557613c7d6009602c8360200151600381111561315057613150615ac1565b915050610cef565b613dd1565b6000198303613d1757600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d149190615a95565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7b9190615a95565b90506103e8613d8a8583615aae565b1015613d94578093505b613da2848360400151615350565b60608301819052600f546103e891613db991615aae565b1015613dc857600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d9191613e0f9130918b9190600401615b84565b6020604051808303816000875af1158015613e2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e529190615a95565b90508015613e7057613e676003602b836148e5565b92505050610cef565b4360095414613e8557613e67600a602f612e8b565b613e95600f548360600151614987565b60a0840181905260208401826003811115613eb257613eb2615ac1565b6003811115613ec357613ec3615ac1565b9052506000905082602001516003811115613ee057613ee0615ac1565b14613f0257613e67600960318460200151600381111561315057613150615ac1565b6001600160a01b0386166000908152601060205260409020546060830151613f2a9190614987565b60c0840181905260208401826003811115613f4757613f47615ac1565b6003811115613f5857613f58615ac1565b9052506000905082602001516003811115613f7557613f75615ac1565b14613f9757613e67600960308460200151600381111561315057613150615ac1565b8160800151613fa4612968565b1015613fb657613e67600e6032612e8b565b60a0820151600f5560c08201516001600160a01b0387166000908152601060205260409020556080820151613fec9087906125f0565b306001600160a01b0316866001600160a01b0316600080516020615c3e833981519152846060015160405161402391815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b1580156140e757600080fd5b505af11580156140fb573d6000803e3d6000fd5b5060009250614108915050565b9695505050505050565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b8161414e84615a78565b93508360ff168151811061416457614164615a62565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8161418f84615a78565b93508360ff16815181106141a5576141a5615a62565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b816141d084615a78565b93508360ff16815181106141e6576141e6615a62565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b8161421184615a78565b93508360ff168151811061422757614227615a62565b6001600160e01b03199092166020928302919091019091015263073a938160e11b8161425284615a78565b93508360ff168151811061426857614268615a62565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b8161429384615a78565b93508360ff16815181106142a9576142a9615a62565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b816142d484615a78565b93508360ff16815181106142ea576142ea615a62565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b8161431584615a78565b93508360ff168151811061432b5761432b615a62565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b8161435684615a78565b93508360ff168151811061436c5761436c615a62565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b8161439784615a78565b93508360ff16815181106143ad576143ad615a62565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b816143d884615a78565b93508360ff16815181106143ee576143ee615a62565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b8161441984615a78565b93508360ff168151811061442f5761442f615a62565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b8161445a84615a78565b93508360ff168151811061447057614470615a62565b6001600160e01b03199092166020928302919091019091015260ff8216156108235760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610518565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e19061451890309089908990600401615b84565b6020604051808303816000875af1158015614537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061455b9190615a95565b9050801561457c5761457060036021836148e5565b600092509250506148de565b436009541461459157614570600a6024612e8b565b6145d26040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146349190615a95565b60408201526146438686612702565b60c0820181905260408051602081018252908301518152614664919061538b565b606083018190526020830182600381111561468157614681615ac1565b600381111561469257614692615ac1565b90525060009050816020015160038111156146af576146af615ac1565b146146fc5760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610518565b60008160600151116147505760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a45435445440000000000006044820152606401610518565b8060600151600f546147629190615a4f565b608082015260608101516001600160a01b03871660009081526010602052604090205461478f9190615a4f565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b0316600080516020615c3e833981519152836060015160405161483e91815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b1580156148b157600080fd5b505af11580156148c5573d6000803e3d6000fd5b50600092506148d2915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601181111561491a5761491a615ac1565b84606181111561492c5761492c615ac1565b604080519283526020830191909152810184905260600160405180910390a1600384601181111561495f5761495f615ac1565b1461497b5783601181111561497657614976615ac1565b610d63565b610d63826103e8615a4f565b6000808383116149a657600061499d8486615aae565b915091506148de565b506003905060006148de565b6000670de0b6b3a76400006149cb84846000015161539b565b6108209190615bbe565b6000806149e284846153dd565b9050610d638161540e565b600080838301848110614a05576000925090506148de565b6002600092509250506148de565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c90614a5090309088908890600401615b84565b6020604051808303816000875af1158015614a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a939190615a95565b90508015614ab057614aa860036010836148e5565b915050610823565b4360095414614ac557614aa8600a600c612e8b565b6000614acf612968565b905083811015614aee57614ae5600e600b612e8b565b92505050610823565b614b1a604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b879190615a95565b60208201819052614b9890866149ed565b6040830181905282826003811115614bb257614bb2615ac1565b6003811115614bc357614bc3615ac1565b9052506000905081516003811115614bdd57614bdd615ac1565b14614c0957614bff6009600e8360000151600381111561315057613150615ac1565b9350505050610823565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c869190615a95565b92508215614c9b57614bff60036010856148e5565b614ca7600b54866149ed565b6060830181905282826003811115614cc157614cc1615ac1565b6003811115614cd257614cd2615ac1565b9052506000905081516003811115614cec57614cec615ac1565b14614d0e57614bff6009600d8360000151600381111561315057613150615ac1565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b55614d4a86866125f0565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af1158015614e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e489190615a95565b90508015614e6957614e5d60036014836148e5565b60009250925050615262565b4360095414614e7e57614e5d600a6018612e8b565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ebd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee19190615a95565b14614ef257614e5d600a6013612e8b565b866001600160a01b0316866001600160a01b031603614f1757614e5d60066019612e8b565b84600003614f2b57614e5d60076017612e8b565b6000198503614f4057614e5d60076016612e8b565b600080614f4e8989896136be565b90925090508115614f8357614f75826011811115614f6e57614f6e615ac1565b601a612e8b565b600094509450505050615262565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b90614fc09030908c908890600401615b84565b6040805180830381865afa158015614fdc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150009190615bd2565b9092509050811561506f5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b6064820152608401610518565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa1580156150b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150dc9190615a95565b101561512a5760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d55434800000000000000006044820152606401610518565b6000306001600160a01b038a160361514f57615148308d8d85612f87565b90506151c5565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff19061517f908f908f908790600401615b84565b6020604051808303816000875af115801561519e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151c29190615a95565b90505b80156151fc5760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b6044820152606401610518565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6060600080856001600160a01b0316856040516152889190615bf6565b6000604051808303816000865af19150503d80600081146152c5576040519150601f19603f3d011682016040523d82523d6000602084013e6152ca565b606091505b5091509150816128cc578051156152e45780518082602001fd5b8360405162461bcd60e51b81526004016105189190615708565b60008060008061530e8686615426565b9092509050600082600381111561532757615327615ac1565b1461533857509150600090506148de565b60006153438261540e565b9350935050509250929050565b60008161536584670de0b6b3a7640000615c12565b61536f9190615bbe565b905061537b8284615c29565b1561082357610820600182615a4f565b60008060008061530e86866154a2565b600061082083836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615515565b604080516020810190915260008152604051806020016040528061540585600001518561539b565b90529392505050565b805160009061082390670de0b6b3a764000090615bbe565b600061543e6040518060200160405280600081525090565b60008061544f866000015186615568565b9092509050600082600381111561546857615468615ac1565b14615487575060408051602081019091526000815290925090506148de565b60408051602081019091529081526000969095509350505050565b60006154ba6040518060200160405280600081525090565b6000806154cf670de0b6b3a764000087615568565b909250905060008260038111156154e8576154e8615ac1565b14615507575060408051602081019091526000815290925090506148de565b6153438186600001516155aa565b6000831580615522575082155b1561552f57506000610cef565b600061553b8486615c12565b9050836155488683615bbe565b1483906106f25760405162461bcd60e51b81526004016105189190615708565b6000808360000361557e575060009050806148de565b8383028361558c8683615bbe565b1461559f576002600092509250506148de565b6000925090506148de565b60006155c26040518060200160405280600081525090565b6000806155d786670de0b6b3a7640000615568565b909250905060008260038111156155f0576155f0615ac1565b1461560f575060408051602081019091526000815290925090506148de565b60008061561c8388615675565b9092509050600082600381111561563557615635615ac1565b1461565857816040518060200160405280600081525095509550505050506148de565b604080516020810190915290815260009890975095505050505050565b6000808260000361568c57506001905060006148de565b60006156988486615bbe565b915091509250929050565b6001600160a01b0381168114610ab757600080fd5b600080604083850312156156cb57600080fd5b82356156d6816156a3565b946020939093013593505050565b60005b838110156156ff5781810151838201526020016156e7565b50506000910152565b60208152600082518060208401526157278160408501602087016156e4565b601f01601f19169190910160400192915050565b60006020828403121561574d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561577c57600080fd5b813567ffffffffffffffff8082111561579457600080fd5b818401915084601f8301126157a857600080fd5b8135818111156157ba576157ba615754565b604051601f8201601f19908116603f011681019083821181831017156157e2576157e2615754565b816040528281528760208487010111156157fb57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561582e57600080fd5b8235615839816156a3565b91506020830135615849816156a3565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156158965783516001600160e01b03191683529284019291840191600101615870565b50909695505050505050565b6000806000606084860312156158b757600080fd5b83356158c2816156a3565b925060208401356158d2816156a3565b929592945050506040919091013590565b6000806000606084860312156158f857600080fd5b8335615903816156a3565b925060208401359150604084013561591a816156a3565b809150509250925092565b600181811c9082168061593957607f821691505b60208210810361152457634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561599e57600080fd5b81518015158114610cef57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b600060208284031215615a1457600080fd5b8151610cef816156a3565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561082357610823615a39565b634e487b7160e01b600052603260045260246000fd5b600060ff821680615a8b57615a8b615a39565b6000190192915050565b600060208284031215615aa757600080fd5b5051919050565b8181038181111561082357610823615a39565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b600082615bcd57615bcd615ba8565b500490565b60008060408385031215615be557600080fd5b505080516020909101519092909150565b60008251615c088184602087016156e4565b9190910192915050565b808202811582820484141761082357610823615a39565b600082615c3857615c38615ba8565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122042c4a52d6659264c8a0ac0075ec49984084e63a61e7a6203f4630a4f29f2c59164736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061023d5760003560e01c80637e5465ba1161013b578063b0d58e49116100b8578063c91a424f1161007c578063c91a424f14610468578063cb2ef6f71461047b578063db006a75146104ac578063f3fdb15a146104bf578063f5e3c462146104d257600080fd5b8063b0d58e4914610417578063b2a02ff11461042a578063be99f1191461043d578063c3bf11cd1461044c578063c5ebeaec1461045557600080fd5b806395d89b41116100ff57806395d89b41146103d75780639826394b146103df578063a0712d68146103e8578063a7b820df146103fb578063aa5af0fd1461040e57600080fd5b80637e5465ba1461038a578063852a12e31461039d57806389f8132e146103b05780638d02d9a1146103c55780638f840ddd146103ce57600080fd5b80633b1d21a2116101c95780635fe3b5671161018d5780635fe3b5671461033f57806361feacff146103575780636752e702146103605780636c540baf1461036e5780636f307dc31461037757600080fd5b80633b1d21a2146102f05780633c4f743c146102f857806347bd3718146103235780634e71d92d1461025557806356e677281461032c57600080fd5b8063173b990411610210578063173b9904146102a957806318160ddd146102b25780632608f818146102bb5780632c436e5b146102ce578063313ce567146102e357600080fd5b8063067db1b31461024257806306fdde03146102575780630e75270214610275578063135f133414610296575b600080fd5b6102556102503660046156b8565b6104e5565b005b61025f61052f565b60405161026c9190615708565b60405180910390f35b61028861028336600461573b565b6105bd565b60405190815260200161026c565b6102886102a43660046156b8565b6107dd565b61028860085481565b610288600f5481565b6102886102c93660046156b8565b610829565b60035b60405160ff909116815260200161026c565b6003546102d19060ff1681565b610288610a59565b60145461030b906001600160a01b031681565b6040516001600160a01b03909116815260200161026c565b610288600b5481565b61025561033a36600461576a565b610a68565b60035461030b9061010090046001600160a01b031681565b610288600d5481565b610288666379da05b6000081565b61028860095481565b60135461030b906001600160a01b031681565b61025561039836600461581b565b610aba565b6102886103ab36600461573b565b610bbc565b6103b8610dd2565b60405161026c9190615854565b61028860065481565b610288600c5481565b61025f610f82565b610288600e5481565b6102886103f636600461573b565b610f8f565b61028861040936600461573b565b61119c565b610288600a5481565b61028861042536600461573b565b61152a565b6102886104383660046158a2565b6117e9565b61028867016345785d8a000081565b61028860075481565b61028861046336600461573b565b611983565b60005461030b906001600160a01b031681565b6040805180820190915260158152744345726332305265776172647344656c656761746560581b602082015261025f565b6102886104ba36600461573b565b611b8a565b60045461030b906001600160a01b031681565b6102886104e03660046158e3565b611d91565b3330146105215760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b60448201526064015b60405180910390fd5b61052b82826125f0565b5050565b6001805461053c90615925565b80601f016020809104026020016040519081016040528092919081815260200182805461056890615925565b80156105b55780601f1061058a576101008083540402835291602001916105b5565b820191906000526020600020905b81548152906001019060200180831161059857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261060a9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064b919061598c565b6106675760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610696906004016159d6565b602060405180830381865afa1580156106b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d79190615a02565b90506001600160a01b0381166106fb5760006106f284612671565b50949350505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561073e57600080fd5b505af1158015610752573d6000803e3d6000fd5b50503332039150610774905057600061076a85612671565b5095945050505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906107a29032903390600401615a1f565b60006040518083038186803b1580156107ba57600080fd5b505afa1580156107ce573d6000803e3d6000fd5b50505050600061076a85612671565b60003330146108165760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b6044820152606401610518565b6108208383612702565b90505b92915050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926108769261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b7919061598c565b6108d35760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610902906004016159d6565b602060405180830381865afa15801561091f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109439190615a02565b90506001600160a01b03811661096957600061095f85856128d5565b5092505050610823565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156109ac57600080fd5b505af11580156109c0573d6000803e3d6000fd5b505033320391506109e490505760006109d986866128d5565b509350505050610823565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610a129032903390600401615a1f565b60006040518083038186803b158015610a2a57600080fd5b505afa158015610a3e573d6000803e3d6000fd5b505050506000610a4e86866128d5565b509695505050505050565b6000610a63612968565b905090565b33301480610a795750610a796129d5565b610ab75760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b6044820152606401610518565b50565b610ac26129d5565b610af75760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610518565b6013546001600160a01b0390811690831603610b435760405162461bcd60e51b815260206004820152600b60248201526a21756e6465726c79696e6760a81b6044820152606401610518565b60405163095ea7b360e01b81526001600160a01b038281166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1158015610b93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb7919061598c565b505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610c099261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a919061598c565b610c665760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610c95906004016159d6565b602060405180830381865afa158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd69190615a02565b90506001600160a01b038116610cf657610cef83612b52565b9392505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50503332039150610d6b905057610d6384612b52565b949350505050565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90610d999032903390600401615a1f565b60006040518083038186803b158015610db157600080fd5b505afa158015610dc5573d6000803e3d6000fd5b50505050610d6384612b52565b606060026000610de0612bda565b90508160ff168151610df29190615a4f565b67ffffffffffffffff811115610e0a57610e0a615754565b604051908082528060200260200182016040528015610e33578160200160208202803683370190505b50925060005b8151811015610e8f57818181518110610e5457610e54615a62565b6020026020010151848281518110610e6e57610e6e615a62565b6001600160e01b031990921660209283029190910190910152600101610e39565b508051634e71d92d60e01b908490610ea685615a78565b9450610eb59060ff8616615a4f565b81518110610ec557610ec5615a62565b6001600160e01b0319909216602092830291909101909101528051633f2a32dd60e11b908490610ef485615a78565b9450610f039060ff8616615a4f565b81518110610f1357610f13615a62565b6001600160e01b03199092166020928302919091019091015260ff821615610f7d5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610518565b505090565b6002805461053c90615925565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892610fdc9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015610ff9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101d919061598c565b6110395760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611068906004016159d6565b602060405180830381865afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190615a02565b90506001600160a01b0381166110c45760006106f284612d4a565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561110757600080fd5b505af115801561111b573d6000803e3d6000fd5b50503332039150611133905057600061076a85612d4a565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906111619032903390600401615a1f565b60006040518083038186803b15801561117957600080fd5b505afa15801561118d573d6000803e3d6000fd5b50505050600061076a85612d4a565b6000806111a881612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac1906111d7906004016159d6565b602060405180830381865afa1580156111f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112189190615a02565b90506001600160a01b03811661137057306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611268573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128c9190615a95565b5043600954146112a9576112a2600a6039612e8b565b925061136a565b836112b2612968565b10156112c4576112a2600e6038612e8b565b600d548411156112da576112a26002603a612e8b565b83600d546112e89190615aae565b600d55600354604080516303e1469160e61b815290516113659261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa15801561133b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135f9190615a02565b856125f0565b600092505b5061151b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906113a09032903390600401615a1f565b60006040518083038186803b1580156113b857600080fd5b505afa1580156113cc573d6000803e3d6000fd5b505050506113d73090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611416573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143a9190615a95565b50436009541461145757611450600a6039612e8b565b9350611518565b84611460612968565b101561147257611450600e6038612e8b565b600d54851115611488576114506002603a612e8b565b84600d546114969190615aae565b600d55600354604080516303e1469160e61b815290516115139261010090046001600160a01b03169163f851a4409160048083019260209291908290030181865afa1580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150d9190615a02565b866125f0565b600093505b50505b61152481612f04565b50919050565b60008061153681612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611565906004016159d6565b602060405180830381865afa158015611582573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a69190615a02565b90506001600160a01b03811661169a57306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156115f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161a9190615a95565b504360095414611630576112a2600a6035612e8b565b83611639612968565b101561164b576112a2600e6034612e8b565b600e54841115611661576112a260026036612e8b565b600084600e546116719190615aae565b600e81905560005490915061168f906001600160a01b0316866125f0565b60009350505061151b565b604051633108c13b60e01b815281906001600160a01b03821690633108c13b906116ca9032903390600401615a1f565b60006040518083038186803b1580156116e257600080fd5b505afa1580156116f6573d6000803e3d6000fd5b505050506117013090565b6001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117649190615a95565b50436009541461177a57611450600a6035612e8b565b84611783612968565b101561179557611450600e6034612e8b565b600e548511156117ab5761145060026036612e8b565b600085600e546117bb9190615aae565b600e8190556000549091506117d9906001600160a01b0316876125f0565b6000945050505061152481612f04565b600060016117f681612dc7565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611825906004016159d6565b602060405180830381865afa158015611842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118669190615a02565b90506001600160a01b03811661188a5761188233878787612f87565b925050611972565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156118cd57600080fd5b505af11580156118e1573d6000803e3d6000fd5b505033320391506119039050576118fa33888888612f87565b93505050611972565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906119319032903390600401615a1f565b60006040518083038186803b15801561194957600080fd5b505afa15801561195d573d6000803e3d6000fd5b5050505061196d33888888612f87565b935050505b61197b81612f04565b509392505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb8926119d09261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa1580156119ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a11919061598c565b611a2d5760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611a5c906004016159d6565b602060405180830381865afa158015611a79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9d9190615a02565b90506001600160a01b038116611ab657610cef8361346f565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611af957600080fd5b505af1158015611b0d573d6000803e3d6000fd5b50503332039150611b23905057610d638461346f565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611b519032903390600401615a1f565b60006040518083038186803b158015611b6957600080fd5b505afa158015611b7d573d6000803e3d6000fd5b50505050610d638461346f565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611bd79261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015611bf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c18919061598c565b611c345760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611c63906004016159d6565b602060405180830381865afa158015611c80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca49190615a02565b90506001600160a01b038116611cbd57610cef836134ea565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015611d0057600080fd5b505af1158015611d14573d6000803e3d6000fd5b50503332039150611d2a905057610d63846134ea565b604051633108c13b60e01b81526001600160a01b03821690633108c13b90611d589032903390600401615a1f565b60006040518083038186803b158015611d7057600080fd5b505afa158015611d84573d6000803e3d6000fd5b50505050610d63846134ea565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb892611dde9261010090910490911690339030906001600160e01b031988351690600401615959565b602060405180830381865afa158015611dfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1f919061598c565b611e3b5760405162461bcd60e51b8152600401610518906159ae565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611e6a906004016159d6565b602060405180830381865afa158015611e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eab9190615a02565b90506001600160a01b0381166120e05760145460405163bf40fac160e01b815286916000916001600160a01b039091169063bf40fac190611eee90600401615ad7565b602060405180830381865afa158015611f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2f9190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac190611f6390600401615af9565b602060405180830381865afa158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa49190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fe4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120089190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261203f92899261010090041690600401615a1f565b602060405180830381865afa15801561205c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120809190615a95565b11156120c557336001600160a01b038216146120ae5760405162461bcd60e51b815260040161051890615b27565b60006120bb898989613567565b5095506120d79050565b60006120d2898989613567565b509550505b50505050610cef565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561212357600080fd5b505af1158015612137573d6000803e3d6000fd5b5050333203915061236a90505760145460405163bf40fac160e01b815287916000916001600160a01b039091169063bf40fac19061217790600401615ad7565b602060405180830381865afa158015612194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b89190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac1906121ec90600401615af9565b602060405180830381865afa158015612209573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222d9190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561226d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122919190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d926122c892899261010090041690600401615a1f565b602060405180830381865afa1580156122e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123099190615a95565b111561234e57336001600160a01b038216146123375760405162461bcd60e51b815260040161051890615b27565b60006123448a8a8a613567565b5096506123609050565b600061235b8a8a8a613567565b509650505b5050505050610cef565b604051633108c13b60e01b81526001600160a01b03821690633108c13b906123989032903390600401615a1f565b60006040518083038186803b1580156123b057600080fd5b505afa1580156123c4573d6000803e3d6000fd5b505060145460405163bf40fac160e01b8152899350600092506001600160a01b039091169063bf40fac1906123fb90600401615ad7565b602060405180830381865afa158015612418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243c9190615a02565b60145460405163bf40fac160e01b81529192506000916001600160a01b039091169063bf40fac19061247090600401615af9565b602060405180830381865afa15801561248d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124b19190615a02565b9050806001600160a01b0316632c89aa2e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125159190615a95565b6003546040516357c89a7d60e01b81526001600160a01b03808616926357c89a7d9261254c92899261010090041690600401615a1f565b602060405180830381865afa158015612569573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258d9190615a95565b11156125d257336001600160a01b038216146125bb5760405162461bcd60e51b815260040161051890615b27565b60006125c88a8a8a613567565b5096506125e49050565b60006125df8a8a8a613567565b509650505b50505050509392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091018252602080820180516001600160e01b031663a9059cbb60e01b1790528251808401909352601983527f544f4b454e5f5452414e534645525f4f55545f4641494c4544000000000000009083015261052b91613661565b600080600061267f81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156126bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e39190615a95565b506126ef3333866136be565b925092506126fc81612f04565b50915091565b6013546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561274f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127739190615a95565b90506128036323b872dd60e01b85308660405160240161279593929190615b84565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280601881526020017f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000815250613661565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561284c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128709190615a95565b9050818110156128c25760405162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f570000000000006044820152606401610518565b6128cc8282615aae565b95945050505050565b60008060006128e381612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612923573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129479190615a95565b506129533386866136be565b9250925061296081612f04565b509250929050565b6013546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156129b1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a639190615a95565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a529190615a02565b6001600160a01b0316336001600160a01b0316148015612acf5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612acf919061598c565b80612b4c57506000546001600160a01b031633148015612b4c5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4c919061598c565b91505090565b600080612b5e81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc29190615a95565b50612bcf33600085613acb565b915061152481612f04565b606060036000612be8614112565b90508160ff168151612bfa9190615a4f565b67ffffffffffffffff811115612c1257612c12615754565b604051908082528060200260200182016040528015612c3b578160200160208202803683370190505b50925060005b8151811015612c9757818181518110612c5c57612c5c615a62565b6020026020010151848281518110612c7657612c76615a62565b6001600160e01b031990921660209283029190910190910152600101612c41565b50805163cb2ef6f760e01b908490612cae85615a78565b9450612cbd9060ff8616615a4f565b81518110612ccd57612ccd615a62565b6001600160e01b0319909216602092830291909101909101528051632c436e5b60e01b908490612cfc85615a78565b9450612d0b9060ff8616615a4f565b81518110612d1b57612d1b615a62565b6001600160e01b0319909216602092830291909101909101528051630adccee560e31b908490610ef485615a78565b6000806000612d5881612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dbc9190615a95565b506126ef33856144da565b600054600160a01b900460ff16612e0d5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610518565b80612e7b57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612e6257600080fd5b505af1158015612e76573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836011811115612ec057612ec0615ac1565b836061811115612ed257612ed2615ac1565b60408051928352602083019190915260009082015260600160405180910390a182601181111561082057610820615ac1565b6000805460ff60a01b1916600160a01b17905580610ab757600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612f6c57600080fd5b505af1158015612f80573d6000803e3d6000fd5b5050505050565b60035460405163d02f735160e01b81523060048201526001600160a01b038681166024830152858116604483015284811660648301526084820184905260009283926101009091049091169063d02f73519060a4016020604051808303816000875af1158015612ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301f9190615a95565b9050801561303c576130346003601d836148e5565b915050610d63565b846001600160a01b0316846001600160a01b031603613061576130346006601e612e8b565b6130c6604080516101808101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152601060205260409020546130e99085614987565b602083018190528282600381111561310357613103615ac1565b600381111561311457613114615ac1565b905250600090508151600381111561312e5761312e615ac1565b1461315e576131556009601c8360000151600381111561315057613150615ac1565b6148e5565b92505050610d63565b61317d846040518060200160405280666379da05b600008152506149b2565b6080820152604080516020810190915267016345785d8a000081526131a39085906149b2565b610140820181905260808201516131ba9086615aae565b6131c49190615aae565b6060820152306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322b9190615a95565b60c08201908152604080516020810190915290518152608082015161325091906149d5565b60a0820152604080516020810190915260c0820151815261014082015161327791906149d5565b61016082015260a0810151600c5461328f9190615a4f565b60e08201526101408101516080820151600f546132ac9190615aae565b6132b69190615aae565b610120820152610160810151600e546132cf9190615a4f565b6101008201526001600160a01b03861660009081526010602052604090205460608201516132fd91906149ed565b604083018190528282600381111561331757613317615ac1565b600381111561332857613328615ac1565b905250600090508151600381111561334257613342615ac1565b14613364576131556009601b8360000151600381111561315057613150615ac1565b60e0810151600c55610120810151600f55610100810151600e556020808201516001600160a01b0387811660008181526010855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615c3e833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615c3e833981519152836080015160405161341191815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a15060009695505050505050565b60008061347b81612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156134bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134df9190615a95565b50612bcf3384614a13565b6000806134f681612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015613536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355a9190615a95565b50612bcf33846000613acb565b600080600061357581612dc7565b306001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af11580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d99190615a95565b50836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561361a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363e9190615a95565b5061364b33878787614dae565b9250925061365881612f04565b50935093915050565b60135460009061367b906001600160a01b0316848461526b565b805190915015610bb75780806020019051810190613699919061598c565b82906136b85760405162461bcd60e51b81526004016105189190615708565b50505050565b600354604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392610100909204909116906324008a62906084016020604051808303816000875af115801561372c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137509190615a95565b905080156137715761376560036043836148e5565b60009250925050613ac3565b436009541461378657613765600a6044612e8b565b6137cf6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601260205260409020600101546060820152306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015613839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385d9190615a95565b6080820152600185016138795760808101516040820152613881565b604081018590525b61388f878260400151612702565b60e0820181905260808201516138a491614987565b60a08301819052602083018260038111156138c1576138c1615ac1565b60038111156138d2576138d2615ac1565b90525060009050816020015160038111156138ef576138ef615ac1565b146139625760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c45440000000000006064820152608401610518565b613972600b548260e00151614987565b60c083018190526020830182600381111561398f5761398f615ac1565b60038111156139a0576139a0615ac1565b90525060009050816020015160038111156139bd576139bd615ac1565b14613a245760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b6064820152608401610518565b60a081810180516001600160a01b03898116600081815260126020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600093509150505b935093915050565b6000821580613ad8575081155b613b245760405162461bcd60e51b815260206004820152601860248201527f2172656465656d20746f6b656e73206f7220616d6f756e7400000000000000006044820152606401610518565b613b656040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bc79190615a95565b60408201528315613c8a5761138884600f54613be39190615aae565b1015613bef57600f5493505b6060810184905260408051602081018252908201518152613c1090856152fe565b6080830181905260208301826003811115613c2d57613c2d615ac1565b6003811115613c3e57613c3e615ac1565b9052506000905081602001516003811115613c5b57613c5b615ac1565b14613c8557613c7d6009602c8360200151600381111561315057613150615ac1565b915050610cef565b613dd1565b6000198303613d1757600354604051630cbb414760e11b81526001600160a01b0387811660048301523060248301526000604483015261010090920490911690631976828e90606401602060405180830381865afa158015613cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d149190615a95565b92505b6000306001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7b9190615a95565b90506103e8613d8a8583615aae565b1015613d94578093505b613da2848360400151615350565b60608301819052600f546103e891613db991615aae565b1015613dc857600f5460608301525b50608081018390525b600354606082015160405163eabe7d9160e01b815260009261010090046001600160a01b03169163eabe7d9191613e0f9130918b9190600401615b84565b6020604051808303816000875af1158015613e2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e529190615a95565b90508015613e7057613e676003602b836148e5565b92505050610cef565b4360095414613e8557613e67600a602f612e8b565b613e95600f548360600151614987565b60a0840181905260208401826003811115613eb257613eb2615ac1565b6003811115613ec357613ec3615ac1565b9052506000905082602001516003811115613ee057613ee0615ac1565b14613f0257613e67600960318460200151600381111561315057613150615ac1565b6001600160a01b0386166000908152601060205260409020546060830151613f2a9190614987565b60c0840181905260208401826003811115613f4757613f47615ac1565b6003811115613f5857613f58615ac1565b9052506000905082602001516003811115613f7557613f75615ac1565b14613f9757613e67600960308460200151600381111561315057613150615ac1565b8160800151613fa4612968565b1015613fb657613e67600e6032612e8b565b60a0820151600f5560c08201516001600160a01b0387166000908152601060205260409020556080820151613fec9087906125f0565b306001600160a01b0316866001600160a01b0316600080516020615c3e833981519152846060015160405161402391815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600354608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906351dff98990608401600060405180830381600087803b1580156140e757600080fd5b505af11580156140fb573d6000803e3d6000fd5b5060009250614108915050565b9695505050505050565b60408051600d8082526101c082019092526060919060009082602082016101a08036833701905050905063140e25ad60e31b8161414e84615a78565b93508360ff168151811061416457614164615a62565b6001600160e01b03199092166020928302919091019091015263db006a7560e01b8161418f84615a78565b93508360ff16815181106141a5576141a5615a62565b6001600160e01b03199092166020928302919091019091015263852a12e360e01b816141d084615a78565b93508360ff16815181106141e6576141e6615a62565b6001600160e01b03199092166020928302919091019091015263317afabb60e21b8161421184615a78565b93508360ff168151811061422757614227615a62565b6001600160e01b03199092166020928302919091019091015263073a938160e11b8161425284615a78565b93508360ff168151811061426857614268615a62565b6001600160e01b0319909216602092830291909101909101526304c11f0360e31b8161429384615a78565b93508360ff16815181106142a9576142a9615a62565b6001600160e01b031990921660209283029190910190910152637af1e23160e11b816142d484615a78565b93508360ff16815181106142ea576142ea615a62565b6001600160e01b031990921660209283029190910190910152631d8e90d160e11b8161431584615a78565b93508360ff168151811061432b5761432b615a62565b6001600160e01b03199092166020928302919091019091015263b2a02ff160e01b8161435684615a78565b93508360ff168151811061436c5761436c615a62565b6001600160e01b03199092166020928302919091019091015263067db1b360e01b8161439784615a78565b93508360ff16815181106143ad576143ad615a62565b6001600160e01b0319909216602092830291909101909101526304d7c4cd60e21b816143d884615a78565b93508360ff16815181106143ee576143ee615a62565b6001600160e01b03199092166020928302919091019091015263b0d58e4960e01b8161441984615a78565b93508360ff168151811061442f5761442f615a62565b6001600160e01b03199092166020928302919091019091015263a7b820df60e01b8161445a84615a78565b93508360ff168151811061447057614470615a62565b6001600160e01b03199092166020928302919091019091015260ff8216156108235760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610518565b600354604051634ef4c3e160e01b81526000918291829161010090046001600160a01b031690634ef4c3e19061451890309089908990600401615b84565b6020604051808303816000875af1158015614537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061455b9190615a95565b9050801561457c5761457060036021836148e5565b600092509250506148de565b436009541461459157614570600a6024612e8b565b6145d26040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b306001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146349190615a95565b60408201526146438686612702565b60c0820181905260408051602081018252908301518152614664919061538b565b606083018190526020830182600381111561468157614681615ac1565b600381111561469257614692615ac1565b90525060009050816020015160038111156146af576146af615ac1565b146146fc5760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610518565b60008160600151116147505760405162461bcd60e51b815260206004820152601a60248201527f4d494e545f5a45524f5f43544f4b454e535f52454a45435445440000000000006044820152606401610518565b8060600151600f546147629190615a4f565b608082015260608101516001600160a01b03871660009081526010602052604090205461478f9190615a4f565b60a082018190526080820151600f556001600160a01b0387166000818152601060209081526040918290209390935560c0840151606080860151835194855294840191909152908201929092527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a1856001600160a01b0316306001600160a01b0316600080516020615c3e833981519152836060015160405161483e91815260200190565b60405180910390a360035460c082015160608301516040516341c728b960e01b81523060048201526001600160a01b038a811660248301526044820193909352606481019190915261010090920416906341c728b990608401600060405180830381600087803b1580156148b157600080fd5b505af11580156148c5573d6000803e3d6000fd5b50600092506148d2915050565b8160c001519350935050505b9250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601181111561491a5761491a615ac1565b84606181111561492c5761492c615ac1565b604080519283526020830191909152810184905260600160405180910390a1600384601181111561495f5761495f615ac1565b1461497b5783601181111561497657614976615ac1565b610d63565b610d63826103e8615a4f565b6000808383116149a657600061499d8486615aae565b915091506148de565b506003905060006148de565b6000670de0b6b3a76400006149cb84846000015161539b565b6108209190615bbe565b6000806149e284846153dd565b9050610d638161540e565b600080838301848110614a05576000925090506148de565b6002600092509250506148de565b60035460405163368f515360e21b815260009182916101009091046001600160a01b03169063da3d454c90614a5090309088908890600401615b84565b6020604051808303816000875af1158015614a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a939190615a95565b90508015614ab057614aa860036010836148e5565b915050610823565b4360095414614ac557614aa8600a600c612e8b565b6000614acf612968565b905083811015614aee57614ae5600e600b612e8b565b92505050610823565b614b1a604080516080810190915280600081526020016000815260200160008152602001600081525090565b306040516305eff7ef60e21b81526001600160a01b03888116600483015291909116906317bfdfbc90602401602060405180830381865afa158015614b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b879190615a95565b60208201819052614b9890866149ed565b6040830181905282826003811115614bb257614bb2615ac1565b6003811115614bc357614bc3615ac1565b9052506000905081516003811115614bdd57614bdd615ac1565b14614c0957614bff6009600e8360000151600381111561315057613150615ac1565b9350505050610823565b6003546040828101519051631de6c8a560e21b815230600482015260248101919091526101009091046001600160a01b03169063779b229490604401602060405180830381865afa158015614c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c869190615a95565b92508215614c9b57614bff60036010856148e5565b614ca7600b54866149ed565b6060830181905282826003811115614cc157614cc1615ac1565b6003811115614cd257614cd2615ac1565b9052506000905081516003811115614cec57614cec615ac1565b14614d0e57614bff6009600d8360000151600381111561315057613150615ac1565b6040808201516001600160a01b0388166000908152601260205291909120908155600a546001909101556060810151600b55614d4a86866125f0565b60408082015160608084015183516001600160a01b038b168152602081018a9052938401929092528201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a160009695505050505050565b600354604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839261010090920490911690635fc7e71e9060a4016020604051808303816000875af1158015614e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e489190615a95565b90508015614e6957614e5d60036014836148e5565b60009250925050615262565b4360095414614e7e57614e5d600a6018612e8b565b43846001600160a01b0316636c540baf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ebd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee19190615a95565b14614ef257614e5d600a6013612e8b565b866001600160a01b0316866001600160a01b031603614f1757614e5d60066019612e8b565b84600003614f2b57614e5d60076017612e8b565b6000198503614f4057614e5d60076016612e8b565b600080614f4e8989896136be565b90925090508115614f8357614f75826011811115614f6e57614f6e615ac1565b601a612e8b565b600094509450505050615262565b60035460405163c488847b60e01b815260009182916101009091046001600160a01b03169063c488847b90614fc09030908c908890600401615b84565b6040805180830381865afa158015614fdc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150009190615bd2565b9092509050811561506f5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b6064820152608401610518565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa1580156150b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150dc9190615a95565b101561512a5760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d55434800000000000000006044820152606401610518565b6000306001600160a01b038a160361514f57615148308d8d85612f87565b90506151c5565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff19061517f908f908f908790600401615b84565b6020604051808303816000875af115801561519e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151c29190615a95565b90505b80156151fc5760405162461bcd60e51b8152602060048201526006602482015265217365697a6560d01b6044820152606401610518565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6060600080856001600160a01b0316856040516152889190615bf6565b6000604051808303816000865af19150503d80600081146152c5576040519150601f19603f3d011682016040523d82523d6000602084013e6152ca565b606091505b5091509150816128cc578051156152e45780518082602001fd5b8360405162461bcd60e51b81526004016105189190615708565b60008060008061530e8686615426565b9092509050600082600381111561532757615327615ac1565b1461533857509150600090506148de565b60006153438261540e565b9350935050509250929050565b60008161536584670de0b6b3a7640000615c12565b61536f9190615bbe565b905061537b8284615c29565b1561082357610820600182615a4f565b60008060008061530e86866154a2565b600061082083836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615515565b604080516020810190915260008152604051806020016040528061540585600001518561539b565b90529392505050565b805160009061082390670de0b6b3a764000090615bbe565b600061543e6040518060200160405280600081525090565b60008061544f866000015186615568565b9092509050600082600381111561546857615468615ac1565b14615487575060408051602081019091526000815290925090506148de565b60408051602081019091529081526000969095509350505050565b60006154ba6040518060200160405280600081525090565b6000806154cf670de0b6b3a764000087615568565b909250905060008260038111156154e8576154e8615ac1565b14615507575060408051602081019091526000815290925090506148de565b6153438186600001516155aa565b6000831580615522575082155b1561552f57506000610cef565b600061553b8486615c12565b9050836155488683615bbe565b1483906106f25760405162461bcd60e51b81526004016105189190615708565b6000808360000361557e575060009050806148de565b8383028361558c8683615bbe565b1461559f576002600092509250506148de565b6000925090506148de565b60006155c26040518060200160405280600081525090565b6000806155d786670de0b6b3a7640000615568565b909250905060008260038111156155f0576155f0615ac1565b1461560f575060408051602081019091526000815290925090506148de565b60008061561c8388615675565b9092509050600082600381111561563557615635615ac1565b1461565857816040518060200160405280600081525095509550505050506148de565b604080516020810190915290815260009890975095505050505050565b6000808260000361568c57506001905060006148de565b60006156988486615bbe565b915091509250929050565b6001600160a01b0381168114610ab757600080fd5b600080604083850312156156cb57600080fd5b82356156d6816156a3565b946020939093013593505050565b60005b838110156156ff5781810151838201526020016156e7565b50506000910152565b60208152600082518060208401526157278160408501602087016156e4565b601f01601f19169190910160400192915050565b60006020828403121561574d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561577c57600080fd5b813567ffffffffffffffff8082111561579457600080fd5b818401915084601f8301126157a857600080fd5b8135818111156157ba576157ba615754565b604051601f8201601f19908116603f011681019083821181831017156157e2576157e2615754565b816040528281528760208487010111156157fb57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806040838503121561582e57600080fd5b8235615839816156a3565b91506020830135615849816156a3565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156158965783516001600160e01b03191683529284019291840191600101615870565b50909695505050505050565b6000806000606084860312156158b757600080fd5b83356158c2816156a3565b925060208401356158d2816156a3565b929592945050506040919091013590565b6000806000606084860312156158f857600080fd5b8335615903816156a3565b925060208401359150604084013561591a816156a3565b809150509250925092565b600181811c9082168061593957607f821691505b60208210810361152457634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561599e57600080fd5b81518015158114610cef57600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b600060208284031215615a1457600080fd5b8151610cef816156a3565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561082357610823615a39565b634e487b7160e01b600052603260045260246000fd5b600060ff821680615a8b57615a8b615a39565b6000190192915050565b600060208284031215615aa757600080fd5b5051919050565b8181038181111561082357610823615a39565b634e487b7160e01b600052602160045260246000fd5b602080825260089082015267506f6f6c4c656e7360c01b604082015260600190565b60208082526014908201527324b7b734b1aab734ab19a634b8bab4b230ba37b960611b604082015260600190565b6020808252603e908201527f4865616c746820666163746f72206e6f74206c6f7720656e6f75676820666f7260408201527f206e6f6e2d7065726d697373696f6e6564206c69717569646174696f6e730000606082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601260045260246000fd5b600082615bcd57615bcd615ba8565b500490565b60008060408385031215615be557600080fd5b505080516020909101519092909150565b60008251615c088184602087016156e4565b9190910192915050565b808202811582820484141761082357610823615a39565b600082615c3857615c38615ba8565b50069056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122042c4a52d6659264c8a0ac0075ec49984084e63a61e7a6203f4630a4f29f2c59164736f6c63430008160033", + "devdoc": { + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "functionSelectors": "a list of all the function selectors that this logic extension exposes" + } + }, + "_withdrawAdminFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_withdrawIonicFees(uint256)": { + "params": { + "withdrawAmount": "Amount of fees to withdraw" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "borrow(uint256)": { + "params": { + "borrowAmount": "The amount of the underlying asset to borrow" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "getCash()": { + "returns": { + "_0": "The quantity of underlying asset owned by this contract" + } + }, + "liquidateBorrow(address,uint256,address)": { + "params": { + "borrower": "The borrower of this cToken to be liquidated", + "cTokenCollateral": "The market in which to seize collateral from the borrower", + "repayAmount": "The amount of the underlying borrowed asset to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "mint(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "mintAmount": "The amount of the underlying asset to supply" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeem(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemTokens": "The number of cTokens to redeem into underlying" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "redeemUnderlying(uint256)": { + "details": "Accrues interest whether or not the operation succeeds, unless reverted", + "params": { + "redeemAmount": "The amount of underlying to redeem" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrow(uint256)": { + "params": { + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "repayBorrowBehalf(address,uint256)": { + "params": { + "borrower": "the account with the debt being payed off", + "repayAmount": "The amount to repay" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "seize(address,address,uint256)": { + "details": "Will fail unless called by another cToken during the process of liquidation. Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.", + "params": { + "borrower": "The account having collateral seized", + "liquidator": "The account receiving seized collateral", + "seizeTokens": "The number of cTokens to seize" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "AccrueInterest(uint256,uint256,uint256,uint256)": { + "notice": "Event emitted when interest is accrued" + }, + "Approval(address,address,uint256)": { + "notice": "EIP20 Approval event" + }, + "Borrow(address,uint256,uint256,uint256)": { + "notice": "Event emitted when underlying is borrowed" + }, + "LiquidateBorrow(address,address,uint256,address,uint256)": { + "notice": "Event emitted when a borrow is liquidated" + }, + "Mint(address,uint256,uint256)": { + "notice": "Event emitted when tokens are minted" + }, + "NewAdminFee(uint256,uint256)": { + "notice": "Event emitted when the admin fee is changed" + }, + "NewIonicFee(uint256,uint256)": { + "notice": "Event emitted when the Ionic fee is changed" + }, + "NewMarketInterestRateModel(address,address)": { + "notice": "Event emitted when interestRateModel is changed" + }, + "NewReserveFactor(uint256,uint256)": { + "notice": "Event emitted when the reserve factor is changed" + }, + "Redeem(address,uint256,uint256)": { + "notice": "Event emitted when tokens are redeemed" + }, + "RepayBorrow(address,address,uint256,uint256,uint256)": { + "notice": "Event emitted when a borrow is repaid" + }, + "ReservesAdded(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are added" + }, + "ReservesReduced(address,uint256,uint256)": { + "notice": "Event emitted when the reserves are reduced" + }, + "Transfer(address,address,uint256)": { + "notice": "EIP20 Transfer event" + } + }, + "kind": "user", + "methods": { + "_becomeImplementation(bytes)": { + "notice": "Called by the delegator on a delegate to initialize it for duty" + }, + "_withdrawAdminFees(uint256)": { + "notice": "Accrues interest and reduces admin fees by transferring to admin" + }, + "_withdrawIonicFees(uint256)": { + "notice": "Accrues interest and reduces Ionic fees by transferring to Ionic" + }, + "accrualBlockNumber()": { + "notice": "Block number that interest was last accrued at" + }, + "adminFeeMantissa()": { + "notice": "Fraction of interest currently set aside for admin fees" + }, + "ap()": { + "notice": "Addresses Provider" + }, + "approve(address,address)": { + "notice": "token approval function" + }, + "borrow(uint256)": { + "notice": "Sender borrows assets from the protocol to their own address" + }, + "borrowIndex()": { + "notice": "Accumulator of the total earned interest rate since the opening of the market" + }, + "claim()": { + "notice": "A reward token claim function to be overridden for use cases where rewardToken needs to be pulled in" + }, + "comptroller()": { + "notice": "Contract which oversees inter-cToken operations" + }, + "decimals()": { + "notice": "EIP-20 token decimals for this token" + }, + "getCash()": { + "notice": "Get cash balance of this cToken in the underlying asset" + }, + "interestRateModel()": { + "notice": "Model which tells what the current interest rate should be" + }, + "ionicFeeMantissa()": { + "notice": "Fraction of interest currently set aside for Ionic fees" + }, + "liquidateBorrow(address,uint256,address)": { + "notice": "The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator." + }, + "mint(uint256)": { + "notice": "Sender supplies assets into the market and receives cTokens in exchange" + }, + "name()": { + "notice": "EIP-20 token name for this token" + }, + "redeem(uint256)": { + "notice": "Sender redeems cTokens in exchange for the underlying asset" + }, + "redeemUnderlying(uint256)": { + "notice": "Sender redeems cTokens in exchange for a specified amount of underlying asset" + }, + "repayBorrow(uint256)": { + "notice": "Sender repays their own borrow" + }, + "repayBorrowBehalf(address,uint256)": { + "notice": "Sender repays a borrow belonging to borrower" + }, + "reserveFactorMantissa()": { + "notice": "Fraction of interest currently set aside for reserves" + }, + "seize(address,address,uint256)": { + "notice": "Transfers collateral tokens (this market) to the liquidator." + }, + "symbol()": { + "notice": "EIP-20 token symbol for this token" + }, + "totalAdminFees()": { + "notice": "Total amount of admin fees of the underlying held in this market" + }, + "totalBorrows()": { + "notice": "Total amount of outstanding borrows of the underlying in this market" + }, + "totalIonicFees()": { + "notice": "Total amount of Ionic fees of the underlying held in this market" + }, + "totalReserves()": { + "notice": "Total amount of reserves of the underlying held in this market" + }, + "totalSupply()": { + "notice": "Total number of tokens in circulation" + }, + "underlying()": { + "notice": "Underlying asset for this CToken" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 17997, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 18003, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "_notEntered", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 18006, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "name", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 18009, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "symbol", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 18012, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "decimals", + "offset": 0, + "slot": "3", + "type": "t_uint8" + }, + { + "astId": 18022, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "comptroller", + "offset": 1, + "slot": "3", + "type": "t_contract(IonicComptroller)25652" + }, + { + "astId": 18026, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "interestRateModel", + "offset": 0, + "slot": "4", + "type": "t_contract(InterestRateModel)28313" + }, + { + "astId": 18028, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "initialExchangeRateMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 18031, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "adminFeeMantissa", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 18034, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "ionicFeeMantissa", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 18037, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "reserveFactorMantissa", + "offset": 0, + "slot": "8", + "type": "t_uint256" + }, + { + "astId": 18040, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "accrualBlockNumber", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 18043, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "borrowIndex", + "offset": 0, + "slot": "10", + "type": "t_uint256" + }, + { + "astId": 18046, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "totalBorrows", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 18049, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "totalReserves", + "offset": 0, + "slot": "12", + "type": "t_uint256" + }, + { + "astId": 18052, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "totalAdminFees", + "offset": 0, + "slot": "13", + "type": "t_uint256" + }, + { + "astId": 18055, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "totalIonicFees", + "offset": 0, + "slot": "14", + "type": "t_uint256" + }, + { + "astId": 18058, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "totalSupply", + "offset": 0, + "slot": "15", + "type": "t_uint256" + }, + { + "astId": 18062, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "accountTokens", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 18068, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "transferAllowances", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 18079, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "accountBorrows", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_struct(BorrowSnapshot)18074_storage)" + }, + { + "astId": 18088, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "underlying", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 18092, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "ap", + "offset": 0, + "slot": "20", + "type": "t_contract(AddressesProvider)37930" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(AddressesProvider)37930": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(InterestRateModel)28313": { + "encoding": "inplace", + "label": "contract InterestRateModel", + "numberOfBytes": "20" + }, + "t_contract(IonicComptroller)25652": { + "encoding": "inplace", + "label": "contract IonicComptroller", + "numberOfBytes": "20" + }, + "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_struct(BorrowSnapshot)18074_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct CErc20Storage.BorrowSnapshot)", + "numberOfBytes": "32", + "value": "t_struct(BorrowSnapshot)18074_storage" + }, + "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_struct(BorrowSnapshot)18074_storage": { + "encoding": "inplace", + "label": "struct CErc20Storage.BorrowSnapshot", + "members": [ + { + "astId": 18071, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "principal", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 18073, + "contract": "contracts/compound/CErc20RewardsDelegate.sol:CErc20RewardsDelegate", + "label": "interestIndex", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/CTokenFirstExtension.json b/packages/contracts/deployments/superseed/CTokenFirstExtension.json new file mode 100644 index 0000000000..bf66f93079 --- /dev/null +++ b/packages/contracts/deployments/superseed/CTokenFirstExtension.json @@ -0,0 +1,1524 @@ +{ + "address": "0x8b2B6a9dC8Cd73309Cef8d64920831d4C73F43a7", + "abi": [ + { + "inputs": [], + "name": "CallerIsNotEOA", + "type": "error" + }, + { + "inputs": [], + "name": "InteractionNotAllowed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "cashPrior", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "interestAccumulated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBorrows", + "type": "uint256" + } + ], + "name": "AccrueInterest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Flash", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldAdminFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFeeMantissa", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldIonicFeeMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newIonicFeeMantissa", + "type": "uint256" + } + ], + "name": "NewIonicFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "oldInterestRateModel", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "NewMarketInterestRateModel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldReserveFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "NewReserveFactor", + "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": "amount", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_ap", + "type": "address" + } + ], + "name": "_setAddressesProvider", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newAdminFeeMantissa", + "type": "uint256" + } + ], + "name": "_setAdminFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "_setInterestRateModel", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "name": "_setNameAndSymbol", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newReserveFactorMantissa", + "type": "uint256" + } + ], + "name": "_setReserveFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accrualBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accrueInterest", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "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": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "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": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "borrowBalanceCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "borrowIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "borrowRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowRatePerBlockAfterBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "comptroller", + "outputs": [ + { + "internalType": "contract IonicComptroller", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRateCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "flash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountSnapshot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalUnderlyingSupplied", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "interestRateModel", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicFeeMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolSeizeShareMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "registerInSFS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reserveFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "supplyRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "supplyRatePerBlockAfterDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "withdrawAmount", + "type": "uint256" + } + ], + "name": "supplyRatePerBlockAfterWithdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAdminFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrowsCurrent", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalIonicFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x1a12889467b360c905f38d8a1d6b044742f2e1a2e5b0c22b66cd2190ab4bbc9a", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x8b2B6a9dC8Cd73309Cef8d64920831d4C73F43a7", + "transactionIndex": 1, + "gasUsed": "3900930", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xad5095556bee20d8c646d7ebf1703845d8fec626b2dfb8ddb22411b1c2234a09", + "transactionHash": "0x1a12889467b360c905f38d8a1d6b044742f2e1a2e5b0c22b66cd2190ab4bbc9a", + "logs": [], + "blockNumber": 4134124, + "cumulativeGasUsed": "3944808", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CallerIsNotEOA\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InteractionNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cashPrior\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"interestAccumulated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"totalBorrows\",\"type\":\"uint256\"}],\"name\":\"AccrueInterest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Flash\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAdminFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldIonicFeeMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newIonicFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"NewIonicFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"oldInterestRateModel\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract InterestRateModel\",\"name\":\"newInterestRateModel\",\"type\":\"address\"}],\"name\":\"NewMarketInterestRateModel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldReserveFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newReserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewReserveFactor\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ap\",\"type\":\"address\"}],\"name\":\"_setAddressesProvider\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newAdminFeeMantissa\",\"type\":\"uint256\"}],\"name\":\"_setAdminFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract InterestRateModel\",\"name\":\"newInterestRateModel\",\"type\":\"address\"}],\"name\":\"_setInterestRateModel\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"name\":\"_setNameAndSymbol\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newReserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"_setReserveFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accrualBlockNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"accrueInterest\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"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\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"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\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOfUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"borrowBalanceCurrent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowRatePerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"}],\"name\":\"borrowRatePerBlockAfterBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"comptroller\",\"outputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"exchangeRateCurrent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"flash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getAccountSnapshot\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTotalUnderlyingSupplied\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interestRateModel\",\"outputs\":[{\"internalType\":\"contract InterestRateModel\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicFeeMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"multicall\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"results\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolSeizeShareMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"registerInSFS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"supplyRatePerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"}],\"name\":\"supplyRatePerBlockAfterDeposit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"supplyRatePerBlockAfterWithdraw\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalAdminFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBorrows\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalBorrowsCurrent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalIonicFees\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalReserves\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underlying\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"_setAdminFee(uint256)\":{\"details\":\"Admin function to accrue interest and set a new admin fee\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_setInterestRateModel(address)\":{\"details\":\"Admin function to accrue interest and update the interest rate model\",\"params\":{\"newInterestRateModel\":\"the new interest rate model to use\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_setNameAndSymbol(string,string)\":{\"details\":\"Admin function to update the cToken ERC20 name and symbol\",\"params\":{\"_name\":\"the new ERC20 token name to use\",\"_symbol\":\"the new ERC20 token symbol to use\"}},\"_setReserveFactor(uint256)\":{\"details\":\"Admin function to accrue interest and set a new reserve factor\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"accrueInterest()\":{\"details\":\"This calculates interest accrued from the last checkpointed block up to the current block and writes new checkpoint to storage.\"},\"allowance(address,address)\":{\"params\":{\"owner\":\"The address of the account which owns the tokens to be spent\",\"spender\":\"The address of the account which may transfer tokens\"},\"returns\":{\"_0\":\"The number of tokens allowed to be spent (-1 means infinite)\"}},\"approve(address,uint256)\":{\"details\":\"This will overwrite the approval amount for `spender` and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\",\"params\":{\"amount\":\"The number of tokens that are approved (-1 means infinite)\",\"spender\":\"The address of the account which may transfer tokens\"},\"returns\":{\"_0\":\"Whether or not the approval succeeded\"}},\"balanceOf(address)\":{\"params\":{\"owner\":\"The address of the account to query\"},\"returns\":{\"_0\":\"The number of tokens owned by `owner`\"}},\"balanceOfUnderlying(address)\":{\"params\":{\"owner\":\"The address of the account to query\"},\"returns\":{\"_0\":\"The amount of underlying owned by `owner`\"}},\"borrowBalanceCurrent(address)\":{\"params\":{\"account\":\"The address whose balance should be calculated after recalculating the borrowIndex\"},\"returns\":{\"_0\":\"The calculated balance\"}},\"borrowRatePerBlock()\":{\"returns\":{\"_0\":\"The borrow interest rate per block, scaled by 1e18\"}},\"exchangeRateCurrent()\":{\"returns\":{\"_0\":\"Calculated exchange rate scaled by 1e18\"}},\"getAccountSnapshot(address)\":{\"details\":\"This is used by comptroller to more efficiently perform liquidity checks.\",\"params\":{\"account\":\"Address of the account to snapshot\"},\"returns\":{\"_0\":\"(possible error, token balance, borrow balance, exchange rate mantissa)\"}},\"supplyRatePerBlock()\":{\"returns\":{\"_0\":\"The supply interest rate per block, scaled by 1e18\"}},\"totalBorrowsCurrent()\":{\"returns\":{\"_0\":\"The total borrows with interest\"}},\"transfer(address,uint256)\":{\"params\":{\"amount\":\"The number of tokens to transfer\",\"dst\":\"The address of the destination account\"},\"returns\":{\"_0\":\"Whether or not the transfer succeeded\"}},\"transferFrom(address,address,uint256)\":{\"params\":{\"amount\":\"The number of tokens to transfer\",\"dst\":\"The address of the destination account\",\"src\":\"The address of the source account\"},\"returns\":{\"_0\":\"Whether or not the transfer succeeded\"}}},\"version\":1},\"userdoc\":{\"events\":{\"AccrueInterest(uint256,uint256,uint256,uint256)\":{\"notice\":\"Event emitted when interest is accrued\"},\"Approval(address,address,uint256)\":{\"notice\":\"EIP20 Approval event\"},\"NewAdminFee(uint256,uint256)\":{\"notice\":\"Event emitted when the admin fee is changed\"},\"NewIonicFee(uint256,uint256)\":{\"notice\":\"Event emitted when the Ionic fee is changed\"},\"NewMarketInterestRateModel(address,address)\":{\"notice\":\"Event emitted when interestRateModel is changed\"},\"NewReserveFactor(uint256,uint256)\":{\"notice\":\"Event emitted when the reserve factor is changed\"},\"Transfer(address,address,uint256)\":{\"notice\":\"EIP20 Transfer event\"}},\"kind\":\"user\",\"methods\":{\"_setAdminFee(uint256)\":{\"notice\":\"accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\"},\"_setInterestRateModel(address)\":{\"notice\":\"accrues interest and updates the interest rate model using _setInterestRateModelFresh\"},\"_setNameAndSymbol(string,string)\":{\"notice\":\"updates the cToken ERC20 name and symbol\"},\"_setReserveFactor(uint256)\":{\"notice\":\"accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\"},\"accrualBlockNumber()\":{\"notice\":\"Block number that interest was last accrued at\"},\"accrueInterest()\":{\"notice\":\"Applies accrued interest to total borrows and reserves\"},\"adminFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for admin fees\"},\"allowance(address,address)\":{\"notice\":\"Get the current allowance from `owner` for `spender`\"},\"ap()\":{\"notice\":\"Addresses Provider\"},\"approve(address,uint256)\":{\"notice\":\"Approve `spender` to transfer up to `amount` from `src`\"},\"balanceOf(address)\":{\"notice\":\"Get the token balance of the `owner`\"},\"balanceOfUnderlying(address)\":{\"notice\":\"Get the underlying balance of the `owner`\"},\"borrowBalanceCurrent(address)\":{\"notice\":\"calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\"},\"borrowIndex()\":{\"notice\":\"Accumulator of the total earned interest rate since the opening of the market\"},\"borrowRatePerBlock()\":{\"notice\":\"Returns the current per-block borrow interest rate for this cToken\"},\"comptroller()\":{\"notice\":\"Contract which oversees inter-cToken operations\"},\"decimals()\":{\"notice\":\"EIP-20 token decimals for this token\"},\"exchangeRateCurrent()\":{\"notice\":\"Accrue interest then return the up-to-date exchange rate\"},\"getAccountSnapshot(address)\":{\"notice\":\"Get a snapshot of the account's balances, and the cached exchange rate\"},\"interestRateModel()\":{\"notice\":\"Model which tells what the current interest rate should be\"},\"ionicFeeMantissa()\":{\"notice\":\"Fraction of interest currently set aside for Ionic fees\"},\"name()\":{\"notice\":\"EIP-20 token name for this token\"},\"reserveFactorMantissa()\":{\"notice\":\"Fraction of interest currently set aside for reserves\"},\"supplyRatePerBlock()\":{\"notice\":\"Returns the current per-block supply interest rate for this cToken\"},\"symbol()\":{\"notice\":\"EIP-20 token symbol for this token\"},\"totalAdminFees()\":{\"notice\":\"Total amount of admin fees of the underlying held in this market\"},\"totalBorrows()\":{\"notice\":\"Total amount of outstanding borrows of the underlying in this market\"},\"totalBorrowsCurrent()\":{\"notice\":\"Returns the current total borrows plus accrued interest\"},\"totalIonicFees()\":{\"notice\":\"Total amount of Ionic fees of the underlying held in this market\"},\"totalReserves()\":{\"notice\":\"Total amount of reserves of the underlying held in this market\"},\"totalSupply()\":{\"notice\":\"Total number of tokens in circulation\"},\"transfer(address,uint256)\":{\"notice\":\"Transfer `amount` tokens from `msg.sender` to `dst`\"},\"transferFrom(address,address,uint256)\":{\"notice\":\"Transfer `amount` tokens from `src` to `dst`\"},\"underlying()\":{\"notice\":\"Underlying asset for this CToken\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/CTokenFirstExtension.sol\":\"CTokenFirstExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.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\":\"0x8f211a9dd6bc7e4bc6c98a062d4729b821b7ff391a888215a48872b205117749\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenFirstExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"../ionic/IFlashLoanReceiver.sol\\\";\\nimport { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { SFSRegister } from \\\"./ComptrollerInterface.sol\\\";\\nimport { TokenErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { CTokenOracleProtected } from \\\"./CTokenOracleProtected.sol\\\";\\n\\nimport { IERC20, SafeERC20 } from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport { Multicall } from \\\"../utils/Multicall.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenFirstExtension is\\n CTokenOracleProtected,\\n CErc20FirstExtensionBase,\\n TokenErrorReporter,\\n Exponential,\\n DiamondExtension,\\n Multicall\\n{\\n modifier isAuthorized() {\\n require(\\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\\n \\\"not authorized\\\"\\n );\\n _;\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 25;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.transfer.selector;\\n functionSelectors[--fnsCount] = this.transferFrom.selector;\\n functionSelectors[--fnsCount] = this.allowance.selector;\\n functionSelectors[--fnsCount] = this.approve.selector;\\n functionSelectors[--fnsCount] = this.balanceOf.selector;\\n functionSelectors[--fnsCount] = this._setAdminFee.selector;\\n functionSelectors[--fnsCount] = this._setInterestRateModel.selector;\\n functionSelectors[--fnsCount] = this._setNameAndSymbol.selector;\\n functionSelectors[--fnsCount] = this._setAddressesProvider.selector;\\n functionSelectors[--fnsCount] = this._setReserveFactor.selector;\\n functionSelectors[--fnsCount] = this.supplyRatePerBlock.selector;\\n functionSelectors[--fnsCount] = this.borrowRatePerBlock.selector;\\n functionSelectors[--fnsCount] = this.exchangeRateCurrent.selector;\\n functionSelectors[--fnsCount] = this.accrueInterest.selector;\\n functionSelectors[--fnsCount] = this.totalBorrowsCurrent.selector;\\n functionSelectors[--fnsCount] = this.balanceOfUnderlying.selector;\\n functionSelectors[--fnsCount] = this.multicall.selector;\\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterDeposit.selector;\\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterWithdraw.selector;\\n functionSelectors[--fnsCount] = this.borrowRatePerBlockAfterBorrow.selector;\\n functionSelectors[--fnsCount] = this.getTotalUnderlyingSupplied.selector;\\n functionSelectors[--fnsCount] = this.flash.selector;\\n functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;\\n functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;\\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n function getTotalUnderlyingSupplied() public view override returns (uint256) {\\n // (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees))\\n return asCToken().getCash() + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees);\\n }\\n\\n /* ERC20 fns */\\n /**\\n * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`\\n * @dev Called by both `transfer` and `transferFrom` internally\\n * @param spender The address of the account performing the transfer\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param tokens The number of tokens to transfer\\n * @return Whether or not the transfer succeeded\\n */\\n function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {\\n /* Fail if transfer not allowed */\\n uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Do not allow self-transfers */\\n if (src == dst) {\\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\\n }\\n\\n /* Get the allowance, infinite for the account owner */\\n uint256 startingAllowance = 0;\\n if (spender == src) {\\n startingAllowance = type(uint256).max;\\n } else {\\n startingAllowance = transferAllowances[src][spender];\\n }\\n\\n /* Do the calculations, checking for {under,over}flow */\\n MathError mathErr;\\n uint256 allowanceNew;\\n uint256 srcTokensNew;\\n uint256 dstTokensNew;\\n\\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\\n if (mathErr != MathError.NO_ERROR) {\\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\\n }\\n\\n (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);\\n if (mathErr != MathError.NO_ERROR) {\\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\\n }\\n\\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\\n if (mathErr != MathError.NO_ERROR) {\\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n accountTokens[src] = srcTokensNew;\\n accountTokens[dst] = dstTokensNew;\\n\\n /* Eat some of the allowance (if necessary) */\\n if (startingAllowance != type(uint256).max) {\\n transferAllowances[src][spender] = allowanceNew;\\n }\\n\\n /* We emit a Transfer event */\\n emit Transfer(src, dst, tokens);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.transferVerify(address(this), src, dst, tokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return Whether or not the transfer succeeded\\n */\\n function transfer(\\n address dst,\\n uint256 amount\\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Transfer `amount` tokens from `src` to `dst`\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return Whether or not the transfer succeeded\\n */\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\\n return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Approve `spender` to transfer up to `amount` from `src`\\n * @dev This will overwrite the approval amount for `spender`\\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\\n * @param spender The address of the account which may transfer tokens\\n * @param amount The number of tokens that are approved (-1 means infinite)\\n * @return Whether or not the approval succeeded\\n */\\n function approve(\\n address spender,\\n uint256 amount\\n ) public override isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\\n address src = msg.sender;\\n transferAllowances[src][spender] = amount;\\n emit Approval(src, spender, amount);\\n return true;\\n }\\n\\n /**\\n * @notice Get the current allowance from `owner` for `spender`\\n * @param owner The address of the account which owns the tokens to be spent\\n * @param spender The address of the account which may transfer tokens\\n * @return The number of tokens allowed to be spent (-1 means infinite)\\n */\\n function allowance(address owner, address spender) public view override returns (uint256) {\\n return transferAllowances[owner][spender];\\n }\\n\\n /**\\n * @notice Get the token balance of the `owner`\\n * @param owner The address of the account to query\\n * @return The number of tokens owned by `owner`\\n */\\n function balanceOf(address owner) public view override returns (uint256) {\\n return accountTokens[owner];\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice updates the cToken ERC20 name and symbol\\n * @dev Admin function to update the cToken ERC20 name and symbol\\n * @param _name the new ERC20 token name to use\\n * @param _symbol the new ERC20 token symbol to use\\n */\\n function _setNameAndSymbol(string calldata _name, string calldata _symbol) external {\\n // Check caller is admin\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Set ERC20 name and symbol\\n name = _name;\\n symbol = _symbol;\\n }\\n\\n function _setAddressesProvider(address _ap) external {\\n // Check caller is admin\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n ap = AddressesProvider(_ap);\\n }\\n\\n /**\\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\\n * @dev Admin function to accrue interest and set a new reserve factor\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setReserveFactor(\\n uint256 newReserveFactorMantissa\\n ) public override nonReentrant(false) returns (uint256) {\\n accrueInterest();\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK);\\n }\\n\\n // Verify market's block number equals current block number\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\\n }\\n\\n // Check newReserveFactor \\u2264 maxReserveFactor\\n if (newReserveFactorMantissa + adminFeeMantissa + ionicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\\n }\\n\\n uint256 oldReserveFactorMantissa = reserveFactorMantissa;\\n reserveFactorMantissa = newReserveFactorMantissa;\\n\\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\\n * @dev Admin function to accrue interest and set a new admin fee\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setAdminFee(\\n uint256 newAdminFeeMantissa\\n ) public override nonReentrant(false) returns (uint256) {\\n accrueInterest();\\n // Verify market's block number equals current block number\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_ADMIN_FEE_FRESH_CHECK);\\n }\\n\\n // Sanitize newAdminFeeMantissa\\n if (newAdminFeeMantissa == type(uint256).max) newAdminFeeMantissa = adminFeeMantissa;\\n\\n // Get latest Ionic fee\\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\\n\\n // Check reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa \\u2264 reserveFactorPlusFeesMaxMantissa\\n if (reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\\n return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK);\\n }\\n\\n // If setting admin fee\\n if (adminFeeMantissa != newAdminFeeMantissa) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_ADMIN_FEE_ADMIN_CHECK);\\n }\\n\\n // Set admin fee\\n uint256 oldAdminFeeMantissa = adminFeeMantissa;\\n adminFeeMantissa = newAdminFeeMantissa;\\n\\n // Emit event\\n emit NewAdminFee(oldAdminFeeMantissa, newAdminFeeMantissa);\\n }\\n\\n // If setting Ionic fee\\n if (ionicFeeMantissa != newIonicFeeMantissa) {\\n // Set Ionic fee\\n uint256 oldIonicFeeMantissa = ionicFeeMantissa;\\n ionicFeeMantissa = newIonicFeeMantissa;\\n\\n // Emit event\\n emit NewIonicFee(oldIonicFeeMantissa, newIonicFeeMantissa);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh\\n * @dev Admin function to accrue interest and update the interest rate model\\n * @param newInterestRateModel the new interest rate model to use\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setInterestRateModel(\\n InterestRateModel newInterestRateModel\\n ) public override nonReentrant(false) returns (uint256) {\\n accrueInterest();\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);\\n }\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\\n }\\n\\n require(newInterestRateModel.isInterestRateModel(), \\\"!notIrm\\\");\\n\\n InterestRateModel oldInterestRateModel = interestRateModel;\\n interestRateModel = newInterestRateModel;\\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Returns the current per-block borrow interest rate for this cToken\\n * @return The borrow interest rate per block, scaled by 1e18\\n */\\n function borrowRatePerBlock() public view override returns (uint256) {\\n return\\n interestRateModel.getBorrowRate(\\n asCToken().getCash(),\\n totalBorrows,\\n totalReserves + totalAdminFees + totalIonicFees\\n );\\n }\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) public view returns (uint256) {\\n uint256 cash = asCToken().getCash();\\n require(cash >= borrowAmount, \\\"market cash not enough\\\");\\n\\n return\\n interestRateModel.getBorrowRate(\\n cash - borrowAmount,\\n totalBorrows + borrowAmount,\\n totalReserves + totalAdminFees + totalIonicFees\\n );\\n }\\n\\n /**\\n * @notice Returns the current per-block supply interest rate for this cToken\\n * @return The supply interest rate per block, scaled by 1e18\\n */\\n function supplyRatePerBlock() public view override returns (uint256) {\\n return\\n interestRateModel.getSupplyRate(\\n asCToken().getCash(),\\n totalBorrows,\\n totalReserves + totalAdminFees + totalIonicFees,\\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\\n );\\n }\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256) {\\n return\\n interestRateModel.getSupplyRate(\\n asCToken().getCash() + mintAmount,\\n totalBorrows,\\n totalReserves + totalAdminFees + totalIonicFees,\\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\\n );\\n }\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256) {\\n uint256 cash = asCToken().getCash();\\n require(cash >= withdrawAmount, \\\"market cash not enough\\\");\\n return\\n interestRateModel.getSupplyRate(\\n cash - withdrawAmount,\\n totalBorrows,\\n totalReserves + totalAdminFees + totalIonicFees,\\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\\n );\\n }\\n\\n /**\\n * @notice Accrue interest then return the up-to-date exchange rate\\n * @return Calculated exchange rate scaled by 1e18\\n */\\n function exchangeRateCurrent() public view override returns (uint256) {\\n if (block.number == accrualBlockNumber) {\\n return\\n _exchangeRateHypothetical(\\n totalSupply,\\n initialExchangeRateMantissa,\\n asCToken().getCash(),\\n totalBorrows,\\n totalReserves,\\n totalAdminFees,\\n totalIonicFees\\n );\\n } else {\\n uint256 cashPrior = asCToken().getCash();\\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\\n\\n return\\n _exchangeRateHypothetical(\\n accrual.totalSupply,\\n initialExchangeRateMantissa,\\n cashPrior,\\n accrual.totalBorrows,\\n accrual.totalReserves,\\n accrual.totalAdminFees,\\n accrual.totalIonicFees\\n );\\n }\\n }\\n\\n function _exchangeRateHypothetical(\\n uint256 _totalSupply,\\n uint256 _initialExchangeRateMantissa,\\n uint256 _totalCash,\\n uint256 _totalBorrows,\\n uint256 _totalReserves,\\n uint256 _totalAdminFees,\\n uint256 _totalIonicFees\\n ) internal pure returns (uint256) {\\n if (_totalSupply == 0) {\\n /*\\n * If there are no tokens minted:\\n * exchangeRate = initialExchangeRate\\n */\\n return _initialExchangeRateMantissa;\\n } else {\\n /*\\n * Otherwise:\\n * exchangeRate = (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees)) / totalSupply\\n */\\n uint256 cashPlusBorrowsMinusReserves;\\n Exp memory exchangeRate;\\n MathError mathErr;\\n\\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(\\n _totalCash,\\n _totalBorrows,\\n _totalReserves + _totalAdminFees + _totalIonicFees\\n );\\n require(mathErr == MathError.NO_ERROR, \\\"!addThenSubUInt overflow check failed\\\");\\n\\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\\n require(mathErr == MathError.NO_ERROR, \\\"!getExp overflow check failed\\\");\\n\\n return exchangeRate.mantissa;\\n }\\n }\\n\\n struct InterestAccrual {\\n uint256 accrualBlockNumber;\\n uint256 borrowIndex;\\n uint256 totalSupply;\\n uint256 totalBorrows;\\n uint256 totalReserves;\\n uint256 totalIonicFees;\\n uint256 totalAdminFees;\\n uint256 interestAccumulated;\\n }\\n\\n function _accrueInterestHypothetical(\\n uint256 blockNumber,\\n uint256 cashPrior\\n ) internal view returns (InterestAccrual memory accrual) {\\n uint256 totalFees = totalAdminFees + totalIonicFees;\\n uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);\\n if (borrowRateMantissa > borrowRateMaxMantissa) {\\n if (cashPrior > totalFees) revert(\\\"!borrowRate\\\");\\n else borrowRateMantissa = borrowRateMaxMantissa;\\n }\\n (MathError mathErr, uint256 blockDelta) = subUInt(blockNumber, accrualBlockNumber);\\n require(mathErr == MathError.NO_ERROR, \\\"!blockDelta\\\");\\n\\n /*\\n * Calculate the interest accumulated into borrows and reserves and the new index:\\n * simpleInterestFactor = borrowRate * blockDelta\\n * interestAccumulated = simpleInterestFactor * totalBorrows\\n * totalBorrowsNew = interestAccumulated + totalBorrows\\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\\n * totalIonicFeesNew = interestAccumulated * ionicFee + totalIonicFees\\n * totalAdminFeesNew = interestAccumulated * adminFee + totalAdminFees\\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\\n */\\n\\n accrual.accrualBlockNumber = blockNumber;\\n accrual.totalSupply = totalSupply;\\n Exp memory simpleInterestFactor = mul_(Exp({ mantissa: borrowRateMantissa }), blockDelta);\\n accrual.interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, totalBorrows);\\n accrual.totalBorrows = accrual.interestAccumulated + totalBorrows;\\n accrual.totalReserves = mul_ScalarTruncateAddUInt(\\n Exp({ mantissa: reserveFactorMantissa }),\\n accrual.interestAccumulated,\\n totalReserves\\n );\\n accrual.totalIonicFees = mul_ScalarTruncateAddUInt(\\n Exp({ mantissa: ionicFeeMantissa }),\\n accrual.interestAccumulated,\\n totalIonicFees\\n );\\n accrual.totalAdminFees = mul_ScalarTruncateAddUInt(\\n Exp({ mantissa: adminFeeMantissa }),\\n accrual.interestAccumulated,\\n totalAdminFees\\n );\\n accrual.borrowIndex = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndex, borrowIndex);\\n }\\n\\n /**\\n * @notice Applies accrued interest to total borrows and reserves\\n * @dev This calculates interest accrued from the last checkpointed block\\n * up to the current block and writes new checkpoint to storage.\\n */\\n function accrueInterest() public override returns (uint256) {\\n /* Remember the initial block number */\\n uint256 currentBlockNumber = block.number;\\n\\n /* Short-circuit accumulating 0 interest */\\n if (accrualBlockNumber == currentBlockNumber) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n uint256 cashPrior = asCToken().getCash();\\n InterestAccrual memory accrual = _accrueInterestHypothetical(currentBlockNumber, cashPrior);\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n accrualBlockNumber = currentBlockNumber;\\n borrowIndex = accrual.borrowIndex;\\n totalBorrows = accrual.totalBorrows;\\n totalReserves = accrual.totalReserves;\\n totalIonicFees = accrual.totalIonicFees;\\n totalAdminFees = accrual.totalAdminFees;\\n emit AccrueInterest(cashPrior, accrual.interestAccumulated, borrowIndex, totalBorrows);\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Returns the current total borrows plus accrued interest\\n * @return The total borrows with interest\\n */\\n function totalBorrowsCurrent() external view override returns (uint256) {\\n if (accrualBlockNumber == block.number) {\\n return totalBorrows;\\n } else {\\n uint256 cashPrior = asCToken().getCash();\\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\\n return accrual.totalBorrows;\\n }\\n }\\n\\n /**\\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\\n * @param account Address of the account to snapshot\\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\\n */\\n function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {\\n uint256 cTokenBalance = accountTokens[account];\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n\\n borrowBalance = borrowBalanceCurrent(account);\\n\\n exchangeRateMantissa = exchangeRateCurrent();\\n\\n return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa);\\n }\\n\\n /**\\n * @notice calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\\n * @param account The address whose balance should be calculated after recalculating the borrowIndex\\n * @return The calculated balance\\n */\\n function borrowBalanceCurrent(address account) public view override returns (uint256) {\\n uint256 _borrowIndex;\\n if (accrualBlockNumber == block.number) {\\n _borrowIndex = borrowIndex;\\n } else {\\n uint256 cashPrior = asCToken().getCash();\\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\\n _borrowIndex = accrual.borrowIndex;\\n }\\n\\n /* Note: we do not assert that the market is up to date */\\n MathError mathErr;\\n uint256 principalTimesIndex;\\n uint256 result;\\n\\n /* Get borrowBalance and borrowIndex */\\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\\n\\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\\n */\\n if (borrowSnapshot.principal == 0) {\\n return 0;\\n }\\n\\n /* Calculate new borrow balance using the interest index:\\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\\n */\\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, _borrowIndex);\\n require(mathErr == MathError.NO_ERROR, \\\"!mulUInt overflow check failed\\\");\\n\\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\\n require(mathErr == MathError.NO_ERROR, \\\"!divUInt overflow check failed\\\");\\n\\n return result;\\n }\\n\\n /**\\n * @notice Get the underlying balance of the `owner`\\n * @param owner The address of the account to query\\n * @return The amount of underlying owned by `owner`\\n */\\n function balanceOfUnderlying(address owner) external view override returns (uint256) {\\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\\n (MathError mErr, uint256 balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\\n require(mErr == MathError.NO_ERROR, \\\"!balance\\\");\\n return balance;\\n }\\n\\n function flash(uint256 amount, bytes calldata data) public override isAuthorized onlyOracleApprovedAllowEOA {\\n accrueInterest();\\n\\n totalBorrows += amount;\\n asCToken().selfTransferOut(msg.sender, amount);\\n\\n IFlashLoanReceiver(msg.sender).receiveFlashLoan(underlying, amount, data);\\n\\n asCToken().selfTransferIn(msg.sender, amount);\\n totalBorrows -= amount;\\n\\n emit Flash(msg.sender, amount);\\n }\\n\\n /*** Reentrancy Guard ***/\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant(bool localOnly) {\\n _beforeNonReentrant(localOnly);\\n _;\\n _afterNonReentrant(localOnly);\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\\n */\\n function _beforeNonReentrant(bool localOnly) private {\\n require(_notEntered, \\\"re-entered\\\");\\n if (!localOnly) comptroller._beforeNonReentrant();\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\\n */\\n function _afterNonReentrant(bool localOnly) private {\\n _notEntered = true; // get a gas-refund post-Istanbul\\n if (!localOnly) comptroller._afterNonReentrant();\\n }\\n\\n function asCToken() internal view returns (ICErc20) {\\n return ICErc20(address(this));\\n }\\n\\n function multicall(\\n bytes[] calldata data\\n ) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {\\n return Multicall.multicall(data);\\n }\\n\\n function registerInSFS() external returns (uint256) {\\n require(hasAdminRights() || msg.sender == address(comptroller), \\\"!admin\\\");\\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\\n }\\n}\\n\",\"keccak256\":\"0x0caba5127eabfdf6766e5354c437a84409497609ed220493bf09fd7f6ed8bf0f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenOracleProtected.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.22;\\n\\nimport { CErc20Storage } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenOracleProtected is CErc20Storage {\\n error InteractionNotAllowed();\\n error CallerIsNotEOA();\\n\\n modifier onlyOracleApproved() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyOracleApprovedAllowEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n if (tx.origin == msg.sender) {\\n _;\\n return;\\n }\\n\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyNotBlacklistedEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n if (msg.sender != tx.origin) {\\n revert CallerIsNotEOA();\\n }\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x42b99e4fbc5880f64a6f1d8b02f3b061b0d3a6c312f47d83e88593eefaf71304\",\"license\":\"Unlicense\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/utils/IMulticall.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.8.0;\\n\\n/// @title Multicall interface\\n/// @notice Enables calling multiple methods in a single call to the contract\\ninterface IMulticall {\\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\\n /// @param data The encoded function data for each of the calls to make to this contract\\n /// @return results The results from each of the calls passed in via data\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n}\\n\",\"keccak256\":\"0x06d957a2af0a31212eea7fcaa5fe0f4e180bcddd9bc8e593fb6345339b2b2038\",\"license\":\"GPL-2.0-or-later\"},\"contracts/utils/Multicall.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IMulticall.sol\\\";\\n\\n/// @title Multicall\\n/// @notice Enables calling multiple methods in a single call to the contract\\nabstract contract Multicall is IMulticall {\\n /// @inheritdoc IMulticall\\n function multicall(bytes[] calldata data) public payable virtual override returns (bytes[] memory results) {\\n results = new bytes[](data.length);\\n for (uint256 i = 0; i < data.length; i++) {\\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\\n\\n if (!success) {\\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\\n if (result.length < 68) revert();\\n assembly {\\n result := add(result, 0x04)\\n }\\n revert(abi.decode(result, (string)));\\n }\\n\\n results[i] = result;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x019e3414dae3e29d4e210311bf82d94e34756b3b015ab352e7bb59a6380b8e9b\",\"license\":\"GPL-2.0-or-later\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50614598806100206000396000f3fe60806040526004361061027d5760003560e01c80638d02d9a11161014f578063b1e23dbb116100c1578063cfcd4c071161007a578063cfcd4c0714610754578063dd62ed3e14610774578063f2b3abbd146107ba578063f3fdb15a146107da578063f8f9da28146107fa578063fca7820b1461080f57600080fd5b8063b1e23dbb1461068d578063bd6d894d146106ad578063be99f119146106c2578063c37f68e2146106de578063c3bf11cd1461071e578063c91a424f1461073457600080fd5b8063a6afed9511610113578063a6afed95146105ed578063a9059cbb14610602578063aa5af0fd14610622578063ac9650d814610638578063ae9d70b014610658578063b0a190761461066d57600080fd5b80638d02d9a1146105765780638f840ddd1461058c57806391dd36c6146105a257806395d89b41146105c25780639826394b146105d757600080fd5b80633c4f743c116101f35780636c540baf116101ac5780636c540baf146104be5780636f307dc3146104d457806370a08231146104f457806373acee981461052a5780637f15e2161461053f57806389f8132e1461055457600080fd5b80633c4f743c1461040557806347bd37181461043d5780634aeb3d9a146104535780635fe3b5671461046857806361feacff1461048d5780636752e702146104a357600080fd5b806323b872dd1161024557806323b872dd14610337578063313ce5671461035757806334154d4c1461038357806335daea64146103a55780633af9e669146103c55780633c3b4b89146103e557600080fd5b806306fdde0314610282578063095ea7b3146102ad578063173b9904146102dd57806317bfdfbc1461030157806318160ddd14610321575b600080fd5b34801561028e57600080fd5b5061029761082f565b6040516102a49190613de5565b60405180910390f35b3480156102b957600080fd5b506102cd6102c8366004613e0d565b6108bd565b60405190151581526020016102a4565b3480156102e957600080fd5b506102f360085481565b6040519081526020016102a4565b34801561030d57600080fd5b506102f361031c366004613e39565b610be8565b34801561032d57600080fd5b506102f3600f5481565b34801561034357600080fd5b506102cd610352366004613e56565b610d99565b34801561036357600080fd5b506003546103719060ff1681565b60405160ff90911681526020016102a4565b34801561038f57600080fd5b506103a361039e366004613ed9565b610fe8565b005b3480156103b157600080fd5b506102f36103c0366004613f45565b61102e565b3480156103d157600080fd5b506102f36103e0366004613e39565b6111b0565b3480156103f157600080fd5b506103a3610400366004613f5e565b61124b565b34801561041157600080fd5b50601454610425906001600160a01b031681565b6040516001600160a01b0390911681526020016102a4565b34801561044957600080fd5b506102f3600b5481565b34801561045f57600080fd5b506102f36117b7565b34801561047457600080fd5b506003546104259061010090046001600160a01b031681565b34801561049957600080fd5b506102f3600d5481565b3480156104af57600080fd5b506102f3666379da05b6000081565b3480156104ca57600080fd5b506102f360095481565b3480156104e057600080fd5b50601354610425906001600160a01b031681565b34801561050057600080fd5b506102f361050f366004613e39565b6001600160a01b031660009081526010602052604090205490565b34801561053657600080fd5b506102f3611854565b34801561054b57600080fd5b506102f36118e3565b34801561056057600080fd5b506105696119b4565b6040516102a49190613faa565b34801561058257600080fd5b506102f360065481565b34801561059857600080fd5b506102f3600c5481565b3480156105ae57600080fd5b506102f36105bd366004613f45565b612088565b3480156105ce57600080fd5b50610297612244565b3480156105e357600080fd5b506102f3600e5481565b3480156105f957600080fd5b506102f3612251565b34801561060e57600080fd5b506102cd61061d366004613e0d565b612362565b34801561062e57600080fd5b506102f3600a5481565b61064b610646366004613ff8565b6125b0565b6040516102a4919061406d565b34801561066457600080fd5b506102f36125bc565b34801561067957600080fd5b506103a3610688366004613e39565b6126e2565b34801561069957600080fd5b506102f36106a8366004613f45565b612728565b3480156106b957600080fd5b506102f3612858565b3480156106ce57600080fd5b506102f367016345785d8a000081565b3480156106ea57600080fd5b506106fe6106f9366004613e39565b612985565b6040805194855260208501939093529183015260608201526080016102a4565b34801561072a57600080fd5b506102f360075481565b34801561074057600080fd5b50600054610425906001600160a01b031681565b34801561076057600080fd5b506102f361076f366004613f45565b6129cb565b34801561078057600080fd5b506102f361078f3660046140d1565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b3480156107c657600080fd5b506102f36107d5366004613e39565b612af2565b3480156107e657600080fd5b50600454610425906001600160a01b031681565b34801561080657600080fd5b506102f3612c31565b34801561081b57600080fd5b506102f361082a366004613f45565b612cf8565b6001805461083c9061410a565b80601f01602080910402602001604051908101604052809291908181526020018280546108689061410a565b80156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261090a9261010090910490911690339030906001600160e01b03198835169060040161413e565b602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b9190614171565b6109705760405162461bcd60e51b815260040161096790614193565b60405180910390fd5b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061099f906004016141bb565b602060405180830381865afa1580156109bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e091906141e7565b90506001600160a01b038116610a55573360008181526011602090815260408083206001600160a01b038916808552908352928190208790555186815283917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3600192505050610be2565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610a9857600080fd5b505af1158015610aac573d6000803e3d6000fd5b50503332039150610b1f9050573360008181526011602090815260408083206001600160a01b038a16808552908352928190208890555187815283917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a360019350505050610be2565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b158015610b6457600080fd5b505afa158015610b78573d6000803e3d6000fd5b50503360008181526011602090815260408083206001600160a01b038c16808552908352928190208a90555189815292945090925083917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3600193505050505b92915050565b6000804360095403610bfd5750600a54610c78565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c619190614204565b90506000610c6f4383612dae565b60200151925050505b6001600160a01b03831660009081526012602052604081208054829182918203610ca9575060009695505050505050565b8054610cb59086613043565b90945092506000846003811115610cce57610cce61421d565b14610d1b5760405162461bcd60e51b815260206004820152601e60248201527f216d756c55496e74206f766572666c6f7720636865636b206661696c656400006044820152606401610967565b610d29838260010154613088565b90945091506000846003811115610d4257610d4261421d565b14610d8f5760405162461bcd60e51b815260206004820152601e60248201527f2164697655496e74206f766572666c6f7720636865636b206661696c656400006044820152606401610967565b5095945050505050565b600080610da5816130b6565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb893610def93610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190614171565b610e4c5760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610e7b906004016141bb565b602060405180830381865afa158015610e98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebc91906141e7565b90506001600160a01b038116610ee3576000610eda3388888861317a565b14925050610fd7565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610f2657600080fd5b505af1158015610f3a573d6000803e3d6000fd5b50503332039150610f5f9050576000610f553389898961317a565b1493505050610fd7565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b158015610fa457600080fd5b505afa158015610fb8573d6000803e3d6000fd5b5060009250610fc5915050565b610fd13389898961317a565b14935050505b610fe08161342f565b509392505050565b610ff06134ae565b61100c5760405162461bcd60e51b815260040161096790614233565b60016110198486836142b9565b5060026110278284836142b9565b5050505050565b600080306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561106f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110939190614204565b9050828110156110de5760405162461bcd60e51b81526020600482015260166024820152750dac2e4d6cae840c6c2e6d040dcdee840cadcdeeaced60531b6044820152606401610967565b6004546001600160a01b031663b81688166110f9858461438f565b600b54600e54600d54600c5461110f91906143a2565b61111991906143a2565b60065460075460085461112c91906143a2565b61113691906143a2565b6040516001600160e01b031960e087901b16815260048101949094526024840192909252604483015260648201526084015b602060405180830381865afa158015611185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a99190614204565b9392505050565b60008060405180602001604052806111c6612858565b90526001600160a01b0384166000908152601060205260408120549192509081906111f2908490613625565b9092509050600082600381111561120b5761120b61421d565b146112435760405162461bcd60e51b81526020600482015260086024820152672162616c616e636560c01b6044820152606401610967565b949350505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb89361129593610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa1580156112b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d69190614171565b6112f25760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611321906004016141bb565b602060405180830381865afa15801561133e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136291906141e7565b90506001600160a01b03811661152d5761137a612251565b5083600b600082825461138d91906143a2565b9091555030905060405163067db1b360e01b8152336004820152602481018690526001600160a01b03919091169063067db1b390604401600060405180830381600087803b1580156113de57600080fd5b505af11580156113f2573d6000803e3d6000fd5b505060135460405163012b1f4560e71b815233935063958fa280925061142a916001600160a01b0316908890889088906004016143b5565b600060405180830381600087803b15801561144457600080fd5b505af1158015611458573d6000803e3d6000fd5b505050506114633090565b6040516304d7c4cd60e21b8152336004820152602481018690526001600160a01b03919091169063135f1334906044016020604051808303816000875af11580156114b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d69190614204565b5083600b60008282546114e9919061438f565b909155505060408051338152602081018690527fe756d016d0e956882a6de9c72a2fe06d7d488ecbe6d76628713077ea7930cff8910160405180910390a150505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561157057600080fd5b505af1158015611584573d6000803e3d6000fd5b5050333203915061174d905057611599612251565b5084600b60008282546115ac91906143a2565b9091555030905060405163067db1b360e01b8152336004820152602481018790526001600160a01b03919091169063067db1b390604401600060405180830381600087803b1580156115fd57600080fd5b505af1158015611611573d6000803e3d6000fd5b505060135460405163012b1f4560e71b815233935063958fa2809250611649916001600160a01b0316908990899089906004016143b5565b600060405180830381600087803b15801561166357600080fd5b505af1158015611677573d6000803e3d6000fd5b505050506116823090565b6040516304d7c4cd60e21b8152336004820152602481018790526001600160a01b03919091169063135f1334906044016020604051808303816000875af11580156116d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f59190614204565b5084600b6000828254611708919061438f565b909155505060408051338152602081018790527fe756d016d0e956882a6de9c72a2fe06d7d488ecbe6d76628713077ea7930cff8910160405180910390a15050505050565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b15801561179257600080fd5b505afa1580156117a6573d6000803e3d6000fd5b50505050611599612251565b505050565b6000600d54600e54600c546117cc91906143a2565b6117d691906143a2565b600b54306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183b9190614204565b61184591906143a2565b61184f919061438f565b905090565b600043600954036118665750600b5490565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ca9190614204565b905060006118d84383612dae565b606001519392505050565b60006118ed6134ae565b80611907575060035461010090046001600160a01b031633145b6119235760405162461bcd60e51b815260040161096790614233565b604051632210724360e11b8152738fba84867ba458e7c6e2c024d2de3d0b5c3ea1c26004820152738680ceabcb9b56913c519c069add6bc3494b7020908190634420e486906024016020604051808303816000875af115801561198a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ae9190614204565b91505090565b60408051601980825261034082019092526060919060009082602082016103208036833701905050905063a9059cbb60e01b816119f0846143fd565b93508360ff1681518110611a0657611a0661441a565b6001600160e01b0319909216602092830291909101909101526323b872dd60e01b81611a31846143fd565b93508360ff1681518110611a4757611a4761441a565b6001600160e01b031990921660209283029190910190910152636eb1769f60e11b81611a72846143fd565b93508360ff1681518110611a8857611a8861441a565b6001600160e01b03199092166020928302919091019091015263095ea7b360e01b81611ab3846143fd565b93508360ff1681518110611ac957611ac961441a565b6001600160e01b0319909216602092830291909101909101526370a0823160e01b81611af4846143fd565b93508360ff1681518110611b0a57611b0a61441a565b6001600160e01b0319909216602092830291909101909101526348ee9b6360e11b81611b35846143fd565b93508360ff1681518110611b4b57611b4b61441a565b6001600160e01b03199092166020928302919091019091015263f2b3abbd60e01b81611b76846143fd565b93508360ff1681518110611b8c57611b8c61441a565b6001600160e01b031990921660209283029190910190910152630d05535360e21b81611bb7846143fd565b93508360ff1681518110611bcd57611bcd61441a565b6001600160e01b031990921660209283029190910190910152635850c83b60e11b81611bf8846143fd565b93508360ff1681518110611c0e57611c0e61441a565b6001600160e01b03199092166020928302919091019091015263fca7820b60e01b81611c39846143fd565b93508360ff1681518110611c4f57611c4f61441a565b6001600160e01b031990921660209283029190910190910152630ae9d70b60e41b81611c7a846143fd565b93508360ff1681518110611c9057611c9061441a565b6001600160e01b031990921660209283029190910190910152631f1f3b4560e31b81611cbb846143fd565b93508360ff1681518110611cd157611cd161441a565b6001600160e01b03199092166020928302919091019091015263bd6d894d60e01b81611cfc846143fd565b93508360ff1681518110611d1257611d1261441a565b6001600160e01b03199092166020928302919091019091015263a6afed9560e01b81611d3d846143fd565b93508360ff1681518110611d5357611d5361441a565b6001600160e01b031990921660209283029190910190910152630e759dd360e31b81611d7e846143fd565b93508360ff1681518110611d9457611d9461441a565b6001600160e01b031990921660209283029190910190910152633af9e66960e01b81611dbf846143fd565b93508360ff1681518110611dd557611dd561441a565b6001600160e01b031990921660209283029190910190910152631592ca1b60e31b81611e00846143fd565b93508360ff1681518110611e1657611e1661441a565b6001600160e01b03199092166020928302919091019091015263b1e23dbb60e01b81611e41846143fd565b93508360ff1681518110611e5757611e5761441a565b6001600160e01b031990921660209283029190910190910152630d76ba9960e21b81611e82846143fd565b93508360ff1681518110611e9857611e9861441a565b6001600160e01b03199092166020928302919091019091015263cfcd4c0760e01b81611ec3846143fd565b93508360ff1681518110611ed957611ed961441a565b6001600160e01b0319909216602092830291909101909101526325759ecd60e11b81611f04846143fd565b93508360ff1681518110611f1a57611f1a61441a565b6001600160e01b031990921660209283029190910190910152633c3b4b8960e01b81611f45846143fd565b93508360ff1681518110611f5b57611f5b61441a565b6001600160e01b0319909216602092830291909101909101526361bfb47160e11b81611f86846143fd565b93508360ff1681518110611f9c57611f9c61441a565b6001600160e01b0319909216602092830291909101909101526305eff7ef60e21b81611fc7846143fd565b93508360ff1681518110611fdd57611fdd61441a565b6001600160e01b031990921660209283029190910190910152633f8af10b60e11b81612008846143fd565b93508360ff168151811061201e5761201e61441a565b6001600160e01b03199092166020928302919091019091015260ff821615610be25760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610967565b600080612094816130b6565b61209c612251565b5043600954146120b9576120b2600a6052613677565b9150612235565b60001983036120c85760065492505b60008060009054906101000a90046001600160a01b03166001600160a01b031663dd86fea16040518163ffffffff1660e01b8152600401602060405180830381865afa15801561211c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121409190614204565b9050670de0b6b3a7640000818560085461215a91906143a2565b61216491906143a2565b111561217e5761217660026053613677565b925050612235565b83600654146121e25761218f6134ae565b61219f5761217660016051613677565b600680549085905560408051828152602081018790527fcdd0b588250e1398549f79cfdb8217c186688822905d6715b0834ea1c865594a910160405180910390a1505b806007541461222e57600780549082905560408051828152602081018490527fedec4b9c99c2cdb231e7fd036f861e0445b015916700f41b9835f984cb9be4cb910160405180910390a1505b60005b9250505b61223e8161342f565b50919050565b6002805461083c9061410a565b60008043905080600954036122675760006119ae565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cb9190614204565b905060006122d98383612dae565b6009849055602081810151600a819055606080840151600b819055608080860151600c5560a0860151600e5560c0860151600d5560e0860151604080518a815296870191909152850193909352908301529192507f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04910160405180910390a16000935050505090565b60008061236e816130b6565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb8936123b893610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa1580156123d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f99190614171565b6124155760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190612444906004016141bb565b602060405180830381865afa158015612461573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248591906141e7565b90506001600160a01b0381166124ac5760006124a33333888861317a565b149250506125a0565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156124ef57600080fd5b505af1158015612503573d6000803e3d6000fd5b50503332039150612528905057600061251e3333898961317a565b14935050506125a0565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b15801561256d57600080fd5b505afa158015612581573d6000803e3d6000fd5b506000925061258e915050565b61259a3333898961317a565b14935050505b6125a98161342f565b5092915050565b60606111a983836136f0565b6004546000906001600160a01b031663b8168816306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126329190614204565b600b54600e54600d54600c5461264891906143a2565b61265291906143a2565b60065460075460085461266591906143a2565b61266f91906143a2565b6040516001600160e01b031960e087901b16815260048101949094526024840192909252604483015260648201526084015b602060405180830381865afa1580156126be573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184f9190614204565b6126ea6134ae565b6127065760405162461bcd60e51b815260040161096790614233565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546000906001600160a01b031663b816881683306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561277b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279f9190614204565b6127a991906143a2565b600b54600e54600d54600c546127bf91906143a2565b6127c991906143a2565b6006546007546008546127dc91906143a2565b6127e691906143a2565b6040516001600160e01b031960e087901b1681526004810194909452602484019290925260448301526064820152608401602060405180830381865afa158015612834573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be29190614204565b600060095443036128e55761184f600f546005546128733090565b6001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d49190614204565b600b54600c54600d54600e54613836565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129499190614204565b905060006129574383612dae565b905061297e816040015160055484846060015185608001518660c001518760a00151613836565b9250505090565b6001600160a01b03811660009081526010602052604081205481908190819081806129af88610be8565b91506129b9612858565b90506000989297509095509350915050565b600080306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a309190614204565b905082811015612a7b5760405162461bcd60e51b81526020600482015260166024820152750dac2e4d6cae840c6c2e6d040dcdee840cadcdeeaced60531b6044820152606401610967565b6004546001600160a01b03166315f24053612a96858461438f565b85600b54612aa491906143a2565b600e54600d54600c54612ab791906143a2565b612ac191906143a2565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401611168565b600080612afe816130b6565b612b06612251565b50612b0f6134ae565b612b1f576120b26001604d613677565b4360095414612b34576120b2600a604c613677565b826001600160a01b0316632191f92a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b969190614171565b612bcc5760405162461bcd60e51b8152602060048201526007602482015266216e6f7449726d60c81b6044820152606401610967565b600480546001600160a01b038581166001600160a01b031983168117909355604080519190921680825260208201939093527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92691015b60405180910390a16000612231565b6004546000906001600160a01b03166315f24053306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca79190614204565b600b54600e54600d54600c54612cbd91906143a2565b612cc791906143a2565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016126a1565b600080612d04816130b6565b612d0c612251565b50612d156134ae565b612d25576120b260016058613677565b4360095414612d3a576120b2600a6059613677565b670de0b6b3a764000060075460065485612d5491906143a2565b612d5e91906143a2565b1115612d70576120b26002605a613677565b600880549084905560408051828152602081018690527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101612c22565b612df660405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000600e54600d54612e0891906143a2565b600454600b54600c549293506000926001600160a01b03909216916315f24053918791612e369087906143a2565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa158015612e7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea39190614204565b905065048c27395000811115612efa5781841115612ef15760405162461bcd60e51b815260206004820152600b60248201526a21626f72726f775261746560a81b6044820152606401610967565b5065048c273950005b600080612f0987600954613978565b90925090506000826003811115612f2257612f2261421d565b14612f5d5760405162461bcd60e51b815260206004820152600b60248201526a21626c6f636b44656c746160a81b6044820152606401610967565b868552600f54604080870191909152805160208101909152838152600090612f8590836139a3565b9050612f9381600b546139d4565b60e08701819052600b54612fa6916143a2565b60608701526040805160208101909152600854815260e0870151600c54612fce9291906139ec565b60808701526040805160208101909152600754815260e0870151600e54612ff69291906139ec565b60a08701526040805160208101909152600654815260e0870151600d5461301e9291906139ec565b60c0870152600a54613032908290806139ec565b602087015250939695505050505050565b6000808360000361305957506000905080613081565b838302836130678683614430565b1461307a57600260009250925050613081565b6000925090505b9250929050565b6000808260000361309f5750600190506000613081565b60006130ab8486614430565b915091509250929050565b600054600160a01b900460ff166130fc5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610967565b8061316a57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561315157600080fd5b505af1158015613165573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b6003546040516317b9b84b60e31b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283926101009091049091169063bdcdc258906084016020604051808303816000875af11580156131e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320a9190614204565b905080156132275761321f6003605b83613a16565b915050611243565b836001600160a01b0316856001600160a01b03160361324c5761321f6002605c613677565b6000856001600160a01b0316876001600160a01b0316036132705750600019613298565b506001600160a01b038086166000908152601160209081526040808320938a16835292905220545b6000806000806132a88589613978565b909450925060008460038111156132c1576132c161421d565b146132df576132d26009605c613677565b9650505050505050611243565b6001600160a01b038a166000908152601060205260409020546133029089613978565b9094509150600084600381111561331b5761331b61421d565b1461332c576132d26009605d613677565b6001600160a01b03891660009081526010602052604090205461334f9089613ab8565b909450905060008460038111156133685761336861421d565b14613379576132d26009605e613677565b6001600160a01b03808b16600090815260106020526040808220859055918b1681522081905560001985146133d1576001600160a01b03808b166000908152601160209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a60405161341691815260200190565b60405180910390a35060009a9950505050505050505050565b6000805460ff60a01b1916600160a01b179055806134ab57600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561349757600080fd5b505af1158015611027573d6000803e3d6000fd5b50565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015613507573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352b91906141e7565b6001600160a01b0316336001600160a01b03161480156135a85750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015613584573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a89190614171565b806119ae57506000546001600160a01b0316331480156119ae5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613601573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ae9190614171565b6000806000806136358686613ade565b9092509050600082600381111561364e5761364e61421d565b1461365f5750915060009050613081565b600061366a82613b5a565b9350935050509250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360118111156136ac576136ac61421d565b8360618111156136be576136be61421d565b60408051928352602083019190915260009082015260600160405180910390a18260118111156111a9576111a961421d565b60608167ffffffffffffffff81111561370b5761370b614253565b60405190808252806020026020018201604052801561373e57816020015b60608152602001906001900390816137295790505b50905060005b828110156125a957600080308686858181106137625761376261441a565b90506020028101906137749190614452565b604051613782929190614499565b600060405180830381855af49150503d80600081146137bd576040519150601f19603f3d011682016040523d82523d6000602084013e6137c2565b606091505b50915091508161380e576044815110156137db57600080fd5b600481019050808060200190518101906137f591906144a9565b60405162461bcd60e51b81526004016109679190613de5565b808484815181106138215761382161441a565b60209081029190910101525050600101613744565b60008760000361384757508561396d565b600061385f6040518060200160405280600081525090565b60006138808989876138718a8c6143a2565b61387b91906143a2565b613b72565b9350905060008160038111156138985761389861421d565b146138f35760405162461bcd60e51b815260206004820152602560248201527f216164645468656e53756255496e74206f766572666c6f7720636865636b2066604482015264185a5b195960da1b6064820152608401610967565b6138fd838c613bc5565b9250905060008160038111156139155761391561421d565b146139625760405162461bcd60e51b815260206004820152601d60248201527f21676574457870206f766572666c6f7720636865636b206661696c65640000006044820152606401610967565b5051915061396d9050565b979650505050505050565b60008083831161399757600061398e848661438f565b91509150613081565b50600390506000613081565b60408051602081019091526000815260405180602001604052806139cb856000015185613c90565b90529392505050565b6000806139e184846139a3565b905061124381613b5a565b6000806139f985856139a3565b9050613a0d613a0782613b5a565b84613cd2565b95945050505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846011811115613a4b57613a4b61421d565b846061811115613a5d57613a5d61421d565b604080519283526020830191909152810184905260600160405180910390a16003846011811115613a9057613a9061421d565b14613aac57836011811115613aa757613aa761421d565b611243565b611243826103e86143a2565b600080838301848110613ad057600092509050613081565b600260009250925050613081565b6000613af66040518060200160405280600081525090565b600080613b07866000015186613043565b90925090506000826003811115613b2057613b2061421d565b14613b3f57506040805160208101909152600081529092509050613081565b60408051602081019091529081526000969095509350505050565b8051600090610be290670de0b6b3a764000090614430565b600080600080613b828787613ab8565b90925090506000826003811115613b9b57613b9b61421d565b14613bac5750915060009050613bbd565b613bb68186613978565b9350935050505b935093915050565b6000613bdd6040518060200160405280600081525090565b600080613bf286670de0b6b3a7640000613043565b90925090506000826003811115613c0b57613c0b61421d565b14613c2a57506040805160208101909152600081529092509050613081565b600080613c378388613088565b90925090506000826003811115613c5057613c5061421d565b14613c735781604051806020016040528060008152509550955050505050613081565b604080516020810190915290815260009890975095505050505050565b60006111a983836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250613d08565b60006111a98383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250613d64565b6000831580613d15575082155b15613d22575060006111a9565b6000613d2e848661454b565b905083613d3b8683614430565b148390613d5b5760405162461bcd60e51b81526004016109679190613de5565b50949350505050565b600080613d7184866143a2565b90508285821015613d5b5760405162461bcd60e51b81526004016109679190613de5565b60005b83811015613db0578181015183820152602001613d98565b50506000910152565b60008151808452613dd1816020860160208601613d95565b601f01601f19169290920160200192915050565b6020815260006111a96020830184613db9565b6001600160a01b03811681146134ab57600080fd5b60008060408385031215613e2057600080fd5b8235613e2b81613df8565b946020939093013593505050565b600060208284031215613e4b57600080fd5b81356111a981613df8565b600080600060608486031215613e6b57600080fd5b8335613e7681613df8565b92506020840135613e8681613df8565b929592945050506040919091013590565b60008083601f840112613ea957600080fd5b50813567ffffffffffffffff811115613ec157600080fd5b60208301915083602082850101111561308157600080fd5b60008060008060408587031215613eef57600080fd5b843567ffffffffffffffff80821115613f0757600080fd5b613f1388838901613e97565b90965094506020870135915080821115613f2c57600080fd5b50613f3987828801613e97565b95989497509550505050565b600060208284031215613f5757600080fd5b5035919050565b600080600060408486031215613f7357600080fd5b83359250602084013567ffffffffffffffff811115613f9157600080fd5b613f9d86828701613e97565b9497909650939450505050565b6020808252825182820181905260009190848201906040850190845b81811015613fec5783516001600160e01b03191683529284019291840191600101613fc6565b50909695505050505050565b6000806020838503121561400b57600080fd5b823567ffffffffffffffff8082111561402357600080fd5b818501915085601f83011261403757600080fd5b81358181111561404657600080fd5b8660208260051b850101111561405b57600080fd5b60209290920196919550909350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b828110156140c457603f198886030184526140b2858351613db9565b94509285019290850190600101614096565b5092979650505050505050565b600080604083850312156140e457600080fd5b82356140ef81613df8565b915060208301356140ff81613df8565b809150509250929050565b600181811c9082168061411e57607f821691505b60208210810361223e57634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561418357600080fd5b815180151581146111a957600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b6000602082840312156141f957600080fd5b81516111a981613df8565b60006020828403121561421657600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b60208082526006908201526510b0b236b4b760d11b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b601f8211156117b2576000816000526020600020601f850160051c810160208610156142925750805b601f850160051c820191505b818110156142b15782815560010161429e565b505050505050565b67ffffffffffffffff8311156142d1576142d1614253565b6142e5836142df835461410a565b83614269565b6000601f84116001811461431957600085156143015750838201355b600019600387901b1c1916600186901b178355611027565b600083815260209020601f19861690835b8281101561434a578685013582556020948501946001909201910161432a565b50868210156143675760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610be257610be2614379565b80820180821115610be257610be2614379565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b600060ff82168061441057614410614379565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b60008261444d57634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261446957600080fd5b83018035915067ffffffffffffffff82111561448457600080fd5b60200191503681900382131561308157600080fd5b8183823760009101908152919050565b6000602082840312156144bb57600080fd5b815167ffffffffffffffff808211156144d357600080fd5b818401915084601f8301126144e757600080fd5b8151818111156144f9576144f9614253565b604051601f8201601f19908116603f0116810190838211818310171561452157614521614253565b8160405282815287602084870101111561453a57600080fd5b61396d836020830160208801613d95565b8082028115828204841417610be257610be261437956fea26469706673582212202015e3098149990088e7974b9931d93c1f7019c501c3d49dfeb83d77e8609f4064736f6c63430008160033", + "deployedBytecode": "0x60806040526004361061027d5760003560e01c80638d02d9a11161014f578063b1e23dbb116100c1578063cfcd4c071161007a578063cfcd4c0714610754578063dd62ed3e14610774578063f2b3abbd146107ba578063f3fdb15a146107da578063f8f9da28146107fa578063fca7820b1461080f57600080fd5b8063b1e23dbb1461068d578063bd6d894d146106ad578063be99f119146106c2578063c37f68e2146106de578063c3bf11cd1461071e578063c91a424f1461073457600080fd5b8063a6afed9511610113578063a6afed95146105ed578063a9059cbb14610602578063aa5af0fd14610622578063ac9650d814610638578063ae9d70b014610658578063b0a190761461066d57600080fd5b80638d02d9a1146105765780638f840ddd1461058c57806391dd36c6146105a257806395d89b41146105c25780639826394b146105d757600080fd5b80633c4f743c116101f35780636c540baf116101ac5780636c540baf146104be5780636f307dc3146104d457806370a08231146104f457806373acee981461052a5780637f15e2161461053f57806389f8132e1461055457600080fd5b80633c4f743c1461040557806347bd37181461043d5780634aeb3d9a146104535780635fe3b5671461046857806361feacff1461048d5780636752e702146104a357600080fd5b806323b872dd1161024557806323b872dd14610337578063313ce5671461035757806334154d4c1461038357806335daea64146103a55780633af9e669146103c55780633c3b4b89146103e557600080fd5b806306fdde0314610282578063095ea7b3146102ad578063173b9904146102dd57806317bfdfbc1461030157806318160ddd14610321575b600080fd5b34801561028e57600080fd5b5061029761082f565b6040516102a49190613de5565b60405180910390f35b3480156102b957600080fd5b506102cd6102c8366004613e0d565b6108bd565b60405190151581526020016102a4565b3480156102e957600080fd5b506102f360085481565b6040519081526020016102a4565b34801561030d57600080fd5b506102f361031c366004613e39565b610be8565b34801561032d57600080fd5b506102f3600f5481565b34801561034357600080fd5b506102cd610352366004613e56565b610d99565b34801561036357600080fd5b506003546103719060ff1681565b60405160ff90911681526020016102a4565b34801561038f57600080fd5b506103a361039e366004613ed9565b610fe8565b005b3480156103b157600080fd5b506102f36103c0366004613f45565b61102e565b3480156103d157600080fd5b506102f36103e0366004613e39565b6111b0565b3480156103f157600080fd5b506103a3610400366004613f5e565b61124b565b34801561041157600080fd5b50601454610425906001600160a01b031681565b6040516001600160a01b0390911681526020016102a4565b34801561044957600080fd5b506102f3600b5481565b34801561045f57600080fd5b506102f36117b7565b34801561047457600080fd5b506003546104259061010090046001600160a01b031681565b34801561049957600080fd5b506102f3600d5481565b3480156104af57600080fd5b506102f3666379da05b6000081565b3480156104ca57600080fd5b506102f360095481565b3480156104e057600080fd5b50601354610425906001600160a01b031681565b34801561050057600080fd5b506102f361050f366004613e39565b6001600160a01b031660009081526010602052604090205490565b34801561053657600080fd5b506102f3611854565b34801561054b57600080fd5b506102f36118e3565b34801561056057600080fd5b506105696119b4565b6040516102a49190613faa565b34801561058257600080fd5b506102f360065481565b34801561059857600080fd5b506102f3600c5481565b3480156105ae57600080fd5b506102f36105bd366004613f45565b612088565b3480156105ce57600080fd5b50610297612244565b3480156105e357600080fd5b506102f3600e5481565b3480156105f957600080fd5b506102f3612251565b34801561060e57600080fd5b506102cd61061d366004613e0d565b612362565b34801561062e57600080fd5b506102f3600a5481565b61064b610646366004613ff8565b6125b0565b6040516102a4919061406d565b34801561066457600080fd5b506102f36125bc565b34801561067957600080fd5b506103a3610688366004613e39565b6126e2565b34801561069957600080fd5b506102f36106a8366004613f45565b612728565b3480156106b957600080fd5b506102f3612858565b3480156106ce57600080fd5b506102f367016345785d8a000081565b3480156106ea57600080fd5b506106fe6106f9366004613e39565b612985565b6040805194855260208501939093529183015260608201526080016102a4565b34801561072a57600080fd5b506102f360075481565b34801561074057600080fd5b50600054610425906001600160a01b031681565b34801561076057600080fd5b506102f361076f366004613f45565b6129cb565b34801561078057600080fd5b506102f361078f3660046140d1565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b3480156107c657600080fd5b506102f36107d5366004613e39565b612af2565b3480156107e657600080fd5b50600454610425906001600160a01b031681565b34801561080657600080fd5b506102f3612c31565b34801561081b57600080fd5b506102f361082a366004613f45565b612cf8565b6001805461083c9061410a565b80601f01602080910402602001604051908101604052809291908181526020018280546108689061410a565b80156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169263df595cb89261090a9261010090910490911690339030906001600160e01b03198835169060040161413e565b602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b9190614171565b6109705760405162461bcd60e51b815260040161096790614193565b60405180910390fd5b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac19061099f906004016141bb565b602060405180830381865afa1580156109bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e091906141e7565b90506001600160a01b038116610a55573360008181526011602090815260408083206001600160a01b038916808552908352928190208790555186815283917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3600192505050610be2565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610a9857600080fd5b505af1158015610aac573d6000803e3d6000fd5b50503332039150610b1f9050573360008181526011602090815260408083206001600160a01b038a16808552908352928190208890555187815283917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a360019350505050610be2565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b158015610b6457600080fd5b505afa158015610b78573d6000803e3d6000fd5b50503360008181526011602090815260408083206001600160a01b038c16808552908352928190208a90555189815292945090925083917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3600193505050505b92915050565b6000804360095403610bfd5750600a54610c78565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c619190614204565b90506000610c6f4383612dae565b60200151925050505b6001600160a01b03831660009081526012602052604081208054829182918203610ca9575060009695505050505050565b8054610cb59086613043565b90945092506000846003811115610cce57610cce61421d565b14610d1b5760405162461bcd60e51b815260206004820152601e60248201527f216d756c55496e74206f766572666c6f7720636865636b206661696c656400006044820152606401610967565b610d29838260010154613088565b90945091506000846003811115610d4257610d4261421d565b14610d8f5760405162461bcd60e51b815260206004820152601e60248201527f2164697655496e74206f766572666c6f7720636865636b206661696c656400006044820152606401610967565b5095945050505050565b600080610da5816130b6565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb893610def93610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190614171565b610e4c5760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190610e7b906004016141bb565b602060405180830381865afa158015610e98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebc91906141e7565b90506001600160a01b038116610ee3576000610eda3388888861317a565b14925050610fd7565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b158015610f2657600080fd5b505af1158015610f3a573d6000803e3d6000fd5b50503332039150610f5f9050576000610f553389898961317a565b1493505050610fd7565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b158015610fa457600080fd5b505afa158015610fb8573d6000803e3d6000fd5b5060009250610fc5915050565b610fd13389898961317a565b14935050505b610fe08161342f565b509392505050565b610ff06134ae565b61100c5760405162461bcd60e51b815260040161096790614233565b60016110198486836142b9565b5060026110278284836142b9565b5050505050565b600080306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561106f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110939190614204565b9050828110156110de5760405162461bcd60e51b81526020600482015260166024820152750dac2e4d6cae840c6c2e6d040dcdee840cadcdeeaced60531b6044820152606401610967565b6004546001600160a01b031663b81688166110f9858461438f565b600b54600e54600d54600c5461110f91906143a2565b61111991906143a2565b60065460075460085461112c91906143a2565b61113691906143a2565b6040516001600160e01b031960e087901b16815260048101949094526024840192909252604483015260648201526084015b602060405180830381865afa158015611185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a99190614204565b9392505050565b60008060405180602001604052806111c6612858565b90526001600160a01b0384166000908152601060205260408120549192509081906111f2908490613625565b9092509050600082600381111561120b5761120b61421d565b146112435760405162461bcd60e51b81526020600482015260086024820152672162616c616e636560c01b6044820152606401610967565b949350505050565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb89361129593610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa1580156112b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d69190614171565b6112f25760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190611321906004016141bb565b602060405180830381865afa15801561133e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136291906141e7565b90506001600160a01b03811661152d5761137a612251565b5083600b600082825461138d91906143a2565b9091555030905060405163067db1b360e01b8152336004820152602481018690526001600160a01b03919091169063067db1b390604401600060405180830381600087803b1580156113de57600080fd5b505af11580156113f2573d6000803e3d6000fd5b505060135460405163012b1f4560e71b815233935063958fa280925061142a916001600160a01b0316908890889088906004016143b5565b600060405180830381600087803b15801561144457600080fd5b505af1158015611458573d6000803e3d6000fd5b505050506114633090565b6040516304d7c4cd60e21b8152336004820152602481018690526001600160a01b03919091169063135f1334906044016020604051808303816000875af11580156114b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d69190614204565b5083600b60008282546114e9919061438f565b909155505060408051338152602081018690527fe756d016d0e956882a6de9c72a2fe06d7d488ecbe6d76628713077ea7930cff8910160405180910390a150505050565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b15801561157057600080fd5b505af1158015611584573d6000803e3d6000fd5b5050333203915061174d905057611599612251565b5084600b60008282546115ac91906143a2565b9091555030905060405163067db1b360e01b8152336004820152602481018790526001600160a01b03919091169063067db1b390604401600060405180830381600087803b1580156115fd57600080fd5b505af1158015611611573d6000803e3d6000fd5b505060135460405163012b1f4560e71b815233935063958fa2809250611649916001600160a01b0316908990899089906004016143b5565b600060405180830381600087803b15801561166357600080fd5b505af1158015611677573d6000803e3d6000fd5b505050506116823090565b6040516304d7c4cd60e21b8152336004820152602481018790526001600160a01b03919091169063135f1334906044016020604051808303816000875af11580156116d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f59190614204565b5084600b6000828254611708919061438f565b909155505060408051338152602081018790527fe756d016d0e956882a6de9c72a2fe06d7d488ecbe6d76628713077ea7930cff8910160405180910390a15050505050565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b15801561179257600080fd5b505afa1580156117a6573d6000803e3d6000fd5b50505050611599612251565b505050565b6000600d54600e54600c546117cc91906143a2565b6117d691906143a2565b600b54306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183b9190614204565b61184591906143a2565b61184f919061438f565b905090565b600043600954036118665750600b5490565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ca9190614204565b905060006118d84383612dae565b606001519392505050565b60006118ed6134ae565b80611907575060035461010090046001600160a01b031633145b6119235760405162461bcd60e51b815260040161096790614233565b604051632210724360e11b8152738fba84867ba458e7c6e2c024d2de3d0b5c3ea1c26004820152738680ceabcb9b56913c519c069add6bc3494b7020908190634420e486906024016020604051808303816000875af115801561198a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ae9190614204565b91505090565b60408051601980825261034082019092526060919060009082602082016103208036833701905050905063a9059cbb60e01b816119f0846143fd565b93508360ff1681518110611a0657611a0661441a565b6001600160e01b0319909216602092830291909101909101526323b872dd60e01b81611a31846143fd565b93508360ff1681518110611a4757611a4761441a565b6001600160e01b031990921660209283029190910190910152636eb1769f60e11b81611a72846143fd565b93508360ff1681518110611a8857611a8861441a565b6001600160e01b03199092166020928302919091019091015263095ea7b360e01b81611ab3846143fd565b93508360ff1681518110611ac957611ac961441a565b6001600160e01b0319909216602092830291909101909101526370a0823160e01b81611af4846143fd565b93508360ff1681518110611b0a57611b0a61441a565b6001600160e01b0319909216602092830291909101909101526348ee9b6360e11b81611b35846143fd565b93508360ff1681518110611b4b57611b4b61441a565b6001600160e01b03199092166020928302919091019091015263f2b3abbd60e01b81611b76846143fd565b93508360ff1681518110611b8c57611b8c61441a565b6001600160e01b031990921660209283029190910190910152630d05535360e21b81611bb7846143fd565b93508360ff1681518110611bcd57611bcd61441a565b6001600160e01b031990921660209283029190910190910152635850c83b60e11b81611bf8846143fd565b93508360ff1681518110611c0e57611c0e61441a565b6001600160e01b03199092166020928302919091019091015263fca7820b60e01b81611c39846143fd565b93508360ff1681518110611c4f57611c4f61441a565b6001600160e01b031990921660209283029190910190910152630ae9d70b60e41b81611c7a846143fd565b93508360ff1681518110611c9057611c9061441a565b6001600160e01b031990921660209283029190910190910152631f1f3b4560e31b81611cbb846143fd565b93508360ff1681518110611cd157611cd161441a565b6001600160e01b03199092166020928302919091019091015263bd6d894d60e01b81611cfc846143fd565b93508360ff1681518110611d1257611d1261441a565b6001600160e01b03199092166020928302919091019091015263a6afed9560e01b81611d3d846143fd565b93508360ff1681518110611d5357611d5361441a565b6001600160e01b031990921660209283029190910190910152630e759dd360e31b81611d7e846143fd565b93508360ff1681518110611d9457611d9461441a565b6001600160e01b031990921660209283029190910190910152633af9e66960e01b81611dbf846143fd565b93508360ff1681518110611dd557611dd561441a565b6001600160e01b031990921660209283029190910190910152631592ca1b60e31b81611e00846143fd565b93508360ff1681518110611e1657611e1661441a565b6001600160e01b03199092166020928302919091019091015263b1e23dbb60e01b81611e41846143fd565b93508360ff1681518110611e5757611e5761441a565b6001600160e01b031990921660209283029190910190910152630d76ba9960e21b81611e82846143fd565b93508360ff1681518110611e9857611e9861441a565b6001600160e01b03199092166020928302919091019091015263cfcd4c0760e01b81611ec3846143fd565b93508360ff1681518110611ed957611ed961441a565b6001600160e01b0319909216602092830291909101909101526325759ecd60e11b81611f04846143fd565b93508360ff1681518110611f1a57611f1a61441a565b6001600160e01b031990921660209283029190910190910152633c3b4b8960e01b81611f45846143fd565b93508360ff1681518110611f5b57611f5b61441a565b6001600160e01b0319909216602092830291909101909101526361bfb47160e11b81611f86846143fd565b93508360ff1681518110611f9c57611f9c61441a565b6001600160e01b0319909216602092830291909101909101526305eff7ef60e21b81611fc7846143fd565b93508360ff1681518110611fdd57611fdd61441a565b6001600160e01b031990921660209283029190910190910152633f8af10b60e11b81612008846143fd565b93508360ff168151811061201e5761201e61441a565b6001600160e01b03199092166020928302919091019091015260ff821615610be25760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610967565b600080612094816130b6565b61209c612251565b5043600954146120b9576120b2600a6052613677565b9150612235565b60001983036120c85760065492505b60008060009054906101000a90046001600160a01b03166001600160a01b031663dd86fea16040518163ffffffff1660e01b8152600401602060405180830381865afa15801561211c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121409190614204565b9050670de0b6b3a7640000818560085461215a91906143a2565b61216491906143a2565b111561217e5761217660026053613677565b925050612235565b83600654146121e25761218f6134ae565b61219f5761217660016051613677565b600680549085905560408051828152602081018790527fcdd0b588250e1398549f79cfdb8217c186688822905d6715b0834ea1c865594a910160405180910390a1505b806007541461222e57600780549082905560408051828152602081018490527fedec4b9c99c2cdb231e7fd036f861e0445b015916700f41b9835f984cb9be4cb910160405180910390a1505b60005b9250505b61223e8161342f565b50919050565b6002805461083c9061410a565b60008043905080600954036122675760006119ae565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cb9190614204565b905060006122d98383612dae565b6009849055602081810151600a819055606080840151600b819055608080860151600c5560a0860151600e5560c0860151600d5560e0860151604080518a815296870191909152850193909352908301529192507f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04910160405180910390a16000935050505090565b60008061236e816130b6565b60008054600354604051631beb2b9760e31b81526001600160a01b039283169363df595cb8936123b893610100900416913391309190356001600160e01b0319169060040161413e565b602060405180830381865afa1580156123d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f99190614171565b6124155760405162461bcd60e51b815260040161096790614193565b60145460405163bf40fac160e01b81526000916001600160a01b03169063bf40fac190612444906004016141bb565b602060405180830381865afa158015612461573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248591906141e7565b90506001600160a01b0381166124ac5760006124a33333888861317a565b149250506125a0565b60405163b230eab960e01b815233600482015281906001600160a01b0382169063b230eab990602401600060405180830381600087803b1580156124ef57600080fd5b505af1158015612503573d6000803e3d6000fd5b50503332039150612528905057600061251e3333898961317a565b14935050506125a0565b604051633108c13b60e01b81523260048201523360248201526001600160a01b03821690633108c13b9060440160006040518083038186803b15801561256d57600080fd5b505afa158015612581573d6000803e3d6000fd5b506000925061258e915050565b61259a3333898961317a565b14935050505b6125a98161342f565b5092915050565b60606111a983836136f0565b6004546000906001600160a01b031663b8168816306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126329190614204565b600b54600e54600d54600c5461264891906143a2565b61265291906143a2565b60065460075460085461266591906143a2565b61266f91906143a2565b6040516001600160e01b031960e087901b16815260048101949094526024840192909252604483015260648201526084015b602060405180830381865afa1580156126be573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184f9190614204565b6126ea6134ae565b6127065760405162461bcd60e51b815260040161096790614233565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546000906001600160a01b031663b816881683306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561277b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279f9190614204565b6127a991906143a2565b600b54600e54600d54600c546127bf91906143a2565b6127c991906143a2565b6006546007546008546127dc91906143a2565b6127e691906143a2565b6040516001600160e01b031960e087901b1681526004810194909452602484019290925260448301526064820152608401602060405180830381865afa158015612834573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be29190614204565b600060095443036128e55761184f600f546005546128733090565b6001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d49190614204565b600b54600c54600d54600e54613836565b6000306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129499190614204565b905060006129574383612dae565b905061297e816040015160055484846060015185608001518660c001518760a00151613836565b9250505090565b6001600160a01b03811660009081526010602052604081205481908190819081806129af88610be8565b91506129b9612858565b90506000989297509095509350915050565b600080306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a309190614204565b905082811015612a7b5760405162461bcd60e51b81526020600482015260166024820152750dac2e4d6cae840c6c2e6d040dcdee840cadcdeeaced60531b6044820152606401610967565b6004546001600160a01b03166315f24053612a96858461438f565b85600b54612aa491906143a2565b600e54600d54600c54612ab791906143a2565b612ac191906143a2565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401611168565b600080612afe816130b6565b612b06612251565b50612b0f6134ae565b612b1f576120b26001604d613677565b4360095414612b34576120b2600a604c613677565b826001600160a01b0316632191f92a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b969190614171565b612bcc5760405162461bcd60e51b8152602060048201526007602482015266216e6f7449726d60c81b6044820152606401610967565b600480546001600160a01b038581166001600160a01b031983168117909355604080519190921680825260208201939093527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92691015b60405180910390a16000612231565b6004546000906001600160a01b03166315f24053306001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca79190614204565b600b54600e54600d54600c54612cbd91906143a2565b612cc791906143a2565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016126a1565b600080612d04816130b6565b612d0c612251565b50612d156134ae565b612d25576120b260016058613677565b4360095414612d3a576120b2600a6059613677565b670de0b6b3a764000060075460065485612d5491906143a2565b612d5e91906143a2565b1115612d70576120b26002605a613677565b600880549084905560408051828152602081018690527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101612c22565b612df660405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000600e54600d54612e0891906143a2565b600454600b54600c549293506000926001600160a01b03909216916315f24053918791612e369087906143a2565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401602060405180830381865afa158015612e7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea39190614204565b905065048c27395000811115612efa5781841115612ef15760405162461bcd60e51b815260206004820152600b60248201526a21626f72726f775261746560a81b6044820152606401610967565b5065048c273950005b600080612f0987600954613978565b90925090506000826003811115612f2257612f2261421d565b14612f5d5760405162461bcd60e51b815260206004820152600b60248201526a21626c6f636b44656c746160a81b6044820152606401610967565b868552600f54604080870191909152805160208101909152838152600090612f8590836139a3565b9050612f9381600b546139d4565b60e08701819052600b54612fa6916143a2565b60608701526040805160208101909152600854815260e0870151600c54612fce9291906139ec565b60808701526040805160208101909152600754815260e0870151600e54612ff69291906139ec565b60a08701526040805160208101909152600654815260e0870151600d5461301e9291906139ec565b60c0870152600a54613032908290806139ec565b602087015250939695505050505050565b6000808360000361305957506000905080613081565b838302836130678683614430565b1461307a57600260009250925050613081565b6000925090505b9250929050565b6000808260000361309f5750600190506000613081565b60006130ab8486614430565b915091509250929050565b600054600160a01b900460ff166130fc5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610967565b8061316a57600360019054906101000a90046001600160a01b03166001600160a01b031663c90c20b16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561315157600080fd5b505af1158015613165573d6000803e3d6000fd5b505050505b506000805460ff60a01b19169055565b6003546040516317b9b84b60e31b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283926101009091049091169063bdcdc258906084016020604051808303816000875af11580156131e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320a9190614204565b905080156132275761321f6003605b83613a16565b915050611243565b836001600160a01b0316856001600160a01b03160361324c5761321f6002605c613677565b6000856001600160a01b0316876001600160a01b0316036132705750600019613298565b506001600160a01b038086166000908152601160209081526040808320938a16835292905220545b6000806000806132a88589613978565b909450925060008460038111156132c1576132c161421d565b146132df576132d26009605c613677565b9650505050505050611243565b6001600160a01b038a166000908152601060205260409020546133029089613978565b9094509150600084600381111561331b5761331b61421d565b1461332c576132d26009605d613677565b6001600160a01b03891660009081526010602052604090205461334f9089613ab8565b909450905060008460038111156133685761336861421d565b14613379576132d26009605e613677565b6001600160a01b03808b16600090815260106020526040808220859055918b1681522081905560001985146133d1576001600160a01b03808b166000908152601160209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a60405161341691815260200190565b60405180910390a35060009a9950505050505050505050565b6000805460ff60a01b1916600160a01b179055806134ab57600360019054906101000a90046001600160a01b03166001600160a01b031663632e51426040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561349757600080fd5b505af1158015611027573d6000803e3d6000fd5b50565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015613507573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352b91906141e7565b6001600160a01b0316336001600160a01b03161480156135a85750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015613584573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a89190614171565b806119ae57506000546001600160a01b0316331480156119ae5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613601573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ae9190614171565b6000806000806136358686613ade565b9092509050600082600381111561364e5761364e61421d565b1461365f5750915060009050613081565b600061366a82613b5a565b9350935050509250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360118111156136ac576136ac61421d565b8360618111156136be576136be61421d565b60408051928352602083019190915260009082015260600160405180910390a18260118111156111a9576111a961421d565b60608167ffffffffffffffff81111561370b5761370b614253565b60405190808252806020026020018201604052801561373e57816020015b60608152602001906001900390816137295790505b50905060005b828110156125a957600080308686858181106137625761376261441a565b90506020028101906137749190614452565b604051613782929190614499565b600060405180830381855af49150503d80600081146137bd576040519150601f19603f3d011682016040523d82523d6000602084013e6137c2565b606091505b50915091508161380e576044815110156137db57600080fd5b600481019050808060200190518101906137f591906144a9565b60405162461bcd60e51b81526004016109679190613de5565b808484815181106138215761382161441a565b60209081029190910101525050600101613744565b60008760000361384757508561396d565b600061385f6040518060200160405280600081525090565b60006138808989876138718a8c6143a2565b61387b91906143a2565b613b72565b9350905060008160038111156138985761389861421d565b146138f35760405162461bcd60e51b815260206004820152602560248201527f216164645468656e53756255496e74206f766572666c6f7720636865636b2066604482015264185a5b195960da1b6064820152608401610967565b6138fd838c613bc5565b9250905060008160038111156139155761391561421d565b146139625760405162461bcd60e51b815260206004820152601d60248201527f21676574457870206f766572666c6f7720636865636b206661696c65640000006044820152606401610967565b5051915061396d9050565b979650505050505050565b60008083831161399757600061398e848661438f565b91509150613081565b50600390506000613081565b60408051602081019091526000815260405180602001604052806139cb856000015185613c90565b90529392505050565b6000806139e184846139a3565b905061124381613b5a565b6000806139f985856139a3565b9050613a0d613a0782613b5a565b84613cd2565b95945050505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846011811115613a4b57613a4b61421d565b846061811115613a5d57613a5d61421d565b604080519283526020830191909152810184905260600160405180910390a16003846011811115613a9057613a9061421d565b14613aac57836011811115613aa757613aa761421d565b611243565b611243826103e86143a2565b600080838301848110613ad057600092509050613081565b600260009250925050613081565b6000613af66040518060200160405280600081525090565b600080613b07866000015186613043565b90925090506000826003811115613b2057613b2061421d565b14613b3f57506040805160208101909152600081529092509050613081565b60408051602081019091529081526000969095509350505050565b8051600090610be290670de0b6b3a764000090614430565b600080600080613b828787613ab8565b90925090506000826003811115613b9b57613b9b61421d565b14613bac5750915060009050613bbd565b613bb68186613978565b9350935050505b935093915050565b6000613bdd6040518060200160405280600081525090565b600080613bf286670de0b6b3a7640000613043565b90925090506000826003811115613c0b57613c0b61421d565b14613c2a57506040805160208101909152600081529092509050613081565b600080613c378388613088565b90925090506000826003811115613c5057613c5061421d565b14613c735781604051806020016040528060008152509550955050505050613081565b604080516020810190915290815260009890975095505050505050565b60006111a983836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250613d08565b60006111a98383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250613d64565b6000831580613d15575082155b15613d22575060006111a9565b6000613d2e848661454b565b905083613d3b8683614430565b148390613d5b5760405162461bcd60e51b81526004016109679190613de5565b50949350505050565b600080613d7184866143a2565b90508285821015613d5b5760405162461bcd60e51b81526004016109679190613de5565b60005b83811015613db0578181015183820152602001613d98565b50506000910152565b60008151808452613dd1816020860160208601613d95565b601f01601f19169290920160200192915050565b6020815260006111a96020830184613db9565b6001600160a01b03811681146134ab57600080fd5b60008060408385031215613e2057600080fd5b8235613e2b81613df8565b946020939093013593505050565b600060208284031215613e4b57600080fd5b81356111a981613df8565b600080600060608486031215613e6b57600080fd5b8335613e7681613df8565b92506020840135613e8681613df8565b929592945050506040919091013590565b60008083601f840112613ea957600080fd5b50813567ffffffffffffffff811115613ec157600080fd5b60208301915083602082850101111561308157600080fd5b60008060008060408587031215613eef57600080fd5b843567ffffffffffffffff80821115613f0757600080fd5b613f1388838901613e97565b90965094506020870135915080821115613f2c57600080fd5b50613f3987828801613e97565b95989497509550505050565b600060208284031215613f5757600080fd5b5035919050565b600080600060408486031215613f7357600080fd5b83359250602084013567ffffffffffffffff811115613f9157600080fd5b613f9d86828701613e97565b9497909650939450505050565b6020808252825182820181905260009190848201906040850190845b81811015613fec5783516001600160e01b03191683529284019291840191600101613fc6565b50909695505050505050565b6000806020838503121561400b57600080fd5b823567ffffffffffffffff8082111561402357600080fd5b818501915085601f83011261403757600080fd5b81358181111561404657600080fd5b8660208260051b850101111561405b57600080fd5b60209290920196919550909350505050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b828110156140c457603f198886030184526140b2858351613db9565b94509285019290850190600101614096565b5092979650505050505050565b600080604083850312156140e457600080fd5b82356140ef81613df8565b915060208301356140ff81613df8565b809150509250929050565b600181811c9082168061411e57607f821691505b60208210810361223e57634e487b7160e01b600052602260045260246000fd5b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b60006020828403121561418357600080fd5b815180151581146111a957600080fd5b6020808252600e908201526d1b9bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526012908201527148595045524e41544956455f4f5241434c4560701b604082015260600190565b6000602082840312156141f957600080fd5b81516111a981613df8565b60006020828403121561421657600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b60208082526006908201526510b0b236b4b760d11b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b601f8211156117b2576000816000526020600020601f850160051c810160208610156142925750805b601f850160051c820191505b818110156142b15782815560010161429e565b505050505050565b67ffffffffffffffff8311156142d1576142d1614253565b6142e5836142df835461410a565b83614269565b6000601f84116001811461431957600085156143015750838201355b600019600387901b1c1916600186901b178355611027565b600083815260209020601f19861690835b8281101561434a578685013582556020948501946001909201910161432a565b50868210156143675760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610be257610be2614379565b80820180821115610be257610be2614379565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b600060ff82168061441057614410614379565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b60008261444d57634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261446957600080fd5b83018035915067ffffffffffffffff82111561448457600080fd5b60200191503681900382131561308157600080fd5b8183823760009101908152919050565b6000602082840312156144bb57600080fd5b815167ffffffffffffffff808211156144d357600080fd5b818401915084601f8301126144e757600080fd5b8151818111156144f9576144f9614253565b604051601f8201601f19908116603f0116810190838211818310171561452157614521614253565b8160405282815287602084870101111561453a57600080fd5b61396d836020830160208801613d95565b8082028115828204841417610be257610be261437956fea26469706673582212202015e3098149990088e7974b9931d93c1f7019c501c3d49dfeb83d77e8609f4064736f6c63430008160033", + "devdoc": { + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "_setAdminFee(uint256)": { + "details": "Admin function to accrue interest and set a new admin fee", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_setInterestRateModel(address)": { + "details": "Admin function to accrue interest and update the interest rate model", + "params": { + "newInterestRateModel": "the new interest rate model to use" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_setNameAndSymbol(string,string)": { + "details": "Admin function to update the cToken ERC20 name and symbol", + "params": { + "_name": "the new ERC20 token name to use", + "_symbol": "the new ERC20 token symbol to use" + } + }, + "_setReserveFactor(uint256)": { + "details": "Admin function to accrue interest and set a new reserve factor", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "accrueInterest()": { + "details": "This calculates interest accrued from the last checkpointed block up to the current block and writes new checkpoint to storage." + }, + "allowance(address,address)": { + "params": { + "owner": "The address of the account which owns the tokens to be spent", + "spender": "The address of the account which may transfer tokens" + }, + "returns": { + "_0": "The number of tokens allowed to be spent (-1 means infinite)" + } + }, + "approve(address,uint256)": { + "details": "This will overwrite the approval amount for `spender` and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)", + "params": { + "amount": "The number of tokens that are approved (-1 means infinite)", + "spender": "The address of the account which may transfer tokens" + }, + "returns": { + "_0": "Whether or not the approval succeeded" + } + }, + "balanceOf(address)": { + "params": { + "owner": "The address of the account to query" + }, + "returns": { + "_0": "The number of tokens owned by `owner`" + } + }, + "balanceOfUnderlying(address)": { + "params": { + "owner": "The address of the account to query" + }, + "returns": { + "_0": "The amount of underlying owned by `owner`" + } + }, + "borrowBalanceCurrent(address)": { + "params": { + "account": "The address whose balance should be calculated after recalculating the borrowIndex" + }, + "returns": { + "_0": "The calculated balance" + } + }, + "borrowRatePerBlock()": { + "returns": { + "_0": "The borrow interest rate per block, scaled by 1e18" + } + }, + "exchangeRateCurrent()": { + "returns": { + "_0": "Calculated exchange rate scaled by 1e18" + } + }, + "getAccountSnapshot(address)": { + "details": "This is used by comptroller to more efficiently perform liquidity checks.", + "params": { + "account": "Address of the account to snapshot" + }, + "returns": { + "_0": "(possible error, token balance, borrow balance, exchange rate mantissa)" + } + }, + "supplyRatePerBlock()": { + "returns": { + "_0": "The supply interest rate per block, scaled by 1e18" + } + }, + "totalBorrowsCurrent()": { + "returns": { + "_0": "The total borrows with interest" + } + }, + "transfer(address,uint256)": { + "params": { + "amount": "The number of tokens to transfer", + "dst": "The address of the destination account" + }, + "returns": { + "_0": "Whether or not the transfer succeeded" + } + }, + "transferFrom(address,address,uint256)": { + "params": { + "amount": "The number of tokens to transfer", + "dst": "The address of the destination account", + "src": "The address of the source account" + }, + "returns": { + "_0": "Whether or not the transfer succeeded" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "AccrueInterest(uint256,uint256,uint256,uint256)": { + "notice": "Event emitted when interest is accrued" + }, + "Approval(address,address,uint256)": { + "notice": "EIP20 Approval event" + }, + "NewAdminFee(uint256,uint256)": { + "notice": "Event emitted when the admin fee is changed" + }, + "NewIonicFee(uint256,uint256)": { + "notice": "Event emitted when the Ionic fee is changed" + }, + "NewMarketInterestRateModel(address,address)": { + "notice": "Event emitted when interestRateModel is changed" + }, + "NewReserveFactor(uint256,uint256)": { + "notice": "Event emitted when the reserve factor is changed" + }, + "Transfer(address,address,uint256)": { + "notice": "EIP20 Transfer event" + } + }, + "kind": "user", + "methods": { + "_setAdminFee(uint256)": { + "notice": "accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh" + }, + "_setInterestRateModel(address)": { + "notice": "accrues interest and updates the interest rate model using _setInterestRateModelFresh" + }, + "_setNameAndSymbol(string,string)": { + "notice": "updates the cToken ERC20 name and symbol" + }, + "_setReserveFactor(uint256)": { + "notice": "accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh" + }, + "accrualBlockNumber()": { + "notice": "Block number that interest was last accrued at" + }, + "accrueInterest()": { + "notice": "Applies accrued interest to total borrows and reserves" + }, + "adminFeeMantissa()": { + "notice": "Fraction of interest currently set aside for admin fees" + }, + "allowance(address,address)": { + "notice": "Get the current allowance from `owner` for `spender`" + }, + "ap()": { + "notice": "Addresses Provider" + }, + "approve(address,uint256)": { + "notice": "Approve `spender` to transfer up to `amount` from `src`" + }, + "balanceOf(address)": { + "notice": "Get the token balance of the `owner`" + }, + "balanceOfUnderlying(address)": { + "notice": "Get the underlying balance of the `owner`" + }, + "borrowBalanceCurrent(address)": { + "notice": "calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex" + }, + "borrowIndex()": { + "notice": "Accumulator of the total earned interest rate since the opening of the market" + }, + "borrowRatePerBlock()": { + "notice": "Returns the current per-block borrow interest rate for this cToken" + }, + "comptroller()": { + "notice": "Contract which oversees inter-cToken operations" + }, + "decimals()": { + "notice": "EIP-20 token decimals for this token" + }, + "exchangeRateCurrent()": { + "notice": "Accrue interest then return the up-to-date exchange rate" + }, + "getAccountSnapshot(address)": { + "notice": "Get a snapshot of the account's balances, and the cached exchange rate" + }, + "interestRateModel()": { + "notice": "Model which tells what the current interest rate should be" + }, + "ionicFeeMantissa()": { + "notice": "Fraction of interest currently set aside for Ionic fees" + }, + "name()": { + "notice": "EIP-20 token name for this token" + }, + "reserveFactorMantissa()": { + "notice": "Fraction of interest currently set aside for reserves" + }, + "supplyRatePerBlock()": { + "notice": "Returns the current per-block supply interest rate for this cToken" + }, + "symbol()": { + "notice": "EIP-20 token symbol for this token" + }, + "totalAdminFees()": { + "notice": "Total amount of admin fees of the underlying held in this market" + }, + "totalBorrows()": { + "notice": "Total amount of outstanding borrows of the underlying in this market" + }, + "totalBorrowsCurrent()": { + "notice": "Returns the current total borrows plus accrued interest" + }, + "totalIonicFees()": { + "notice": "Total amount of Ionic fees of the underlying held in this market" + }, + "totalReserves()": { + "notice": "Total amount of reserves of the underlying held in this market" + }, + "totalSupply()": { + "notice": "Total number of tokens in circulation" + }, + "transfer(address,uint256)": { + "notice": "Transfer `amount` tokens from `msg.sender` to `dst`" + }, + "transferFrom(address,address,uint256)": { + "notice": "Transfer `amount` tokens from `src` to `dst`" + }, + "underlying()": { + "notice": "Underlying asset for this CToken" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 17997, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 18003, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "_notEntered", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 18006, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "name", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 18009, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "symbol", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 18012, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "decimals", + "offset": 0, + "slot": "3", + "type": "t_uint8" + }, + { + "astId": 18022, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "comptroller", + "offset": 1, + "slot": "3", + "type": "t_contract(IonicComptroller)25652" + }, + { + "astId": 18026, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "interestRateModel", + "offset": 0, + "slot": "4", + "type": "t_contract(InterestRateModel)28313" + }, + { + "astId": 18028, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "initialExchangeRateMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 18031, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "adminFeeMantissa", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 18034, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "ionicFeeMantissa", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 18037, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "reserveFactorMantissa", + "offset": 0, + "slot": "8", + "type": "t_uint256" + }, + { + "astId": 18040, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "accrualBlockNumber", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 18043, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "borrowIndex", + "offset": 0, + "slot": "10", + "type": "t_uint256" + }, + { + "astId": 18046, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "totalBorrows", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 18049, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "totalReserves", + "offset": 0, + "slot": "12", + "type": "t_uint256" + }, + { + "astId": 18052, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "totalAdminFees", + "offset": 0, + "slot": "13", + "type": "t_uint256" + }, + { + "astId": 18055, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "totalIonicFees", + "offset": 0, + "slot": "14", + "type": "t_uint256" + }, + { + "astId": 18058, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "totalSupply", + "offset": 0, + "slot": "15", + "type": "t_uint256" + }, + { + "astId": 18062, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "accountTokens", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 18068, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "transferAllowances", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 18079, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "accountBorrows", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_struct(BorrowSnapshot)18074_storage)" + }, + { + "astId": 18088, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "underlying", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 18092, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "ap", + "offset": 0, + "slot": "20", + "type": "t_contract(AddressesProvider)37930" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(AddressesProvider)37930": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(InterestRateModel)28313": { + "encoding": "inplace", + "label": "contract InterestRateModel", + "numberOfBytes": "20" + }, + "t_contract(IonicComptroller)25652": { + "encoding": "inplace", + "label": "contract IonicComptroller", + "numberOfBytes": "20" + }, + "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_struct(BorrowSnapshot)18074_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct CErc20Storage.BorrowSnapshot)", + "numberOfBytes": "32", + "value": "t_struct(BorrowSnapshot)18074_storage" + }, + "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_struct(BorrowSnapshot)18074_storage": { + "encoding": "inplace", + "label": "struct CErc20Storage.BorrowSnapshot", + "members": [ + { + "astId": 18071, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "principal", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 18073, + "contract": "contracts/compound/CTokenFirstExtension.sol:CTokenFirstExtension", + "label": "interestIndex", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/Comptroller.json b/packages/contracts/deployments/superseed/Comptroller.json new file mode 100644 index 0000000000..215bc816a8 --- /dev/null +++ b/packages/contracts/deployments/superseed/Comptroller.json @@ -0,0 +1,2568 @@ +{ + "address": "0x8ea3fc79D9E463464C5159578d38870b770f6E57", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "rewardsDistributor", + "type": "address" + } + ], + "name": "AddedRewardsDistributor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketEntered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MarketExited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "MarketListed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCloseFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCloseFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldCollateralFactorMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "NewCollateralFactor", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldLiquidationIncentiveMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "NewLiquidationIncentive", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract BasePriceOracle", + "name": "oldPriceOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract BasePriceOracle", + "name": "newPriceOracle", + "type": "address" + } + ], + "name": "NewPriceOracle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "enforce", + "type": "bool" + } + ], + "name": "WhitelistEnforcementChanged", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "distributor", + "type": "address" + } + ], + "name": "_addRewardsDistributor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_afterNonReentrant", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_becomeImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_beforeNonReentrant", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "constructorData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "becomeImplData", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + } + ], + "name": "_deployMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "_mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newCloseFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCloseFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newCollateralFactorMantissa", + "type": "uint256" + } + ], + "name": "_setCollateralFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newLiquidationIncentiveMantissa", + "type": "uint256" + } + ], + "name": "_setLiquidationIncentive", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "_setPriceOracle", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "enforce", + "type": "bool" + } + ], + "name": "_setWhitelistEnforcement", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "suppliers", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "statuses", + "type": "bool[]" + } + ], + "name": "_setWhitelistStatuses", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "accountAssets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allBorrowers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allMarkets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + } + ], + "name": "borrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCapForCollateral", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "borrowCapGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "accountBorrowsNew", + "type": "uint256" + } + ], + "name": "borrowWithinLimits", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowingAgainstCollateralBlacklist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cTokensByUnderlying", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "checkMembership", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "closeFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveBorrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveSupplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enforceWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "cTokens", + "type": "address[]" + } + ], + "name": "enterMarkets", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenAddress", + "type": "address" + } + ], + "name": "exitMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAssetsIn", + "outputs": [ + { + "internalType": "contract ICErc20[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenModify", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "getHypotheticalAccountLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenModify", + "type": "address" + }, + { + "internalType": "bool", + "name": "isBorrow", + "type": "bool" + } + ], + "name": "getMaxRedeemOrBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isComptroller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "isDeprecated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "liquidateBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualRepayAmount", + "type": "uint256" + } + ], + "name": "liquidateCalculateSeizeTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidationIncentiveMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mintAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "actualMintAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintTokens", + "type": "uint256" + } + ], + "name": "mintVerify", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "nonAccruingRewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeemVerify", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "repayBorrowAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "rewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenBorrowed", + "type": "address" + }, + { + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "seizeTokens", + "type": "uint256" + } + ], + "name": "seizeAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "seizeGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "suppliers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "supplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "transferTokens", + "type": "uint256" + } + ], + "name": "transferAllowed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "transferGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "whitelistArray", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xfca3a12b4f6a668be71142bd9d8e657ecce62f290addcbccb9279a6408711d1e", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x8ea3fc79D9E463464C5159578d38870b770f6E57", + "transactionIndex": 1, + "gasUsed": "5073860", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xdb5d962f2ce6c12b75c372ad165677b2babe6b33f5ebc3ee4da9f797bc43b960", + "transactionHash": "0xfca3a12b4f6a668be71142bd9d8e657ecce62f290addcbccb9279a6408711d1e", + "logs": [], + "blockNumber": 4134110, + "cumulativeGasUsed": "5117738", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"rewardsDistributor\",\"type\":\"address\"}],\"name\":\"AddedRewardsDistributor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"MarketEntered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"MarketExited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"MarketListed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldCloseFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newCloseFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewCloseFactor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldCollateralFactorMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newCollateralFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"NewCollateralFactor\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldLiquidationIncentiveMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newLiquidationIncentiveMantissa\",\"type\":\"uint256\"}],\"name\":\"NewLiquidationIncentive\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract BasePriceOracle\",\"name\":\"oldPriceOracle\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract BasePriceOracle\",\"name\":\"newPriceOracle\",\"type\":\"address\"}],\"name\":\"NewPriceOracle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enforce\",\"type\":\"bool\"}],\"name\":\"WhitelistEnforcementChanged\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"distributor\",\"type\":\"address\"}],\"name\":\"_addRewardsDistributor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_afterNonReentrant\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_becomeImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_beforeNonReentrant\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"delegateType\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"constructorData\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"becomeImplData\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"_deployMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newCloseFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"_setCloseFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newCollateralFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"_setCollateralFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newLiquidationIncentiveMantissa\",\"type\":\"uint256\"}],\"name\":\"_setLiquidationIncentive\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"newOracle\",\"type\":\"address\"}],\"name\":\"_setPriceOracle\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"enforce\",\"type\":\"bool\"}],\"name\":\"_setWhitelistEnforcement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"suppliers\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"statuses\",\"type\":\"bool[]\"}],\"name\":\"_setWhitelistStatuses\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"accountAssets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allBorrowers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allMarkets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"}],\"name\":\"borrowAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCapForCollateral\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowCapGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"accountBorrowsNew\",\"type\":\"uint256\"}],\"name\":\"borrowWithinLimits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowingAgainstCollateralBlacklist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"cTokensByUnderlying\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"checkMembership\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"closeFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveBorrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveSupplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplyCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enforceWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"cTokens\",\"type\":\"address[]\"}],\"name\":\"enterMarkets\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenAddress\",\"type\":\"address\"}],\"name\":\"exitMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getAccountLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getAssetsIn\",\"outputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenModify\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"getHypotheticalAccountLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenModify\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBorrow\",\"type\":\"bool\"}],\"name\":\"getMaxRedeemOrBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isComptroller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"isDeprecated\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrowed\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"liquidateBorrowAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrowed\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"actualRepayAmount\",\"type\":\"uint256\"}],\"name\":\"liquidateCalculateSeizeTokens\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidationIncentiveMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"markets\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isListed\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactorMantissa\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"mintAmount\",\"type\":\"uint256\"}],\"name\":\"mintAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"actualMintAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"mintTokens\",\"type\":\"uint256\"}],\"name\":\"mintVerify\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"nonAccruingRewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"redeemAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"redeemAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"}],\"name\":\"redeemVerify\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"payer\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"repayBorrowAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"rewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenBorrowed\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"seizeTokens\",\"type\":\"uint256\"}],\"name\":\"seizeAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"seizeGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"suppliers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"supplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"src\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"dst\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"transferTokens\",\"type\":\"uint256\"}],\"name\":\"transferAllowed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"whitelistArray\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Compound\",\"details\":\"This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\",\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_addRewardsDistributor(address)\":{\"details\":\"Admin function to add a RewardsDistributor contract\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_afterNonReentrant()\":{\"details\":\"Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention. Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\"},\"_beforeNonReentrant()\":{\"details\":\"Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention. Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\"},\"_deployMarket(uint8,bytes,bytes,uint256)\":{\"details\":\"Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See enum Error for details)\"}},\"_getExtensionFunctions()\":{\"returns\":{\"functionSelectors\":\"a list of all the function selectors that this logic extension exposes\"}},\"_setCloseFactor(uint256)\":{\"details\":\"Admin function to set closeFactor\",\"params\":{\"newCloseFactorMantissa\":\"New close factor, scaled by 1e18\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See ErrorReporter for details)\"}},\"_setCollateralFactor(address,uint256)\":{\"details\":\"Admin function to set per-market collateralFactor\",\"params\":{\"cToken\":\"The market to set the factor on\",\"newCollateralFactorMantissa\":\"The new collateral factor, scaled by 1e18\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See ErrorReporter for details)\"}},\"_setLiquidationIncentive(uint256)\":{\"details\":\"Admin function to set liquidationIncentive\",\"params\":{\"newLiquidationIncentiveMantissa\":\"New liquidationIncentive scaled by 1e18\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See ErrorReporter for details)\"}},\"_setPriceOracle(address)\":{\"details\":\"Admin function to set a new price oracle\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_setWhitelistEnforcement(bool)\":{\"details\":\"Admin function to set a new whitelist enforcement boolean\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"_setWhitelistStatuses(address[],bool[])\":{\"details\":\"Admin function to set the whitelist `statuses` for `suppliers`\",\"returns\":{\"_0\":\"uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\"}},\"borrowAllowed(address,address,uint256)\":{\"params\":{\"borrowAmount\":\"The amount of underlying the account would borrow\",\"borrower\":\"The account which would borrow the asset\",\"cToken\":\"The market to verify the borrow against\"},\"returns\":{\"_0\":\"0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\"}},\"borrowWithinLimits(address,uint256)\":{\"params\":{\"accountBorrowsNew\":\"The user's new borrow balance of the underlying asset\",\"cToken\":\"Asset whose underlying is being borrowed\"}},\"checkMembership(address,address)\":{\"params\":{\"account\":\"The address of the account to check\",\"cToken\":\"The cToken to check\"},\"returns\":{\"_0\":\"True if the account is in the asset, otherwise false.\"}},\"effectiveBorrowCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"effectiveSupplyCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"enterMarkets(address[])\":{\"params\":{\"cTokens\":\"The list of addresses of the cToken markets to be enabled\"},\"returns\":{\"_0\":\"Success indicator for whether each corresponding market was entered\"}},\"exitMarket(address)\":{\"details\":\"Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral for an outstanding borrow.\",\"params\":{\"cTokenAddress\":\"The address of the asset to be removed\"},\"returns\":{\"_0\":\"Whether or not the account successfully exited the market\"}},\"getAssetsIn(address)\":{\"params\":{\"account\":\"The address of the account to pull assets for\"},\"returns\":{\"_0\":\"A dynamic list with the assets the account has entered\"}},\"getHypotheticalAccountLiquidity(address,address,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account to determine liquidity for\",\"borrowAmount\":\"The amount of underlying to hypothetically borrow\",\"cTokenModify\":\"The market to hypothetically redeem/borrow in\",\"redeemTokens\":\"The number of tokens to hypothetically redeem\"},\"returns\":{\"_0\":\"(possible error code (semi-opaque), hypothetical account liquidity in excess of collateral requirements, hypothetical account shortfall below collateral requirements)\"}},\"isDeprecated(address)\":{\"details\":\"All borrows in a deprecated cToken market can be immediately liquidated\",\"params\":{\"cToken\":\"The market to check if deprecated\"}},\"liquidateBorrowAllowed(address,address,address,address,uint256)\":{\"params\":{\"borrower\":\"The address of the borrower\",\"cTokenBorrowed\":\"Asset which was borrowed by the borrower\",\"cTokenCollateral\":\"Asset which was used as collateral and will be seized\",\"liquidator\":\"The address repaying the borrow and seizing the collateral\",\"repayAmount\":\"The amount of underlying being repaid\"}},\"liquidateCalculateSeizeTokens(address,address,uint256)\":{\"details\":\"Used in liquidation (called in cToken.liquidateBorrowFresh)\",\"params\":{\"actualRepayAmount\":\"The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\",\"cTokenBorrowed\":\"The address of the borrowed cToken\",\"cTokenCollateral\":\"The address of the collateral cToken\"},\"returns\":{\"_0\":\"(errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\"}},\"mintAllowed(address,address,uint256)\":{\"params\":{\"cTokenAddress\":\"The market to verify the mint against\",\"mintAmount\":\"The amount of underlying being supplied to the market in exchange for tokens\",\"minter\":\"The account which would get the minted tokens\"},\"returns\":{\"_0\":\"0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\"}},\"mintVerify(address,address,uint256,uint256)\":{\"params\":{\"actualMintAmount\":\"The amount of the underlying asset being minted\",\"cToken\":\"Asset being minted\",\"mintTokens\":\"The number of tokens being minted\",\"minter\":\"The address minting the tokens\"}},\"redeemAllowed(address,address,uint256)\":{\"params\":{\"cToken\":\"The market to verify the redeem against\",\"redeemTokens\":\"The number of cTokens to exchange for the underlying asset in the market\",\"redeemer\":\"The account which would redeem the tokens\"},\"returns\":{\"_0\":\"0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\"}},\"redeemVerify(address,address,uint256,uint256)\":{\"params\":{\"cToken\":\"Asset being redeemed\",\"redeemAmount\":\"The amount of the underlying asset being redeemed\",\"redeemTokens\":\"The number of tokens being redeemed\",\"redeemer\":\"The address redeeming the tokens\"}},\"repayBorrowAllowed(address,address,address,uint256)\":{\"params\":{\"borrower\":\"The account which would borrowed the asset\",\"cToken\":\"The market to verify the repay against\",\"payer\":\"The account which would repay the asset\",\"repayAmount\":\"The amount of the underlying asset the account would repay\"},\"returns\":{\"_0\":\"0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\"}},\"seizeAllowed(address,address,address,address,uint256)\":{\"params\":{\"borrower\":\"The address of the borrower\",\"cTokenBorrowed\":\"Asset which was borrowed by the borrower\",\"cTokenCollateral\":\"Asset which was used as collateral and will be seized\",\"liquidator\":\"The address repaying the borrow and seizing the collateral\",\"seizeTokens\":\"The number of collateral tokens to seize\"}},\"transferAllowed(address,address,address,uint256)\":{\"params\":{\"cToken\":\"The market to verify the transfer against\",\"dst\":\"The account which receives the tokens\",\"src\":\"The account which sources the tokens\",\"transferTokens\":\"The number of cTokens to transfer\"},\"returns\":{\"_0\":\"0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\"}}},\"title\":\"Compound's Comptroller Contract\",\"version\":1},\"userdoc\":{\"events\":{\"AddedRewardsDistributor(address)\":{\"notice\":\"Emitted when a new RewardsDistributor contract is added to hooks\"},\"MarketEntered(address,address)\":{\"notice\":\"Emitted when an account enters a market\"},\"MarketExited(address,address)\":{\"notice\":\"Emitted when an account exits a market\"},\"MarketListed(address)\":{\"notice\":\"Emitted when an admin supports a market\"},\"NewCloseFactor(uint256,uint256)\":{\"notice\":\"Emitted when close factor is changed by admin\"},\"NewCollateralFactor(address,uint256,uint256)\":{\"notice\":\"Emitted when a collateral factor is changed by admin\"},\"NewLiquidationIncentive(uint256,uint256)\":{\"notice\":\"Emitted when liquidation incentive is changed by admin\"},\"NewPriceOracle(address,address)\":{\"notice\":\"Emitted when price oracle is changed\"},\"WhitelistEnforcementChanged(bool)\":{\"notice\":\"Emitted when the whitelist enforcement is changed\"}},\"kind\":\"user\",\"methods\":{\"_addRewardsDistributor(address)\":{\"notice\":\"Add a RewardsDistributor contracts.\"},\"_deployMarket(uint8,bytes,bytes,uint256)\":{\"notice\":\"Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\"},\"_setCloseFactor(uint256)\":{\"notice\":\"Sets the closeFactor used when liquidating borrows\"},\"_setCollateralFactor(address,uint256)\":{\"notice\":\"Sets the collateralFactor for a market\"},\"_setLiquidationIncentive(uint256)\":{\"notice\":\"Sets liquidationIncentive\"},\"_setPriceOracle(address)\":{\"notice\":\"Sets a new price oracle for the comptroller\"},\"_setWhitelistEnforcement(bool)\":{\"notice\":\"Sets the whitelist enforcement for the comptroller\"},\"_setWhitelistStatuses(address[],bool[])\":{\"notice\":\"Sets the whitelist `statuses` for `suppliers`\"},\"accountAssets(address,uint256)\":{\"notice\":\"Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\"},\"admin()\":{\"notice\":\"Administrator for this contract\"},\"adminHasRights()\":{\"notice\":\"Whether or not the admin has admin rights\"},\"allBorrowers(uint256)\":{\"notice\":\"A list of all borrowers who have entered markets\"},\"allMarkets(uint256)\":{\"notice\":\"A list of all markets\"},\"borrowAllowed(address,address,uint256)\":{\"notice\":\"Checks if the account should be allowed to borrow the underlying asset of the given market\"},\"borrowCapGuardian()\":{\"notice\":\"The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\"},\"borrowCaps(address)\":{\"notice\":\"Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\"},\"borrowWithinLimits(address,uint256)\":{\"notice\":\"Checks if the account should be allowed to borrow the underlying asset of the given market\"},\"cTokensByUnderlying(address)\":{\"notice\":\"All cTokens addresses mapped by their underlying token addresses\"},\"checkMembership(address,address)\":{\"notice\":\"Returns whether the given account is entered in the given asset\"},\"closeFactorMantissa()\":{\"notice\":\"Multiplier used to calculate the maximum repayAmount when liquidating a borrow\"},\"effectiveBorrowCaps(address)\":{\"notice\":\"Gets the borrow cap of a cToken in the units of the underlying asset.\"},\"effectiveSupplyCaps(address)\":{\"notice\":\"Gets the supply cap of a cToken in the units of the underlying asset.\"},\"enforceWhitelist()\":{\"notice\":\"Whether or not the supplier whitelist is enforced\"},\"enterMarkets(address[])\":{\"notice\":\"Add assets to be included in account liquidity calculation\"},\"exitMarket(address)\":{\"notice\":\"Removes asset from sender's account liquidity calculation\"},\"getAssetsIn(address)\":{\"notice\":\"Returns the assets an account has entered\"},\"getHypotheticalAccountLiquidity(address,address,uint256,uint256,uint256)\":{\"notice\":\"Determine what the account liquidity would be if the given amounts were redeemed/borrowed\"},\"ionicAdminHasRights()\":{\"notice\":\"Whether or not the Ionic admin has admin rights\"},\"isComptroller()\":{\"notice\":\"Indicator that this is a Comptroller contract (for inspection)\"},\"isDeprecated(address)\":{\"notice\":\"Returns true if the given cToken market has been deprecated\"},\"liquidateBorrowAllowed(address,address,address,address,uint256)\":{\"notice\":\"Checks if the liquidation should be allowed to occur\"},\"liquidateCalculateSeizeTokens(address,address,uint256)\":{\"notice\":\"Calculate number of tokens of collateral asset to seize given an underlying amount\"},\"liquidationIncentiveMantissa()\":{\"notice\":\"Multiplier representing the discount on collateral that a liquidator receives\"},\"markets(address)\":{\"notice\":\"Official mapping of cTokens -> Market metadata\"},\"mintAllowed(address,address,uint256)\":{\"notice\":\"Checks if the account should be allowed to mint tokens in the given market\"},\"mintVerify(address,address,uint256,uint256)\":{\"notice\":\"Validates mint and reverts on rejection. May emit logs.\"},\"nonAccruingRewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor to list for claiming, but not to notify of flywheel changes.\"},\"oracle()\":{\"notice\":\"Oracle which gives the price of any given asset\"},\"pauseGuardian()\":{\"notice\":\"The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market.\"},\"pendingAdmin()\":{\"notice\":\"Pending administrator for this contract\"},\"redeemAllowed(address,address,uint256)\":{\"notice\":\"Checks if the account should be allowed to redeem tokens in the given market\"},\"redeemVerify(address,address,uint256,uint256)\":{\"notice\":\"Validates redeem and reverts on rejection. May emit logs.\"},\"repayBorrowAllowed(address,address,address,uint256)\":{\"notice\":\"Checks if the account should be allowed to repay a borrow in the given market\"},\"rewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor contracts to notify of flywheel changes.\"},\"seizeAllowed(address,address,address,address,uint256)\":{\"notice\":\"Checks if the seizing of assets should be allowed to occur\"},\"supplyCaps(address)\":{\"notice\":\"Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\"},\"transferAllowed(address,address,address,uint256)\":{\"notice\":\"Checks if the account should be allowed to transfer tokens in the given market\"},\"whitelist(address)\":{\"notice\":\"Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\"},\"whitelistArray(uint256)\":{\"notice\":\"An array of all whitelisted accounts\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/Comptroller.sol\":\"Comptroller\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040526002805461ffff60a01b191661010160a01b17905534801561002557600080fd5b50615a6480620000366000396000f3fe608060405234801561001057600080fd5b50600436106103da5760003560e01c80637e361b111161020a578063c299823811610125578063d251fefc116100b8578063e6653f3d11610087578063e6653f3d146109ce578063e8755446146109e2578063eabe7d91146109eb578063ede4edd0146109fe578063f851a44014610a1157600080fd5b8063d251fefc14610982578063da3d454c14610995578063dce15449146109a8578063e4028eee146109bb57600080fd5b8063c90c20b1116100f4578063c90c20b114610940578063c91a424f14610948578063cf6bfd2d1461095b578063d02f73511461096f57600080fd5b8063c2998238146108d2578063c488847b146108f2578063c6c5b0dd1461091a578063c8c9c9751461092d57600080fd5b80639b19251a1161019d578063b10348821161016c578063b103488214610886578063b452ef6214610899578063b9b5b153146108ac578063bdcdc258146108bf57600080fd5b80639b19251a14610822578063abfceffc14610845578063ac0b0bb714610865578063b09572101461087957600080fd5b8063929fe9a1116101d9578063929fe9a114610790578063940cd6f1146107d157806394543c15146107fc578063952adf5a1461080f57600080fd5b80637e361b111461071057806387f763031461072357806389f8132e146107375780638e8f294b1461074c57600080fd5b80634ada90af116102fa5780635fc7e71e1161028d578063731f0c2b1161025c578063731f0c2b146106b45780637515bafa146106d7578063779b2294146106ea5780637dc0d1d0146106fd57600080fd5b80635fc7e71e14610663578063632e5142146106765780636bd02b8a1461067e5780636d154ea51461069157600080fd5b806352d84d1e116102c957806352d84d1e1461060257806355ee1fe1146106155780635d72de62146106285780635ec88c791461063057600080fd5b80634ada90af146105c05780634ef4c3e1146105c95780634fd42e17146105dc57806351dff989146105ef57600080fd5b806324a3d6221161037257806331ff47fa1161034157806331ff47fa1461052c5780633c94786f1461055557806341c728b9146105695780634a584432146105a057600080fd5b806324a3d622146104e057806326782247146104f35780632ccf47a414610506578063317b0b771461051957600080fd5b80631976828e116103ae5780631976828e146104615780631c819e431461047457806321af4569146104a257806324008a62146104cd57600080fd5b80627e3dd2146103df57806302c3bcbb146103fc5780630a755ec21461042a57806316dc15fe1461043e575b600080fd5b6103e7600181565b60405190151581526020015b60405180910390f35b61041c61040a366004614ff9565b60186020526000908152604090205481565b6040519081526020016103f3565b6002546103e790600160a81b900460ff1681565b6103e761044c366004614ff9565b600d6020526000908152604090205460ff1681565b61041c61046f366004615024565b610a24565b6103e761048236600461506f565b601d60209081526000928352604080842090915290825290205460ff1681565b6016546104b5906001600160a01b031681565b6040516001600160a01b0390911681526020016103f3565b61041c6104db3660046150a8565b610c19565b6013546104b5906001600160a01b031681565b6002546104b5906001600160a01b031681565b61041c610514366004614ff9565b610c5b565b61041c6105273660046150f9565b610c6c565b6104b561053a366004614ff9565b600e602052600090815260409020546001600160a01b031681565b6013546103e790600160a01b900460ff1681565b61059e610577366004615112565b50506001600160a01b03166000908152600d60205260409020805460ff1916600117905550565b005b61041c6105ae366004614ff9565b60176020526000908152604090205481565b61041c60055481565b61041c6105d7366004615158565b610d40565b61041c6105ea3660046150f9565b610f8c565b61059e6105fd366004615112565b611048565b6104b56106103660046150f9565b6110da565b61041c610623366004614ff9565b611104565b61059e611184565b61064361063e366004614ff9565b6111e1565b6040805194855260208501939093529183015260608201526080016103f3565b61041c610671366004615199565b611225565b61059e6113e9565b6104b561068c3660046150f9565b611457565b6103e761069f366004614ff9565b60156020526000908152604090205460ff1681565b6103e76106c2366004614ff9565b60146020526000908152604090205460ff1681565b6104b56106e53660046150f9565b611467565b61041c6106f83660046151fd565b611477565b6003546104b5906001600160a01b031681565b61064361071e366004615229565b6115d5565b6013546103e790600160b01b900460ff1681565b61073f61161f565b6040516103f3919061527a565b61077961075a366004614ff9565b6008602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016103f3565b6103e761079e36600461506f565b6001600160a01b038082166000908152600860209081526040808320938616835260029093019052205460ff1692915050565b61041c6107df36600461506f565b601c60209081526000928352604080842090915290825290205481565b6103e761080a366004614ff9565b611eba565b61041c61081d3660046152c8565b612024565b6103e7610830366004614ff9565b60106020526000908152604090205460ff1681565b610858610853366004614ff9565b6120a3565b6040516103f391906152e5565b6013546103e790600160b81b900460ff1681565b600f546103e79060ff1681565b61041c610894366004614ff9565b612119565b61041c6108a7366004615377565b612124565b61041c6108ba366004614ff9565b612302565b61041c6108cd3660046150a8565b6124e0565b6108e56108e0366004615449565b612563565b6040516103f391906154fb565b610905610900366004615158565b6126e3565b604080519283526020830191909152016103f3565b6104b56109283660046150f9565b612a0f565b61041c61093b366004615578565b612a1f565b61059e612cbc565b6000546104b5906001600160a01b031681565b6002546103e790600160a01b900460ff1681565b61041c61097d366004615199565b612d66565b6104b56109903660046150f9565b612eed565b61041c6109a3366004615158565b612efd565b6104b56109b63660046151fd565b61337b565b61041c6109c93660046151fd565b6133b3565b6013546103e790600160a81b900460ff1681565b61041c60045481565b61041c6109f9366004615158565b61353d565b61041c610a0c366004614ff9565b61355a565b6001546104b5906001600160a01b031681565b604051633af9e66960e01b81526001600160a01b0384811660048301526000918491839190831690633af9e66990602401602060405180830381865afa158015610a72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9691906155e4565b90506000806000610ab98988610aad576000610aaf565b895b6000806000613add565b929550935090915060009050836014811115610ad757610ad76155fd565b14610b165760405162461bcd60e51b815260206004820152600a602482015269216c697175696469747960b01b60448201526064015b60405180910390fd5b8015610b2a57600095505050505050610c12565b600087158015610b6457506001600160a01b038087166000908152600860209081526040808320938e16835260029093019052205460ff16155b15610b70575083610b92565b610b7b838a8a613f58565b905087158015610b8a57508085105b15610b925750835b6000896001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf691906155e4565b905080821115610c065780610c08565b815b9750505050505050505b9392505050565b6001600160a01b03841660009081526008602052604081205460ff16610c435760085b9050610c53565b610c4d8584614074565b60005b90505b949350505050565b6000610c6682614115565b92915050565b6000610c76614387565b610c8657610c66600160076143db565b6040805160208082018352848252825190810190925266b1a2bc2ec50000808352815191929111610cbd57610c53600560086143db565b6040805160208101909152670c7d713b49da000080825283511115610cf157610ce8600560086143db565b95945050505050565b600480549086905560408051828152602081018890527f3b9670cf975d26958e754b57098eaa2ac914d8d2a31b83257997b9f346110fd991015b60405180910390a160005b9695505050505050565b6001600160a01b03831660009081526014602052604081205460ff1615610d985760405162461bcd60e51b815260206004820152600c60248201526b085b5a5b9d0e9c185d5cd95960a21b6044820152606401610b0d565b6001600160a01b03841660009081526008602052604090205460ff16610dc25760085b9050610c12565b600f5460ff168015610ded57506001600160a01b03831660009081526010602052604090205460ff16155b15610df9576011610dbb565b6000610e0485610c5b565b90508015801590610e3357506001600160a01b03851660009081526020805260409020610e319085614454565b155b15610f77576000856001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9c91906155e4565b9050600030604051637db121fd60e11b81526001600160a01b038981166004830152919091169063fb6243fa90602401602060405180830381865afa158015610ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0d91906155e4565b90506000828210610f2057506000610f2d565b610f2a8284615629565b90505b83610f38878361563c565b10610f735760405162461bcd60e51b815260206004820152600b60248201526a021737570706c79206361760ac1b6044820152606401610b0d565b5050505b610f818585614476565b600095945050505050565b6000610f96614387565b610fa657610c666001600d6143db565b60408051602080820183528482528251908101909252670de0b6b3a764000080835281519192911015610fdf57610c536007600e6143db565b60408051602081019091526714d1120d7b1600008082528351111561100a57610ce86007600e6143db565b600580549086905560408051828152602081018890527faeba5a6c40a8ac138134bff1aaa65debf25971188a58804bad717f82f0ec13169101610d2b565b3360009081526008602052604090205460ff166110915760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610b0d565b8015801561109f5750600082115b156110d45760405162461bcd60e51b8152602060048201526005602482015264217a65726f60d81b6044820152606401610b0d565b50505050565b600981815481106110ea57600080fd5b6000918252602090912001546001600160a01b0316905081565b600061110e614387565b61111e57610c66600160126143db565b600380546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22910160405180910390a160009392505050565b3330146111c05760405162461bcd60e51b815260206004820152600a602482015269085cd95b198818d85b1b60b21b6044820152606401610b0d565b601a54610100900460ff166111df57601a805461ffff19166101011790555b565b6000806000806000806000806111fc89600080600080613add565b9350935093509350836014811115611216576112166155fd565b99929850909650945092505050565b6001600160a01b03851660009081526008602052604081205460ff16158061126657506001600160a01b03851660009081526008602052604090205460ff16155b156112755760085b9050610ce8565b6040516305eff7ef60e21b81526001600160a01b038481166004830152600091908816906317bfdfbc90602401602060405180830381865afa1580156112bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e391906155e4565b90506112ee87611eba565b1561133857828110156113335760405162461bcd60e51b815260206004820152600d60248201526c21626f72726f773e726570617960981b6044820152606401610b0d565b6113dc565b60008061134a86600080600080613add565b93505050915060006014811115611363576113636155fd565b826014811115611375576113756155fd565b146113965781601481111561138c5761138c6155fd565b9350505050610ce8565b806000036113a557600361138c565b60006113c1604051806020016040528060045481525085614511565b9050808611156113d8576010945050505050610ce8565b5050505b5060009695505050505050565b3360009081526008602052604090205460ff166114485760405162461bcd60e51b815260206004820152601f60248201527f21436f6d7074726f6c6c65723a5f61667465724e6f6e5265656e7472616e74006044820152606401610b0d565b601a805460ff19166001179055565b601b81815481106110ea57600080fd5b600b81815481106110ea57600080fd5b600080546040805163fdb25fb160e01b8152905183926001600160a01b03169163fdb25fb19160048083019260209291908290030181865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906155e4565b905080156115cb5760035460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015611538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155c91906155e4565b90508060000361157157600c92505050610c66565b60008061158c60405180602001604052808581525087614529565b909250905060008260038111156115a5576115a56155fd565b146115b857600a5b945050505050610c66565b838110156115c75760126115ad565b5050505b6000949350505050565b6000806000806000806000806115ee8d8d8d8d8d613add565b9350935093509350836014811115611608576116086155fd565b975091955093509150505b95509550955095915050565b60408051602080825261042082019092526060919081808201610400803683370190505091506394543c1560e01b826116578361564f565b92508260ff168151811061166d5761166d61566c565b6001600160e01b031990921660209283029190910190910152635a2977b160e11b826116988361564f565b92508260ff16815181106116ae576116ae61566c565b6001600160e01b031990921660209283029190910190910152632aff3bff60e21b826116d98361564f565b92508260ff16815181106116ef576116ef61566c565b6001600160e01b03199092166020928302919091019091015263929fe9a160e01b8261171a8361564f565b92508260ff16815181106117305761173061566c565b6001600160e01b0319909216602092830291909101909101526355ee1fe160e01b8261175b8361564f565b92508260ff16815181106117715761177161566c565b6001600160e01b03199092166020928302919091019091015263317b0b7760e01b8261179c8361564f565b92508260ff16815181106117b2576117b261566c565b6001600160e01b031990921660209283029190910190910152637201477760e11b826117dd8361564f565b92508260ff16815181106117f3576117f361566c565b6001600160e01b031990921660209283029190910190910152634fd42e1760e01b8261181e8361564f565b92508260ff16815181106118345761183461566c565b6001600160e01b031990921660209283029190910190910152634a956fad60e11b8261185f8361564f565b92508260ff16815181106118755761187561566c565b6001600160e01b03199092166020928302919091019091015263c8c9c97560e01b826118a08361564f565b92508260ff16815181106118b6576118b661566c565b6001600160e01b03199092166020928302919091019091015263b9b5b15360e01b826118e18361564f565b92508260ff16815181106118f7576118f761566c565b6001600160e01b031990921660209283029190910190910152637e361b1160e01b826119228361564f565b92508260ff16815181106119385761193861566c565b6001600160e01b031990921660209283029190910190910152630cbb414760e11b826119638361564f565b92508260ff16815181106119795761197961566c565b6001600160e01b031990921660209283029190910190910152631853304760e31b826119a48361564f565b92508260ff16815181106119ba576119ba61566c565b6001600160e01b031990921660209283029190910190910152630ede4edd60e41b826119e58361564f565b92508260ff16815181106119fb576119fb61566c565b6001600160e01b031990921660209283029190910190910152634ef4c3e160e01b82611a268361564f565b92508260ff1681518110611a3c57611a3c61566c565b6001600160e01b03199092166020928302919091019091015263eabe7d9160e01b82611a678361564f565b92508260ff1681518110611a7d57611a7d61566c565b6001600160e01b0319909216602092830291909101909101526351dff98960e01b82611aa88361564f565b92508260ff1681518110611abe57611abe61566c565b6001600160e01b03199092166020928302919091019091015263368f515360e21b82611ae98361564f565b92508260ff1681518110611aff57611aff61566c565b6001600160e01b031990921660209283029190910190910152631de6c8a560e21b82611b2a8361564f565b92508260ff1681518110611b4057611b4061566c565b6001600160e01b031990921660209283029190910190910152631200453160e11b82611b6b8361564f565b92508260ff1681518110611b8157611b8161566c565b6001600160e01b031990921660209283029190910190910152632fe3f38f60e11b82611bac8361564f565b92508260ff1681518110611bc257611bc261566c565b6001600160e01b03199092166020928302919091019091015263d02f735160e01b82611bed8361564f565b92508260ff1681518110611c0357611c0361566c565b6001600160e01b0319909216602092830291909101909101526317b9b84b60e31b82611c2e8361564f565b92508260ff1681518110611c4457611c4461566c565b6001600160e01b0319909216602092830291909101909101526341c728b960e01b82611c6f8361564f565b92508260ff1681518110611c8557611c8561566c565b6001600160e01b031990921660209283029190910190910152635ec88c7960e01b82611cb08361564f565b92508260ff1681518110611cc657611cc661566c565b6001600160e01b03199092166020928302919091019091015263c488847b60e01b82611cf18361564f565b92508260ff1681518110611d0757611d0761566c565b6001600160e01b03199092166020928302919091019091015263c90c20b160e01b82611d328361564f565b92508260ff1681518110611d4857611d4861566c565b6001600160e01b03199092166020928302919091019091015263319728a160e11b82611d738361564f565b92508260ff1681518110611d8957611d8961566c565b6001600160e01b031990921660209283029190910190910152632eb96f3160e11b82611db48361564f565b92508260ff1681518110611dca57611dca61566c565b6001600160e01b031990921660209283029190910190910152630b33d1e960e21b82611df58361564f565b92508260ff1681518110611e0b57611e0b61566c565b6001600160e01b031990921660209283029190910190910152635881a44160e11b82611e368361564f565b92508260ff1681518110611e4c57611e4c61566c565b6001600160e01b03199092166020928302919091019091015260ff811615611eb65760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610b0d565b5090565b6001600160a01b038116600090815260086020526040812060010154158015611f0057506001600160a01b03821660009081526015602052604090205460ff1615156001145b8015610c665750612014611fd6836001600160a01b031663173b99046040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6f91906155e4565b846001600160a01b0316638d02d9a16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd191906155e4565b61457c565b836001600160a01b031663c3bf11cd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fad573d6000803e3d6000fd5b670de0b6b3a76400001492915050565b600061202e614387565b61203e57610c66600160136143db565b600f5482151560ff909116151503612057576000610c66565b600f805460ff19168315159081179091556040519081527f84c7d948374a180eddab35d27d2f7a94167a1ff4e79467f1e89c061984190a1e906020015b60405180910390a16000610c66565b6001600160a01b038116600090815260076020908152604080832080548251818502810185019093528083526060949383018282801561210c57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120ee575b5093979650505050505050565b6000610c66826145b2565b600061212e614387565b6121455761213e600160166143db565b9050610d36565b60028054600160a01b60ff60a01b1982168117909255600080546040516328f816b560e11b81529390920460ff169290916001600160a01b0316906351f02d6a9061219c908c908c908c908c908c906004016156ab565b6020604051808303816000875af11580156121bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121df91906156db565b6002805460ff60a01b1916600160a01b851515021790559050600061220382614651565b905060008054906101000a90046001600160a01b03166001600160a01b0316638aac2f0c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227a91906156db565b604051635a89ef5160e01b81523060048201526001600160a01b039190911690635a89ef5190602401600060405180830381600087803b1580156122bd57600080fd5b505af11580156122d1573d6000803e3d6000fd5b50600092506122de915050565b81146122ea57806122f4565b6122f482866133b3565b9a9950505050505050505050565b600061230c614387565b6123415760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610b0d565b816001600160a01b031663abc6d72d6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612381573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a591906156f8565b6123e95760405162461bcd60e51b815260206004820152601560248201527410b4b9a932bbb0b93239a234b9ba3934b13aba37b960591b6044820152606401610b0d565b60005b60195481101561246157601981815481106124095761240961566c565b6000918252602090912001546001600160a01b03908116908416036124595760405162461bcd60e51b815260206004820152600660248201526508585919195960d21b6044820152606401610b0d565b6001016123ec565b50601980546001810182556000919091527f944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c96950180546001600160a01b0319166001600160a01b0384169081179091556040519081527f98ef1187fb6fd2bc85f8996489877eb2b5428f9e9bdfc068c9ad6c2ea82eacc790602001612094565b601354600090600160b01b900460ff16156125305760405162461bcd60e51b815260206004820152601060248201526f085d1c985b9cd9995c8e9c185d5cd95960821b6044820152606401610b0d565b600061253d868685614898565b9050801561254c579050610c53565b612557868686614960565b60009695505050505050565b60008054604051631beb2b9760e31b81526060926001600160a01b039092169163df595cb8916125a89130913391839190356001600160e01b03191690600401615715565b602060405180830381865afa1580156125c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e991906156f8565b6126265760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610b0d565b815160008167ffffffffffffffff81111561264357612643615402565b60405190808252806020026020018201604052801561266c578160200160208202803683370190505b50905060005b828110156126d957600085828151811061268e5761268e61566c565b602002602001015190506126a28133614a04565b60148111156126b3576126b36155fd565b8383815181106126c5576126c561566c565b602090810291909101015250600101612672565b509150505b919050565b60035460405163fc57d4df60e01b81526001600160a01b038581166004830152600092839283929091169063fc57d4df90602401602060405180830381865afa158015612734573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275891906155e4565b60035460405163fc57d4df60e01b81526001600160a01b0388811660048301529293506000929091169063fc57d4df90602401602060405180830381865afa1580156127a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127cc91906155e4565b90508115806127d9575080155b156127ed57600c6000935093505050612a07565b60008690506000816001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285691906155e4565b905060006128706040518060200160405280600081525090565b6040805160208101909152600081526040805160208101909152600081526000866001600160a01b0316636752e7026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128f291906155e4565b90506000876001600160a01b031663be99f1196040518163ffffffff1660e01b8152600401602060405180830381865afa158015612934573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061295891906155e4565b9050600061299b6129876040518060200160405280600554815250604051806020016040528087815250614b9e565b604051806020016040528085815250614b9e565b90506129b58160405180602001604052808e815250614bd3565b95506129dd60405180602001604052808c81525060405180602001604052808b815250614bd3565b94506129e98686614c12565b93506129f5848f614511565b60009d509b5050505050505050505050505b935093915050565b601981815481106110ea57600080fd5b6000612a29614387565b612a3957610c3c600160146143db565b60005b84811015612cb4576000868683818110612a5857612a5861566c565b9050602002016020810190612a6d9190614ff9565b9050848483818110612a8157612a8161566c565b9050602002016020810190612a9691906152c8565b15612b4e576001600160a01b03811660009081526010602052604090205460ff16612b49576001600160a01b0381166000818152601060205260408120805460ff19166001908117909155601180548083018255928190527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6890920180546001600160a01b03191690931790925554612b2f9190615629565b6001600160a01b0382166000908152601260205260409020555b612cab565b6001600160a01b03811660009081526010602052604090205460ff1615612cab5760118054612b7f90600190615629565b81548110612b8f57612b8f61566c565b60009182526020808320909101546001600160a01b0384811684526012909252604090922054601180549290931692918110612bcd57612bcd61566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506011805480612c0c57612c0c615748565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038316825260129081905260408220546011805491939184908110612c6057612c6061566c565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301822094909455918416825260128352808220829055601090925220805460ff191690555b50600101612a3c565b506000610c50565b3360009081526008602052604090205460ff16612d1b5760405162461bcd60e51b815260206004820181905260248201527f21436f6d7074726f6c6c65723a5f6265666f72654e6f6e5265656e7472616e746044820152606401610b0d565b601a5460ff16612d5a5760405162461bcd60e51b815260206004820152600a602482015269085c99595b9d195c995960b21b6044820152606401610b0d565b601a805460ff19169055565b601354600090600160b81b900460ff1615612db35760405162461bcd60e51b815260206004820152600d60248201526c085cd95a5e994e9c185d5cd959609a1b6044820152606401610b0d565b6001600160a01b03861660009081526008602052604090205460ff161580612df457506001600160a01b03851660009081526008602052604090205460ff16155b15612e0057600861126e565b846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6291906156db565b6001600160a01b0316866001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecd91906156db565b6001600160a01b031614612ee257600261126e565b612557868486614960565b601181815481106110ea57600080fd5b6001600160a01b03831660009081526015602052604081205460ff1615612f575760405162461bcd60e51b815260206004820152600e60248201526d08589bdc9c9bddce9c185d5cd95960921b6044820152606401610b0d565b6001600160a01b03841660009081526008602052604090205460ff16612f7e576008610dbb565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff1661306d57336001600160a01b03851614612ff15760405162461bcd60e51b815260206004820152600760248201526610b1ba37b5b2b760c91b6044820152606401610b0d565b6000612ffd3385614a04565b90506000816014811115613013576130136155fd565b146130325780601481111561302a5761302a6155fd565b915050610c12565b6001600160a01b038086166000908152600860209081526040808320938816835260029093019052205460ff1661306b5761306b61575e565b505b60035460405163fc57d4df60e01b81526001600160a01b0386811660048301529091169063fc57d4df90602401602060405180830381865afa1580156130b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130db91906155e4565b6000036130e957600c610dbb565b600f5460ff16801561311457506001600160a01b03831660009081526010602052604090205460ff16155b15613120576011610dbb565b600061312b85612119565b9050801580159061315b57506001600160a01b03851660009081526021602052604090206131599085614454565b155b1561329f576000856001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c491906155e4565b9050600030604051631d3965af60e11b81526001600160a01b0389811660048301529190911690633a72cb5e90602401602060405180830381865afa158015613211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323591906155e4565b9050600082821061324857506000613255565b6132528284615629565b90505b83613260878361563c565b1061329b5760405162461bcd60e51b815260206004820152600b60248201526a021626f72726f773a6361760ac1b6044820152606401610b0d565b5050505b6132a98585614074565b604051637e361b1160e01b81526001600160a01b0380861660048301528616602482015260006044820181905260648201859052608482018190529081903090637e361b119060a401608060405180830381865afa15801561330f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133339190615774565b9350505091506000601481111561334c5761334c6155fd565b821461335c57509150610c129050565b801561336e5760049350505050610c12565b6000979650505050505050565b6007602052816000526040600020818154811061339757600080fd5b6000918252602090912001546001600160a01b03169150829050565b60006133bd614387565b6133d4576133cd600160096143db565b9050610c66565b6001600160a01b0383166000908152600860205260409020805460ff16613409576134016008600a6143db565b915050610c66565b60408051602080820183528582528251908101909252670c7d713b49da000082529061343781835190511090565b15613452576134486006600b6143db565b9350505050610c66565b84158015906134cc575060035460405163fc57d4df60e01b81526001600160a01b0388811660048301529091169063fc57d4df90602401602060405180830381865afa1580156134a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ca91906155e4565b155b156134dc57613448600c806143db565b60018301805490869055604080516001600160a01b0389168152602081018390529081018790527f70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc59060600160405180910390a16000979650505050505050565b60008061354b858585614898565b90508015610f77579050610c12565b60008054604051631beb2b9760e31b81526001600160a01b039091169063df595cb89061359c903090339082906001600160e01b031988351690600401615715565b602060405180830381865afa1580156135b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135dd91906156f8565b61361a5760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610b0d565b6001600160a01b03821660009081526008602052604090205460ff166136825760405162461bcd60e51b815260206004820152601760248201527f21436f6d7074726f6c6c65723a657869744d61726b65740000000000000000006044820152606401610b0d565b6040516361bfb47160e11b81523360048201528290600090819081906001600160a01b0385169063c37f68e290602401608060405180830381865afa1580156136cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f39190615774565b50925092509250826000146137385760405162461bcd60e51b815260206004820152600b60248201526a08595e1a5d13585c9ad95d60aa1b6044820152606401610b0d565b801561374a57610d36600b60036143db565b6000613757873385614898565b905080156137775761376c600d600483614c4c565b979650505050505050565b6001600160a01b0387166000908152600860209081526040808320338452600281019092529091205460ff166137b557600098975050505050505050565b3360009081526002820160209081526040808320805460ff19169055600782528083208054825181850281018501909352808352919290919083018282801561382757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613809575b5050835193945083925060009150505b82811015613881578b6001600160a01b031684828151811061385b5761385b61566c565b60200260200101516001600160a01b03160361387957809150613881565b600101613837565b508181106138915761389161575e565b336000908152600760205260409020805481906138b090600190615629565b815481106138c0576138c061566c565b9060005260206000200160009054906101000a90046001600160a01b03168183815481106138f0576138f061566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080548061392e5761392e615748565b600082815260208120820160001990810180546001600160a01b031916905590910190915581549003613a8a57600b805461396b90600190615629565b8154811061397b5761397b61566c565b6000918252602080832090910154338352600c909152604090912054600b80546001600160a01b039093169290919081106139b8576139b861566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b8054806139f7576139f7615748565b60008281526020808220830160001990810180546001600160a01b0319169055909201909255338252600c908190526040822054600b805491939184908110613a4257613a4261566c565b60009182526020808320909101546001600160a01b03168352828101939093526040918201812093909355338352600c8252808320839055600a9091529020805460ff191690555b604080516001600160a01b038e1681523360208201527fe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d910160405180910390a160009c9b505050505050505050505050565b600080600080613aeb614f19565b6001600160a01b03891615613b6f5760035460405163fc57d4df60e01b81526001600160a01b038b811660048301529091169063fc57d4df90602401602060405180830381865afa158015613b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b6891906155e4565b6101808201525b60005b6001600160a01b038b16600090815260076020526040902054811015613ef4576001600160a01b038b166000908152600760205260409020805482908110613bbc57613bbc61566c565b60009182526020822001546001600160a01b039081168085526040516361bfb47160e11b8152918e1660048301529063c37f68e290602401608060405180830381865afa158015613c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c359190615774565b60a08701526080860152606085015290508015613c6357600e60008060009650965096509650505050611613565b50604080516020808201835284516001600160a01b0390811660009081526008835284902060010154835260e08601929092528251908101835260a085015181526101008501526003548451925163fc57d4df60e01b81529282166004840152169063fc57d4df90602401602060405180830381865afa158015613ceb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0f91906155e4565b60c08301819052600003613d3357600c600080600095509550955095505050611613565b604080516020810190915260c0830151815261012083015260e0820151610100830151613d6e91613d6391614bd3565b836101200151614bd3565b610140830152308251604051633c1f884b60e11b81526001600160a01b0391821660048201528c821660248201528b151560448201528d8216606482015291169063783f109690608401602060405180830381865afa158015613dd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df991906155e4565b6101a08301526101408201516060830151600091613e1691614511565b9050826101a00151811115613e2d57506101a08201515b8083602001818151613e3f919061563c565b9052505061012082015160808301516040840151613e5e929190614cc4565b604083015281516001600160a01b03808c16911603613eec57613e8b8261014001518a8460400151614cc4565b60408301819052610120830151613ea3918a90614cc4565b6040830152610120820151600090613ebb9089614511565b905082604001518110613ed45760006040840152613eea565b8083604001818151613ee69190615629565b9052505b505b600101613b72565b50806040015181602001511115613f2d576020810151604082015160009190613f1d9082615629565b6000945094509450945050611613565b60008160200151600083602001518460400151613f4a9190615629565b945094509450945050611613565b600083600003613f6a57506000610c12565b60035460405163fc57d4df60e01b81526001600160a01b038581166004830152600092169063fc57d4df90602401602060405180830381865afa158015613fb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd991906155e4565b9050600081116140155760405162461bcd60e51b8152602060048201526007602482015266216f7261636c6560c81b6044820152606401610b0d565b82614057576001600160a01b038416600090815260086020526040902060010154670de0b6b3a764000061404983836157aa565b61405391906157c1565b9150505b8061406a86670de0b6b3a76400006157aa565b610ce891906157c1565b60005b60195481101561411057601981815481106140945761409461566c565b600091825260209091200154604051631cdc2c5d60e31b81526001600160a01b03858116600483015284811660248301529091169063e6e162e890604401600060405180830381600087803b1580156140ec57600080fd5b505af1158015614100573d6000803e3d6000fd5b5050600190920191506140779050565b505050565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215614365576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141bb91906156db565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa158015614214573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061423891906157fb565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b038616916142919190615896565b600060405180830381855afa9150503d80600081146142cc576040519150601f19603f3d011682016040523d82523d6000602084013e6142d1565b606091505b50915091508180156142e4575080516020145b1561430357808060200190518101906142fd91906158b2565b60ff1692505b60408501516143159060000b846158cf565b92506000831261433b5761432a83600a6159d3565b61433490876157aa565b955061435c565b614344836159df565b61434f90600a6159d3565b61435990876157c1565b95505b50505050614381565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6001546000906001600160a01b0316331480156143ad5750600254600160a81b900460ff165b806143d657506000546001600160a01b0316331480156143d65750600254600160a01b900460ff165b905090565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836014811115614410576144106155fd565b83601a811115614422576144226155fd565b60408051928352602083019190915260009082015260600160405180910390a1826014811115610c1257610c126155fd565b6001600160a01b03811660009081526001830160205260408120541515610c12565b60005b60195481101561411057601981815481106144965761449661566c565b60009182526020909120015460405162e48b0f60e51b81526001600160a01b038581166004830152848116602483015290911690631c9161e090604401600060405180830381600087803b1580156144ed57600080fd5b505af1158015614501573d6000803e3d6000fd5b5050600190920191506144799050565b60008061451e8484614ce5565b9050610c5381614d0d565b6000806000806145398686614d25565b90925090506000826003811115614552576145526155fd565b146145635750915060009050614575565b600061456e82614d0d565b9350935050505b9250929050565b6000610c128383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250614da1565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215614634576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614197573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b600061465b614387565b61466b57610c66600160166143db565b6001600160a01b03821660009081526008602052604090205460ff161561469857610c66600960156143db565b306001600160a01b0316826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061470491906156db565b6001600160a01b0316146147495760405162461bcd60e51b815260206004820152600c60248201526b10b1b7b6b83a3937b63632b960a11b6044820152606401610b0d565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614789573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147ad91906156db565b6001600160a01b038082166000908152600e602052604090205491925016156147dc57610c12600960156143db565b6001600160a01b038381166000818152600860209081526040808320805460ff1916600190811782558082018590556009805491820190557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b031990811687179091559587168452600e835292819020805490951684179094559251918252917fcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f910160405180910390a16000610c53565b6001600160a01b03831660009081526008602052604081205460ff166148bf576008610dbb565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff166148f7576000610dbb565b600080614908858786600080613add565b93505050915060006014811115614921576149216155fd565b826014811115614933576149336155fd565b146149535781601481111561494a5761494a6155fd565b92505050610c12565b801561255757600461494a565b60005b6019548110156110d457601981815481106149805761498061566c565b600091825260209091200154604051634e081c9560e01b81526001600160a01b0386811660048301528581166024830152848116604483015290911690634e081c9590606401600060405180830381600087803b1580156149e057600080fd5b505af11580156149f4573d6000803e3d6000fd5b5050600190920191506149639050565b6001600160a01b0382166000908152600860205260408120805460ff16614a2f576008915050610c66565b6001600160a01b038316600090815260028201602052604090205460ff161515600103614a60576000915050610c66565b6001600160a01b03838116600081815260028401602090815260408083208054600160ff199091168117909155600783528184208054918201815584528284200180546001600160a01b031916958a1695909517909455918152600a909152205460ff16614b5157600b8054600180820183557f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db990910180546001600160a01b0319166001600160a01b0387169081179091556000908152600a60205260409020805460ff1916821790559054614b379190615629565b6001600160a01b0384166000908152600c60205260409020555b604080516001600160a01b038087168252851660208201527f3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a5910160405180910390a15060009392505050565b6040805160208101909152600081526040518060200160405280614bca8560000151856000015161457c565b90529392505050565b6040805160208101909152600081526040518060200160405280670de0b6b3a7640000614c0886600001518660000151614ddb565b614bca91906157c1565b6040805160208101909152600081526040518060200160405280614bca614c458660000151670de0b6b3a7640000614ddb565b8551614e1d565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846014811115614c8157614c816155fd565b84601a811115614c9357614c936155fd565b604080519283526020830191909152810184905260600160405180910390a1836014811115610c5357610c536155fd565b600080614cd18585614ce5565b9050610ce8614cdf82614d0d565b8461457c565b6040805160208101909152600081526040518060200160405280614bca856000015185614ddb565b8051600090610c6690670de0b6b3a7640000906157c1565b6000614d3d6040518060200160405280600081525090565b600080614d4e866000015186614e50565b90925090506000826003811115614d6757614d676155fd565b14614d8657506040805160208101909152600081529092509050614575565b60408051602081019091529081526000969095509350505050565b600080614dae848661563c565b90508285821015614dd25760405162461bcd60e51b8152600401610b0d91906159fb565b50949350505050565b6000610c1283836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250614e9a565b6000610c1283836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250614eed565b60008083600003614e6657506000905080614575565b83830283614e7486836157c1565b14614e8757600260009250925050614575565b600092509050614575565b509250929050565b6000831580614ea7575082155b15614eb457506000610c12565b6000614ec084866157aa565b905083614ecd86836157c1565b148390614dd25760405162461bcd60e51b8152600401610b0d91906159fb565b60008183614f0e5760405162461bcd60e51b8152600401610b0d91906159fb565b50610c5383856157c1565b604051806101c0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001614f756040518060200160405280600081525090565b8152602001614f906040518060200160405280600081525090565b8152602001614fab6040518060200160405280600081525090565b8152602001614fc66040518060200160405280600081525090565b81526020016000815260200160008152602001600081525090565b6001600160a01b0381168114614ff657600080fd5b50565b60006020828403121561500b57600080fd5b8135610c1281614fe1565b8015158114614ff657600080fd5b60008060006060848603121561503957600080fd5b833561504481614fe1565b9250602084013561505481614fe1565b9150604084013561506481615016565b809150509250925092565b6000806040838503121561508257600080fd5b823561508d81614fe1565b9150602083013561509d81614fe1565b809150509250929050565b600080600080608085870312156150be57600080fd5b84356150c981614fe1565b935060208501356150d981614fe1565b925060408501356150e981614fe1565b9396929550929360600135925050565b60006020828403121561510b57600080fd5b5035919050565b6000806000806080858703121561512857600080fd5b843561513381614fe1565b9350602085013561514381614fe1565b93969395505050506040820135916060013590565b60008060006060848603121561516d57600080fd5b833561517881614fe1565b9250602084013561518881614fe1565b929592945050506040919091013590565b600080600080600060a086880312156151b157600080fd5b85356151bc81614fe1565b945060208601356151cc81614fe1565b935060408601356151dc81614fe1565b925060608601356151ec81614fe1565b949793965091946080013592915050565b6000806040838503121561521057600080fd5b823561521b81614fe1565b946020939093013593505050565b600080600080600060a0868803121561524157600080fd5b853561524c81614fe1565b9450602086013561525c81614fe1565b94979496505050506040830135926060810135926080909101359150565b6020808252825182820181905260009190848201906040850190845b818110156152bc5783516001600160e01b03191683529284019291840191600101615296565b50909695505050505050565b6000602082840312156152da57600080fd5b8135610c1281615016565b6020808252825182820181905260009190848201906040850190845b818110156152bc5783516001600160a01b031683529284019291840191600101615301565b60ff81168114614ff657600080fd5b60008083601f84011261534757600080fd5b50813567ffffffffffffffff81111561535f57600080fd5b60208301915083602082850101111561457557600080fd5b6000806000806000806080878903121561539057600080fd5b863561539b81615326565b9550602087013567ffffffffffffffff808211156153b857600080fd5b6153c48a838b01615335565b909750955060408901359150808211156153dd57600080fd5b506153ea89828a01615335565b979a9699509497949695606090950135949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561544157615441615402565b604052919050565b6000602080838503121561545c57600080fd5b823567ffffffffffffffff8082111561547457600080fd5b818501915085601f83011261548857600080fd5b81358181111561549a5761549a615402565b8060051b91506154ab848301615418565b81815291830184019184810190888411156154c557600080fd5b938501935b838510156154ef57843592506154df83614fe1565b82825293850193908501906154ca565b98975050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156152bc57835183529284019291840191600101615517565b60008083601f84011261554557600080fd5b50813567ffffffffffffffff81111561555d57600080fd5b6020830191508360208260051b850101111561457557600080fd5b6000806000806040858703121561558e57600080fd5b843567ffffffffffffffff808211156155a657600080fd5b6155b288838901615533565b909650945060208701359150808211156155cb57600080fd5b506155d887828801615533565b95989497509550505050565b6000602082840312156155f657600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6657610c66615613565b80820180821115610c6657610c66615613565b600060ff82168061566257615662615613565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60ff861681526060602082015260006156c8606083018688615682565b82810360408401526154ef818587615682565b6000602082840312156156ed57600080fd5b8151610c1281614fe1565b60006020828403121561570a57600080fd5b8151610c1281615016565b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b6000806000806080858703121561578a57600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610c6657610c66615613565b6000826157de57634e487b7160e01b600052601260045260246000fd5b500490565b805167ffffffffffffffff811681146126de57600080fd5b60006060828403121561580d57600080fd5b6040516060810181811067ffffffffffffffff8211171561583057615830615402565b60405261583c836157e3565b815261584a602084016157e3565b6020820152604083015163ffffffff8116811461586657600080fd5b60408201529392505050565b60005b8381101561588d578181015183820152602001615875565b50506000910152565b600082516158a8818460208701615872565b9190910192915050565b6000602082840312156158c457600080fd5b8151610c1281615326565b80820182811260008312801582168215821617156158ef576158ef615613565b505092915050565b600181815b80851115614e9257816000190482111561591857615918615613565b8085161561592557918102915b93841c93908002906158fc565b60008261594157506001610c66565b8161594e57506000610c66565b8160018114615964576002811461596e5761598a565b6001915050610c66565b60ff84111561597f5761597f615613565b50506001821b610c66565b5060208310610133831016604e8410600b84101617156159ad575081810a610c66565b6159b783836158f7565b80600019048211156159cb576159cb615613565b029392505050565b6000610c128383615932565b6000600160ff1b82016159f4576159f4615613565b5060000390565b6020815260008251806020840152615a1a816040850160208701615872565b601f01601f1916919091016040019291505056fea2646970667358221220bba991f953a0ec9721b327889c949cdcded9ead7aaaf711b80ec61b18035cd4964736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103da5760003560e01c80637e361b111161020a578063c299823811610125578063d251fefc116100b8578063e6653f3d11610087578063e6653f3d146109ce578063e8755446146109e2578063eabe7d91146109eb578063ede4edd0146109fe578063f851a44014610a1157600080fd5b8063d251fefc14610982578063da3d454c14610995578063dce15449146109a8578063e4028eee146109bb57600080fd5b8063c90c20b1116100f4578063c90c20b114610940578063c91a424f14610948578063cf6bfd2d1461095b578063d02f73511461096f57600080fd5b8063c2998238146108d2578063c488847b146108f2578063c6c5b0dd1461091a578063c8c9c9751461092d57600080fd5b80639b19251a1161019d578063b10348821161016c578063b103488214610886578063b452ef6214610899578063b9b5b153146108ac578063bdcdc258146108bf57600080fd5b80639b19251a14610822578063abfceffc14610845578063ac0b0bb714610865578063b09572101461087957600080fd5b8063929fe9a1116101d9578063929fe9a114610790578063940cd6f1146107d157806394543c15146107fc578063952adf5a1461080f57600080fd5b80637e361b111461071057806387f763031461072357806389f8132e146107375780638e8f294b1461074c57600080fd5b80634ada90af116102fa5780635fc7e71e1161028d578063731f0c2b1161025c578063731f0c2b146106b45780637515bafa146106d7578063779b2294146106ea5780637dc0d1d0146106fd57600080fd5b80635fc7e71e14610663578063632e5142146106765780636bd02b8a1461067e5780636d154ea51461069157600080fd5b806352d84d1e116102c957806352d84d1e1461060257806355ee1fe1146106155780635d72de62146106285780635ec88c791461063057600080fd5b80634ada90af146105c05780634ef4c3e1146105c95780634fd42e17146105dc57806351dff989146105ef57600080fd5b806324a3d6221161037257806331ff47fa1161034157806331ff47fa1461052c5780633c94786f1461055557806341c728b9146105695780634a584432146105a057600080fd5b806324a3d622146104e057806326782247146104f35780632ccf47a414610506578063317b0b771461051957600080fd5b80631976828e116103ae5780631976828e146104615780631c819e431461047457806321af4569146104a257806324008a62146104cd57600080fd5b80627e3dd2146103df57806302c3bcbb146103fc5780630a755ec21461042a57806316dc15fe1461043e575b600080fd5b6103e7600181565b60405190151581526020015b60405180910390f35b61041c61040a366004614ff9565b60186020526000908152604090205481565b6040519081526020016103f3565b6002546103e790600160a81b900460ff1681565b6103e761044c366004614ff9565b600d6020526000908152604090205460ff1681565b61041c61046f366004615024565b610a24565b6103e761048236600461506f565b601d60209081526000928352604080842090915290825290205460ff1681565b6016546104b5906001600160a01b031681565b6040516001600160a01b0390911681526020016103f3565b61041c6104db3660046150a8565b610c19565b6013546104b5906001600160a01b031681565b6002546104b5906001600160a01b031681565b61041c610514366004614ff9565b610c5b565b61041c6105273660046150f9565b610c6c565b6104b561053a366004614ff9565b600e602052600090815260409020546001600160a01b031681565b6013546103e790600160a01b900460ff1681565b61059e610577366004615112565b50506001600160a01b03166000908152600d60205260409020805460ff1916600117905550565b005b61041c6105ae366004614ff9565b60176020526000908152604090205481565b61041c60055481565b61041c6105d7366004615158565b610d40565b61041c6105ea3660046150f9565b610f8c565b61059e6105fd366004615112565b611048565b6104b56106103660046150f9565b6110da565b61041c610623366004614ff9565b611104565b61059e611184565b61064361063e366004614ff9565b6111e1565b6040805194855260208501939093529183015260608201526080016103f3565b61041c610671366004615199565b611225565b61059e6113e9565b6104b561068c3660046150f9565b611457565b6103e761069f366004614ff9565b60156020526000908152604090205460ff1681565b6103e76106c2366004614ff9565b60146020526000908152604090205460ff1681565b6104b56106e53660046150f9565b611467565b61041c6106f83660046151fd565b611477565b6003546104b5906001600160a01b031681565b61064361071e366004615229565b6115d5565b6013546103e790600160b01b900460ff1681565b61073f61161f565b6040516103f3919061527a565b61077961075a366004614ff9565b6008602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016103f3565b6103e761079e36600461506f565b6001600160a01b038082166000908152600860209081526040808320938616835260029093019052205460ff1692915050565b61041c6107df36600461506f565b601c60209081526000928352604080842090915290825290205481565b6103e761080a366004614ff9565b611eba565b61041c61081d3660046152c8565b612024565b6103e7610830366004614ff9565b60106020526000908152604090205460ff1681565b610858610853366004614ff9565b6120a3565b6040516103f391906152e5565b6013546103e790600160b81b900460ff1681565b600f546103e79060ff1681565b61041c610894366004614ff9565b612119565b61041c6108a7366004615377565b612124565b61041c6108ba366004614ff9565b612302565b61041c6108cd3660046150a8565b6124e0565b6108e56108e0366004615449565b612563565b6040516103f391906154fb565b610905610900366004615158565b6126e3565b604080519283526020830191909152016103f3565b6104b56109283660046150f9565b612a0f565b61041c61093b366004615578565b612a1f565b61059e612cbc565b6000546104b5906001600160a01b031681565b6002546103e790600160a01b900460ff1681565b61041c61097d366004615199565b612d66565b6104b56109903660046150f9565b612eed565b61041c6109a3366004615158565b612efd565b6104b56109b63660046151fd565b61337b565b61041c6109c93660046151fd565b6133b3565b6013546103e790600160a81b900460ff1681565b61041c60045481565b61041c6109f9366004615158565b61353d565b61041c610a0c366004614ff9565b61355a565b6001546104b5906001600160a01b031681565b604051633af9e66960e01b81526001600160a01b0384811660048301526000918491839190831690633af9e66990602401602060405180830381865afa158015610a72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9691906155e4565b90506000806000610ab98988610aad576000610aaf565b895b6000806000613add565b929550935090915060009050836014811115610ad757610ad76155fd565b14610b165760405162461bcd60e51b815260206004820152600a602482015269216c697175696469747960b01b60448201526064015b60405180910390fd5b8015610b2a57600095505050505050610c12565b600087158015610b6457506001600160a01b038087166000908152600860209081526040808320938e16835260029093019052205460ff16155b15610b70575083610b92565b610b7b838a8a613f58565b905087158015610b8a57508085105b15610b925750835b6000896001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf691906155e4565b905080821115610c065780610c08565b815b9750505050505050505b9392505050565b6001600160a01b03841660009081526008602052604081205460ff16610c435760085b9050610c53565b610c4d8584614074565b60005b90505b949350505050565b6000610c6682614115565b92915050565b6000610c76614387565b610c8657610c66600160076143db565b6040805160208082018352848252825190810190925266b1a2bc2ec50000808352815191929111610cbd57610c53600560086143db565b6040805160208101909152670c7d713b49da000080825283511115610cf157610ce8600560086143db565b95945050505050565b600480549086905560408051828152602081018890527f3b9670cf975d26958e754b57098eaa2ac914d8d2a31b83257997b9f346110fd991015b60405180910390a160005b9695505050505050565b6001600160a01b03831660009081526014602052604081205460ff1615610d985760405162461bcd60e51b815260206004820152600c60248201526b085b5a5b9d0e9c185d5cd95960a21b6044820152606401610b0d565b6001600160a01b03841660009081526008602052604090205460ff16610dc25760085b9050610c12565b600f5460ff168015610ded57506001600160a01b03831660009081526010602052604090205460ff16155b15610df9576011610dbb565b6000610e0485610c5b565b90508015801590610e3357506001600160a01b03851660009081526020805260409020610e319085614454565b155b15610f77576000856001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9c91906155e4565b9050600030604051637db121fd60e11b81526001600160a01b038981166004830152919091169063fb6243fa90602401602060405180830381865afa158015610ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0d91906155e4565b90506000828210610f2057506000610f2d565b610f2a8284615629565b90505b83610f38878361563c565b10610f735760405162461bcd60e51b815260206004820152600b60248201526a021737570706c79206361760ac1b6044820152606401610b0d565b5050505b610f818585614476565b600095945050505050565b6000610f96614387565b610fa657610c666001600d6143db565b60408051602080820183528482528251908101909252670de0b6b3a764000080835281519192911015610fdf57610c536007600e6143db565b60408051602081019091526714d1120d7b1600008082528351111561100a57610ce86007600e6143db565b600580549086905560408051828152602081018890527faeba5a6c40a8ac138134bff1aaa65debf25971188a58804bad717f82f0ec13169101610d2b565b3360009081526008602052604090205460ff166110915760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610b0d565b8015801561109f5750600082115b156110d45760405162461bcd60e51b8152602060048201526005602482015264217a65726f60d81b6044820152606401610b0d565b50505050565b600981815481106110ea57600080fd5b6000918252602090912001546001600160a01b0316905081565b600061110e614387565b61111e57610c66600160126143db565b600380546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fd52b2b9b7e9ee655fcb95d2e5b9e0c9f69e7ef2b8e9d2d0ea78402d576d22e22910160405180910390a160009392505050565b3330146111c05760405162461bcd60e51b815260206004820152600a602482015269085cd95b198818d85b1b60b21b6044820152606401610b0d565b601a54610100900460ff166111df57601a805461ffff19166101011790555b565b6000806000806000806000806111fc89600080600080613add565b9350935093509350836014811115611216576112166155fd565b99929850909650945092505050565b6001600160a01b03851660009081526008602052604081205460ff16158061126657506001600160a01b03851660009081526008602052604090205460ff16155b156112755760085b9050610ce8565b6040516305eff7ef60e21b81526001600160a01b038481166004830152600091908816906317bfdfbc90602401602060405180830381865afa1580156112bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e391906155e4565b90506112ee87611eba565b1561133857828110156113335760405162461bcd60e51b815260206004820152600d60248201526c21626f72726f773e726570617960981b6044820152606401610b0d565b6113dc565b60008061134a86600080600080613add565b93505050915060006014811115611363576113636155fd565b826014811115611375576113756155fd565b146113965781601481111561138c5761138c6155fd565b9350505050610ce8565b806000036113a557600361138c565b60006113c1604051806020016040528060045481525085614511565b9050808611156113d8576010945050505050610ce8565b5050505b5060009695505050505050565b3360009081526008602052604090205460ff166114485760405162461bcd60e51b815260206004820152601f60248201527f21436f6d7074726f6c6c65723a5f61667465724e6f6e5265656e7472616e74006044820152606401610b0d565b601a805460ff19166001179055565b601b81815481106110ea57600080fd5b600b81815481106110ea57600080fd5b600080546040805163fdb25fb160e01b8152905183926001600160a01b03169163fdb25fb19160048083019260209291908290030181865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906155e4565b905080156115cb5760035460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015611538573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155c91906155e4565b90508060000361157157600c92505050610c66565b60008061158c60405180602001604052808581525087614529565b909250905060008260038111156115a5576115a56155fd565b146115b857600a5b945050505050610c66565b838110156115c75760126115ad565b5050505b6000949350505050565b6000806000806000806000806115ee8d8d8d8d8d613add565b9350935093509350836014811115611608576116086155fd565b975091955093509150505b95509550955095915050565b60408051602080825261042082019092526060919081808201610400803683370190505091506394543c1560e01b826116578361564f565b92508260ff168151811061166d5761166d61566c565b6001600160e01b031990921660209283029190910190910152635a2977b160e11b826116988361564f565b92508260ff16815181106116ae576116ae61566c565b6001600160e01b031990921660209283029190910190910152632aff3bff60e21b826116d98361564f565b92508260ff16815181106116ef576116ef61566c565b6001600160e01b03199092166020928302919091019091015263929fe9a160e01b8261171a8361564f565b92508260ff16815181106117305761173061566c565b6001600160e01b0319909216602092830291909101909101526355ee1fe160e01b8261175b8361564f565b92508260ff16815181106117715761177161566c565b6001600160e01b03199092166020928302919091019091015263317b0b7760e01b8261179c8361564f565b92508260ff16815181106117b2576117b261566c565b6001600160e01b031990921660209283029190910190910152637201477760e11b826117dd8361564f565b92508260ff16815181106117f3576117f361566c565b6001600160e01b031990921660209283029190910190910152634fd42e1760e01b8261181e8361564f565b92508260ff16815181106118345761183461566c565b6001600160e01b031990921660209283029190910190910152634a956fad60e11b8261185f8361564f565b92508260ff16815181106118755761187561566c565b6001600160e01b03199092166020928302919091019091015263c8c9c97560e01b826118a08361564f565b92508260ff16815181106118b6576118b661566c565b6001600160e01b03199092166020928302919091019091015263b9b5b15360e01b826118e18361564f565b92508260ff16815181106118f7576118f761566c565b6001600160e01b031990921660209283029190910190910152637e361b1160e01b826119228361564f565b92508260ff16815181106119385761193861566c565b6001600160e01b031990921660209283029190910190910152630cbb414760e11b826119638361564f565b92508260ff16815181106119795761197961566c565b6001600160e01b031990921660209283029190910190910152631853304760e31b826119a48361564f565b92508260ff16815181106119ba576119ba61566c565b6001600160e01b031990921660209283029190910190910152630ede4edd60e41b826119e58361564f565b92508260ff16815181106119fb576119fb61566c565b6001600160e01b031990921660209283029190910190910152634ef4c3e160e01b82611a268361564f565b92508260ff1681518110611a3c57611a3c61566c565b6001600160e01b03199092166020928302919091019091015263eabe7d9160e01b82611a678361564f565b92508260ff1681518110611a7d57611a7d61566c565b6001600160e01b0319909216602092830291909101909101526351dff98960e01b82611aa88361564f565b92508260ff1681518110611abe57611abe61566c565b6001600160e01b03199092166020928302919091019091015263368f515360e21b82611ae98361564f565b92508260ff1681518110611aff57611aff61566c565b6001600160e01b031990921660209283029190910190910152631de6c8a560e21b82611b2a8361564f565b92508260ff1681518110611b4057611b4061566c565b6001600160e01b031990921660209283029190910190910152631200453160e11b82611b6b8361564f565b92508260ff1681518110611b8157611b8161566c565b6001600160e01b031990921660209283029190910190910152632fe3f38f60e11b82611bac8361564f565b92508260ff1681518110611bc257611bc261566c565b6001600160e01b03199092166020928302919091019091015263d02f735160e01b82611bed8361564f565b92508260ff1681518110611c0357611c0361566c565b6001600160e01b0319909216602092830291909101909101526317b9b84b60e31b82611c2e8361564f565b92508260ff1681518110611c4457611c4461566c565b6001600160e01b0319909216602092830291909101909101526341c728b960e01b82611c6f8361564f565b92508260ff1681518110611c8557611c8561566c565b6001600160e01b031990921660209283029190910190910152635ec88c7960e01b82611cb08361564f565b92508260ff1681518110611cc657611cc661566c565b6001600160e01b03199092166020928302919091019091015263c488847b60e01b82611cf18361564f565b92508260ff1681518110611d0757611d0761566c565b6001600160e01b03199092166020928302919091019091015263c90c20b160e01b82611d328361564f565b92508260ff1681518110611d4857611d4861566c565b6001600160e01b03199092166020928302919091019091015263319728a160e11b82611d738361564f565b92508260ff1681518110611d8957611d8961566c565b6001600160e01b031990921660209283029190910190910152632eb96f3160e11b82611db48361564f565b92508260ff1681518110611dca57611dca61566c565b6001600160e01b031990921660209283029190910190910152630b33d1e960e21b82611df58361564f565b92508260ff1681518110611e0b57611e0b61566c565b6001600160e01b031990921660209283029190910190910152635881a44160e11b82611e368361564f565b92508260ff1681518110611e4c57611e4c61566c565b6001600160e01b03199092166020928302919091019091015260ff811615611eb65760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610b0d565b5090565b6001600160a01b038116600090815260086020526040812060010154158015611f0057506001600160a01b03821660009081526015602052604090205460ff1615156001145b8015610c665750612014611fd6836001600160a01b031663173b99046040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6f91906155e4565b846001600160a01b0316638d02d9a16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd191906155e4565b61457c565b836001600160a01b031663c3bf11cd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fad573d6000803e3d6000fd5b670de0b6b3a76400001492915050565b600061202e614387565b61203e57610c66600160136143db565b600f5482151560ff909116151503612057576000610c66565b600f805460ff19168315159081179091556040519081527f84c7d948374a180eddab35d27d2f7a94167a1ff4e79467f1e89c061984190a1e906020015b60405180910390a16000610c66565b6001600160a01b038116600090815260076020908152604080832080548251818502810185019093528083526060949383018282801561210c57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120ee575b5093979650505050505050565b6000610c66826145b2565b600061212e614387565b6121455761213e600160166143db565b9050610d36565b60028054600160a01b60ff60a01b1982168117909255600080546040516328f816b560e11b81529390920460ff169290916001600160a01b0316906351f02d6a9061219c908c908c908c908c908c906004016156ab565b6020604051808303816000875af11580156121bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121df91906156db565b6002805460ff60a01b1916600160a01b851515021790559050600061220382614651565b905060008054906101000a90046001600160a01b03166001600160a01b0316638aac2f0c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227a91906156db565b604051635a89ef5160e01b81523060048201526001600160a01b039190911690635a89ef5190602401600060405180830381600087803b1580156122bd57600080fd5b505af11580156122d1573d6000803e3d6000fd5b50600092506122de915050565b81146122ea57806122f4565b6122f482866133b3565b9a9950505050505050505050565b600061230c614387565b6123415760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610b0d565b816001600160a01b031663abc6d72d6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612381573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a591906156f8565b6123e95760405162461bcd60e51b815260206004820152601560248201527410b4b9a932bbb0b93239a234b9ba3934b13aba37b960591b6044820152606401610b0d565b60005b60195481101561246157601981815481106124095761240961566c565b6000918252602090912001546001600160a01b03908116908416036124595760405162461bcd60e51b815260206004820152600660248201526508585919195960d21b6044820152606401610b0d565b6001016123ec565b50601980546001810182556000919091527f944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c96950180546001600160a01b0319166001600160a01b0384169081179091556040519081527f98ef1187fb6fd2bc85f8996489877eb2b5428f9e9bdfc068c9ad6c2ea82eacc790602001612094565b601354600090600160b01b900460ff16156125305760405162461bcd60e51b815260206004820152601060248201526f085d1c985b9cd9995c8e9c185d5cd95960821b6044820152606401610b0d565b600061253d868685614898565b9050801561254c579050610c53565b612557868686614960565b60009695505050505050565b60008054604051631beb2b9760e31b81526060926001600160a01b039092169163df595cb8916125a89130913391839190356001600160e01b03191690600401615715565b602060405180830381865afa1580156125c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e991906156f8565b6126265760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610b0d565b815160008167ffffffffffffffff81111561264357612643615402565b60405190808252806020026020018201604052801561266c578160200160208202803683370190505b50905060005b828110156126d957600085828151811061268e5761268e61566c565b602002602001015190506126a28133614a04565b60148111156126b3576126b36155fd565b8383815181106126c5576126c561566c565b602090810291909101015250600101612672565b509150505b919050565b60035460405163fc57d4df60e01b81526001600160a01b038581166004830152600092839283929091169063fc57d4df90602401602060405180830381865afa158015612734573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275891906155e4565b60035460405163fc57d4df60e01b81526001600160a01b0388811660048301529293506000929091169063fc57d4df90602401602060405180830381865afa1580156127a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127cc91906155e4565b90508115806127d9575080155b156127ed57600c6000935093505050612a07565b60008690506000816001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612832573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285691906155e4565b905060006128706040518060200160405280600081525090565b6040805160208101909152600081526040805160208101909152600081526000866001600160a01b0316636752e7026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128f291906155e4565b90506000876001600160a01b031663be99f1196040518163ffffffff1660e01b8152600401602060405180830381865afa158015612934573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061295891906155e4565b9050600061299b6129876040518060200160405280600554815250604051806020016040528087815250614b9e565b604051806020016040528085815250614b9e565b90506129b58160405180602001604052808e815250614bd3565b95506129dd60405180602001604052808c81525060405180602001604052808b815250614bd3565b94506129e98686614c12565b93506129f5848f614511565b60009d509b5050505050505050505050505b935093915050565b601981815481106110ea57600080fd5b6000612a29614387565b612a3957610c3c600160146143db565b60005b84811015612cb4576000868683818110612a5857612a5861566c565b9050602002016020810190612a6d9190614ff9565b9050848483818110612a8157612a8161566c565b9050602002016020810190612a9691906152c8565b15612b4e576001600160a01b03811660009081526010602052604090205460ff16612b49576001600160a01b0381166000818152601060205260408120805460ff19166001908117909155601180548083018255928190527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6890920180546001600160a01b03191690931790925554612b2f9190615629565b6001600160a01b0382166000908152601260205260409020555b612cab565b6001600160a01b03811660009081526010602052604090205460ff1615612cab5760118054612b7f90600190615629565b81548110612b8f57612b8f61566c565b60009182526020808320909101546001600160a01b0384811684526012909252604090922054601180549290931692918110612bcd57612bcd61566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506011805480612c0c57612c0c615748565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b038316825260129081905260408220546011805491939184908110612c6057612c6061566c565b60009182526020808320909101546001600160a01b039081168452838201949094526040928301822094909455918416825260128352808220829055601090925220805460ff191690555b50600101612a3c565b506000610c50565b3360009081526008602052604090205460ff16612d1b5760405162461bcd60e51b815260206004820181905260248201527f21436f6d7074726f6c6c65723a5f6265666f72654e6f6e5265656e7472616e746044820152606401610b0d565b601a5460ff16612d5a5760405162461bcd60e51b815260206004820152600a602482015269085c99595b9d195c995960b21b6044820152606401610b0d565b601a805460ff19169055565b601354600090600160b81b900460ff1615612db35760405162461bcd60e51b815260206004820152600d60248201526c085cd95a5e994e9c185d5cd959609a1b6044820152606401610b0d565b6001600160a01b03861660009081526008602052604090205460ff161580612df457506001600160a01b03851660009081526008602052604090205460ff16155b15612e0057600861126e565b846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6291906156db565b6001600160a01b0316866001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecd91906156db565b6001600160a01b031614612ee257600261126e565b612557868486614960565b601181815481106110ea57600080fd5b6001600160a01b03831660009081526015602052604081205460ff1615612f575760405162461bcd60e51b815260206004820152600e60248201526d08589bdc9c9bddce9c185d5cd95960921b6044820152606401610b0d565b6001600160a01b03841660009081526008602052604090205460ff16612f7e576008610dbb565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff1661306d57336001600160a01b03851614612ff15760405162461bcd60e51b815260206004820152600760248201526610b1ba37b5b2b760c91b6044820152606401610b0d565b6000612ffd3385614a04565b90506000816014811115613013576130136155fd565b146130325780601481111561302a5761302a6155fd565b915050610c12565b6001600160a01b038086166000908152600860209081526040808320938816835260029093019052205460ff1661306b5761306b61575e565b505b60035460405163fc57d4df60e01b81526001600160a01b0386811660048301529091169063fc57d4df90602401602060405180830381865afa1580156130b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130db91906155e4565b6000036130e957600c610dbb565b600f5460ff16801561311457506001600160a01b03831660009081526010602052604090205460ff16155b15613120576011610dbb565b600061312b85612119565b9050801580159061315b57506001600160a01b03851660009081526021602052604090206131599085614454565b155b1561329f576000856001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c491906155e4565b9050600030604051631d3965af60e11b81526001600160a01b0389811660048301529190911690633a72cb5e90602401602060405180830381865afa158015613211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323591906155e4565b9050600082821061324857506000613255565b6132528284615629565b90505b83613260878361563c565b1061329b5760405162461bcd60e51b815260206004820152600b60248201526a021626f72726f773a6361760ac1b6044820152606401610b0d565b5050505b6132a98585614074565b604051637e361b1160e01b81526001600160a01b0380861660048301528616602482015260006044820181905260648201859052608482018190529081903090637e361b119060a401608060405180830381865afa15801561330f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133339190615774565b9350505091506000601481111561334c5761334c6155fd565b821461335c57509150610c129050565b801561336e5760049350505050610c12565b6000979650505050505050565b6007602052816000526040600020818154811061339757600080fd5b6000918252602090912001546001600160a01b03169150829050565b60006133bd614387565b6133d4576133cd600160096143db565b9050610c66565b6001600160a01b0383166000908152600860205260409020805460ff16613409576134016008600a6143db565b915050610c66565b60408051602080820183528582528251908101909252670c7d713b49da000082529061343781835190511090565b15613452576134486006600b6143db565b9350505050610c66565b84158015906134cc575060035460405163fc57d4df60e01b81526001600160a01b0388811660048301529091169063fc57d4df90602401602060405180830381865afa1580156134a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ca91906155e4565b155b156134dc57613448600c806143db565b60018301805490869055604080516001600160a01b0389168152602081018390529081018790527f70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc59060600160405180910390a16000979650505050505050565b60008061354b858585614898565b90508015610f77579050610c12565b60008054604051631beb2b9760e31b81526001600160a01b039091169063df595cb89061359c903090339082906001600160e01b031988351690600401615715565b602060405180830381865afa1580156135b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135dd91906156f8565b61361a5760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610b0d565b6001600160a01b03821660009081526008602052604090205460ff166136825760405162461bcd60e51b815260206004820152601760248201527f21436f6d7074726f6c6c65723a657869744d61726b65740000000000000000006044820152606401610b0d565b6040516361bfb47160e11b81523360048201528290600090819081906001600160a01b0385169063c37f68e290602401608060405180830381865afa1580156136cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f39190615774565b50925092509250826000146137385760405162461bcd60e51b815260206004820152600b60248201526a08595e1a5d13585c9ad95d60aa1b6044820152606401610b0d565b801561374a57610d36600b60036143db565b6000613757873385614898565b905080156137775761376c600d600483614c4c565b979650505050505050565b6001600160a01b0387166000908152600860209081526040808320338452600281019092529091205460ff166137b557600098975050505050505050565b3360009081526002820160209081526040808320805460ff19169055600782528083208054825181850281018501909352808352919290919083018282801561382757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613809575b5050835193945083925060009150505b82811015613881578b6001600160a01b031684828151811061385b5761385b61566c565b60200260200101516001600160a01b03160361387957809150613881565b600101613837565b508181106138915761389161575e565b336000908152600760205260409020805481906138b090600190615629565b815481106138c0576138c061566c565b9060005260206000200160009054906101000a90046001600160a01b03168183815481106138f0576138f061566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080548061392e5761392e615748565b600082815260208120820160001990810180546001600160a01b031916905590910190915581549003613a8a57600b805461396b90600190615629565b8154811061397b5761397b61566c565b6000918252602080832090910154338352600c909152604090912054600b80546001600160a01b039093169290919081106139b8576139b861566c565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b8054806139f7576139f7615748565b60008281526020808220830160001990810180546001600160a01b0319169055909201909255338252600c908190526040822054600b805491939184908110613a4257613a4261566c565b60009182526020808320909101546001600160a01b03168352828101939093526040918201812093909355338352600c8252808320839055600a9091529020805460ff191690555b604080516001600160a01b038e1681523360208201527fe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d910160405180910390a160009c9b505050505050505050505050565b600080600080613aeb614f19565b6001600160a01b03891615613b6f5760035460405163fc57d4df60e01b81526001600160a01b038b811660048301529091169063fc57d4df90602401602060405180830381865afa158015613b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b6891906155e4565b6101808201525b60005b6001600160a01b038b16600090815260076020526040902054811015613ef4576001600160a01b038b166000908152600760205260409020805482908110613bbc57613bbc61566c565b60009182526020822001546001600160a01b039081168085526040516361bfb47160e11b8152918e1660048301529063c37f68e290602401608060405180830381865afa158015613c11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c359190615774565b60a08701526080860152606085015290508015613c6357600e60008060009650965096509650505050611613565b50604080516020808201835284516001600160a01b0390811660009081526008835284902060010154835260e08601929092528251908101835260a085015181526101008501526003548451925163fc57d4df60e01b81529282166004840152169063fc57d4df90602401602060405180830381865afa158015613ceb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0f91906155e4565b60c08301819052600003613d3357600c600080600095509550955095505050611613565b604080516020810190915260c0830151815261012083015260e0820151610100830151613d6e91613d6391614bd3565b836101200151614bd3565b610140830152308251604051633c1f884b60e11b81526001600160a01b0391821660048201528c821660248201528b151560448201528d8216606482015291169063783f109690608401602060405180830381865afa158015613dd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df991906155e4565b6101a08301526101408201516060830151600091613e1691614511565b9050826101a00151811115613e2d57506101a08201515b8083602001818151613e3f919061563c565b9052505061012082015160808301516040840151613e5e929190614cc4565b604083015281516001600160a01b03808c16911603613eec57613e8b8261014001518a8460400151614cc4565b60408301819052610120830151613ea3918a90614cc4565b6040830152610120820151600090613ebb9089614511565b905082604001518110613ed45760006040840152613eea565b8083604001818151613ee69190615629565b9052505b505b600101613b72565b50806040015181602001511115613f2d576020810151604082015160009190613f1d9082615629565b6000945094509450945050611613565b60008160200151600083602001518460400151613f4a9190615629565b945094509450945050611613565b600083600003613f6a57506000610c12565b60035460405163fc57d4df60e01b81526001600160a01b038581166004830152600092169063fc57d4df90602401602060405180830381865afa158015613fb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd991906155e4565b9050600081116140155760405162461bcd60e51b8152602060048201526007602482015266216f7261636c6560c81b6044820152606401610b0d565b82614057576001600160a01b038416600090815260086020526040902060010154670de0b6b3a764000061404983836157aa565b61405391906157c1565b9150505b8061406a86670de0b6b3a76400006157aa565b610ce891906157c1565b60005b60195481101561411057601981815481106140945761409461566c565b600091825260209091200154604051631cdc2c5d60e31b81526001600160a01b03858116600483015284811660248301529091169063e6e162e890604401600060405180830381600087803b1580156140ec57600080fd5b505af1158015614100573d6000803e3d6000fd5b5050600190920191506140779050565b505050565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215614365576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141bb91906156db565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa158015614214573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061423891906157fb565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b038616916142919190615896565b600060405180830381855afa9150503d80600081146142cc576040519150601f19603f3d011682016040523d82523d6000602084013e6142d1565b606091505b50915091508180156142e4575080516020145b1561430357808060200190518101906142fd91906158b2565b60ff1692505b60408501516143159060000b846158cf565b92506000831261433b5761432a83600a6159d3565b61433490876157aa565b955061435c565b614344836159df565b61434f90600a6159d3565b61435990876157c1565b95505b50505050614381565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6001546000906001600160a01b0316331480156143ad5750600254600160a81b900460ff165b806143d657506000546001600160a01b0316331480156143d65750600254600160a01b900460ff165b905090565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836014811115614410576144106155fd565b83601a811115614422576144226155fd565b60408051928352602083019190915260009082015260600160405180910390a1826014811115610c1257610c126155fd565b6001600160a01b03811660009081526001830160205260408120541515610c12565b60005b60195481101561411057601981815481106144965761449661566c565b60009182526020909120015460405162e48b0f60e51b81526001600160a01b038581166004830152848116602483015290911690631c9161e090604401600060405180830381600087803b1580156144ed57600080fd5b505af1158015614501573d6000803e3d6000fd5b5050600190920191506144799050565b60008061451e8484614ce5565b9050610c5381614d0d565b6000806000806145398686614d25565b90925090506000826003811115614552576145526155fd565b146145635750915060009050614575565b600061456e82614d0d565b9350935050505b9250929050565b6000610c128383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250614da1565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215614634576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614197573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b600061465b614387565b61466b57610c66600160166143db565b6001600160a01b03821660009081526008602052604090205460ff161561469857610c66600960156143db565b306001600160a01b0316826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061470491906156db565b6001600160a01b0316146147495760405162461bcd60e51b815260206004820152600c60248201526b10b1b7b6b83a3937b63632b960a11b6044820152606401610b0d565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614789573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147ad91906156db565b6001600160a01b038082166000908152600e602052604090205491925016156147dc57610c12600960156143db565b6001600160a01b038381166000818152600860209081526040808320805460ff1916600190811782558082018590556009805491820190557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b031990811687179091559587168452600e835292819020805490951684179094559251918252917fcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f910160405180910390a16000610c53565b6001600160a01b03831660009081526008602052604081205460ff166148bf576008610dbb565b6001600160a01b038085166000908152600860209081526040808320938716835260029093019052205460ff166148f7576000610dbb565b600080614908858786600080613add565b93505050915060006014811115614921576149216155fd565b826014811115614933576149336155fd565b146149535781601481111561494a5761494a6155fd565b92505050610c12565b801561255757600461494a565b60005b6019548110156110d457601981815481106149805761498061566c565b600091825260209091200154604051634e081c9560e01b81526001600160a01b0386811660048301528581166024830152848116604483015290911690634e081c9590606401600060405180830381600087803b1580156149e057600080fd5b505af11580156149f4573d6000803e3d6000fd5b5050600190920191506149639050565b6001600160a01b0382166000908152600860205260408120805460ff16614a2f576008915050610c66565b6001600160a01b038316600090815260028201602052604090205460ff161515600103614a60576000915050610c66565b6001600160a01b03838116600081815260028401602090815260408083208054600160ff199091168117909155600783528184208054918201815584528284200180546001600160a01b031916958a1695909517909455918152600a909152205460ff16614b5157600b8054600180820183557f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db990910180546001600160a01b0319166001600160a01b0387169081179091556000908152600a60205260409020805460ff1916821790559054614b379190615629565b6001600160a01b0384166000908152600c60205260409020555b604080516001600160a01b038087168252851660208201527f3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a5910160405180910390a15060009392505050565b6040805160208101909152600081526040518060200160405280614bca8560000151856000015161457c565b90529392505050565b6040805160208101909152600081526040518060200160405280670de0b6b3a7640000614c0886600001518660000151614ddb565b614bca91906157c1565b6040805160208101909152600081526040518060200160405280614bca614c458660000151670de0b6b3a7640000614ddb565b8551614e1d565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846014811115614c8157614c816155fd565b84601a811115614c9357614c936155fd565b604080519283526020830191909152810184905260600160405180910390a1836014811115610c5357610c536155fd565b600080614cd18585614ce5565b9050610ce8614cdf82614d0d565b8461457c565b6040805160208101909152600081526040518060200160405280614bca856000015185614ddb565b8051600090610c6690670de0b6b3a7640000906157c1565b6000614d3d6040518060200160405280600081525090565b600080614d4e866000015186614e50565b90925090506000826003811115614d6757614d676155fd565b14614d8657506040805160208101909152600081529092509050614575565b60408051602081019091529081526000969095509350505050565b600080614dae848661563c565b90508285821015614dd25760405162461bcd60e51b8152600401610b0d91906159fb565b50949350505050565b6000610c1283836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250614e9a565b6000610c1283836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250614eed565b60008083600003614e6657506000905080614575565b83830283614e7486836157c1565b14614e8757600260009250925050614575565b600092509050614575565b509250929050565b6000831580614ea7575082155b15614eb457506000610c12565b6000614ec084866157aa565b905083614ecd86836157c1565b148390614dd25760405162461bcd60e51b8152600401610b0d91906159fb565b60008183614f0e5760405162461bcd60e51b8152600401610b0d91906159fb565b50610c5383856157c1565b604051806101c0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001614f756040518060200160405280600081525090565b8152602001614f906040518060200160405280600081525090565b8152602001614fab6040518060200160405280600081525090565b8152602001614fc66040518060200160405280600081525090565b81526020016000815260200160008152602001600081525090565b6001600160a01b0381168114614ff657600080fd5b50565b60006020828403121561500b57600080fd5b8135610c1281614fe1565b8015158114614ff657600080fd5b60008060006060848603121561503957600080fd5b833561504481614fe1565b9250602084013561505481614fe1565b9150604084013561506481615016565b809150509250925092565b6000806040838503121561508257600080fd5b823561508d81614fe1565b9150602083013561509d81614fe1565b809150509250929050565b600080600080608085870312156150be57600080fd5b84356150c981614fe1565b935060208501356150d981614fe1565b925060408501356150e981614fe1565b9396929550929360600135925050565b60006020828403121561510b57600080fd5b5035919050565b6000806000806080858703121561512857600080fd5b843561513381614fe1565b9350602085013561514381614fe1565b93969395505050506040820135916060013590565b60008060006060848603121561516d57600080fd5b833561517881614fe1565b9250602084013561518881614fe1565b929592945050506040919091013590565b600080600080600060a086880312156151b157600080fd5b85356151bc81614fe1565b945060208601356151cc81614fe1565b935060408601356151dc81614fe1565b925060608601356151ec81614fe1565b949793965091946080013592915050565b6000806040838503121561521057600080fd5b823561521b81614fe1565b946020939093013593505050565b600080600080600060a0868803121561524157600080fd5b853561524c81614fe1565b9450602086013561525c81614fe1565b94979496505050506040830135926060810135926080909101359150565b6020808252825182820181905260009190848201906040850190845b818110156152bc5783516001600160e01b03191683529284019291840191600101615296565b50909695505050505050565b6000602082840312156152da57600080fd5b8135610c1281615016565b6020808252825182820181905260009190848201906040850190845b818110156152bc5783516001600160a01b031683529284019291840191600101615301565b60ff81168114614ff657600080fd5b60008083601f84011261534757600080fd5b50813567ffffffffffffffff81111561535f57600080fd5b60208301915083602082850101111561457557600080fd5b6000806000806000806080878903121561539057600080fd5b863561539b81615326565b9550602087013567ffffffffffffffff808211156153b857600080fd5b6153c48a838b01615335565b909750955060408901359150808211156153dd57600080fd5b506153ea89828a01615335565b979a9699509497949695606090950135949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561544157615441615402565b604052919050565b6000602080838503121561545c57600080fd5b823567ffffffffffffffff8082111561547457600080fd5b818501915085601f83011261548857600080fd5b81358181111561549a5761549a615402565b8060051b91506154ab848301615418565b81815291830184019184810190888411156154c557600080fd5b938501935b838510156154ef57843592506154df83614fe1565b82825293850193908501906154ca565b98975050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156152bc57835183529284019291840191600101615517565b60008083601f84011261554557600080fd5b50813567ffffffffffffffff81111561555d57600080fd5b6020830191508360208260051b850101111561457557600080fd5b6000806000806040858703121561558e57600080fd5b843567ffffffffffffffff808211156155a657600080fd5b6155b288838901615533565b909650945060208701359150808211156155cb57600080fd5b506155d887828801615533565b95989497509550505050565b6000602082840312156155f657600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6657610c66615613565b80820180821115610c6657610c66615613565b600060ff82168061566257615662615613565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60ff861681526060602082015260006156c8606083018688615682565b82810360408401526154ef818587615682565b6000602082840312156156ed57600080fd5b8151610c1281614fe1565b60006020828403121561570a57600080fd5b8151610c1281615016565b6001600160a01b0394851681529284166020840152921660408201526001600160e01b0319909116606082015260800190565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b6000806000806080858703121561578a57600080fd5b505082516020840151604085015160609095015191969095509092509050565b8082028115828204841417610c6657610c66615613565b6000826157de57634e487b7160e01b600052601260045260246000fd5b500490565b805167ffffffffffffffff811681146126de57600080fd5b60006060828403121561580d57600080fd5b6040516060810181811067ffffffffffffffff8211171561583057615830615402565b60405261583c836157e3565b815261584a602084016157e3565b6020820152604083015163ffffffff8116811461586657600080fd5b60408201529392505050565b60005b8381101561588d578181015183820152602001615875565b50506000910152565b600082516158a8818460208701615872565b9190910192915050565b6000602082840312156158c457600080fd5b8151610c1281615326565b80820182811260008312801582168215821617156158ef576158ef615613565b505092915050565b600181815b80851115614e9257816000190482111561591857615918615613565b8085161561592557918102915b93841c93908002906158fc565b60008261594157506001610c66565b8161594e57506000610c66565b8160018114615964576002811461596e5761598a565b6001915050610c66565b60ff84111561597f5761597f615613565b50506001821b610c66565b5060208310610133831016604e8410600b84101617156159ad575081810a610c66565b6159b783836158f7565b80600019048211156159cb576159cb615613565b029392505050565b6000610c128383615932565b6000600160ff1b82016159f4576159f4615613565b5060000390565b6020815260008251806020840152615a1a816040850160208701615872565b601f01601f1916919091016040019291505056fea2646970667358221220bba991f953a0ec9721b327889c949cdcded9ead7aaaf711b80ec61b18035cd4964736f6c63430008160033", + "devdoc": { + "author": "Compound", + "details": "This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).", + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_addRewardsDistributor(address)": { + "details": "Admin function to add a RewardsDistributor contract", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_afterNonReentrant()": { + "details": "Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention. Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream." + }, + "_beforeNonReentrant()": { + "details": "Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention. Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream." + }, + "_deployMarket(uint8,bytes,bytes,uint256)": { + "details": "Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor", + "returns": { + "_0": "uint 0=success, otherwise a failure. (See enum Error for details)" + } + }, + "_getExtensionFunctions()": { + "returns": { + "functionSelectors": "a list of all the function selectors that this logic extension exposes" + } + }, + "_setCloseFactor(uint256)": { + "details": "Admin function to set closeFactor", + "params": { + "newCloseFactorMantissa": "New close factor, scaled by 1e18" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure. (See ErrorReporter for details)" + } + }, + "_setCollateralFactor(address,uint256)": { + "details": "Admin function to set per-market collateralFactor", + "params": { + "cToken": "The market to set the factor on", + "newCollateralFactorMantissa": "The new collateral factor, scaled by 1e18" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure. (See ErrorReporter for details)" + } + }, + "_setLiquidationIncentive(uint256)": { + "details": "Admin function to set liquidationIncentive", + "params": { + "newLiquidationIncentiveMantissa": "New liquidationIncentive scaled by 1e18" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure. (See ErrorReporter for details)" + } + }, + "_setPriceOracle(address)": { + "details": "Admin function to set a new price oracle", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_setWhitelistEnforcement(bool)": { + "details": "Admin function to set a new whitelist enforcement boolean", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "_setWhitelistStatuses(address[],bool[])": { + "details": "Admin function to set the whitelist `statuses` for `suppliers`", + "returns": { + "_0": "uint 0=success, otherwise a failure (see ErrorReporter.sol for details)" + } + }, + "borrowAllowed(address,address,uint256)": { + "params": { + "borrowAmount": "The amount of underlying the account would borrow", + "borrower": "The account which would borrow the asset", + "cToken": "The market to verify the borrow against" + }, + "returns": { + "_0": "0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)" + } + }, + "borrowWithinLimits(address,uint256)": { + "params": { + "accountBorrowsNew": "The user's new borrow balance of the underlying asset", + "cToken": "Asset whose underlying is being borrowed" + } + }, + "checkMembership(address,address)": { + "params": { + "account": "The address of the account to check", + "cToken": "The cToken to check" + }, + "returns": { + "_0": "True if the account is in the asset, otherwise false." + } + }, + "effectiveBorrowCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "effectiveSupplyCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "enterMarkets(address[])": { + "params": { + "cTokens": "The list of addresses of the cToken markets to be enabled" + }, + "returns": { + "_0": "Success indicator for whether each corresponding market was entered" + } + }, + "exitMarket(address)": { + "details": "Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral for an outstanding borrow.", + "params": { + "cTokenAddress": "The address of the asset to be removed" + }, + "returns": { + "_0": "Whether or not the account successfully exited the market" + } + }, + "getAssetsIn(address)": { + "params": { + "account": "The address of the account to pull assets for" + }, + "returns": { + "_0": "A dynamic list with the assets the account has entered" + } + }, + "getHypotheticalAccountLiquidity(address,address,uint256,uint256,uint256)": { + "params": { + "account": "The account to determine liquidity for", + "borrowAmount": "The amount of underlying to hypothetically borrow", + "cTokenModify": "The market to hypothetically redeem/borrow in", + "redeemTokens": "The number of tokens to hypothetically redeem" + }, + "returns": { + "_0": "(possible error code (semi-opaque), hypothetical account liquidity in excess of collateral requirements, hypothetical account shortfall below collateral requirements)" + } + }, + "isDeprecated(address)": { + "details": "All borrows in a deprecated cToken market can be immediately liquidated", + "params": { + "cToken": "The market to check if deprecated" + } + }, + "liquidateBorrowAllowed(address,address,address,address,uint256)": { + "params": { + "borrower": "The address of the borrower", + "cTokenBorrowed": "Asset which was borrowed by the borrower", + "cTokenCollateral": "Asset which was used as collateral and will be seized", + "liquidator": "The address repaying the borrow and seizing the collateral", + "repayAmount": "The amount of underlying being repaid" + } + }, + "liquidateCalculateSeizeTokens(address,address,uint256)": { + "details": "Used in liquidation (called in cToken.liquidateBorrowFresh)", + "params": { + "actualRepayAmount": "The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens", + "cTokenBorrowed": "The address of the borrowed cToken", + "cTokenCollateral": "The address of the collateral cToken" + }, + "returns": { + "_0": "(errorCode, number of cTokenCollateral tokens to be seized in a liquidation)" + } + }, + "mintAllowed(address,address,uint256)": { + "params": { + "cTokenAddress": "The market to verify the mint against", + "mintAmount": "The amount of underlying being supplied to the market in exchange for tokens", + "minter": "The account which would get the minted tokens" + }, + "returns": { + "_0": "0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)" + } + }, + "mintVerify(address,address,uint256,uint256)": { + "params": { + "actualMintAmount": "The amount of the underlying asset being minted", + "cToken": "Asset being minted", + "mintTokens": "The number of tokens being minted", + "minter": "The address minting the tokens" + } + }, + "redeemAllowed(address,address,uint256)": { + "params": { + "cToken": "The market to verify the redeem against", + "redeemTokens": "The number of cTokens to exchange for the underlying asset in the market", + "redeemer": "The account which would redeem the tokens" + }, + "returns": { + "_0": "0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)" + } + }, + "redeemVerify(address,address,uint256,uint256)": { + "params": { + "cToken": "Asset being redeemed", + "redeemAmount": "The amount of the underlying asset being redeemed", + "redeemTokens": "The number of tokens being redeemed", + "redeemer": "The address redeeming the tokens" + } + }, + "repayBorrowAllowed(address,address,address,uint256)": { + "params": { + "borrower": "The account which would borrowed the asset", + "cToken": "The market to verify the repay against", + "payer": "The account which would repay the asset", + "repayAmount": "The amount of the underlying asset the account would repay" + }, + "returns": { + "_0": "0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)" + } + }, + "seizeAllowed(address,address,address,address,uint256)": { + "params": { + "borrower": "The address of the borrower", + "cTokenBorrowed": "Asset which was borrowed by the borrower", + "cTokenCollateral": "Asset which was used as collateral and will be seized", + "liquidator": "The address repaying the borrow and seizing the collateral", + "seizeTokens": "The number of collateral tokens to seize" + } + }, + "transferAllowed(address,address,address,uint256)": { + "params": { + "cToken": "The market to verify the transfer against", + "dst": "The account which receives the tokens", + "src": "The account which sources the tokens", + "transferTokens": "The number of cTokens to transfer" + }, + "returns": { + "_0": "0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)" + } + } + }, + "title": "Compound's Comptroller Contract", + "version": 1 + }, + "userdoc": { + "events": { + "AddedRewardsDistributor(address)": { + "notice": "Emitted when a new RewardsDistributor contract is added to hooks" + }, + "MarketEntered(address,address)": { + "notice": "Emitted when an account enters a market" + }, + "MarketExited(address,address)": { + "notice": "Emitted when an account exits a market" + }, + "MarketListed(address)": { + "notice": "Emitted when an admin supports a market" + }, + "NewCloseFactor(uint256,uint256)": { + "notice": "Emitted when close factor is changed by admin" + }, + "NewCollateralFactor(address,uint256,uint256)": { + "notice": "Emitted when a collateral factor is changed by admin" + }, + "NewLiquidationIncentive(uint256,uint256)": { + "notice": "Emitted when liquidation incentive is changed by admin" + }, + "NewPriceOracle(address,address)": { + "notice": "Emitted when price oracle is changed" + }, + "WhitelistEnforcementChanged(bool)": { + "notice": "Emitted when the whitelist enforcement is changed" + } + }, + "kind": "user", + "methods": { + "_addRewardsDistributor(address)": { + "notice": "Add a RewardsDistributor contracts." + }, + "_deployMarket(uint8,bytes,bytes,uint256)": { + "notice": "Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor" + }, + "_setCloseFactor(uint256)": { + "notice": "Sets the closeFactor used when liquidating borrows" + }, + "_setCollateralFactor(address,uint256)": { + "notice": "Sets the collateralFactor for a market" + }, + "_setLiquidationIncentive(uint256)": { + "notice": "Sets liquidationIncentive" + }, + "_setPriceOracle(address)": { + "notice": "Sets a new price oracle for the comptroller" + }, + "_setWhitelistEnforcement(bool)": { + "notice": "Sets the whitelist enforcement for the comptroller" + }, + "_setWhitelistStatuses(address[],bool[])": { + "notice": "Sets the whitelist `statuses` for `suppliers`" + }, + "accountAssets(address,uint256)": { + "notice": "Per-account mapping of \"assets you are in\", capped by maxAssets" + }, + "admin()": { + "notice": "Administrator for this contract" + }, + "adminHasRights()": { + "notice": "Whether or not the admin has admin rights" + }, + "allBorrowers(uint256)": { + "notice": "A list of all borrowers who have entered markets" + }, + "allMarkets(uint256)": { + "notice": "A list of all markets" + }, + "borrowAllowed(address,address,uint256)": { + "notice": "Checks if the account should be allowed to borrow the underlying asset of the given market" + }, + "borrowCapGuardian()": { + "notice": "The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market." + }, + "borrowCaps(address)": { + "notice": "Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing." + }, + "borrowWithinLimits(address,uint256)": { + "notice": "Checks if the account should be allowed to borrow the underlying asset of the given market" + }, + "cTokensByUnderlying(address)": { + "notice": "All cTokens addresses mapped by their underlying token addresses" + }, + "checkMembership(address,address)": { + "notice": "Returns whether the given account is entered in the given asset" + }, + "closeFactorMantissa()": { + "notice": "Multiplier used to calculate the maximum repayAmount when liquidating a borrow" + }, + "effectiveBorrowCaps(address)": { + "notice": "Gets the borrow cap of a cToken in the units of the underlying asset." + }, + "effectiveSupplyCaps(address)": { + "notice": "Gets the supply cap of a cToken in the units of the underlying asset." + }, + "enforceWhitelist()": { + "notice": "Whether or not the supplier whitelist is enforced" + }, + "enterMarkets(address[])": { + "notice": "Add assets to be included in account liquidity calculation" + }, + "exitMarket(address)": { + "notice": "Removes asset from sender's account liquidity calculation" + }, + "getAssetsIn(address)": { + "notice": "Returns the assets an account has entered" + }, + "getHypotheticalAccountLiquidity(address,address,uint256,uint256,uint256)": { + "notice": "Determine what the account liquidity would be if the given amounts were redeemed/borrowed" + }, + "ionicAdminHasRights()": { + "notice": "Whether or not the Ionic admin has admin rights" + }, + "isComptroller()": { + "notice": "Indicator that this is a Comptroller contract (for inspection)" + }, + "isDeprecated(address)": { + "notice": "Returns true if the given cToken market has been deprecated" + }, + "liquidateBorrowAllowed(address,address,address,address,uint256)": { + "notice": "Checks if the liquidation should be allowed to occur" + }, + "liquidateCalculateSeizeTokens(address,address,uint256)": { + "notice": "Calculate number of tokens of collateral asset to seize given an underlying amount" + }, + "liquidationIncentiveMantissa()": { + "notice": "Multiplier representing the discount on collateral that a liquidator receives" + }, + "markets(address)": { + "notice": "Official mapping of cTokens -> Market metadata" + }, + "mintAllowed(address,address,uint256)": { + "notice": "Checks if the account should be allowed to mint tokens in the given market" + }, + "mintVerify(address,address,uint256,uint256)": { + "notice": "Validates mint and reverts on rejection. May emit logs." + }, + "nonAccruingRewardsDistributors(uint256)": { + "notice": "RewardsDistributor to list for claiming, but not to notify of flywheel changes." + }, + "oracle()": { + "notice": "Oracle which gives the price of any given asset" + }, + "pauseGuardian()": { + "notice": "The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market." + }, + "pendingAdmin()": { + "notice": "Pending administrator for this contract" + }, + "redeemAllowed(address,address,uint256)": { + "notice": "Checks if the account should be allowed to redeem tokens in the given market" + }, + "redeemVerify(address,address,uint256,uint256)": { + "notice": "Validates redeem and reverts on rejection. May emit logs." + }, + "repayBorrowAllowed(address,address,address,uint256)": { + "notice": "Checks if the account should be allowed to repay a borrow in the given market" + }, + "rewardsDistributors(uint256)": { + "notice": "RewardsDistributor contracts to notify of flywheel changes." + }, + "seizeAllowed(address,address,address,address,uint256)": { + "notice": "Checks if the seizing of assets should be allowed to occur" + }, + "supplyCaps(address)": { + "notice": "Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying." + }, + "transferAllowed(address,address,address,uint256)": { + "notice": "Checks if the account should be allowed to transfer tokens in the given market" + }, + "whitelist(address)": { + "notice": "Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)" + }, + "whitelistArray(uint256)": { + "notice": "An array of all whitelisted accounts" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 34026, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 34029, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "admin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 34032, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "pendingAdmin", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 34036, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "ionicAdminHasRights", + "offset": 20, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34040, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "adminHasRights", + "offset": 21, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34073, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "oracle", + "offset": 0, + "slot": "3", + "type": "t_contract(BasePriceOracle)78405" + }, + { + "astId": 34076, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "closeFactorMantissa", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 34079, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "liquidationIncentiveMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 34081, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "maxAssets", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 34088, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "accountAssets", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)" + }, + { + "astId": 34106, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "markets", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_struct(Market)34100_storage)" + }, + { + "astId": 34111, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "allMarkets", + "offset": 0, + "slot": "9", + "type": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + { + "astId": 34116, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowers", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34120, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "allBorrowers", + "offset": 0, + "slot": "11", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34124, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowerIndexes", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34129, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "suppliers", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34135, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "cTokensByUnderlying", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_contract(ICErc20)26708)" + }, + { + "astId": 34138, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "enforceWhitelist", + "offset": 0, + "slot": "15", + "type": "t_bool" + }, + { + "astId": 34143, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "whitelist", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34147, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "whitelistArray", + "offset": 0, + "slot": "17", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34151, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "whitelistIndexes", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34154, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "pauseGuardian", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 34156, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_mintGuardianPaused", + "offset": 20, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34158, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_borrowGuardianPaused", + "offset": 21, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34160, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "transferGuardianPaused", + "offset": 22, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34162, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "seizeGuardianPaused", + "offset": 23, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34166, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "mintGuardianPaused", + "offset": 0, + "slot": "20", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34170, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowGuardianPaused", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34176, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCapGuardian", + "offset": 0, + "slot": "22", + "type": "t_address" + }, + { + "astId": 34181, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCaps", + "offset": 0, + "slot": "23", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34186, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "supplyCaps", + "offset": 0, + "slot": "24", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34190, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "rewardsDistributors", + "offset": 0, + "slot": "25", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34193, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_notEntered", + "offset": 0, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34196, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_notEnteredInitialized", + "offset": 1, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34200, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "nonAccruingRewardsDistributors", + "offset": 0, + "slot": "27", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34207, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCapForCollateral", + "offset": 0, + "slot": "28", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 34214, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowingAgainstCollateralBlacklist", + "offset": 0, + "slot": "29", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))" + }, + { + "astId": 34222, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCapForCollateralWhitelist", + "offset": 0, + "slot": "30", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34230, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowingAgainstCollateralBlacklistWhitelist", + "offset": 0, + "slot": "31", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34236, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "supplyCapWhitelist", + "offset": 0, + "slot": "32", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34242, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCapWhitelist", + "offset": 0, + "slot": "33", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34249, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "borrowCapConfig", + "offset": 0, + "slot": "34", + "type": "t_struct(PrudentiaConfig)18257_storage" + }, + { + "astId": 34253, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "supplyCapConfig", + "offset": 0, + "slot": "35", + "type": "t_struct(PrudentiaConfig)18257_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "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(ICErc20)26708)dyn_storage": { + "base": "t_contract(ICErc20)26708", + "encoding": "dynamic_array", + "label": "contract ICErc20[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(BasePriceOracle)78405": { + "encoding": "inplace", + "label": "contract BasePriceOracle", + "numberOfBytes": "20" + }, + "t_contract(ICErc20)26708": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_int8": { + "encoding": "inplace", + "label": "int8", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + "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_contract(ICErc20)26708)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20)", + "numberOfBytes": "32", + "value": "t_contract(ICErc20)26708" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct EnumerableSet.AddressSet))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_address,t_struct(Market)34100_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct ComptrollerV2Storage.Market)", + "numberOfBytes": "32", + "value": "t_struct(Market)34100_storage" + }, + "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_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Market)34100_storage": { + "encoding": "inplace", + "label": "struct ComptrollerV2Storage.Market", + "members": [ + { + "astId": 34093, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "isListed", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 34095, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "collateralFactorMantissa", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 34099, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "accountMembership", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_bool)" + } + ], + "numberOfBytes": "96" + }, + "t_struct(PrudentiaConfig)18257_storage": { + "encoding": "inplace", + "label": "struct PrudentiaLib.PrudentiaConfig", + "members": [ + { + "astId": 18252, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "controller", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 18254, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "offset", + "offset": 20, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 18256, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "decimalShift", + "offset": 21, + "slot": "0", + "type": "t_int8" + } + ], + "numberOfBytes": "32" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/compound/Comptroller.sol:Comptroller", + "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" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/ComptrollerFirstExtension.json b/packages/contracts/deployments/superseed/ComptrollerFirstExtension.json new file mode 100644 index 0000000000..5512a237c4 --- /dev/null +++ b/packages/contracts/deployments/superseed/ComptrollerFirstExtension.json @@ -0,0 +1,2253 @@ +{ + "address": "0x284bb7298F3d7B99CA105a468c4E696D11150E6E", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "action", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "pauseState", + "type": "bool" + } + ], + "name": "ActionPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "error", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "detail", + "type": "uint256" + } + ], + "name": "Failure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "action", + "type": "string" + }, + { + "indexed": false, + "internalType": "bool", + "name": "pauseState", + "type": "bool" + } + ], + "name": "MarketActionPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "MarketUnlisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBorrowCap", + "type": "uint256" + } + ], + "name": "NewBorrowCap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldBorrowCapGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newBorrowCapGuardian", + "type": "address" + } + ], + "name": "NewBorrowCapGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPauseGuardian", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "NewPauseGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupplyCap", + "type": "uint256" + } + ], + "name": "NewSupplyCap", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "bool", + "name": "blacklisted", + "type": "bool" + } + ], + "name": "_blacklistBorrowingAgainstCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_blacklistBorrowingAgainstCollateralWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_borrowCapWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "_borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "_mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "flywheelAddress", + "type": "address" + } + ], + "name": "_removeFlywheel", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "name": "_setBorrowCapForCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_setBorrowCapForCollateralWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newBorrowCapGuardian", + "type": "address" + } + ], + "name": "_setBorrowCapGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setBorrowPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "newBorrowCaps", + "type": "uint256[]" + } + ], + "name": "_setMarketBorrowCaps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20[]", + "name": "cTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "newSupplyCaps", + "type": "uint256[]" + } + ], + "name": "_setMarketSupplyCaps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setMintPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPauseGuardian", + "type": "address" + } + ], + "name": "_setPauseGuardian", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setSeizePaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "state", + "type": "bool" + } + ], + "name": "_setTransferPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_supplyCapWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "_unsupportMarket", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "accountAssets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "flywheelAddress", + "type": "address" + } + ], + "name": "addNonAccruingFlywheel", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allBorrowers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allMarkets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCapForCollateral", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "borrowCapGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowingAgainstCollateralBlacklist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cTokensByUnderlying", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "closeFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveBorrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveSupplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enforceWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAccruingFlywheels", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllBorrowers", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllBorrowersCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllMarkets", + "outputs": [ + { + "internalType": "contract ICErc20[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "collateral", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenModify", + "type": "address" + }, + { + "internalType": "bool", + "name": "redeeming", + "type": "bool" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getAssetAsCollateralValueCap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "page", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pageSize", + "type": "uint256" + } + ], + "name": "getPaginatedBorrowers", + "outputs": [ + { + "internalType": "uint256", + "name": "_totalPages", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "_pageOfBorrowers", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRewardsDistributors", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelist", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "getWhitelistedBorrowersBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowed", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "getWhitelistedSuppliersSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "supplied", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isBlacklistBorrowingAgainstCollateralWhitelisted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cTokenBorrow", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isBorrowCapForCollateralWhitelisted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isBorrowCapWhitelisted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isComptroller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isSupplyCapWhitelisted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "isUserOfPool", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidationIncentiveMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "nonAccruingRewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "registerInSFS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "rewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "seizeGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "suppliers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "supplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "transferGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "whitelistArray", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x580266018cff9556ee61bcb4a67a62e6227bad34d45d081ad2f6c0a57fe740e1", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x284bb7298F3d7B99CA105a468c4E696D11150E6E", + "transactionIndex": 1, + "gasUsed": "3575655", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x65d036b65436ead2396b27c0f2faa872c7610a582aba848a2b7c7bebfdbe5a97", + "transactionHash": "0x580266018cff9556ee61bcb4a67a62e6227bad34d45d081ad2f6c0a57fe740e1", + "logs": [], + "blockNumber": 4134114, + "cumulativeGasUsed": "3619533", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"action\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"pauseState\",\"type\":\"bool\"}],\"name\":\"ActionPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"error\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"info\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"detail\",\"type\":\"uint256\"}],\"name\":\"Failure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"action\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"pauseState\",\"type\":\"bool\"}],\"name\":\"MarketActionPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"MarketUnlisted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBorrowCap\",\"type\":\"uint256\"}],\"name\":\"NewBorrowCap\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldBorrowCapGuardian\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newBorrowCapGuardian\",\"type\":\"address\"}],\"name\":\"NewBorrowCapGuardian\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPauseGuardian\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPauseGuardian\",\"type\":\"address\"}],\"name\":\"NewPauseGuardian\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSupplyCap\",\"type\":\"uint256\"}],\"name\":\"NewSupplyCap\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"blacklisted\",\"type\":\"bool\"}],\"name\":\"_blacklistBorrowingAgainstCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_blacklistBorrowingAgainstCollateralWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_borrowCapWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"flywheelAddress\",\"type\":\"address\"}],\"name\":\"_removeFlywheel\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrowCap\",\"type\":\"uint256\"}],\"name\":\"_setBorrowCapForCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_setBorrowCapForCollateralWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newBorrowCapGuardian\",\"type\":\"address\"}],\"name\":\"_setBorrowCapGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"state\",\"type\":\"bool\"}],\"name\":\"_setBorrowPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"cTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"newBorrowCaps\",\"type\":\"uint256[]\"}],\"name\":\"_setMarketBorrowCaps\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"cTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"newSupplyCaps\",\"type\":\"uint256[]\"}],\"name\":\"_setMarketSupplyCaps\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"state\",\"type\":\"bool\"}],\"name\":\"_setMintPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPauseGuardian\",\"type\":\"address\"}],\"name\":\"_setPauseGuardian\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"state\",\"type\":\"bool\"}],\"name\":\"_setSeizePaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"state\",\"type\":\"bool\"}],\"name\":\"_setTransferPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_supplyCapWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"_unsupportMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"accountAssets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"flywheelAddress\",\"type\":\"address\"}],\"name\":\"addNonAccruingFlywheel\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allBorrowers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allMarkets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCapForCollateral\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowCapGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowingAgainstCollateralBlacklist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"cTokensByUnderlying\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"closeFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveBorrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveSupplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplyCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enforceWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAccruingFlywheels\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllBorrowers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllBorrowersCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllMarkets\",\"outputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"collateral\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenModify\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"redeeming\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getAssetAsCollateralValueCap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"page\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"pageSize\",\"type\":\"uint256\"}],\"name\":\"getPaginatedBorrowers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_totalPages\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"_pageOfBorrowers\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRewardsDistributors\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWhitelist\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"getWhitelistedBorrowersBorrows\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowed\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"getWhitelistedSuppliersSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplied\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isBlacklistBorrowingAgainstCollateralWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cTokenBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isBorrowCapForCollateralWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isBorrowCapWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isComptroller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isSupplyCapWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"isUserOfPool\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidationIncentiveMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"markets\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isListed\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactorMantissa\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"nonAccruingRewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"registerInSFS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"rewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"seizeGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"suppliers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"supplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"whitelistArray\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Failure(uint256,uint256,uint256)\":{\"details\":\"`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*\"}},\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"_removeFlywheel(address)\":{\"details\":\"Removes a flywheel from the accruing or non-accruing array\",\"params\":{\"flywheelAddress\":\"The address of the flywheel to remove from the accruing or non-accruing array\"},\"returns\":{\"_0\":\"true if the flywheel was found and removed\"}},\"_setBorrowCapGuardian(address)\":{\"params\":{\"newBorrowCapGuardian\":\"The address of the new Borrow Cap Guardian\"}},\"_setMarketBorrowCaps(address[],uint256[])\":{\"details\":\"Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\",\"params\":{\"cTokens\":\"The addresses of the markets (tokens) to change the borrow caps for\",\"newBorrowCaps\":\"The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\"}},\"_setMarketSupplyCaps(address[],uint256[])\":{\"details\":\"Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\",\"params\":{\"cTokens\":\"The addresses of the markets (tokens) to change the supply caps for\",\"newSupplyCaps\":\"The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\"}},\"_setPauseGuardian(address)\":{\"params\":{\"newPauseGuardian\":\"The address of the new Pause Guardian\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See enum Error for details)\"}},\"_unsupportMarket(address)\":{\"details\":\"Admin function unset isListed and collateralFactorMantissa and unadd support for the market\",\"params\":{\"cToken\":\"The address of the market (token) to unlist\"},\"returns\":{\"_0\":\"uint 0=success, otherwise a failure. (See enum Error for details)\"}},\"addNonAccruingFlywheel(address)\":{\"details\":\"Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\",\"params\":{\"flywheelAddress\":\"The address of the flywheel to add to the non-accruing\"}},\"effectiveBorrowCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"effectiveSupplyCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"getAllBorrowers()\":{\"details\":\"The automatic getter may be used to access an individual borrower.\",\"returns\":{\"_0\":\"The list of borrower account addresses\"}},\"getAllMarkets()\":{\"details\":\"The automatic getter may be used to access an individual market.\",\"returns\":{\"_0\":\"The list of market addresses\"}},\"getWhitelist()\":{\"details\":\"The automatic getter may be used to access an individual whitelist status.\",\"returns\":{\"_0\":\"The list of borrower account addresses\"}}},\"version\":1},\"userdoc\":{\"events\":{\"ActionPaused(string,bool)\":{\"notice\":\"Emitted when an action is paused globally\"},\"MarketActionPaused(address,string,bool)\":{\"notice\":\"Emitted when an action is paused on a market\"},\"MarketUnlisted(address)\":{\"notice\":\"Emitted when an admin unsupports a market\"},\"NewBorrowCap(address,uint256)\":{\"notice\":\"Emitted when borrow cap for a cToken is changed\"},\"NewBorrowCapGuardian(address,address)\":{\"notice\":\"Emitted when borrow cap guardian is changed\"},\"NewPauseGuardian(address,address)\":{\"notice\":\"Emitted when pause guardian is changed\"},\"NewSupplyCap(address,uint256)\":{\"notice\":\"Emitted when supply cap for a cToken is changed\"}},\"kind\":\"user\",\"methods\":{\"_setBorrowCapGuardian(address)\":{\"notice\":\"Admin function to change the Borrow Cap Guardian\"},\"_setMarketBorrowCaps(address[],uint256[])\":{\"notice\":\"Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\"},\"_setMarketSupplyCaps(address[],uint256[])\":{\"notice\":\"Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\"},\"_setPauseGuardian(address)\":{\"notice\":\"Admin function to change the Pause Guardian\"},\"_unsupportMarket(address)\":{\"notice\":\"Removed a market from the markets mapping and sets it as unlisted\"},\"accountAssets(address,uint256)\":{\"notice\":\"Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\"},\"addNonAccruingFlywheel(address)\":{\"notice\":\"Returns true if the accruing flyhwheel was found and replaced\"},\"admin()\":{\"notice\":\"Administrator for this contract\"},\"adminHasRights()\":{\"notice\":\"Whether or not the admin has admin rights\"},\"allBorrowers(uint256)\":{\"notice\":\"A list of all borrowers who have entered markets\"},\"allMarkets(uint256)\":{\"notice\":\"A list of all markets\"},\"borrowCapGuardian()\":{\"notice\":\"The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\"},\"borrowCaps(address)\":{\"notice\":\"Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\"},\"cTokensByUnderlying(address)\":{\"notice\":\"All cTokens addresses mapped by their underlying token addresses\"},\"closeFactorMantissa()\":{\"notice\":\"Multiplier used to calculate the maximum repayAmount when liquidating a borrow\"},\"effectiveBorrowCaps(address)\":{\"notice\":\"Gets the borrow cap of a cToken in the units of the underlying asset.\"},\"effectiveSupplyCaps(address)\":{\"notice\":\"Gets the supply cap of a cToken in the units of the underlying asset.\"},\"enforceWhitelist()\":{\"notice\":\"Whether or not the supplier whitelist is enforced\"},\"getAllBorrowers()\":{\"notice\":\"Return all of the borrowers\"},\"getAllMarkets()\":{\"notice\":\"Return all of the markets\"},\"getRewardsDistributors()\":{\"notice\":\"Returns an array of all accruing and non-accruing flywheels\"},\"getWhitelist()\":{\"notice\":\"Return all of the whitelist\"},\"ionicAdminHasRights()\":{\"notice\":\"Whether or not the Ionic admin has admin rights\"},\"isComptroller()\":{\"notice\":\"Indicator that this is a Comptroller contract (for inspection)\"},\"liquidationIncentiveMantissa()\":{\"notice\":\"Multiplier representing the discount on collateral that a liquidator receives\"},\"markets(address)\":{\"notice\":\"Official mapping of cTokens -> Market metadata\"},\"nonAccruingRewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor to list for claiming, but not to notify of flywheel changes.\"},\"oracle()\":{\"notice\":\"Oracle which gives the price of any given asset\"},\"pauseGuardian()\":{\"notice\":\"The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market.\"},\"pendingAdmin()\":{\"notice\":\"Pending administrator for this contract\"},\"rewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor contracts to notify of flywheel changes.\"},\"supplyCaps(address)\":{\"notice\":\"Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\"},\"whitelist(address)\":{\"notice\":\"Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\"},\"whitelistArray(uint256)\":{\"notice\":\"An array of all whitelisted accounts\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/ComptrollerFirstExtension.sol\":\"ComptrollerFirstExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerFirstExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"../compound/ErrorReporter.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract ComptrollerFirstExtension is\\n DiamondExtension,\\n ComptrollerBase,\\n ComptrollerExtensionInterface,\\n ComptrollerErrorReporter\\n{\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when supply cap for a cToken is changed\\n event NewSupplyCap(ICErc20 indexed cToken, uint256 newSupplyCap);\\n\\n /// @notice Emitted when borrow cap for a cToken is changed\\n event NewBorrowCap(ICErc20 indexed cToken, uint256 newBorrowCap);\\n\\n /// @notice Emitted when borrow cap guardian is changed\\n event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);\\n\\n /// @notice Emitted when pause guardian is changed\\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\\n\\n /// @notice Emitted when an action is paused globally\\n event ActionPaused(string action, bool pauseState);\\n\\n /// @notice Emitted when an action is paused on a market\\n event MarketActionPaused(ICErc20 cToken, string action, bool pauseState);\\n\\n /// @notice Emitted when an admin unsupports a market\\n event MarketUnlisted(ICErc20 cToken);\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 33;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector;\\n functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this._setMarketBorrowCaps.selector;\\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateralWhitelist.selector;\\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateralWhitelist.selector;\\n functionSelectors[--fnsCount] = this._supplyCapWhitelist.selector;\\n functionSelectors[--fnsCount] = this._borrowCapWhitelist.selector;\\n functionSelectors[--fnsCount] = this._setBorrowCapGuardian.selector;\\n functionSelectors[--fnsCount] = this._setPauseGuardian.selector;\\n functionSelectors[--fnsCount] = this._setMintPaused.selector;\\n functionSelectors[--fnsCount] = this._setBorrowPaused.selector;\\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\\n functionSelectors[--fnsCount] = this._unsupportMarket.selector;\\n functionSelectors[--fnsCount] = this.getAllMarkets.selector;\\n functionSelectors[--fnsCount] = this.getAllBorrowers.selector;\\n functionSelectors[--fnsCount] = this.getAllBorrowersCount.selector;\\n functionSelectors[--fnsCount] = this.getPaginatedBorrowers.selector;\\n functionSelectors[--fnsCount] = this.getWhitelist.selector;\\n functionSelectors[--fnsCount] = this.getRewardsDistributors.selector;\\n functionSelectors[--fnsCount] = this.isUserOfPool.selector;\\n functionSelectors[--fnsCount] = this.getAccruingFlywheels.selector;\\n functionSelectors[--fnsCount] = this._removeFlywheel.selector;\\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateral.selector;\\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateral.selector;\\n functionSelectors[--fnsCount] = this.isBorrowCapForCollateralWhitelisted.selector;\\n functionSelectors[--fnsCount] = this.isBlacklistBorrowingAgainstCollateralWhitelisted.selector;\\n functionSelectors[--fnsCount] = this.isSupplyCapWhitelisted.selector;\\n functionSelectors[--fnsCount] = this.isBorrowCapWhitelisted.selector;\\n functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector;\\n functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector;\\n functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector;\\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /**\\n * @notice Returns true if the accruing flyhwheel was found and replaced\\n * @dev Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\\n * @param flywheelAddress The address of the flywheel to add to the non-accruing\\n */\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n require(flywheelAddress != address(0), \\\"!flywheel\\\");\\n\\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\\n require(flywheelAddress != nonAccruingRewardsDistributors[i], \\\"!alreadyadded\\\");\\n }\\n\\n // add it to the non-accruing\\n nonAccruingRewardsDistributors.push(flywheelAddress);\\n\\n // remove it from the accruing\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\\n if (flywheelAddress == rewardsDistributors[i]) {\\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\\n rewardsDistributors.pop();\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256) {\\n if (address(collateral) == address(cTokenModify) && !redeeming) {\\n // the collateral asset counts as 0 liquidity when borrowed\\n return 0;\\n }\\n\\n uint256 assetAsCollateralValueCap = type(uint256).max;\\n if (address(cTokenModify) != address(0)) {\\n // if the borrowed asset is blacklisted against this collateral & account is not whitelisted\\n if (\\n borrowingAgainstCollateralBlacklist[address(cTokenModify)][address(collateral)] &&\\n !borrowingAgainstCollateralBlacklistWhitelist[address(cTokenModify)][address(collateral)].contains(account)\\n ) {\\n assetAsCollateralValueCap = 0;\\n } else {\\n // for each user the value of this kind of collateral is capped regardless of the amount borrowed\\n // denominated in the borrowed asset\\n uint256 borrowCapForCollateral = borrowCapForCollateral[address(cTokenModify)][address(collateral)];\\n // check if set to any value & account is not whitelisted\\n if (\\n borrowCapForCollateral != 0 &&\\n !borrowCapForCollateralWhitelist[address(cTokenModify)][address(collateral)].contains(account)\\n ) {\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n // this asset usage as collateral is capped at the native value of the borrow cap\\n assetAsCollateralValueCap = (borrowCapForCollateral * borrowedAssetPrice) / 1e18;\\n }\\n }\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(address(collateral));\\n\\n // if there is any supply cap, don't allow donations to the market/plugin to go around it\\n if (supplyCap > 0 && !supplyCapWhitelist[address(collateral)].contains(account)) {\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateral);\\n uint256 supplyCapValue = (supplyCap * collateralAssetPrice) / 1e18;\\n supplyCapValue = (supplyCapValue * markets[address(collateral)].collateralFactorMantissa) / 1e18;\\n if (supplyCapValue < assetAsCollateralValueCap) assetAsCollateralValueCap = supplyCapValue;\\n }\\n\\n return assetAsCollateralValueCap;\\n }\\n\\n /**\\n * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\\n * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\\n * @param cTokens The addresses of the markets (tokens) to change the supply caps for\\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\\n */\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external {\\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \\\"!admin\\\");\\n\\n uint256 numMarkets = cTokens.length;\\n uint256 numSupplyCaps = newSupplyCaps.length;\\n\\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \\\"!input\\\");\\n\\n for (uint256 i = 0; i < numMarkets; i++) {\\n supplyCaps[address(cTokens[i])] = newSupplyCaps[i];\\n emit NewSupplyCap(cTokens[i], newSupplyCaps[i]);\\n }\\n }\\n\\n /**\\n * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\\n * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\\n * @param cTokens The addresses of the markets (tokens) to change the borrow caps for\\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\\n */\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external {\\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \\\"!admin\\\");\\n\\n uint256 numMarkets = cTokens.length;\\n uint256 numBorrowCaps = newBorrowCaps.length;\\n\\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \\\"!input\\\");\\n\\n for (uint256 i = 0; i < numMarkets; i++) {\\n borrowCaps[address(cTokens[i])] = newBorrowCaps[i];\\n emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);\\n }\\n }\\n\\n /**\\n * @notice Admin function to change the Borrow Cap Guardian\\n * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian\\n */\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external {\\n require(msg.sender == admin, \\\"!admin\\\");\\n\\n // Save current value for inclusion in log\\n address oldBorrowCapGuardian = borrowCapGuardian;\\n\\n // Store borrowCapGuardian with value newBorrowCapGuardian\\n borrowCapGuardian = newBorrowCapGuardian;\\n\\n // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)\\n emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);\\n }\\n\\n /**\\n * @notice Admin function to change the Pause Guardian\\n * @param newPauseGuardian The address of the new Pause Guardian\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _setPauseGuardian(address newPauseGuardian) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);\\n }\\n\\n // Save current value for inclusion in log\\n address oldPauseGuardian = pauseGuardian;\\n\\n // Store pauseGuardian with value newPauseGuardian\\n pauseGuardian = newPauseGuardian;\\n\\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\\n emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function _setMintPaused(ICErc20 cToken, bool state) public returns (bool) {\\n require(markets[address(cToken)].isListed, \\\"!market\\\");\\n require(msg.sender == pauseGuardian || hasAdminRights(), \\\"!guardian\\\");\\n require(hasAdminRights() || state == true, \\\"!admin\\\");\\n\\n mintGuardianPaused[address(cToken)] = state;\\n emit MarketActionPaused(cToken, \\\"Mint\\\", state);\\n return state;\\n }\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) public returns (bool) {\\n require(markets[address(cToken)].isListed, \\\"!market\\\");\\n require(msg.sender == pauseGuardian || hasAdminRights(), \\\"!guardian\\\");\\n require(hasAdminRights() || state == true, \\\"!admin\\\");\\n\\n borrowGuardianPaused[address(cToken)] = state;\\n emit MarketActionPaused(cToken, \\\"Borrow\\\", state);\\n return state;\\n }\\n\\n function _setTransferPaused(bool state) public returns (bool) {\\n require(msg.sender == pauseGuardian || hasAdminRights(), \\\"!guardian\\\");\\n require(hasAdminRights() || state == true, \\\"!admin\\\");\\n\\n transferGuardianPaused = state;\\n emit ActionPaused(\\\"Transfer\\\", state);\\n return state;\\n }\\n\\n function _setSeizePaused(bool state) public returns (bool) {\\n require(msg.sender == pauseGuardian || hasAdminRights(), \\\"!guardian\\\");\\n require(hasAdminRights() || state == true, \\\"!admin\\\");\\n\\n seizeGuardianPaused = state;\\n emit ActionPaused(\\\"Seize\\\", state);\\n return state;\\n }\\n\\n /**\\n * @notice Removed a market from the markets mapping and sets it as unlisted\\n * @dev Admin function unset isListed and collateralFactorMantissa and unadd support for the market\\n * @param cToken The address of the market (token) to unlist\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256) {\\n // Check admin rights\\n if (!hasAdminRights()) return fail(Error.UNAUTHORIZED, FailureInfo.UNSUPPORT_MARKET_OWNER_CHECK);\\n\\n // Check if market is already unlisted\\n if (!markets[address(cToken)].isListed)\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNSUPPORT_MARKET_DOES_NOT_EXIST);\\n\\n // Check if market is in use\\n if (cToken.totalSupply() > 0) return fail(Error.NONZERO_TOTAL_SUPPLY, FailureInfo.UNSUPPORT_MARKET_IN_USE);\\n\\n // Unlist market\\n delete markets[address(cToken)];\\n\\n /* Delete cToken from allMarkets */\\n // load into memory for faster iteration\\n ICErc20[] memory _allMarkets = allMarkets;\\n uint256 len = _allMarkets.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (_allMarkets[i] == cToken) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n allMarkets[assetIndex] = allMarkets[allMarkets.length - 1];\\n allMarkets.pop();\\n\\n cTokensByUnderlying[ICErc20(address(cToken)).underlying()] = ICErc20(address(0));\\n emit MarketUnlisted(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n borrowCapForCollateral[cTokenBorrow][cTokenCollateral] = borrowCap;\\n }\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n if (whitelisted) borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].add(account);\\n else borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\\n }\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) public view returns (bool) {\\n return borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\\n }\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n borrowingAgainstCollateralBlacklist[cTokenBorrow][cTokenCollateral] = blacklisted;\\n }\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n if (whitelisted) borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].add(account);\\n else borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\\n }\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) public view returns (bool) {\\n return borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\\n }\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n if (whitelisted) supplyCapWhitelist[cToken].add(account);\\n else supplyCapWhitelist[cToken].remove(account);\\n }\\n\\n function isSupplyCapWhitelisted(address cToken, address account) public view returns (bool) {\\n return supplyCapWhitelist[cToken].contains(account);\\n }\\n\\n function getWhitelistedSuppliersSupply(address cToken) public view returns (uint256 supplied) {\\n address[] memory whitelistedSuppliers = supplyCapWhitelist[cToken].values();\\n for (uint256 i = 0; i < whitelistedSuppliers.length; i++) {\\n supplied += ICErc20(cToken).balanceOfUnderlying(whitelistedSuppliers[i]);\\n }\\n }\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) public {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n if (whitelisted) borrowCapWhitelist[cToken].add(account);\\n else borrowCapWhitelist[cToken].remove(account);\\n }\\n\\n function isBorrowCapWhitelisted(address cToken, address account) public view returns (bool) {\\n return borrowCapWhitelist[cToken].contains(account);\\n }\\n\\n function getWhitelistedBorrowersBorrows(address cToken) public view returns (uint256 borrowed) {\\n address[] memory whitelistedBorrowers = borrowCapWhitelist[cToken].values();\\n for (uint256 i = 0; i < whitelistedBorrowers.length; i++) {\\n borrowed += ICErc20(cToken).borrowBalanceCurrent(whitelistedBorrowers[i]);\\n }\\n }\\n\\n /**\\n * @notice Return all of the markets\\n * @dev The automatic getter may be used to access an individual market.\\n * @return The list of market addresses\\n */\\n function getAllMarkets() public view returns (ICErc20[] memory) {\\n return allMarkets;\\n }\\n\\n /**\\n * @notice Return all of the borrowers\\n * @dev The automatic getter may be used to access an individual borrower.\\n * @return The list of borrower account addresses\\n */\\n function getAllBorrowers() public view returns (address[] memory) {\\n return allBorrowers;\\n }\\n\\n function getAllBorrowersCount() public view returns (uint256) {\\n return allBorrowers.length;\\n }\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) public view returns (uint256 _totalPages, address[] memory _pageOfBorrowers) {\\n uint256 allBorrowersCount = allBorrowers.length;\\n if (allBorrowersCount == 0) {\\n return (0, new address[](0));\\n }\\n\\n if (pageSize == 0) pageSize = 300;\\n uint256 currentPageSize = pageSize;\\n uint256 sizeOfPageFromRemainder = allBorrowersCount % pageSize;\\n\\n _totalPages = allBorrowersCount / pageSize;\\n if (sizeOfPageFromRemainder > 0) {\\n _totalPages++;\\n if (page + 1 == _totalPages) {\\n currentPageSize = sizeOfPageFromRemainder;\\n }\\n }\\n\\n if (page + 1 > _totalPages) {\\n return (_totalPages, new address[](0));\\n }\\n\\n uint256 offset = page * pageSize;\\n _pageOfBorrowers = new address[](currentPageSize);\\n for (uint256 i = 0; i < currentPageSize; i++) {\\n _pageOfBorrowers[i] = allBorrowers[i + offset];\\n }\\n }\\n\\n /**\\n * @notice Return all of the whitelist\\n * @dev The automatic getter may be used to access an individual whitelist status.\\n * @return The list of borrower account addresses\\n */\\n function getWhitelist() external view returns (address[] memory) {\\n return whitelistArray;\\n }\\n\\n /**\\n * @notice Returns an array of all accruing and non-accruing flywheels\\n */\\n function getRewardsDistributors() external view returns (address[] memory) {\\n address[] memory allFlywheels = new address[](rewardsDistributors.length + nonAccruingRewardsDistributors.length);\\n\\n uint8 i = 0;\\n while (i < rewardsDistributors.length) {\\n allFlywheels[i] = rewardsDistributors[i];\\n i++;\\n }\\n uint8 j = 0;\\n while (j < nonAccruingRewardsDistributors.length) {\\n allFlywheels[i + j] = nonAccruingRewardsDistributors[j];\\n j++;\\n }\\n\\n return allFlywheels;\\n }\\n\\n function getAccruingFlywheels() external view returns (address[] memory) {\\n return rewardsDistributors;\\n }\\n\\n /**\\n * @dev Removes a flywheel from the accruing or non-accruing array\\n * @param flywheelAddress The address of the flywheel to remove from the accruing or non-accruing array\\n * @return true if the flywheel was found and removed\\n */\\n function _removeFlywheel(address flywheelAddress) external returns (bool) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n require(flywheelAddress != address(0), \\\"!flywheel\\\");\\n\\n // remove it from the accruing\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\\n if (flywheelAddress == rewardsDistributors[i]) {\\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\\n rewardsDistributors.pop();\\n return true;\\n }\\n }\\n\\n // or remove it from the non-accruing\\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\\n if (flywheelAddress == nonAccruingRewardsDistributors[i]) {\\n nonAccruingRewardsDistributors[i] = nonAccruingRewardsDistributors[nonAccruingRewardsDistributors.length - 1];\\n nonAccruingRewardsDistributors.pop();\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n function isUserOfPool(address user) external view returns (bool) {\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n address marketAddress = address(allMarkets[i]);\\n if (markets[marketAddress].accountMembership[user]) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n function registerInSFS() external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\\n\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n allMarkets[i].registerInSFS();\\n }\\n\\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\\n }\\n}\\n\",\"keccak256\":\"0x91bbdc157e7acfd7fa311d0af3c95886771f700fa03ca1ad86cb8eda56c50c6a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040526002805461ffff60a01b191661010160a01b17905534801561002557600080fd5b50613f48806100356000396000f3fe608060405234801561001057600080fd5b50600436106103fb5760003560e01c80637515bafa11610215578063be945a6411610125578063d9e0ea6b116100b8578063e875544611610087578063e875544614610986578063ee5b9a2f1461098f578063f851a440146109a2578063f874eb0c146109b5578063fb6243fa146109c857600080fd5b8063d9e0ea6b1461092b578063dce154491461093e578063e6653f3d14610951578063e68065911461096557600080fd5b8063cf6bfd2d116100f4578063cf6bfd2d146108e9578063d01f63f5146108fd578063d219fca714610905578063d251fefc1461091857600080fd5b8063be945a641461089d578063c6c5b0dd146108b0578063c76ae260146108c3578063c91a424f146108d657600080fd5b80638ebf6364116101a8578063ac0b0bb711610177578063ac0b0bb714610841578063b0772d0b14610855578063b09572101461086a578063b103488214610877578063b32538011461088a57600080fd5b80638ebf6364146107cd578063940cd6f1146107e05780639b19251a1461080b578063a5fb48571461082e57600080fd5b8063819605a8116101e4578063819605a81461074d57806387f763031461076057806389f8132e146107745780638e8f294b1461078957600080fd5b80637515bafa1461070c578063783f10961461071f5780637dc0d1d0146107325780637f15e2161461074557600080fd5b80633605b51b1161031057806351a485e4116102a3578063607ef6c111610272578063607ef6c11461068d578063692fd2a9146106a05780636bd02b8a146106b35780636d154ea5146106c6578063731f0c2b146106e957600080fd5b806351a485e41461064157806351c8491d1461065457806352d84d1e146106675780635f5af1aa1461067a57600080fd5b80633c94786f116102df5780633c94786f146105fc5780634a584432146106105780634a76e727146106305780634ada90af1461063857600080fd5b80633605b51b146105b9578063391957d7146105c15780633a72cb5e146105d65780633bcf7ec1146105e957600080fd5b80631c819e4311610393578063267822471161036257806326782247146105425780632ccf47a4146105555780632d70db781461056857806331ff47fa1461057b57806332abcdbe146105a457600080fd5b80631c819e43146104c357806321af4569146104f15780632273f40e1461051c57806324a3d6221461052f57600080fd5b8063109908ce116103cf578063109908ce1461047257806315c3b9b01461048557806316dc15fe1461048d57806318c882a5146104b057600080fd5b80627e3dd21461040057806302c3bcbb1461041d578063088e0fce1461044b5780630a755ec21461045e575b600080fd5b610408600181565b60405190151581526020015b60405180910390f35b61043d61042b3660046136af565b60186020526000908152604090205481565b604051908152602001610414565b6104086104593660046136cc565b6109db565b60025461040890600160a81b900460ff1681565b6104086104803660046136af565b610a14565b600b5461043d565b61040861049b3660046136af565b600d6020526000908152604090205460ff1681565b6104086104be36600461372c565b610c5e565b6104086104d1366004613761565b601d60209081526000928352604080842090915290825290205460ff1681565b601654610504906001600160a01b031681565b6040516001600160a01b039091168152602001610414565b61040861052a366004613761565b610da4565b601354610504906001600160a01b031681565b600254610504906001600160a01b031681565b61043d6105633660046136af565b610dcc565b61040861057636600461379a565b61103e565b6105046105893660046136af565b600e602052600090815260409020546001600160a01b031681565b6105ac611121565b60405161041491906137fa565b6105ac611183565b6105d46105cf3660046136af565b6112eb565b005b61043d6105e43660046136af565b611376565b6104086105f736600461372c565b611457565b60135461040890600160a01b900460ff1681565b61043d61061e3660046136af565b60176020526000908152604090205481565b6105ac61158e565b61043d60055481565b6105d461064f366004613852565b6115ee565b6105d46106623660046138be565b61176d565b610504610675366004613905565b6117df565b61043d6106883660046136af565b611809565b6105d461069b366004613852565b611889565b6104086106ae3660046136af565b6119ff565b6105046106c1366004613905565b611b86565b6104086106d43660046136af565b60156020526000908152604090205460ff1681565b6104086106f73660046136af565b60146020526000908152604090205460ff1681565b61050461071a366004613905565b611b96565b61043d61072d36600461391e565b611ba6565b600354610504906001600160a01b031681565b61043d611e76565b61043d61075b3660046136af565b611fe0565b60135461040890600160b01b900460ff1681565b61077c61230b565b6040516104149190613978565b6107b66107973660046136af565b6008602052600090815260409020805460019091015460ff9091169082565b604080519215158352602083019190915201610414565b6104086107db36600461379a565b612be7565b61043d6107ee366004613761565b601c60209081526000928352604080842090915290825290205481565b6104086108193660046136af565b60106020526000908152604090205460ff1681565b6105d461083c3660046139c6565b612cc1565b60135461040890600160b81b900460ff1681565b61085d612d11565b6040516104149190613a07565b600f546104089060ff1681565b61043d6108853660046136af565b612d71565b610408610898366004613761565b612e10565b6105d46108ab3660046138be565b612e32565b6105046108be366004613905565b612ea0565b6105d46108d1366004613a48565b612eb0565b600054610504906001600160a01b031681565b60025461040890600160a01b900460ff1681565b6105ac612f45565b6105d4610913366004613a48565b612fa5565b610504610926366004613905565b61302d565b6104086109393660046136af565b61303d565b61050461094c366004613aa2565b6130b4565b60135461040890600160a81b900460ff1681565b610978610973366004613ace565b6130ec565b604051610414929190613af0565b61043d60045481565b6105d461099d3660046138be565b61326b565b600154610504906001600160a01b031681565b6104086109c33660046136cc565b6132c9565b61043d6109d63660046136af565b6132fa565b6001600160a01b038084166000908152601e602090815260408083209386168352929052908120610a0c90836133d3565b949350505050565b6000610a1e6133f5565b610a435760405162461bcd60e51b8152600401610a3a90613b09565b60405180910390fd5b6001600160a01b038216610a855760405162461bcd60e51b815260206004820152600960248201526808599b1e5dda19595b60ba1b6044820152606401610a3a565b60005b601954811015610b825760198181548110610aa557610aa5613b29565b6000918252602090912001546001600160a01b0390811690841603610b7a5760198054610ad490600190613b55565b81548110610ae457610ae4613b29565b600091825260209091200154601980546001600160a01b039092169183908110610b1057610b10613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506019805480610b4f57610b4f613b68565b600082815260209020810160001990810180546001600160a01b031916905501905550600192915050565b600101610a88565b5060005b601b54811015610c5557601b8181548110610ba357610ba3613b29565b6000918252602090912001546001600160a01b0390811690841603610c4d57601b8054610bd290600190613b55565b81548110610be257610be2613b29565b600091825260209091200154601b80546001600160a01b039092169183908110610c0e57610c0e613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550601b805480610b4f57610b4f613b68565b600101610b86565b50600092915050565b6001600160a01b03821660009081526008602052604081205460ff16610cb05760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610a3a565b6013546001600160a01b0316331480610ccc5750610ccc6133f5565b610ce85760405162461bcd60e51b8152600401610a3a90613b7e565b610cf06133f5565b80610cfd57506001821515145b610d195760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038316600081815260156020908152604091829020805460ff19168615159081179091558251938452606091840182905260069184019190915265426f72726f7760d01b6080840152908201527f4ab2c577b7459254dd330a38beef1d66ae70ba1ab28db7147d52d3a752a03cdc9060a0015b60405180910390a150805b92915050565b6001600160a01b03821660009081526020805260408120610dc590836133d3565b9392505050565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b938301939093521561101c576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e729190613ba1565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa158015610ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eef9190613bec565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b03861691610f489190613c71565b600060405180830381855afa9150503d8060008114610f83576040519150601f19603f3d011682016040523d82523d6000602084013e610f88565b606091505b5091509150818015610f9b575080516020145b15610fba5780806020019051810190610fb49190613ca0565b60ff1692505b6040850151610fcc9060000b84613cc3565b925060008312610ff257610fe183600a613dcf565b610feb9087613ddb565b9550611013565b610ffb83613df2565b61100690600a613dcf565b6110109087613e24565b95505b50505050611038565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6013546000906001600160a01b031633148061105d575061105d6133f5565b6110795760405162461bcd60e51b8152600401610a3a90613b7e565b6110816133f5565b8061108e57506001821515145b6110aa5760405162461bcd60e51b8152600401610a3a90613b09565b60138054831515600160b81b0260ff60b81b199091161790556040517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0906111159084906040808252600590820152645365697a6560d81b6060820152901515602082015260800190565b60405180910390a15090565b6060600b80548060200260200160405190810160405280929190818152602001828054801561117957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161115b575b5050505050905090565b601b546019546060916000916111999190613e38565b67ffffffffffffffff8111156111b1576111b1613bbe565b6040519080825280602002602001820160405280156111da578160200160208202803683370190505b50905060005b60195460ff821610156112605760198160ff168154811061120357611203613b29565b9060005260206000200160009054906101000a90046001600160a01b0316828260ff168151811061123657611236613b29565b6001600160a01b03909216602092830291909101909101528061125881613e4b565b9150506111e0565b60005b601b5460ff821610156112e357601b8160ff168154811061128657611286613b29565b6000918252602090912001546001600160a01b0316836112a68385613e6a565b60ff16815181106112b9576112b9613b29565b6001600160a01b0390921660209283029190910190910152806112db81613e4b565b915050611263565b509092915050565b6001546001600160a01b031633146113155760405162461bcd60e51b8152600401610a3a90613b09565b601680546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527feda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29910160405180910390a15050565b6001600160a01b0381166000908152602160205260408120819061139990613449565b905060005b815181101561145057836001600160a01b03166317bfdfbc8383815181106113c8576113c8613b29565b60200260200101516040518263ffffffff1660e01b81526004016113fb91906001600160a01b0391909116815260200190565b602060405180830381865afa158015611418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143c9190613e83565b6114469084613e38565b925060010161139e565b5050919050565b6001600160a01b03821660009081526008602052604081205460ff166114a95760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610a3a565b6013546001600160a01b03163314806114c557506114c56133f5565b6114e15760405162461bcd60e51b8152600401610a3a90613b7e565b6114e96133f5565b806114f657506001821515145b6115125760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038316600081815260146020908152604091829020805460ff19168615159081179091558251938452606091840182905260049184019190915263135a5b9d60e21b6080840152908201527f4ab2c577b7459254dd330a38beef1d66ae70ba1ab28db7147d52d3a752a03cdc9060a001610d93565b60606019805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b6001546001600160a01b031633148061161157506016546001600160a01b031633145b61162d5760405162461bcd60e51b8152600401610a3a90613b09565b8281811580159061163d57508082145b6116725760405162461bcd60e51b8152602060048201526006602482015265085a5b9c1d5d60d21b6044820152606401610a3a565b60005b828110156117645784848281811061168f5761168f613b29565b90506020020135601860008989858181106116ac576116ac613b29565b90506020020160208101906116c191906136af565b6001600160a01b031681526020810191909152604001600020558686828181106116ed576116ed613b29565b905060200201602081019061170291906136af565b6001600160a01b03167f9e0ad9cee10bdf36b7fbd38910c0bdff0f275ace679b45b922381c2723d676f886868481811061173e5761173e613b29565b9050602002013560405161175491815260200190565b60405180910390a2600101611675565b50505050505050565b6117756133f5565b6117915760405162461bcd60e51b8152600401610a3a90613b09565b80156117be576001600160a01b038316600090815260208052604090206117b89083613456565b50505050565b6001600160a01b038316600090815260208052604090206117b8908361346b565b600981815481106117ef57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006118136133f5565b61182357610d9e60016017613480565b601380546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e910160405180910390a160009392505050565b6001546001600160a01b03163314806118ac57506016546001600160a01b031633145b6118c85760405162461bcd60e51b8152600401610a3a90613b09565b828181158015906118d857508082145b61190d5760405162461bcd60e51b8152602060048201526006602482015265085a5b9c1d5d60d21b6044820152606401610a3a565b60005b828110156117645784848281811061192a5761192a613b29565b905060200201356017600089898581811061194757611947613b29565b905060200201602081019061195c91906136af565b6001600160a01b0316815260208101919091526040016000205586868281811061198857611988613b29565b905060200201602081019061199d91906136af565b6001600160a01b03167f6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f68686848181106119d9576119d9613b29565b905060200201356040516119ef91815260200190565b60405180910390a2600101611910565b6000611a096133f5565b611a255760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038216611a675760405162461bcd60e51b815260206004820152600960248201526808599b1e5dda19595b60ba1b6044820152606401610a3a565b60005b601b54811015611ae657601b8181548110611a8757611a87613b29565b6000918252602090912001546001600160a01b0390811690841603611ade5760405162461bcd60e51b815260206004820152600d60248201526c08585b1c9958591e5859191959609a1b6044820152606401610a3a565b600101611a6a565b50601b805460018101825560009182527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b0385161790555b601954811015610c555760198181548110611b4f57611b4f613b29565b6000918252602090912001546001600160a01b0390811690841603611b7e5760198054610ad490600190613b55565b600101611b32565b601b81815481106117ef57600080fd5b600b81815481106117ef57600080fd5b6000836001600160a01b0316856001600160a01b0316148015611bc7575082155b15611bd457506000610a0c565b6000196001600160a01b03851615611d4e576001600160a01b038086166000908152601d60209081526040808320938a168352929052205460ff168015611c4757506001600160a01b038086166000908152601f60209081526040808320938a16835292905220611c4590846133d3565b155b15611c5457506000611d4e565b6001600160a01b038086166000908152601c60209081526040808320938a16835292905220548015801590611cb557506001600160a01b038087166000908152601e60209081526040808320938b16835292905220611cb390856133d3565b155b15611d4c5760035460405163fc57d4df60e01b81526001600160a01b038881166004830152600092169063fc57d4df90602401602060405180830381865afa158015611d05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d299190613e83565b9050670de0b6b3a7640000611d3e8284613ddb565b611d489190613e24565b9250505b505b6000611d5987610dcc565b9050600081118015611d8957506001600160a01b03871660009081526020805260409020611d8790856133d3565b155b15611e6c5760035460405163fc57d4df60e01b81526001600160a01b038981166004830152600092169063fc57d4df90602401602060405180830381865afa158015611dd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dfd9190613e83565b90506000670de0b6b3a7640000611e148385613ddb565b611e1e9190613e24565b6001600160a01b038a16600090815260086020526040902060010154909150670de0b6b3a764000090611e519083613ddb565b611e5b9190613e24565b905083811015611e69578093505b50505b5095945050505050565b6000611e806133f5565b611e9c5760405162461bcd60e51b8152600401610a3a90613b09565b738680ceabcb9b56913c519c069add6bc3494b702060005b600954811015611f5b5760098181548110611ed157611ed1613b29565b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b0316637f15e2166040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f529190613e83565b50600101611eb4565b50604051632210724360e11b8152738fba84867ba458e7c6e2c024d2de3d0b5c3ea1c260048201526001600160a01b03821690634420e486906024016020604051808303816000875af1158015611fb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fda9190613e83565b91505090565b6000611fea6133f5565b611ffa57610d9e60016018613480565b6001600160a01b03821660009081526008602052604090205460ff1661202657610d9e60086019613480565b6000826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612066573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208a9190613e83565b111561209c57610d9e6014601a613480565b6001600160a01b0382166000908152600860209081526040808320805460ff1916815560010183905560098054825181850281018501909352808352919290919083018282801561211657602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120f8575b5050835193945083925060009150505b8281101561217057856001600160a01b031684828151811061214a5761214a613b29565b60200260200101516001600160a01b03160361216857809150612170565b600101612126565b5081811061218057612180613eb2565b6009805461219090600190613b55565b815481106121a0576121a0613b29565b600091825260209091200154600980546001600160a01b0390921691839081106121cc576121cc613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061220b5761220b613b68565b6001900381819060005260206000200160006101000a8154906001600160a01b03021916905590556000600e6000876001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b9190613ba1565b6001600160a01b039081168252602080830193909352604091820160002080546001600160a01b031916948216949094179093555191871682527f302feb03efd5741df80efe7f97f5d93d74d46a542a3d312d0faae64fa1f3e0e9910160405180910390a1600095945050505050565b60408051602180825261044082019092526060919060009082602082016104208036833701905050905063692fd2a960e01b8161234784613ec8565b93508360ff168151811061235d5761235d613b29565b6001600160e01b031990921660209283029190910190910152631469217960e21b8161238884613ec8565b93508360ff168151811061239e5761239e613b29565b6001600160e01b03199092166020928302919091019091015263607ef6c160e01b816123c984613ec8565b93508360ff16815181106123df576123df613b29565b6001600160e01b03199092166020928302919091019091015263d219fca760e01b8161240a84613ec8565b93508360ff168151811061242057612420613b29565b6001600160e01b03199092166020928302919091019091015263063b571360e51b8161244b84613ec8565b93508360ff168151811061246157612461613b29565b6001600160e01b0319909216602092830291909101909101526351c8491d60e01b8161248c84613ec8565b93508360ff16815181106124a2576124a2613b29565b6001600160e01b031990921660209283029190910190910152632fa5169960e21b816124cd84613ec8565b93508360ff16815181106124e3576124e3613b29565b6001600160e01b03199092166020928302919091019091015263391957d760e01b8161250e84613ec8565b93508360ff168151811061252457612524613b29565b6001600160e01b031990921660209283029190910190910152632fad78d560e11b8161254f84613ec8565b93508360ff168151811061256557612565613b29565b6001600160e01b031990921660209283029190910190910152633bcf7ec160e01b8161259084613ec8565b93508360ff16815181106125a6576125a6613b29565b6001600160e01b0319909216602092830291909101909101526318c882a560e01b816125d184613ec8565b93508360ff16815181106125e7576125e7613b29565b6001600160e01b0319909216602092830291909101909101526323afd8d960e21b8161261284613ec8565b93508360ff168151811061262857612628613b29565b6001600160e01b0319909216602092830291909101909101526305ae1b6f60e31b8161265384613ec8565b93508360ff168151811061266957612669613b29565b6001600160e01b031990921660209283029190910190910152631032c0b560e31b8161269484613ec8565b93508360ff16815181106126aa576126aa613b29565b6001600160e01b03199092166020928302919091019091015263b0772d0b60e01b816126d584613ec8565b93508360ff16815181106126eb576126eb613b29565b6001600160e01b031990921660209283029190910190910152631955e6df60e11b8161271684613ec8565b93508360ff168151811061272c5761272c613b29565b6001600160e01b03199092166020928302919091019091015263015c3b9b60e41b8161275784613ec8565b93508360ff168151811061276d5761276d613b29565b6001600160e01b03199092166020928302919091019091015263e680659160e01b8161279884613ec8565b93508360ff16815181106127ae576127ae613b29565b6001600160e01b03199092166020928302919091019091015263d01f63f560e01b816127d984613ec8565b93508360ff16815181106127ef576127ef613b29565b6001600160e01b031990921660209283029190910190910152633605b51b60e01b8161281a84613ec8565b93508360ff168151811061283057612830613b29565b6001600160e01b03199092166020928302919091019091015263d9e0ea6b60e01b8161285b84613ec8565b93508360ff168151811061287157612871613b29565b6001600160e01b031990921660209283029190910190910152634a76e72760e01b8161289c84613ec8565b93508360ff16815181106128b2576128b2613b29565b6001600160e01b03199092166020928302919091019091015263084c846760e11b816128dd84613ec8565b93508360ff16815181106128f3576128f3613b29565b6001600160e01b03199092166020928302919091019091015263a5fb485760e01b8161291e84613ec8565b93508360ff168151811061293457612934613b29565b6001600160e01b03199092166020928302919091019091015263ee5b9a2f60e01b8161295f84613ec8565b93508360ff168151811061297557612975613b29565b6001600160e01b03199092166020928302919091019091015263044707e760e11b816129a084613ec8565b93508360ff16815181106129b6576129b6613b29565b6001600160e01b031990921660209283029190910190910152633e1d3ac360e21b816129e184613ec8565b93508360ff16815181106129f7576129f7613b29565b6001600160e01b031990921660209283029190910190910152631139fa0760e11b81612a2284613ec8565b93508360ff1681518110612a3857612a38613b29565b6001600160e01b03199092166020928302919091019091015263b325380160e01b81612a6384613ec8565b93508360ff1681518110612a7957612a79613b29565b6001600160e01b031990921660209283029190910190910152637db121fd60e11b81612aa484613ec8565b93508360ff1681518110612aba57612aba613b29565b6001600160e01b031990921660209283029190910190910152631d3965af60e11b81612ae584613ec8565b93508360ff1681518110612afb57612afb613b29565b6001600160e01b031990921660209283029190910190910152633c1f884b60e11b81612b2684613ec8565b93508360ff1681518110612b3c57612b3c613b29565b6001600160e01b031990921660209283029190910190910152633f8af10b60e11b81612b6784613ec8565b93508360ff1681518110612b7d57612b7d613b29565b6001600160e01b03199092166020928302919091019091015260ff821615610d9e5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610a3a565b6013546000906001600160a01b0316331480612c065750612c066133f5565b612c225760405162461bcd60e51b8152600401610a3a90613b7e565b612c2a6133f5565b80612c3757506001821515145b612c535760405162461bcd60e51b8152600401610a3a90613b09565b60138054831515600160b01b0260ff60b01b199091161790556040517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0906111159084906040808252600890820152672a3930b739b332b960c11b6060820152901515602082015260800190565b612cc96133f5565b612ce55760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b039283166000908152601c602090815260408083209490951682529290925291902055565b60606009805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215612df3576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e4e573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b6001600160a01b0382166000908152602160205260408120610dc590836133d3565b612e3a6133f5565b612e565760405162461bcd60e51b8152600401610a3a90613b09565b8015612e7e576001600160a01b03831660009081526021602052604090206117b89083613456565b6001600160a01b03831660009081526021602052604090206117b8908361346b565b601981815481106117ef57600080fd5b612eb86133f5565b612ed45760405162461bcd60e51b8152600401610a3a90613b09565b8015612f0f576001600160a01b038085166000908152601f60209081526040808320938716835292905220612f099083613456565b506117b8565b6001600160a01b038085166000908152601f60209081526040808320938716835292905220612f3e908361346b565b5050505050565b60606011805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b612fad6133f5565b612fc95760405162461bcd60e51b8152600401610a3a90613b09565b8015612ffe576001600160a01b038085166000908152601e60209081526040808320938716835292905220612f099083613456565b6001600160a01b038085166000908152601e60209081526040808320938716835292905220612f3e908361346b565b601181815481106117ef57600080fd5b6000805b600954811015610c555760006009828154811061306057613060613b29565b60009182526020808320909101546001600160a01b03908116808452600883526040808520928916855260029092019092529091205490915060ff16156130ab575060019392505050565b50600101613041565b600760205281600052604060002081815481106130d057600080fd5b6000918252602090912001546001600160a01b03169150829050565b600b5460009060609080830361311657604080516000808252602082019092529250925050613264565b836000036131245761012c93505b8360006131318284613ee5565b905061313d8684613e24565b94508015613168578461314f81613ef9565b955085905061315f886001613e38565b03613168578091505b84613174886001613e38565b111561319457505060408051600081526020810190915291506132649050565b60006131a08789613ddb565b90508267ffffffffffffffff8111156131bb576131bb613bbe565b6040519080825280602002602001820160405280156131e4578160200160208202803683370190505b50945060005b8381101561325e57600b6131fe8383613e38565b8154811061320e5761320e613b29565b9060005260206000200160009054906101000a90046001600160a01b031686828151811061323e5761323e613b29565b6001600160a01b03909216602092830291909101909101526001016131ea565b50505050505b9250929050565b6132736133f5565b61328f5760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b039283166000908152601d6020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6001600160a01b038084166000908152601f602090815260408083209386168352929052908120610a0c90836133d3565b6001600160a01b03811660009081526020805260408120819061331c90613449565b905060005b815181101561145057836001600160a01b0316633af9e66983838151811061334b5761334b613b29565b60200260200101516040518263ffffffff1660e01b815260040161337e91906001600160a01b0391909116815260200190565b602060405180830381865afa15801561339b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bf9190613e83565b6133c99084613e38565b9250600101613321565b6001600160a01b03811660009081526001830160205260408120541515610dc5565b6001546000906001600160a01b03163314801561341b5750600254600160a81b900460ff165b8061344457506000546001600160a01b0316331480156134445750600254600160a01b900460ff165b905090565b60606000610dc5836134f9565b6000610dc5836001600160a01b038416613555565b6000610dc5836001600160a01b0384166135a4565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360148111156134b5576134b5613e9c565b83601a8111156134c7576134c7613e9c565b60408051928352602083019190915260009082015260600160405180910390a1826014811115610dc557610dc5613e9c565b60608160000180548060200260200160405190810160405280929190818152602001828054801561354957602002820191906000526020600020905b815481526020019060010190808311613535575b50505050509050919050565b600081815260018301602052604081205461359c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610d9e565b506000610d9e565b6000818152600183016020526040812054801561368d5760006135c8600183613b55565b85549091506000906135dc90600190613b55565b90508181146136415760008660000182815481106135fc576135fc613b29565b906000526020600020015490508087600001848154811061361f5761361f613b29565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061365257613652613b68565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610d9e565b6000915050610d9e565b6001600160a01b03811681146136ac57600080fd5b50565b6000602082840312156136c157600080fd5b8135610dc581613697565b6000806000606084860312156136e157600080fd5b83356136ec81613697565b925060208401356136fc81613697565b9150604084013561370c81613697565b809150509250925092565b8035801515811461372757600080fd5b919050565b6000806040838503121561373f57600080fd5b823561374a81613697565b915061375860208401613717565b90509250929050565b6000806040838503121561377457600080fd5b823561377f81613697565b9150602083013561378f81613697565b809150509250929050565b6000602082840312156137ac57600080fd5b610dc582613717565b60008151808452602080850194506020840160005b838110156137ef5781516001600160a01b0316875295820195908201906001016137ca565b509495945050505050565b602081526000610dc560208301846137b5565b60008083601f84011261381f57600080fd5b50813567ffffffffffffffff81111561383757600080fd5b6020830191508360208260051b850101111561326457600080fd5b6000806000806040858703121561386857600080fd5b843567ffffffffffffffff8082111561388057600080fd5b61388c8883890161380d565b909650945060208701359150808211156138a557600080fd5b506138b28782880161380d565b95989497509550505050565b6000806000606084860312156138d357600080fd5b83356138de81613697565b925060208401356138ee81613697565b91506138fc60408501613717565b90509250925092565b60006020828403121561391757600080fd5b5035919050565b6000806000806080858703121561393457600080fd5b843561393f81613697565b9350602085013561394f81613697565b925061395d60408601613717565b9150606085013561396d81613697565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b818110156139ba5783516001600160e01b03191683529284019291840191600101613994565b50909695505050505050565b6000806000606084860312156139db57600080fd5b83356139e681613697565b925060208401356139f681613697565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156139ba5783516001600160a01b031683529284019291840191600101613a23565b60008060008060808587031215613a5e57600080fd5b8435613a6981613697565b93506020850135613a7981613697565b92506040850135613a8981613697565b9150613a9760608601613717565b905092959194509250565b60008060408385031215613ab557600080fd5b8235613ac081613697565b946020939093013593505050565b60008060408385031215613ae157600080fd5b50508035926020909101359150565b828152604060208201526000610a0c60408301846137b5565b60208082526006908201526510b0b236b4b760d11b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610d9e57610d9e613b3f565b634e487b7160e01b600052603160045260246000fd5b60208082526009908201526810b3bab0b93234b0b760b91b604082015260600190565b600060208284031215613bb357600080fd5b8151610dc581613697565b634e487b7160e01b600052604160045260246000fd5b805167ffffffffffffffff8116811461372757600080fd5b600060608284031215613bfe57600080fd5b6040516060810181811067ffffffffffffffff82111715613c2f57634e487b7160e01b600052604160045260246000fd5b604052613c3b83613bd4565b8152613c4960208401613bd4565b6020820152604083015163ffffffff81168114613c6557600080fd5b60408201529392505050565b6000825160005b81811015613c925760208186018101518583015201613c78565b506000920191825250919050565b600060208284031215613cb257600080fd5b815160ff81168114610dc557600080fd5b8082018281126000831280158216821582161715613ce357613ce3613b3f565b505092915050565b600181815b80851115613d26578160001904821115613d0c57613d0c613b3f565b80851615613d1957918102915b93841c9390800290613cf0565b509250929050565b600082613d3d57506001610d9e565b81613d4a57506000610d9e565b8160018114613d605760028114613d6a57613d86565b6001915050610d9e565b60ff841115613d7b57613d7b613b3f565b50506001821b610d9e565b5060208310610133831016604e8410600b8410161715613da9575081810a610d9e565b613db38383613ceb565b8060001904821115613dc757613dc7613b3f565b029392505050565b6000610dc58383613d2e565b8082028115828204841417610d9e57610d9e613b3f565b6000600160ff1b8201613e0757613e07613b3f565b5060000390565b634e487b7160e01b600052601260045260246000fd5b600082613e3357613e33613e0e565b500490565b80820180821115610d9e57610d9e613b3f565b600060ff821660ff8103613e6157613e61613b3f565b60010192915050565b60ff8181168382160190811115610d9e57610d9e613b3f565b600060208284031215613e9557600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600060ff821680613edb57613edb613b3f565b6000190192915050565b600082613ef457613ef4613e0e565b500690565b600060018201613f0b57613f0b613b3f565b506001019056fea26469706673582212204a79bfe3806f2d15b90a91e9b5b4a01fea29671ba7d13d1a25399899bdc97cba64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103fb5760003560e01c80637515bafa11610215578063be945a6411610125578063d9e0ea6b116100b8578063e875544611610087578063e875544614610986578063ee5b9a2f1461098f578063f851a440146109a2578063f874eb0c146109b5578063fb6243fa146109c857600080fd5b8063d9e0ea6b1461092b578063dce154491461093e578063e6653f3d14610951578063e68065911461096557600080fd5b8063cf6bfd2d116100f4578063cf6bfd2d146108e9578063d01f63f5146108fd578063d219fca714610905578063d251fefc1461091857600080fd5b8063be945a641461089d578063c6c5b0dd146108b0578063c76ae260146108c3578063c91a424f146108d657600080fd5b80638ebf6364116101a8578063ac0b0bb711610177578063ac0b0bb714610841578063b0772d0b14610855578063b09572101461086a578063b103488214610877578063b32538011461088a57600080fd5b80638ebf6364146107cd578063940cd6f1146107e05780639b19251a1461080b578063a5fb48571461082e57600080fd5b8063819605a8116101e4578063819605a81461074d57806387f763031461076057806389f8132e146107745780638e8f294b1461078957600080fd5b80637515bafa1461070c578063783f10961461071f5780637dc0d1d0146107325780637f15e2161461074557600080fd5b80633605b51b1161031057806351a485e4116102a3578063607ef6c111610272578063607ef6c11461068d578063692fd2a9146106a05780636bd02b8a146106b35780636d154ea5146106c6578063731f0c2b146106e957600080fd5b806351a485e41461064157806351c8491d1461065457806352d84d1e146106675780635f5af1aa1461067a57600080fd5b80633c94786f116102df5780633c94786f146105fc5780634a584432146106105780634a76e727146106305780634ada90af1461063857600080fd5b80633605b51b146105b9578063391957d7146105c15780633a72cb5e146105d65780633bcf7ec1146105e957600080fd5b80631c819e4311610393578063267822471161036257806326782247146105425780632ccf47a4146105555780632d70db781461056857806331ff47fa1461057b57806332abcdbe146105a457600080fd5b80631c819e43146104c357806321af4569146104f15780632273f40e1461051c57806324a3d6221461052f57600080fd5b8063109908ce116103cf578063109908ce1461047257806315c3b9b01461048557806316dc15fe1461048d57806318c882a5146104b057600080fd5b80627e3dd21461040057806302c3bcbb1461041d578063088e0fce1461044b5780630a755ec21461045e575b600080fd5b610408600181565b60405190151581526020015b60405180910390f35b61043d61042b3660046136af565b60186020526000908152604090205481565b604051908152602001610414565b6104086104593660046136cc565b6109db565b60025461040890600160a81b900460ff1681565b6104086104803660046136af565b610a14565b600b5461043d565b61040861049b3660046136af565b600d6020526000908152604090205460ff1681565b6104086104be36600461372c565b610c5e565b6104086104d1366004613761565b601d60209081526000928352604080842090915290825290205460ff1681565b601654610504906001600160a01b031681565b6040516001600160a01b039091168152602001610414565b61040861052a366004613761565b610da4565b601354610504906001600160a01b031681565b600254610504906001600160a01b031681565b61043d6105633660046136af565b610dcc565b61040861057636600461379a565b61103e565b6105046105893660046136af565b600e602052600090815260409020546001600160a01b031681565b6105ac611121565b60405161041491906137fa565b6105ac611183565b6105d46105cf3660046136af565b6112eb565b005b61043d6105e43660046136af565b611376565b6104086105f736600461372c565b611457565b60135461040890600160a01b900460ff1681565b61043d61061e3660046136af565b60176020526000908152604090205481565b6105ac61158e565b61043d60055481565b6105d461064f366004613852565b6115ee565b6105d46106623660046138be565b61176d565b610504610675366004613905565b6117df565b61043d6106883660046136af565b611809565b6105d461069b366004613852565b611889565b6104086106ae3660046136af565b6119ff565b6105046106c1366004613905565b611b86565b6104086106d43660046136af565b60156020526000908152604090205460ff1681565b6104086106f73660046136af565b60146020526000908152604090205460ff1681565b61050461071a366004613905565b611b96565b61043d61072d36600461391e565b611ba6565b600354610504906001600160a01b031681565b61043d611e76565b61043d61075b3660046136af565b611fe0565b60135461040890600160b01b900460ff1681565b61077c61230b565b6040516104149190613978565b6107b66107973660046136af565b6008602052600090815260409020805460019091015460ff9091169082565b604080519215158352602083019190915201610414565b6104086107db36600461379a565b612be7565b61043d6107ee366004613761565b601c60209081526000928352604080842090915290825290205481565b6104086108193660046136af565b60106020526000908152604090205460ff1681565b6105d461083c3660046139c6565b612cc1565b60135461040890600160b81b900460ff1681565b61085d612d11565b6040516104149190613a07565b600f546104089060ff1681565b61043d6108853660046136af565b612d71565b610408610898366004613761565b612e10565b6105d46108ab3660046138be565b612e32565b6105046108be366004613905565b612ea0565b6105d46108d1366004613a48565b612eb0565b600054610504906001600160a01b031681565b60025461040890600160a01b900460ff1681565b6105ac612f45565b6105d4610913366004613a48565b612fa5565b610504610926366004613905565b61302d565b6104086109393660046136af565b61303d565b61050461094c366004613aa2565b6130b4565b60135461040890600160a81b900460ff1681565b610978610973366004613ace565b6130ec565b604051610414929190613af0565b61043d60045481565b6105d461099d3660046138be565b61326b565b600154610504906001600160a01b031681565b6104086109c33660046136cc565b6132c9565b61043d6109d63660046136af565b6132fa565b6001600160a01b038084166000908152601e602090815260408083209386168352929052908120610a0c90836133d3565b949350505050565b6000610a1e6133f5565b610a435760405162461bcd60e51b8152600401610a3a90613b09565b60405180910390fd5b6001600160a01b038216610a855760405162461bcd60e51b815260206004820152600960248201526808599b1e5dda19595b60ba1b6044820152606401610a3a565b60005b601954811015610b825760198181548110610aa557610aa5613b29565b6000918252602090912001546001600160a01b0390811690841603610b7a5760198054610ad490600190613b55565b81548110610ae457610ae4613b29565b600091825260209091200154601980546001600160a01b039092169183908110610b1057610b10613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506019805480610b4f57610b4f613b68565b600082815260209020810160001990810180546001600160a01b031916905501905550600192915050565b600101610a88565b5060005b601b54811015610c5557601b8181548110610ba357610ba3613b29565b6000918252602090912001546001600160a01b0390811690841603610c4d57601b8054610bd290600190613b55565b81548110610be257610be2613b29565b600091825260209091200154601b80546001600160a01b039092169183908110610c0e57610c0e613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550601b805480610b4f57610b4f613b68565b600101610b86565b50600092915050565b6001600160a01b03821660009081526008602052604081205460ff16610cb05760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610a3a565b6013546001600160a01b0316331480610ccc5750610ccc6133f5565b610ce85760405162461bcd60e51b8152600401610a3a90613b7e565b610cf06133f5565b80610cfd57506001821515145b610d195760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038316600081815260156020908152604091829020805460ff19168615159081179091558251938452606091840182905260069184019190915265426f72726f7760d01b6080840152908201527f4ab2c577b7459254dd330a38beef1d66ae70ba1ab28db7147d52d3a752a03cdc9060a0015b60405180910390a150805b92915050565b6001600160a01b03821660009081526020805260408120610dc590836133d3565b9392505050565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b938301939093521561101c576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e729190613ba1565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa158015610ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eef9190613bec565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b03861691610f489190613c71565b600060405180830381855afa9150503d8060008114610f83576040519150601f19603f3d011682016040523d82523d6000602084013e610f88565b606091505b5091509150818015610f9b575080516020145b15610fba5780806020019051810190610fb49190613ca0565b60ff1692505b6040850151610fcc9060000b84613cc3565b925060008312610ff257610fe183600a613dcf565b610feb9087613ddb565b9550611013565b610ffb83613df2565b61100690600a613dcf565b6110109087613e24565b95505b50505050611038565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6013546000906001600160a01b031633148061105d575061105d6133f5565b6110795760405162461bcd60e51b8152600401610a3a90613b7e565b6110816133f5565b8061108e57506001821515145b6110aa5760405162461bcd60e51b8152600401610a3a90613b09565b60138054831515600160b81b0260ff60b81b199091161790556040517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0906111159084906040808252600590820152645365697a6560d81b6060820152901515602082015260800190565b60405180910390a15090565b6060600b80548060200260200160405190810160405280929190818152602001828054801561117957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161115b575b5050505050905090565b601b546019546060916000916111999190613e38565b67ffffffffffffffff8111156111b1576111b1613bbe565b6040519080825280602002602001820160405280156111da578160200160208202803683370190505b50905060005b60195460ff821610156112605760198160ff168154811061120357611203613b29565b9060005260206000200160009054906101000a90046001600160a01b0316828260ff168151811061123657611236613b29565b6001600160a01b03909216602092830291909101909101528061125881613e4b565b9150506111e0565b60005b601b5460ff821610156112e357601b8160ff168154811061128657611286613b29565b6000918252602090912001546001600160a01b0316836112a68385613e6a565b60ff16815181106112b9576112b9613b29565b6001600160a01b0390921660209283029190910190910152806112db81613e4b565b915050611263565b509092915050565b6001546001600160a01b031633146113155760405162461bcd60e51b8152600401610a3a90613b09565b601680546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527feda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29910160405180910390a15050565b6001600160a01b0381166000908152602160205260408120819061139990613449565b905060005b815181101561145057836001600160a01b03166317bfdfbc8383815181106113c8576113c8613b29565b60200260200101516040518263ffffffff1660e01b81526004016113fb91906001600160a01b0391909116815260200190565b602060405180830381865afa158015611418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143c9190613e83565b6114469084613e38565b925060010161139e565b5050919050565b6001600160a01b03821660009081526008602052604081205460ff166114a95760405162461bcd60e51b8152602060048201526007602482015266085b585c9ad95d60ca1b6044820152606401610a3a565b6013546001600160a01b03163314806114c557506114c56133f5565b6114e15760405162461bcd60e51b8152600401610a3a90613b7e565b6114e96133f5565b806114f657506001821515145b6115125760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038316600081815260146020908152604091829020805460ff19168615159081179091558251938452606091840182905260049184019190915263135a5b9d60e21b6080840152908201527f4ab2c577b7459254dd330a38beef1d66ae70ba1ab28db7147d52d3a752a03cdc9060a001610d93565b60606019805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b6001546001600160a01b031633148061161157506016546001600160a01b031633145b61162d5760405162461bcd60e51b8152600401610a3a90613b09565b8281811580159061163d57508082145b6116725760405162461bcd60e51b8152602060048201526006602482015265085a5b9c1d5d60d21b6044820152606401610a3a565b60005b828110156117645784848281811061168f5761168f613b29565b90506020020135601860008989858181106116ac576116ac613b29565b90506020020160208101906116c191906136af565b6001600160a01b031681526020810191909152604001600020558686828181106116ed576116ed613b29565b905060200201602081019061170291906136af565b6001600160a01b03167f9e0ad9cee10bdf36b7fbd38910c0bdff0f275ace679b45b922381c2723d676f886868481811061173e5761173e613b29565b9050602002013560405161175491815260200190565b60405180910390a2600101611675565b50505050505050565b6117756133f5565b6117915760405162461bcd60e51b8152600401610a3a90613b09565b80156117be576001600160a01b038316600090815260208052604090206117b89083613456565b50505050565b6001600160a01b038316600090815260208052604090206117b8908361346b565b600981815481106117ef57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006118136133f5565b61182357610d9e60016017613480565b601380546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e910160405180910390a160009392505050565b6001546001600160a01b03163314806118ac57506016546001600160a01b031633145b6118c85760405162461bcd60e51b8152600401610a3a90613b09565b828181158015906118d857508082145b61190d5760405162461bcd60e51b8152602060048201526006602482015265085a5b9c1d5d60d21b6044820152606401610a3a565b60005b828110156117645784848281811061192a5761192a613b29565b905060200201356017600089898581811061194757611947613b29565b905060200201602081019061195c91906136af565b6001600160a01b0316815260208101919091526040016000205586868281811061198857611988613b29565b905060200201602081019061199d91906136af565b6001600160a01b03167f6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f68686848181106119d9576119d9613b29565b905060200201356040516119ef91815260200190565b60405180910390a2600101611910565b6000611a096133f5565b611a255760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b038216611a675760405162461bcd60e51b815260206004820152600960248201526808599b1e5dda19595b60ba1b6044820152606401610a3a565b60005b601b54811015611ae657601b8181548110611a8757611a87613b29565b6000918252602090912001546001600160a01b0390811690841603611ade5760405162461bcd60e51b815260206004820152600d60248201526c08585b1c9958591e5859191959609a1b6044820152606401610a3a565b600101611a6a565b50601b805460018101825560009182527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b0385161790555b601954811015610c555760198181548110611b4f57611b4f613b29565b6000918252602090912001546001600160a01b0390811690841603611b7e5760198054610ad490600190613b55565b600101611b32565b601b81815481106117ef57600080fd5b600b81815481106117ef57600080fd5b6000836001600160a01b0316856001600160a01b0316148015611bc7575082155b15611bd457506000610a0c565b6000196001600160a01b03851615611d4e576001600160a01b038086166000908152601d60209081526040808320938a168352929052205460ff168015611c4757506001600160a01b038086166000908152601f60209081526040808320938a16835292905220611c4590846133d3565b155b15611c5457506000611d4e565b6001600160a01b038086166000908152601c60209081526040808320938a16835292905220548015801590611cb557506001600160a01b038087166000908152601e60209081526040808320938b16835292905220611cb390856133d3565b155b15611d4c5760035460405163fc57d4df60e01b81526001600160a01b038881166004830152600092169063fc57d4df90602401602060405180830381865afa158015611d05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d299190613e83565b9050670de0b6b3a7640000611d3e8284613ddb565b611d489190613e24565b9250505b505b6000611d5987610dcc565b9050600081118015611d8957506001600160a01b03871660009081526020805260409020611d8790856133d3565b155b15611e6c5760035460405163fc57d4df60e01b81526001600160a01b038981166004830152600092169063fc57d4df90602401602060405180830381865afa158015611dd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dfd9190613e83565b90506000670de0b6b3a7640000611e148385613ddb565b611e1e9190613e24565b6001600160a01b038a16600090815260086020526040902060010154909150670de0b6b3a764000090611e519083613ddb565b611e5b9190613e24565b905083811015611e69578093505b50505b5095945050505050565b6000611e806133f5565b611e9c5760405162461bcd60e51b8152600401610a3a90613b09565b738680ceabcb9b56913c519c069add6bc3494b702060005b600954811015611f5b5760098181548110611ed157611ed1613b29565b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b0316637f15e2166040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f529190613e83565b50600101611eb4565b50604051632210724360e11b8152738fba84867ba458e7c6e2c024d2de3d0b5c3ea1c260048201526001600160a01b03821690634420e486906024016020604051808303816000875af1158015611fb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fda9190613e83565b91505090565b6000611fea6133f5565b611ffa57610d9e60016018613480565b6001600160a01b03821660009081526008602052604090205460ff1661202657610d9e60086019613480565b6000826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612066573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208a9190613e83565b111561209c57610d9e6014601a613480565b6001600160a01b0382166000908152600860209081526040808320805460ff1916815560010183905560098054825181850281018501909352808352919290919083018282801561211657602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120f8575b5050835193945083925060009150505b8281101561217057856001600160a01b031684828151811061214a5761214a613b29565b60200260200101516001600160a01b03160361216857809150612170565b600101612126565b5081811061218057612180613eb2565b6009805461219090600190613b55565b815481106121a0576121a0613b29565b600091825260209091200154600980546001600160a01b0390921691839081106121cc576121cc613b29565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600980548061220b5761220b613b68565b6001900381819060005260206000200160006101000a8154906001600160a01b03021916905590556000600e6000876001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b9190613ba1565b6001600160a01b039081168252602080830193909352604091820160002080546001600160a01b031916948216949094179093555191871682527f302feb03efd5741df80efe7f97f5d93d74d46a542a3d312d0faae64fa1f3e0e9910160405180910390a1600095945050505050565b60408051602180825261044082019092526060919060009082602082016104208036833701905050905063692fd2a960e01b8161234784613ec8565b93508360ff168151811061235d5761235d613b29565b6001600160e01b031990921660209283029190910190910152631469217960e21b8161238884613ec8565b93508360ff168151811061239e5761239e613b29565b6001600160e01b03199092166020928302919091019091015263607ef6c160e01b816123c984613ec8565b93508360ff16815181106123df576123df613b29565b6001600160e01b03199092166020928302919091019091015263d219fca760e01b8161240a84613ec8565b93508360ff168151811061242057612420613b29565b6001600160e01b03199092166020928302919091019091015263063b571360e51b8161244b84613ec8565b93508360ff168151811061246157612461613b29565b6001600160e01b0319909216602092830291909101909101526351c8491d60e01b8161248c84613ec8565b93508360ff16815181106124a2576124a2613b29565b6001600160e01b031990921660209283029190910190910152632fa5169960e21b816124cd84613ec8565b93508360ff16815181106124e3576124e3613b29565b6001600160e01b03199092166020928302919091019091015263391957d760e01b8161250e84613ec8565b93508360ff168151811061252457612524613b29565b6001600160e01b031990921660209283029190910190910152632fad78d560e11b8161254f84613ec8565b93508360ff168151811061256557612565613b29565b6001600160e01b031990921660209283029190910190910152633bcf7ec160e01b8161259084613ec8565b93508360ff16815181106125a6576125a6613b29565b6001600160e01b0319909216602092830291909101909101526318c882a560e01b816125d184613ec8565b93508360ff16815181106125e7576125e7613b29565b6001600160e01b0319909216602092830291909101909101526323afd8d960e21b8161261284613ec8565b93508360ff168151811061262857612628613b29565b6001600160e01b0319909216602092830291909101909101526305ae1b6f60e31b8161265384613ec8565b93508360ff168151811061266957612669613b29565b6001600160e01b031990921660209283029190910190910152631032c0b560e31b8161269484613ec8565b93508360ff16815181106126aa576126aa613b29565b6001600160e01b03199092166020928302919091019091015263b0772d0b60e01b816126d584613ec8565b93508360ff16815181106126eb576126eb613b29565b6001600160e01b031990921660209283029190910190910152631955e6df60e11b8161271684613ec8565b93508360ff168151811061272c5761272c613b29565b6001600160e01b03199092166020928302919091019091015263015c3b9b60e41b8161275784613ec8565b93508360ff168151811061276d5761276d613b29565b6001600160e01b03199092166020928302919091019091015263e680659160e01b8161279884613ec8565b93508360ff16815181106127ae576127ae613b29565b6001600160e01b03199092166020928302919091019091015263d01f63f560e01b816127d984613ec8565b93508360ff16815181106127ef576127ef613b29565b6001600160e01b031990921660209283029190910190910152633605b51b60e01b8161281a84613ec8565b93508360ff168151811061283057612830613b29565b6001600160e01b03199092166020928302919091019091015263d9e0ea6b60e01b8161285b84613ec8565b93508360ff168151811061287157612871613b29565b6001600160e01b031990921660209283029190910190910152634a76e72760e01b8161289c84613ec8565b93508360ff16815181106128b2576128b2613b29565b6001600160e01b03199092166020928302919091019091015263084c846760e11b816128dd84613ec8565b93508360ff16815181106128f3576128f3613b29565b6001600160e01b03199092166020928302919091019091015263a5fb485760e01b8161291e84613ec8565b93508360ff168151811061293457612934613b29565b6001600160e01b03199092166020928302919091019091015263ee5b9a2f60e01b8161295f84613ec8565b93508360ff168151811061297557612975613b29565b6001600160e01b03199092166020928302919091019091015263044707e760e11b816129a084613ec8565b93508360ff16815181106129b6576129b6613b29565b6001600160e01b031990921660209283029190910190910152633e1d3ac360e21b816129e184613ec8565b93508360ff16815181106129f7576129f7613b29565b6001600160e01b031990921660209283029190910190910152631139fa0760e11b81612a2284613ec8565b93508360ff1681518110612a3857612a38613b29565b6001600160e01b03199092166020928302919091019091015263b325380160e01b81612a6384613ec8565b93508360ff1681518110612a7957612a79613b29565b6001600160e01b031990921660209283029190910190910152637db121fd60e11b81612aa484613ec8565b93508360ff1681518110612aba57612aba613b29565b6001600160e01b031990921660209283029190910190910152631d3965af60e11b81612ae584613ec8565b93508360ff1681518110612afb57612afb613b29565b6001600160e01b031990921660209283029190910190910152633c1f884b60e11b81612b2684613ec8565b93508360ff1681518110612b3c57612b3c613b29565b6001600160e01b031990921660209283029190910190910152633f8af10b60e11b81612b6784613ec8565b93508360ff1681518110612b7d57612b7d613b29565b6001600160e01b03199092166020928302919091019091015260ff821615610d9e5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610a3a565b6013546000906001600160a01b0316331480612c065750612c066133f5565b612c225760405162461bcd60e51b8152600401610a3a90613b7e565b612c2a6133f5565b80612c3757506001821515145b612c535760405162461bcd60e51b8152600401610a3a90613b09565b60138054831515600160b01b0260ff60b01b199091161790556040517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de0906111159084906040808252600890820152672a3930b739b332b960c11b6060820152901515602082015260800190565b612cc96133f5565b612ce55760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b039283166000908152601c602090815260408083209490951682529290925291902055565b60606009805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215612df3576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e4e573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b6001600160a01b0382166000908152602160205260408120610dc590836133d3565b612e3a6133f5565b612e565760405162461bcd60e51b8152600401610a3a90613b09565b8015612e7e576001600160a01b03831660009081526021602052604090206117b89083613456565b6001600160a01b03831660009081526021602052604090206117b8908361346b565b601981815481106117ef57600080fd5b612eb86133f5565b612ed45760405162461bcd60e51b8152600401610a3a90613b09565b8015612f0f576001600160a01b038085166000908152601f60209081526040808320938716835292905220612f099083613456565b506117b8565b6001600160a01b038085166000908152601f60209081526040808320938716835292905220612f3e908361346b565b5050505050565b60606011805480602002602001604051908101604052809291908181526020018280548015611179576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831161115b575050505050905090565b612fad6133f5565b612fc95760405162461bcd60e51b8152600401610a3a90613b09565b8015612ffe576001600160a01b038085166000908152601e60209081526040808320938716835292905220612f099083613456565b6001600160a01b038085166000908152601e60209081526040808320938716835292905220612f3e908361346b565b601181815481106117ef57600080fd5b6000805b600954811015610c555760006009828154811061306057613060613b29565b60009182526020808320909101546001600160a01b03908116808452600883526040808520928916855260029092019092529091205490915060ff16156130ab575060019392505050565b50600101613041565b600760205281600052604060002081815481106130d057600080fd5b6000918252602090912001546001600160a01b03169150829050565b600b5460009060609080830361311657604080516000808252602082019092529250925050613264565b836000036131245761012c93505b8360006131318284613ee5565b905061313d8684613e24565b94508015613168578461314f81613ef9565b955085905061315f886001613e38565b03613168578091505b84613174886001613e38565b111561319457505060408051600081526020810190915291506132649050565b60006131a08789613ddb565b90508267ffffffffffffffff8111156131bb576131bb613bbe565b6040519080825280602002602001820160405280156131e4578160200160208202803683370190505b50945060005b8381101561325e57600b6131fe8383613e38565b8154811061320e5761320e613b29565b9060005260206000200160009054906101000a90046001600160a01b031686828151811061323e5761323e613b29565b6001600160a01b03909216602092830291909101909101526001016131ea565b50505050505b9250929050565b6132736133f5565b61328f5760405162461bcd60e51b8152600401610a3a90613b09565b6001600160a01b039283166000908152601d6020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6001600160a01b038084166000908152601f602090815260408083209386168352929052908120610a0c90836133d3565b6001600160a01b03811660009081526020805260408120819061331c90613449565b905060005b815181101561145057836001600160a01b0316633af9e66983838151811061334b5761334b613b29565b60200260200101516040518263ffffffff1660e01b815260040161337e91906001600160a01b0391909116815260200190565b602060405180830381865afa15801561339b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bf9190613e83565b6133c99084613e38565b9250600101613321565b6001600160a01b03811660009081526001830160205260408120541515610dc5565b6001546000906001600160a01b03163314801561341b5750600254600160a81b900460ff165b8061344457506000546001600160a01b0316331480156134445750600254600160a01b900460ff165b905090565b60606000610dc5836134f9565b6000610dc5836001600160a01b038416613555565b6000610dc5836001600160a01b0384166135a4565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360148111156134b5576134b5613e9c565b83601a8111156134c7576134c7613e9c565b60408051928352602083019190915260009082015260600160405180910390a1826014811115610dc557610dc5613e9c565b60608160000180548060200260200160405190810160405280929190818152602001828054801561354957602002820191906000526020600020905b815481526020019060010190808311613535575b50505050509050919050565b600081815260018301602052604081205461359c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610d9e565b506000610d9e565b6000818152600183016020526040812054801561368d5760006135c8600183613b55565b85549091506000906135dc90600190613b55565b90508181146136415760008660000182815481106135fc576135fc613b29565b906000526020600020015490508087600001848154811061361f5761361f613b29565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061365257613652613b68565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610d9e565b6000915050610d9e565b6001600160a01b03811681146136ac57600080fd5b50565b6000602082840312156136c157600080fd5b8135610dc581613697565b6000806000606084860312156136e157600080fd5b83356136ec81613697565b925060208401356136fc81613697565b9150604084013561370c81613697565b809150509250925092565b8035801515811461372757600080fd5b919050565b6000806040838503121561373f57600080fd5b823561374a81613697565b915061375860208401613717565b90509250929050565b6000806040838503121561377457600080fd5b823561377f81613697565b9150602083013561378f81613697565b809150509250929050565b6000602082840312156137ac57600080fd5b610dc582613717565b60008151808452602080850194506020840160005b838110156137ef5781516001600160a01b0316875295820195908201906001016137ca565b509495945050505050565b602081526000610dc560208301846137b5565b60008083601f84011261381f57600080fd5b50813567ffffffffffffffff81111561383757600080fd5b6020830191508360208260051b850101111561326457600080fd5b6000806000806040858703121561386857600080fd5b843567ffffffffffffffff8082111561388057600080fd5b61388c8883890161380d565b909650945060208701359150808211156138a557600080fd5b506138b28782880161380d565b95989497509550505050565b6000806000606084860312156138d357600080fd5b83356138de81613697565b925060208401356138ee81613697565b91506138fc60408501613717565b90509250925092565b60006020828403121561391757600080fd5b5035919050565b6000806000806080858703121561393457600080fd5b843561393f81613697565b9350602085013561394f81613697565b925061395d60408601613717565b9150606085013561396d81613697565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b818110156139ba5783516001600160e01b03191683529284019291840191600101613994565b50909695505050505050565b6000806000606084860312156139db57600080fd5b83356139e681613697565b925060208401356139f681613697565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b818110156139ba5783516001600160a01b031683529284019291840191600101613a23565b60008060008060808587031215613a5e57600080fd5b8435613a6981613697565b93506020850135613a7981613697565b92506040850135613a8981613697565b9150613a9760608601613717565b905092959194509250565b60008060408385031215613ab557600080fd5b8235613ac081613697565b946020939093013593505050565b60008060408385031215613ae157600080fd5b50508035926020909101359150565b828152604060208201526000610a0c60408301846137b5565b60208082526006908201526510b0b236b4b760d11b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610d9e57610d9e613b3f565b634e487b7160e01b600052603160045260246000fd5b60208082526009908201526810b3bab0b93234b0b760b91b604082015260600190565b600060208284031215613bb357600080fd5b8151610dc581613697565b634e487b7160e01b600052604160045260246000fd5b805167ffffffffffffffff8116811461372757600080fd5b600060608284031215613bfe57600080fd5b6040516060810181811067ffffffffffffffff82111715613c2f57634e487b7160e01b600052604160045260246000fd5b604052613c3b83613bd4565b8152613c4960208401613bd4565b6020820152604083015163ffffffff81168114613c6557600080fd5b60408201529392505050565b6000825160005b81811015613c925760208186018101518583015201613c78565b506000920191825250919050565b600060208284031215613cb257600080fd5b815160ff81168114610dc557600080fd5b8082018281126000831280158216821582161715613ce357613ce3613b3f565b505092915050565b600181815b80851115613d26578160001904821115613d0c57613d0c613b3f565b80851615613d1957918102915b93841c9390800290613cf0565b509250929050565b600082613d3d57506001610d9e565b81613d4a57506000610d9e565b8160018114613d605760028114613d6a57613d86565b6001915050610d9e565b60ff841115613d7b57613d7b613b3f565b50506001821b610d9e565b5060208310610133831016604e8410600b8410161715613da9575081810a610d9e565b613db38383613ceb565b8060001904821115613dc757613dc7613b3f565b029392505050565b6000610dc58383613d2e565b8082028115828204841417610d9e57610d9e613b3f565b6000600160ff1b8201613e0757613e07613b3f565b5060000390565b634e487b7160e01b600052601260045260246000fd5b600082613e3357613e33613e0e565b500490565b80820180821115610d9e57610d9e613b3f565b600060ff821660ff8103613e6157613e61613b3f565b60010192915050565b60ff8181168382160190811115610d9e57610d9e613b3f565b600060208284031215613e9557600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600060ff821680613edb57613edb613b3f565b6000190192915050565b600082613ef457613ef4613e0e565b500690565b600060018201613f0b57613f0b613b3f565b506001019056fea26469706673582212204a79bfe3806f2d15b90a91e9b5b4a01fea29671ba7d13d1a25399899bdc97cba64736f6c63430008160033", + "devdoc": { + "events": { + "Failure(uint256,uint256,uint256)": { + "details": "`error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary contract-specific code that enables us to report opaque error codes from upgradeable contracts.*" + } + }, + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "_removeFlywheel(address)": { + "details": "Removes a flywheel from the accruing or non-accruing array", + "params": { + "flywheelAddress": "The address of the flywheel to remove from the accruing or non-accruing array" + }, + "returns": { + "_0": "true if the flywheel was found and removed" + } + }, + "_setBorrowCapGuardian(address)": { + "params": { + "newBorrowCapGuardian": "The address of the new Borrow Cap Guardian" + } + }, + "_setMarketBorrowCaps(address[],uint256[])": { + "details": "Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.", + "params": { + "cTokens": "The addresses of the markets (tokens) to change the borrow caps for", + "newBorrowCaps": "The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing." + } + }, + "_setMarketSupplyCaps(address[],uint256[])": { + "details": "Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.", + "params": { + "cTokens": "The addresses of the markets (tokens) to change the supply caps for", + "newSupplyCaps": "The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying." + } + }, + "_setPauseGuardian(address)": { + "params": { + "newPauseGuardian": "The address of the new Pause Guardian" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure. (See enum Error for details)" + } + }, + "_unsupportMarket(address)": { + "details": "Admin function unset isListed and collateralFactorMantissa and unadd support for the market", + "params": { + "cToken": "The address of the market (token) to unlist" + }, + "returns": { + "_0": "uint 0=success, otherwise a failure. (See enum Error for details)" + } + }, + "addNonAccruingFlywheel(address)": { + "details": "Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list", + "params": { + "flywheelAddress": "The address of the flywheel to add to the non-accruing" + } + }, + "effectiveBorrowCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "effectiveSupplyCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "getAllBorrowers()": { + "details": "The automatic getter may be used to access an individual borrower.", + "returns": { + "_0": "The list of borrower account addresses" + } + }, + "getAllMarkets()": { + "details": "The automatic getter may be used to access an individual market.", + "returns": { + "_0": "The list of market addresses" + } + }, + "getWhitelist()": { + "details": "The automatic getter may be used to access an individual whitelist status.", + "returns": { + "_0": "The list of borrower account addresses" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "ActionPaused(string,bool)": { + "notice": "Emitted when an action is paused globally" + }, + "MarketActionPaused(address,string,bool)": { + "notice": "Emitted when an action is paused on a market" + }, + "MarketUnlisted(address)": { + "notice": "Emitted when an admin unsupports a market" + }, + "NewBorrowCap(address,uint256)": { + "notice": "Emitted when borrow cap for a cToken is changed" + }, + "NewBorrowCapGuardian(address,address)": { + "notice": "Emitted when borrow cap guardian is changed" + }, + "NewPauseGuardian(address,address)": { + "notice": "Emitted when pause guardian is changed" + }, + "NewSupplyCap(address,uint256)": { + "notice": "Emitted when supply cap for a cToken is changed" + } + }, + "kind": "user", + "methods": { + "_setBorrowCapGuardian(address)": { + "notice": "Admin function to change the Borrow Cap Guardian" + }, + "_setMarketBorrowCaps(address[],uint256[])": { + "notice": "Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert." + }, + "_setMarketSupplyCaps(address[],uint256[])": { + "notice": "Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert." + }, + "_setPauseGuardian(address)": { + "notice": "Admin function to change the Pause Guardian" + }, + "_unsupportMarket(address)": { + "notice": "Removed a market from the markets mapping and sets it as unlisted" + }, + "accountAssets(address,uint256)": { + "notice": "Per-account mapping of \"assets you are in\", capped by maxAssets" + }, + "addNonAccruingFlywheel(address)": { + "notice": "Returns true if the accruing flyhwheel was found and replaced" + }, + "admin()": { + "notice": "Administrator for this contract" + }, + "adminHasRights()": { + "notice": "Whether or not the admin has admin rights" + }, + "allBorrowers(uint256)": { + "notice": "A list of all borrowers who have entered markets" + }, + "allMarkets(uint256)": { + "notice": "A list of all markets" + }, + "borrowCapGuardian()": { + "notice": "The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market." + }, + "borrowCaps(address)": { + "notice": "Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing." + }, + "cTokensByUnderlying(address)": { + "notice": "All cTokens addresses mapped by their underlying token addresses" + }, + "closeFactorMantissa()": { + "notice": "Multiplier used to calculate the maximum repayAmount when liquidating a borrow" + }, + "effectiveBorrowCaps(address)": { + "notice": "Gets the borrow cap of a cToken in the units of the underlying asset." + }, + "effectiveSupplyCaps(address)": { + "notice": "Gets the supply cap of a cToken in the units of the underlying asset." + }, + "enforceWhitelist()": { + "notice": "Whether or not the supplier whitelist is enforced" + }, + "getAllBorrowers()": { + "notice": "Return all of the borrowers" + }, + "getAllMarkets()": { + "notice": "Return all of the markets" + }, + "getRewardsDistributors()": { + "notice": "Returns an array of all accruing and non-accruing flywheels" + }, + "getWhitelist()": { + "notice": "Return all of the whitelist" + }, + "ionicAdminHasRights()": { + "notice": "Whether or not the Ionic admin has admin rights" + }, + "isComptroller()": { + "notice": "Indicator that this is a Comptroller contract (for inspection)" + }, + "liquidationIncentiveMantissa()": { + "notice": "Multiplier representing the discount on collateral that a liquidator receives" + }, + "markets(address)": { + "notice": "Official mapping of cTokens -> Market metadata" + }, + "nonAccruingRewardsDistributors(uint256)": { + "notice": "RewardsDistributor to list for claiming, but not to notify of flywheel changes." + }, + "oracle()": { + "notice": "Oracle which gives the price of any given asset" + }, + "pauseGuardian()": { + "notice": "The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market." + }, + "pendingAdmin()": { + "notice": "Pending administrator for this contract" + }, + "rewardsDistributors(uint256)": { + "notice": "RewardsDistributor contracts to notify of flywheel changes." + }, + "supplyCaps(address)": { + "notice": "Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying." + }, + "whitelist(address)": { + "notice": "Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)" + }, + "whitelistArray(uint256)": { + "notice": "An array of all whitelisted accounts" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 34026, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 34029, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "admin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 34032, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "pendingAdmin", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 34036, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "ionicAdminHasRights", + "offset": 20, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34040, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "adminHasRights", + "offset": 21, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34073, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "oracle", + "offset": 0, + "slot": "3", + "type": "t_contract(BasePriceOracle)78405" + }, + { + "astId": 34076, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "closeFactorMantissa", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 34079, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "liquidationIncentiveMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 34081, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "maxAssets", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 34088, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "accountAssets", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)" + }, + { + "astId": 34106, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "markets", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_struct(Market)34100_storage)" + }, + { + "astId": 34111, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "allMarkets", + "offset": 0, + "slot": "9", + "type": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + { + "astId": 34116, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowers", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34120, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "allBorrowers", + "offset": 0, + "slot": "11", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34124, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowerIndexes", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34129, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "suppliers", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34135, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "cTokensByUnderlying", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_contract(ICErc20)26708)" + }, + { + "astId": 34138, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "enforceWhitelist", + "offset": 0, + "slot": "15", + "type": "t_bool" + }, + { + "astId": 34143, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "whitelist", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34147, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "whitelistArray", + "offset": 0, + "slot": "17", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34151, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "whitelistIndexes", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34154, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "pauseGuardian", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 34156, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_mintGuardianPaused", + "offset": 20, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34158, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_borrowGuardianPaused", + "offset": 21, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34160, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "transferGuardianPaused", + "offset": 22, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34162, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "seizeGuardianPaused", + "offset": 23, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34166, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "mintGuardianPaused", + "offset": 0, + "slot": "20", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34170, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowGuardianPaused", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34176, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCapGuardian", + "offset": 0, + "slot": "22", + "type": "t_address" + }, + { + "astId": 34181, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCaps", + "offset": 0, + "slot": "23", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34186, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "supplyCaps", + "offset": 0, + "slot": "24", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34190, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "rewardsDistributors", + "offset": 0, + "slot": "25", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34193, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_notEntered", + "offset": 0, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34196, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_notEnteredInitialized", + "offset": 1, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34200, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "nonAccruingRewardsDistributors", + "offset": 0, + "slot": "27", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34207, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCapForCollateral", + "offset": 0, + "slot": "28", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 34214, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowingAgainstCollateralBlacklist", + "offset": 0, + "slot": "29", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))" + }, + { + "astId": 34222, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCapForCollateralWhitelist", + "offset": 0, + "slot": "30", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34230, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowingAgainstCollateralBlacklistWhitelist", + "offset": 0, + "slot": "31", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34236, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "supplyCapWhitelist", + "offset": 0, + "slot": "32", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34242, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCapWhitelist", + "offset": 0, + "slot": "33", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34249, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "borrowCapConfig", + "offset": 0, + "slot": "34", + "type": "t_struct(PrudentiaConfig)18257_storage" + }, + { + "astId": 34253, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "supplyCapConfig", + "offset": 0, + "slot": "35", + "type": "t_struct(PrudentiaConfig)18257_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "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(ICErc20)26708)dyn_storage": { + "base": "t_contract(ICErc20)26708", + "encoding": "dynamic_array", + "label": "contract ICErc20[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(BasePriceOracle)78405": { + "encoding": "inplace", + "label": "contract BasePriceOracle", + "numberOfBytes": "20" + }, + "t_contract(ICErc20)26708": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_int8": { + "encoding": "inplace", + "label": "int8", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + "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_contract(ICErc20)26708)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20)", + "numberOfBytes": "32", + "value": "t_contract(ICErc20)26708" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct EnumerableSet.AddressSet))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_address,t_struct(Market)34100_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct ComptrollerV2Storage.Market)", + "numberOfBytes": "32", + "value": "t_struct(Market)34100_storage" + }, + "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_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Market)34100_storage": { + "encoding": "inplace", + "label": "struct ComptrollerV2Storage.Market", + "members": [ + { + "astId": 34093, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "isListed", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 34095, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "collateralFactorMantissa", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 34099, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "accountMembership", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_bool)" + } + ], + "numberOfBytes": "96" + }, + "t_struct(PrudentiaConfig)18257_storage": { + "encoding": "inplace", + "label": "struct PrudentiaLib.PrudentiaConfig", + "members": [ + { + "astId": 18252, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "controller", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 18254, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "offset", + "offset": 20, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 18256, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "decimalShift", + "offset": 21, + "slot": "0", + "type": "t_int8" + } + ], + "numberOfBytes": "32" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/compound/ComptrollerFirstExtension.sol:ComptrollerFirstExtension", + "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" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/ComptrollerPrudentiaCapsExt.json b/packages/contracts/deployments/superseed/ComptrollerPrudentiaCapsExt.json new file mode 100644 index 0000000000..505620149f --- /dev/null +++ b/packages/contracts/deployments/superseed/ComptrollerPrudentiaCapsExt.json @@ -0,0 +1,1577 @@ +{ + "address": "0xA7B9F9B18587A3854aE41C80a08291eca149bCB7", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "indexed": false, + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "oldConfig", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "indexed": false, + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "newConfig", + "type": "tuple" + } + ], + "name": "NewBorrowCapConfig", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "indexed": false, + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "oldConfig", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "indexed": false, + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "newConfig", + "type": "tuple" + } + ], + "name": "NewSupplyCapConfig", + "type": "event" + }, + { + "inputs": [], + "name": "_borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "_mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "newConfig", + "type": "tuple" + } + ], + "name": "_setBorrowCapConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "newConfig", + "type": "tuple" + } + ], + "name": "_setSupplyCapConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "accountAssets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allBorrowers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "allMarkets", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCapForCollateral", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "borrowCapGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "borrowingAgainstCollateralBlacklist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cTokensByUnderlying", + "outputs": [ + { + "internalType": "contract ICErc20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "closeFactorMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveBorrowCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "effectiveSupplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enforceWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBorrowCapConfig", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSupplyCapConfig", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "uint8", + "name": "offset", + "type": "uint8" + }, + { + "internalType": "int8", + "name": "decimalShift", + "type": "int8" + } + ], + "internalType": "struct PrudentiaLib.PrudentiaConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdmin", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ionicAdminHasRights", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isComptroller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidationIncentiveMantissa", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "bool", + "name": "isListed", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "collateralFactorMantissa", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "mintGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "nonAccruingRewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseGuardian", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "rewardsDistributors", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "seizeGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "suppliers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "supplyCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "transferGuardianPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "whitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "whitelistArray", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x32b1161e7c1eacc5ce057b05275c61d9340305638775d50875df697155f53a46", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xA7B9F9B18587A3854aE41C80a08291eca149bCB7", + "transactionIndex": 1, + "gasUsed": "1128854", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x66bb09ba091d4be6b2697520eef23c58be2721719284d8057b1e93459e2d5951", + "transactionHash": "0x32b1161e7c1eacc5ce057b05275c61d9340305638775d50875df697155f53a46", + "logs": [], + "blockNumber": 4134117, + "cumulativeGasUsed": "1172732", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"indexed\":false,\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"oldConfig\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"indexed\":false,\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"newConfig\",\"type\":\"tuple\"}],\"name\":\"NewBorrowCapConfig\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"indexed\":false,\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"oldConfig\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"indexed\":false,\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"newConfig\",\"type\":\"tuple\"}],\"name\":\"NewSupplyCapConfig\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"newConfig\",\"type\":\"tuple\"}],\"name\":\"_setBorrowCapConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"newConfig\",\"type\":\"tuple\"}],\"name\":\"_setSupplyCapConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"accountAssets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"adminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allBorrowers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allMarkets\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCapForCollateral\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowCapGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"borrowingAgainstCollateralBlacklist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"cTokensByUnderlying\",\"outputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"closeFactorMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveBorrowCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"borrowCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"effectiveSupplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"supplyCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enforceWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBorrowCapConfig\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSupplyCapConfig\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"controller\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"offset\",\"type\":\"uint8\"},{\"internalType\":\"int8\",\"name\":\"decimalShift\",\"type\":\"int8\"}],\"internalType\":\"struct PrudentiaLib.PrudentiaConfig\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdmin\",\"outputs\":[{\"internalType\":\"address payable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ionicAdminHasRights\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isComptroller\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidationIncentiveMantissa\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"markets\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isListed\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactorMantissa\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"mintGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"nonAccruingRewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"rewardsDistributors\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"seizeGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"suppliers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"supplyCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferGuardianPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"whitelistArray\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)\",\"events\":{\"NewBorrowCapConfig((address,uint8,int8),(address,uint8,int8))\":{\"params\":{\"newConfig\":\"The new config.\",\"oldConfig\":\"The old config.\"}},\"NewSupplyCapConfig((address,uint8,int8),(address,uint8,int8))\":{\"params\":{\"newConfig\":\"The new config.\",\"oldConfig\":\"The old config.\"}}},\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"_setBorrowCapConfig((address,uint8,int8))\":{\"details\":\"Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\",\"params\":{\"newConfig\":\"The new config.\"}},\"_setSupplyCapConfig((address,uint8,int8))\":{\"details\":\"Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\",\"params\":{\"newConfig\":\"The new config.\"}},\"effectiveBorrowCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"effectiveSupplyCaps(address)\":{\"params\":{\"cToken\":\"The address of the cToken.\"}},\"getBorrowCapConfig()\":{\"returns\":{\"_0\":\"The config.\"}},\"getSupplyCapConfig()\":{\"returns\":{\"_0\":\"The config.\"}}},\"title\":\"ComptrollerPrudentiaCapsExt\",\"version\":1},\"userdoc\":{\"events\":{\"NewBorrowCapConfig((address,uint8,int8),(address,uint8,int8))\":{\"notice\":\"Emitted when the Adrastia Prudentia borrow cap config is changed.\"},\"NewSupplyCapConfig((address,uint8,int8),(address,uint8,int8))\":{\"notice\":\"Emitted when the Adrastia Prudentia supply cap config is changed.\"}},\"kind\":\"user\",\"methods\":{\"_setBorrowCapConfig((address,uint8,int8))\":{\"notice\":\"Sets the Adrastia Prudentia supply cap config.\"},\"_setSupplyCapConfig((address,uint8,int8))\":{\"notice\":\"Sets the Adrastia Prudentia supply cap config.\"},\"accountAssets(address,uint256)\":{\"notice\":\"Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\"},\"admin()\":{\"notice\":\"Administrator for this contract\"},\"adminHasRights()\":{\"notice\":\"Whether or not the admin has admin rights\"},\"allBorrowers(uint256)\":{\"notice\":\"A list of all borrowers who have entered markets\"},\"allMarkets(uint256)\":{\"notice\":\"A list of all markets\"},\"borrowCapGuardian()\":{\"notice\":\"The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\"},\"borrowCaps(address)\":{\"notice\":\"Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\"},\"cTokensByUnderlying(address)\":{\"notice\":\"All cTokens addresses mapped by their underlying token addresses\"},\"closeFactorMantissa()\":{\"notice\":\"Multiplier used to calculate the maximum repayAmount when liquidating a borrow\"},\"effectiveBorrowCaps(address)\":{\"notice\":\"Gets the borrow cap of a cToken in the units of the underlying asset.\"},\"effectiveSupplyCaps(address)\":{\"notice\":\"Gets the supply cap of a cToken in the units of the underlying asset.\"},\"enforceWhitelist()\":{\"notice\":\"Whether or not the supplier whitelist is enforced\"},\"getBorrowCapConfig()\":{\"notice\":\"Retrieves Adrastia Prudentia borrow cap config from storage.\"},\"getSupplyCapConfig()\":{\"notice\":\"Retrieves Adrastia Prudentia supply cap config from storage.\"},\"ionicAdminHasRights()\":{\"notice\":\"Whether or not the Ionic admin has admin rights\"},\"isComptroller()\":{\"notice\":\"Indicator that this is a Comptroller contract (for inspection)\"},\"liquidationIncentiveMantissa()\":{\"notice\":\"Multiplier representing the discount on collateral that a liquidator receives\"},\"markets(address)\":{\"notice\":\"Official mapping of cTokens -> Market metadata\"},\"nonAccruingRewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor to list for claiming, but not to notify of flywheel changes.\"},\"oracle()\":{\"notice\":\"Oracle which gives the price of any given asset\"},\"pauseGuardian()\":{\"notice\":\"The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market.\"},\"pendingAdmin()\":{\"notice\":\"Pending administrator for this contract\"},\"rewardsDistributors(uint256)\":{\"notice\":\"RewardsDistributor contracts to notify of flywheel changes.\"},\"supplyCaps(address)\":{\"notice\":\"Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\"},\"whitelist(address)\":{\"notice\":\"Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\"},\"whitelistArray(uint256)\":{\"notice\":\"An array of all whitelisted accounts\"}},\"notice\":\"A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/ComptrollerPrudentiaCapsExt.sol\":\"ComptrollerPrudentiaCapsExt\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerPrudentiaCapsExt.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerPrudentiaCapsExtInterface, ComptrollerBase } from \\\"./ComptrollerInterface.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\n/**\\n * @title ComptrollerPrudentiaCapsExt\\n * @author Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)\\n * @notice A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.\\n */\\ncontract ComptrollerPrudentiaCapsExt is DiamondExtension, ComptrollerBase, ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Emitted when the Adrastia Prudentia supply cap config is changed.\\n * @param oldConfig The old config.\\n * @param newConfig The new config.\\n */\\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\\n\\n /**\\n * @notice Emitted when the Adrastia Prudentia borrow cap config is changed.\\n * @param oldConfig The old config.\\n * @param newConfig The new config.\\n */\\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\\n\\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \\\"!admin\\\");\\n\\n PrudentiaLib.PrudentiaConfig memory oldConfig = supplyCapConfig;\\n supplyCapConfig = newConfig;\\n\\n emit NewSupplyCapConfig(oldConfig, newConfig);\\n }\\n\\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \\\"!admin\\\");\\n\\n PrudentiaLib.PrudentiaConfig memory oldConfig = borrowCapConfig;\\n borrowCapConfig = newConfig;\\n\\n emit NewBorrowCapConfig(oldConfig, newConfig);\\n }\\n\\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\\n return borrowCapConfig;\\n }\\n\\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\\n return supplyCapConfig;\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 4;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this._setSupplyCapConfig.selector;\\n functionSelectors[--fnsCount] = this._setBorrowCapConfig.selector;\\n functionSelectors[--fnsCount] = this.getBorrowCapConfig.selector;\\n functionSelectors[--fnsCount] = this.getSupplyCapConfig.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n}\\n\",\"keccak256\":\"0x2a7a6be36f2446bee628c65ebf4a7f2b79cd27279df271e4929a6c4395e13cfd\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040526002805461ffff60a01b191661010160a01b17905534801561002557600080fd5b5061130b806100356000396000f3fe608060405234801561001057600080fd5b506004361061023c5760003560e01c80637515bafa1161013b578063b1034882116100b8578063dbfb09d61161007c578063dbfb09d614610665578063dce1544914610678578063e6653f3d1461068b578063e87554461461069f578063f851a440146106a857600080fd5b8063b103488214610605578063c6c5b0dd14610618578063c91a424f1461062b578063cf6bfd2d1461063e578063d251fefc1461065257600080fd5b80638e8f294b116100ff5780638e8f294b14610552578063940cd6f1146105965780639b19251a146105c1578063ac0b0bb7146105e4578063b0957210146105f857600080fd5b80637515bafa146104a65780637dc0d1d0146104b957806387f76303146104cc57806389f8132e146104e05780638d3df1b2146104f557600080fd5b80632ccf47a4116101c95780634ada90af1161018d5780634ada90af1461043157806352d84d1e1461043a5780636bd02b8a1461044d5780636d154ea514610460578063731f0c2b1461048357600080fd5b80632ccf47a4146103ac5780632d6af6b0146103bf57806331ff47fa146103d45780633c94786f146103fd5780634a5844321461041157600080fd5b806316dc15fe1161021057806316dc15fe1461030a5780631c819e431461032d57806321af45691461035b57806324a3d62214610386578063267822471461039957600080fd5b80627e3dd21461024157806302c3bcbb1461025e5780630a755ec21461028c5780630dd0cefa146102a0575b600080fd5b610249600181565b60405190151581526020015b60405180910390f35b61027e61026c366004610dc0565b60186020526000908152604090205481565b604051908152602001610255565b60025461024990600160a81b900460ff1681565b6102fd604080516060810182526000808252602082018190529181019190915250604080516060810182526022546001600160a01b038116825260ff600160a01b8204166020830152600160a81b900460000b9181019190915290565b6040516102559190610de4565b610249610318366004610dc0565b600d6020526000908152604090205460ff1681565b61024961033b366004610e14565b601d60209081526000928352604080842090915290825290205460ff1681565b60165461036e906001600160a01b031681565b6040516001600160a01b039091168152602001610255565b60135461036e906001600160a01b031681565b60025461036e906001600160a01b031681565b61027e6103ba366004610dc0565b6106bb565b6103d26103cd366004610e4d565b61092d565b005b61036e6103e2366004610dc0565b600e602052600090815260409020546001600160a01b031681565b60135461024990600160a01b900460ff1681565b61027e61041f366004610dc0565b60176020526000908152604090205481565b61027e60055481565b61036e610448366004610e5f565b610a11565b61036e61045b366004610e5f565b610a3b565b61024961046e366004610dc0565b60156020526000908152604090205460ff1681565b610249610491366004610dc0565b60146020526000908152604090205460ff1681565b61036e6104b4366004610e5f565b610a4b565b60035461036e906001600160a01b031681565b60135461024990600160b01b900460ff1681565b6104e8610a5b565b6040516102559190610e78565b6102fd604080516060810182526000808252602082018190529181019190915250604080516060810182526023546001600160a01b038116825260ff600160a01b8204166020830152600160a81b900460000b9181019190915290565b61057f610560366004610dc0565b6008602052600090815260409020805460019091015460ff9091169082565b604080519215158352602083019190915201610255565b61027e6105a4366004610e14565b601c60209081526000928352604080842090915290825290205481565b6102496105cf366004610dc0565b60106020526000908152604090205460ff1681565b60135461024990600160b81b900460ff1681565b600f546102499060ff1681565b61027e610613366004610dc0565b610bde565b61036e610626366004610e5f565b610c7d565b60005461036e906001600160a01b031681565b60025461024990600160a01b900460ff1681565b61036e610660366004610e5f565b610c8d565b6103d2610673366004610e4d565b610c9d565b61036e610686366004610ec6565b610d70565b60135461024990600160a81b900460ff1681565b61027e60045481565b60015461036e906001600160a01b031681565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b938301939093521561090b576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610ef2565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa1580156107ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107de9190610f2c565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b038616916108379190610fb1565b600060405180830381855afa9150503d8060008114610872576040519150601f19603f3d011682016040523d82523d6000602084013e610877565b606091505b509150915081801561088a575080516020145b156108a957808060200190518101906108a39190610fef565b60ff1692505b60408501516108bb9060000b84611022565b9250600083126108e1576108d083600a61112e565b6108da908761113a565b9550610902565b6108ea83611151565b6108f590600a61112e565b6108ff908761116d565b95505b50505050610927565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6001546001600160a01b031633148061095057506016546001600160a01b031633145b61098a5760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064015b60405180910390fd5b60408051606081018252602380546001600160a01b038116835260ff600160a01b8204166020840152600160a81b900460000b928201929092529082906109d1828261119e565b9050507f1fd35ea350fffd290d8aecb52fb5db35cf6ce7a0cbb0dfa33a50607998fa193f8183604051610a05929190611229565b60405180910390a15050565b60098181548110610a2157600080fd5b6000918252602090912001546001600160a01b0316905081565b601b8181548110610a2157600080fd5b600b8181548110610a2157600080fd5b60408051600480825260a082019092526060919060009082602082016080803683370190505090506302d6af6b60e41b81610a95846112a2565b93508360ff1681518110610aab57610aab6112bf565b6001600160e01b031990921660209283029190910190910152636dfd84eb60e11b81610ad6846112a2565b93508360ff1681518110610aec57610aec6112bf565b6001600160e01b0319909216602092830291909101909101526306e8677d60e11b81610b17846112a2565b93508360ff1681518110610b2d57610b2d6112bf565b6001600160e01b03199092166020928302919091019091015263469ef8d960e11b81610b58846112a2565b93508360ff1681518110610b6e57610b6e6112bf565b6001600160e01b03199092166020928302919091019091015260ff821615610bd85760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610981565b92915050565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215610c60576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073d573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b60198181548110610a2157600080fd5b60118181548110610a2157600080fd5b6001546001600160a01b0316331480610cc057506016546001600160a01b031633145b610cf55760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610981565b60408051606081018252602280546001600160a01b038116835260ff600160a01b8204166020840152600160a81b900460000b92820192909252908290610d3c828261119e565b9050507f1f259051c3c5d7c898a1194cce1b9e9a037675b276b1dff78534ff76d6ef12928183604051610a05929190611229565b60076020528160005260406000208181548110610d8c57600080fd5b6000918252602090912001546001600160a01b03169150829050565b6001600160a01b0381168114610dbd57600080fd5b50565b600060208284031215610dd257600080fd5b8135610ddd81610da8565b9392505050565b81516001600160a01b0316815260208083015160ff169082015260408083015160000b9082015260608101610bd8565b60008060408385031215610e2757600080fd5b8235610e3281610da8565b91506020830135610e4281610da8565b809150509250929050565b60006060828403121561092757600080fd5b600060208284031215610e7157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b81811015610eba5783516001600160e01b03191683529284019291840191600101610e94565b50909695505050505050565b60008060408385031215610ed957600080fd5b8235610ee481610da8565b946020939093013593505050565b600060208284031215610f0457600080fd5b8151610ddd81610da8565b805167ffffffffffffffff81168114610f2757600080fd5b919050565b600060608284031215610f3e57600080fd5b6040516060810181811067ffffffffffffffff82111715610f6f57634e487b7160e01b600052604160045260246000fd5b604052610f7b83610f0f565b8152610f8960208401610f0f565b6020820152604083015163ffffffff81168114610fa557600080fd5b60408201529392505050565b6000825160005b81811015610fd25760208186018101518583015201610fb8565b506000920191825250919050565b60ff81168114610dbd57600080fd5b60006020828403121561100157600080fd5b8151610ddd81610fe0565b634e487b7160e01b600052601160045260246000fd5b80820182811260008312801582168215821617156110425761104261100c565b505092915050565b600181815b8085111561108557816000190482111561106b5761106b61100c565b8085161561107857918102915b93841c939080029061104f565b509250929050565b60008261109c57506001610bd8565b816110a957506000610bd8565b81600181146110bf57600281146110c9576110e5565b6001915050610bd8565b60ff8411156110da576110da61100c565b50506001821b610bd8565b5060208310610133831016604e8410600b8410161715611108575081810a610bd8565b611112838361104a565b80600019048211156111265761112661100c565b029392505050565b6000610ddd838361108d565b8082028115828204841417610bd857610bd861100c565b6000600160ff1b82016111665761116661100c565b5060000390565b60008261118a57634e487b7160e01b600052601260045260246000fd5b500490565b8060000b8114610dbd57600080fd5b81356111a981610da8565b81546001600160a01b031981166001600160a01b0392909216918217835560208401356111d581610fe0565b60ff60a01b60a09190911b166001600160a81b0319821683178117845560408501356112008161118f565b8060a81b60ff60a81b168469ffffffffffffffffffff60b01b8516178317178555505050505050565b82516001600160a01b0316815260208084015160ff169082015260408084015160000b9082015260c08101823561125f81610da8565b6001600160a01b03166060830152602083013561127b81610fe0565b60ff16608083015260408301356112918161118f565b8060000b60a0840152509392505050565b600060ff8216806112b5576112b561100c565b6000190192915050565b634e487b7160e01b600052603260045260246000fdfea264697066735822122029e719b27130f883a9ad32f0d6db4a9ebdef11af6d2705b227ed3f794f25253b64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061023c5760003560e01c80637515bafa1161013b578063b1034882116100b8578063dbfb09d61161007c578063dbfb09d614610665578063dce1544914610678578063e6653f3d1461068b578063e87554461461069f578063f851a440146106a857600080fd5b8063b103488214610605578063c6c5b0dd14610618578063c91a424f1461062b578063cf6bfd2d1461063e578063d251fefc1461065257600080fd5b80638e8f294b116100ff5780638e8f294b14610552578063940cd6f1146105965780639b19251a146105c1578063ac0b0bb7146105e4578063b0957210146105f857600080fd5b80637515bafa146104a65780637dc0d1d0146104b957806387f76303146104cc57806389f8132e146104e05780638d3df1b2146104f557600080fd5b80632ccf47a4116101c95780634ada90af1161018d5780634ada90af1461043157806352d84d1e1461043a5780636bd02b8a1461044d5780636d154ea514610460578063731f0c2b1461048357600080fd5b80632ccf47a4146103ac5780632d6af6b0146103bf57806331ff47fa146103d45780633c94786f146103fd5780634a5844321461041157600080fd5b806316dc15fe1161021057806316dc15fe1461030a5780631c819e431461032d57806321af45691461035b57806324a3d62214610386578063267822471461039957600080fd5b80627e3dd21461024157806302c3bcbb1461025e5780630a755ec21461028c5780630dd0cefa146102a0575b600080fd5b610249600181565b60405190151581526020015b60405180910390f35b61027e61026c366004610dc0565b60186020526000908152604090205481565b604051908152602001610255565b60025461024990600160a81b900460ff1681565b6102fd604080516060810182526000808252602082018190529181019190915250604080516060810182526022546001600160a01b038116825260ff600160a01b8204166020830152600160a81b900460000b9181019190915290565b6040516102559190610de4565b610249610318366004610dc0565b600d6020526000908152604090205460ff1681565b61024961033b366004610e14565b601d60209081526000928352604080842090915290825290205460ff1681565b60165461036e906001600160a01b031681565b6040516001600160a01b039091168152602001610255565b60135461036e906001600160a01b031681565b60025461036e906001600160a01b031681565b61027e6103ba366004610dc0565b6106bb565b6103d26103cd366004610e4d565b61092d565b005b61036e6103e2366004610dc0565b600e602052600090815260409020546001600160a01b031681565b60135461024990600160a01b900460ff1681565b61027e61041f366004610dc0565b60176020526000908152604090205481565b61027e60055481565b61036e610448366004610e5f565b610a11565b61036e61045b366004610e5f565b610a3b565b61024961046e366004610dc0565b60156020526000908152604090205460ff1681565b610249610491366004610dc0565b60146020526000908152604090205460ff1681565b61036e6104b4366004610e5f565b610a4b565b60035461036e906001600160a01b031681565b60135461024990600160b01b900460ff1681565b6104e8610a5b565b6040516102559190610e78565b6102fd604080516060810182526000808252602082018190529181019190915250604080516060810182526023546001600160a01b038116825260ff600160a01b8204166020830152600160a81b900460000b9181019190915290565b61057f610560366004610dc0565b6008602052600090815260409020805460019091015460ff9091169082565b604080519215158352602083019190915201610255565b61027e6105a4366004610e14565b601c60209081526000928352604080842090915290825290205481565b6102496105cf366004610dc0565b60106020526000908152604090205460ff1681565b60135461024990600160b81b900460ff1681565b600f546102499060ff1681565b61027e610613366004610dc0565b610bde565b61036e610626366004610e5f565b610c7d565b60005461036e906001600160a01b031681565b60025461024990600160a01b900460ff1681565b61036e610660366004610e5f565b610c8d565b6103d2610673366004610e4d565b610c9d565b61036e610686366004610ec6565b610d70565b60135461024990600160a81b900460ff1681565b61027e60045481565b60015461036e906001600160a01b031681565b604080516060810182526023546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b938301939093521561090b576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610ef2565b8251602084015160405163197c92ab60e31b81526001600160a01b03808516600483015260ff9092166024820152929350169063cbe4955890604401606060405180830381865afa1580156107ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107de9190610f2c565b602090810151604080516004815260248101825292830180516001600160e01b031663313ce56760e01b1790525167ffffffffffffffff909116945060129160009182916001600160a01b038616916108379190610fb1565b600060405180830381855afa9150503d8060008114610872576040519150601f19603f3d011682016040523d82523d6000602084013e610877565b606091505b509150915081801561088a575080516020145b156108a957808060200190518101906108a39190610fef565b60ff1692505b60408501516108bb9060000b84611022565b9250600083126108e1576108d083600a61112e565b6108da908761113a565b9550610902565b6108ea83611151565b6108f590600a61112e565b6108ff908761116d565b95505b50505050610927565b6001600160a01b03831660009081526018602052604090205491505b50919050565b6001546001600160a01b031633148061095057506016546001600160a01b031633145b61098a5760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064015b60405180910390fd5b60408051606081018252602380546001600160a01b038116835260ff600160a01b8204166020840152600160a81b900460000b928201929092529082906109d1828261119e565b9050507f1fd35ea350fffd290d8aecb52fb5db35cf6ce7a0cbb0dfa33a50607998fa193f8183604051610a05929190611229565b60405180910390a15050565b60098181548110610a2157600080fd5b6000918252602090912001546001600160a01b0316905081565b601b8181548110610a2157600080fd5b600b8181548110610a2157600080fd5b60408051600480825260a082019092526060919060009082602082016080803683370190505090506302d6af6b60e41b81610a95846112a2565b93508360ff1681518110610aab57610aab6112bf565b6001600160e01b031990921660209283029190910190910152636dfd84eb60e11b81610ad6846112a2565b93508360ff1681518110610aec57610aec6112bf565b6001600160e01b0319909216602092830291909101909101526306e8677d60e11b81610b17846112a2565b93508360ff1681518110610b2d57610b2d6112bf565b6001600160e01b03199092166020928302919091019091015263469ef8d960e11b81610b58846112a2565b93508360ff1681518110610b6e57610b6e6112bf565b6001600160e01b03199092166020928302919091019091015260ff821615610bd85760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610981565b92915050565b604080516060810182526022546001600160a01b03811680835260ff600160a01b8304166020840152600160a81b909104600090810b9383019390935215610c60576000836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073d573d6000803e3d6000fd5b50506001600160a01b031660009081526017602052604090205490565b60198181548110610a2157600080fd5b60118181548110610a2157600080fd5b6001546001600160a01b0316331480610cc057506016546001600160a01b031633145b610cf55760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b6044820152606401610981565b60408051606081018252602280546001600160a01b038116835260ff600160a01b8204166020840152600160a81b900460000b92820192909252908290610d3c828261119e565b9050507f1f259051c3c5d7c898a1194cce1b9e9a037675b276b1dff78534ff76d6ef12928183604051610a05929190611229565b60076020528160005260406000208181548110610d8c57600080fd5b6000918252602090912001546001600160a01b03169150829050565b6001600160a01b0381168114610dbd57600080fd5b50565b600060208284031215610dd257600080fd5b8135610ddd81610da8565b9392505050565b81516001600160a01b0316815260208083015160ff169082015260408083015160000b9082015260608101610bd8565b60008060408385031215610e2757600080fd5b8235610e3281610da8565b91506020830135610e4281610da8565b809150509250929050565b60006060828403121561092757600080fd5b600060208284031215610e7157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b81811015610eba5783516001600160e01b03191683529284019291840191600101610e94565b50909695505050505050565b60008060408385031215610ed957600080fd5b8235610ee481610da8565b946020939093013593505050565b600060208284031215610f0457600080fd5b8151610ddd81610da8565b805167ffffffffffffffff81168114610f2757600080fd5b919050565b600060608284031215610f3e57600080fd5b6040516060810181811067ffffffffffffffff82111715610f6f57634e487b7160e01b600052604160045260246000fd5b604052610f7b83610f0f565b8152610f8960208401610f0f565b6020820152604083015163ffffffff81168114610fa557600080fd5b60408201529392505050565b6000825160005b81811015610fd25760208186018101518583015201610fb8565b506000920191825250919050565b60ff81168114610dbd57600080fd5b60006020828403121561100157600080fd5b8151610ddd81610fe0565b634e487b7160e01b600052601160045260246000fd5b80820182811260008312801582168215821617156110425761104261100c565b505092915050565b600181815b8085111561108557816000190482111561106b5761106b61100c565b8085161561107857918102915b93841c939080029061104f565b509250929050565b60008261109c57506001610bd8565b816110a957506000610bd8565b81600181146110bf57600281146110c9576110e5565b6001915050610bd8565b60ff8411156110da576110da61100c565b50506001821b610bd8565b5060208310610133831016604e8410600b8410161715611108575081810a610bd8565b611112838361104a565b80600019048211156111265761112661100c565b029392505050565b6000610ddd838361108d565b8082028115828204841417610bd857610bd861100c565b6000600160ff1b82016111665761116661100c565b5060000390565b60008261118a57634e487b7160e01b600052601260045260246000fd5b500490565b8060000b8114610dbd57600080fd5b81356111a981610da8565b81546001600160a01b031981166001600160a01b0392909216918217835560208401356111d581610fe0565b60ff60a01b60a09190911b166001600160a81b0319821683178117845560408501356112008161118f565b8060a81b60ff60a81b168469ffffffffffffffffffff60b01b8516178317178555505050505050565b82516001600160a01b0316815260208084015160ff169082015260408084015160000b9082015260c08101823561125f81610da8565b6001600160a01b03166060830152602083013561127b81610fe0565b60ff16608083015260408301356112918161118f565b8060000b60a0840152509392505050565b600060ff8216806112b5576112b561100c565b6000190192915050565b634e487b7160e01b600052603260045260246000fdfea264697066735822122029e719b27130f883a9ad32f0d6db4a9ebdef11af6d2705b227ed3f794f25253b64736f6c63430008160033", + "devdoc": { + "author": "Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)", + "events": { + "NewBorrowCapConfig((address,uint8,int8),(address,uint8,int8))": { + "params": { + "newConfig": "The new config.", + "oldConfig": "The old config." + } + }, + "NewSupplyCapConfig((address,uint8,int8),(address,uint8,int8))": { + "params": { + "newConfig": "The new config.", + "oldConfig": "The old config." + } + } + }, + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "_setBorrowCapConfig((address,uint8,int8))": { + "details": "Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.", + "params": { + "newConfig": "The new config." + } + }, + "_setSupplyCapConfig((address,uint8,int8))": { + "details": "Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.", + "params": { + "newConfig": "The new config." + } + }, + "effectiveBorrowCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "effectiveSupplyCaps(address)": { + "params": { + "cToken": "The address of the cToken." + } + }, + "getBorrowCapConfig()": { + "returns": { + "_0": "The config." + } + }, + "getSupplyCapConfig()": { + "returns": { + "_0": "The config." + } + } + }, + "title": "ComptrollerPrudentiaCapsExt", + "version": 1 + }, + "userdoc": { + "events": { + "NewBorrowCapConfig((address,uint8,int8),(address,uint8,int8))": { + "notice": "Emitted when the Adrastia Prudentia borrow cap config is changed." + }, + "NewSupplyCapConfig((address,uint8,int8),(address,uint8,int8))": { + "notice": "Emitted when the Adrastia Prudentia supply cap config is changed." + } + }, + "kind": "user", + "methods": { + "_setBorrowCapConfig((address,uint8,int8))": { + "notice": "Sets the Adrastia Prudentia supply cap config." + }, + "_setSupplyCapConfig((address,uint8,int8))": { + "notice": "Sets the Adrastia Prudentia supply cap config." + }, + "accountAssets(address,uint256)": { + "notice": "Per-account mapping of \"assets you are in\", capped by maxAssets" + }, + "admin()": { + "notice": "Administrator for this contract" + }, + "adminHasRights()": { + "notice": "Whether or not the admin has admin rights" + }, + "allBorrowers(uint256)": { + "notice": "A list of all borrowers who have entered markets" + }, + "allMarkets(uint256)": { + "notice": "A list of all markets" + }, + "borrowCapGuardian()": { + "notice": "The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market." + }, + "borrowCaps(address)": { + "notice": "Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing." + }, + "cTokensByUnderlying(address)": { + "notice": "All cTokens addresses mapped by their underlying token addresses" + }, + "closeFactorMantissa()": { + "notice": "Multiplier used to calculate the maximum repayAmount when liquidating a borrow" + }, + "effectiveBorrowCaps(address)": { + "notice": "Gets the borrow cap of a cToken in the units of the underlying asset." + }, + "effectiveSupplyCaps(address)": { + "notice": "Gets the supply cap of a cToken in the units of the underlying asset." + }, + "enforceWhitelist()": { + "notice": "Whether or not the supplier whitelist is enforced" + }, + "getBorrowCapConfig()": { + "notice": "Retrieves Adrastia Prudentia borrow cap config from storage." + }, + "getSupplyCapConfig()": { + "notice": "Retrieves Adrastia Prudentia supply cap config from storage." + }, + "ionicAdminHasRights()": { + "notice": "Whether or not the Ionic admin has admin rights" + }, + "isComptroller()": { + "notice": "Indicator that this is a Comptroller contract (for inspection)" + }, + "liquidationIncentiveMantissa()": { + "notice": "Multiplier representing the discount on collateral that a liquidator receives" + }, + "markets(address)": { + "notice": "Official mapping of cTokens -> Market metadata" + }, + "nonAccruingRewardsDistributors(uint256)": { + "notice": "RewardsDistributor to list for claiming, but not to notify of flywheel changes." + }, + "oracle()": { + "notice": "Oracle which gives the price of any given asset" + }, + "pauseGuardian()": { + "notice": "The Pause Guardian can pause certain actions as a safety mechanism. Actions which allow users to remove their own assets cannot be paused. Liquidation / seizing / transfer can only be paused globally, not by market." + }, + "pendingAdmin()": { + "notice": "Pending administrator for this contract" + }, + "rewardsDistributors(uint256)": { + "notice": "RewardsDistributor contracts to notify of flywheel changes." + }, + "supplyCaps(address)": { + "notice": "Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying." + }, + "whitelist(address)": { + "notice": "Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)" + }, + "whitelistArray(uint256)": { + "notice": "An array of all whitelisted accounts" + } + }, + "notice": "A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 34026, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "ionicAdmin", + "offset": 0, + "slot": "0", + "type": "t_address_payable" + }, + { + "astId": 34029, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "admin", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 34032, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "pendingAdmin", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 34036, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "ionicAdminHasRights", + "offset": 20, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34040, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "adminHasRights", + "offset": 21, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 34073, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "oracle", + "offset": 0, + "slot": "3", + "type": "t_contract(BasePriceOracle)78405" + }, + { + "astId": 34076, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "closeFactorMantissa", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 34079, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "liquidationIncentiveMantissa", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 34081, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "maxAssets", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 34088, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "accountAssets", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)" + }, + { + "astId": 34106, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "markets", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_struct(Market)34100_storage)" + }, + { + "astId": 34111, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "allMarkets", + "offset": 0, + "slot": "9", + "type": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + { + "astId": 34116, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowers", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34120, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "allBorrowers", + "offset": 0, + "slot": "11", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34124, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowerIndexes", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34129, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "suppliers", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34135, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "cTokensByUnderlying", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_contract(ICErc20)26708)" + }, + { + "astId": 34138, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "enforceWhitelist", + "offset": 0, + "slot": "15", + "type": "t_bool" + }, + { + "astId": 34143, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "whitelist", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34147, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "whitelistArray", + "offset": 0, + "slot": "17", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34151, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "whitelistIndexes", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34154, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "pauseGuardian", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 34156, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_mintGuardianPaused", + "offset": 20, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34158, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_borrowGuardianPaused", + "offset": 21, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34160, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "transferGuardianPaused", + "offset": 22, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34162, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "seizeGuardianPaused", + "offset": 23, + "slot": "19", + "type": "t_bool" + }, + { + "astId": 34166, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "mintGuardianPaused", + "offset": 0, + "slot": "20", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34170, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowGuardianPaused", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 34176, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCapGuardian", + "offset": 0, + "slot": "22", + "type": "t_address" + }, + { + "astId": 34181, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCaps", + "offset": 0, + "slot": "23", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34186, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "supplyCaps", + "offset": 0, + "slot": "24", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 34190, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "rewardsDistributors", + "offset": 0, + "slot": "25", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34193, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_notEntered", + "offset": 0, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34196, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_notEnteredInitialized", + "offset": 1, + "slot": "26", + "type": "t_bool" + }, + { + "astId": 34200, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "nonAccruingRewardsDistributors", + "offset": 0, + "slot": "27", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 34207, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCapForCollateral", + "offset": 0, + "slot": "28", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 34214, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowingAgainstCollateralBlacklist", + "offset": 0, + "slot": "29", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))" + }, + { + "astId": 34222, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCapForCollateralWhitelist", + "offset": 0, + "slot": "30", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34230, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowingAgainstCollateralBlacklistWhitelist", + "offset": 0, + "slot": "31", + "type": "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))" + }, + { + "astId": 34236, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "supplyCapWhitelist", + "offset": 0, + "slot": "32", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34242, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCapWhitelist", + "offset": 0, + "slot": "33", + "type": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 34249, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "borrowCapConfig", + "offset": 0, + "slot": "34", + "type": "t_struct(PrudentiaConfig)18257_storage" + }, + { + "astId": 34253, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "supplyCapConfig", + "offset": 0, + "slot": "35", + "type": "t_struct(PrudentiaConfig)18257_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_address_payable": { + "encoding": "inplace", + "label": "address payable", + "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(ICErc20)26708)dyn_storage": { + "base": "t_contract(ICErc20)26708", + "encoding": "dynamic_array", + "label": "contract ICErc20[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(BasePriceOracle)78405": { + "encoding": "inplace", + "label": "contract BasePriceOracle", + "numberOfBytes": "20" + }, + "t_contract(ICErc20)26708": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_int8": { + "encoding": "inplace", + "label": "int8", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_contract(ICErc20)26708)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(ICErc20)26708)dyn_storage" + }, + "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_contract(ICErc20)26708)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract ICErc20)", + "numberOfBytes": "32", + "value": "t_contract(ICErc20)26708" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_struct(AddressSet)7179_storage))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => struct EnumerableSet.AddressSet))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_struct(AddressSet)7179_storage)" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_address,t_struct(Market)34100_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct ComptrollerV2Storage.Market)", + "numberOfBytes": "32", + "value": "t_struct(Market)34100_storage" + }, + "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_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Market)34100_storage": { + "encoding": "inplace", + "label": "struct ComptrollerV2Storage.Market", + "members": [ + { + "astId": 34093, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "isListed", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 34095, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "collateralFactorMantissa", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 34099, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "accountMembership", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_bool)" + } + ], + "numberOfBytes": "96" + }, + "t_struct(PrudentiaConfig)18257_storage": { + "encoding": "inplace", + "label": "struct PrudentiaLib.PrudentiaConfig", + "members": [ + { + "astId": 18252, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "controller", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 18254, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "offset", + "offset": 20, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 18256, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "decimalShift", + "offset": 21, + "slot": "0", + "type": "t_int8" + } + ], + "numberOfBytes": "32" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/compound/ComptrollerPrudentiaCapsExt.sol:ComptrollerPrudentiaCapsExt", + "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" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/DefaultProxyAdmin.json b/packages/contracts/deployments/superseed/DefaultProxyAdmin.json new file mode 100644 index 0000000000..fb4aee2052 --- /dev/null +++ b/packages/contracts/deployments/superseed/DefaultProxyAdmin.json @@ -0,0 +1,259 @@ +{ + "address": "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOwner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeProxyAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + } + ], + "name": "getProxyImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract TransparentUpgradeableProxy", + "name": "proxy", + "type": "address" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x91392212934caf8241fc31b6bfbb7911252e896e159c4f162d3bbeaefd705f30", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "transactionIndex": 1, + "gasUsed": "644163", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000000000000100000080000000000000000000000000000000000000000000000000001000000000000000001000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000400000000", + "blockHash": "0x372e70da6a306833cc1383819d9f519c90f33e2d30b283d95d67fe3b3027fdd1", + "transactionHash": "0x91392212934caf8241fc31b6bfbb7911252e896e159c4f162d3bbeaefd705f30", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 3212535, + "transactionHash": "0x91392212934caf8241fc31b6bfbb7911252e896e159c4f162d3bbeaefd705f30", + "address": "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x372e70da6a306833cc1383819d9f519c90f33e2d30b283d95d67fe3b3027fdd1" + } + ], + "blockNumber": 3212535, + "cumulativeGasUsed": "688053", + "status": 1, + "byzantium": true + }, + "args": [ + "0x1155b614971f16758C92c4890eD338C9e3ede6b7" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialOwner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\",\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"details\":\"Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`.\"},\"getProxyAdmin(address)\":{\"details\":\"Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"getProxyImplementation(address)\":{\"details\":\"Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgrade(address,address)\":{\"details\":\"Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`.\"},\"upgradeAndCall(address,address,bytes)\":{\"details\":\"Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor (address initialOwner) {\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x9b2bbba5bb04f53f277739c1cdff896ba8b3bf591cfc4eab2098c655e8ac251e\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./TransparentUpgradeableProxy.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\n\\n/**\\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\\n */\\ncontract ProxyAdmin is Ownable {\\n\\n constructor (address initialOwner) Ownable(initialOwner) {}\\n\\n /**\\n * @dev Returns the current implementation of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"implementation()\\\")) == 0x5c60da1b\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"5c60da1b\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Returns the current admin of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"admin()\\\")) == 0xf851a440\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"f851a440\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Changes the admin of `proxy` to `newAdmin`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the current admin of `proxy`.\\n */\\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\\n proxy.changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\\n proxy.upgradeTo(implementation);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgradeAndCall(\\n TransparentUpgradeableProxy proxy,\\n address implementation,\\n bytes memory data\\n ) public payable virtual onlyOwner {\\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\\n }\\n}\\n\",\"keccak256\":\"0x754888b9c9ab5525343460b0a4fa2e2f4fca9b6a7e0e7ddea4154e2b1182a45d\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/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\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051610b17380380610b1783398101604081905261002f91610090565b8061003981610040565b50506100c0565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100a257600080fd5b81516001600160a01b03811681146100b957600080fd5b9392505050565b610a48806100cf6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220bd6c09ab03bfaf9ec60a4bf8cd98903cecb891974e17e2d76a3b2002c97eeb8964736f6c634300080a0033", + "devdoc": { + "details": "This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.", + "kind": "dev", + "methods": { + "changeProxyAdmin(address,address)": { + "details": "Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`." + }, + "getProxyAdmin(address)": { + "details": "Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`." + }, + "getProxyImplementation(address)": { + "details": "Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "upgrade(address,address)": { + "details": "Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`." + }, + "upgradeAndCall(address,address,bytes)": { + "details": "Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/FeeDistributor.json b/packages/contracts/deployments/superseed/FeeDistributor.json new file mode 100644 index 0000000000..623c7ce485 --- /dev/null +++ b/packages/contracts/deployments/superseed/FeeDistributor.json @@ -0,0 +1,1013 @@ +{ + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "_callPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "_callPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "pool", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToAdd", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToReplace", + "type": "address" + } + ], + "name": "_registerComptrollerExtension", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cErc20Delegate", + "type": "address" + }, + { + "internalType": "contract DiamondExtension[]", + "name": "extensions", + "type": "address[]" + } + ], + "name": "_setCErc20DelegateExtensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "contract DiamondExtension[]", + "name": "extensions", + "type": "address[]" + } + ], + "name": "_setComptrollerExtensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "int256", + "name": "rate", + "type": "int256" + } + ], + "name": "_setCustomInterestFeeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_defaultInterestFeeRate", + "type": "uint256" + } + ], + "name": "_setDefaultInterestFeeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "becomeImplementationData", + "type": "bytes" + } + ], + "name": "_setLatestCErc20Delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "_setLatestComptrollerImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "_setLatestPluginImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_minBorrowEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maxUtilizationRate", + "type": "uint256" + } + ], + "name": "_setPoolLimits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cDelegator", + "type": "address" + } + ], + "name": "_upgradePluginToLatestImplementation", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "erc20Contract", + "type": "address" + } + ], + "name": "_withdrawAssets", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "authoritiesRegistry", + "outputs": [ + { + "internalType": "contract AuthoritiesRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "pool", + "type": "address" + } + ], + "name": "autoUpgradePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "cErc20DelegateExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "functionSig", + "type": "bytes4" + } + ], + "name": "canCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "comptrollerExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "customInterestFeeRates", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "defaultInterestFeeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "constructorData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "becomeImplData", + "type": "bytes" + } + ], + "name": "deployCErc20", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cErc20Delegate", + "type": "address" + } + ], + "name": "getCErc20DelegateExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + } + ], + "name": "getComptrollerExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_ctoken", + "type": "address" + } + ], + "name": "getMinBorrowEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_defaultInterestFeeRate", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "interestFeeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + } + ], + "name": "latestCErc20Delegate", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + } + ], + "name": "latestComptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + } + ], + "name": "latestPluginImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "marketsCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxUtilizationRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minBorrowEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract AuthoritiesRegistry", + "name": "_ar", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "transactionIndex": 1, + "gasUsed": "816791", + "logsBloom": "0x00000000000000000020000000000000400000000000000000800000000200020000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000100000400000000000001000000040000000000000000000000080000000000000c00000000000000000000000000000010400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc", + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000141ed81ba9f0a70b03ff545711c931e69dab1b7b" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + } + ], + "blockNumber": 3212544, + "cumulativeGasUsed": "860681", + "status": 1, + "byzantium": true + }, + "args": [ + "0x141eD81BA9f0a70B03FF545711C931E69DAb1b7B", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xfe4b84df000000000000000000000000000000000000000000000000016345785d8a0000" + ], + "numDeployments": 2, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "implementation": "0x985a323A1CccA8Cd5fb8935590EE33FbcFE849d0", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/FeeDistributor_Implementation.json b/packages/contracts/deployments/superseed/FeeDistributor_Implementation.json new file mode 100644 index 0000000000..210c307299 --- /dev/null +++ b/packages/contracts/deployments/superseed/FeeDistributor_Implementation.json @@ -0,0 +1,1175 @@ +{ + "address": "0x985a323A1CccA8Cd5fb8935590EE33FbcFE849d0", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "_callPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "targets", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "_callPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "pool", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToAdd", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToReplace", + "type": "address" + } + ], + "name": "_registerComptrollerExtension", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cErc20Delegate", + "type": "address" + }, + { + "internalType": "contract DiamondExtension[]", + "name": "extensions", + "type": "address[]" + } + ], + "name": "_setCErc20DelegateExtensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "contract DiamondExtension[]", + "name": "extensions", + "type": "address[]" + } + ], + "name": "_setComptrollerExtensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "int256", + "name": "rate", + "type": "int256" + } + ], + "name": "_setCustomInterestFeeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_defaultInterestFeeRate", + "type": "uint256" + } + ], + "name": "_setDefaultInterestFeeRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "becomeImplementationData", + "type": "bytes" + } + ], + "name": "_setLatestCErc20Delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "_setLatestComptrollerImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + }, + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "_setLatestPluginImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_minBorrowEth", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maxUtilizationRate", + "type": "uint256" + } + ], + "name": "_setPoolLimits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cDelegator", + "type": "address" + } + ], + "name": "_upgradePluginToLatestImplementation", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "erc20Contract", + "type": "address" + } + ], + "name": "_withdrawAssets", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "authoritiesRegistry", + "outputs": [ + { + "internalType": "contract AuthoritiesRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "pool", + "type": "address" + } + ], + "name": "autoUpgradePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "cErc20DelegateExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes4", + "name": "functionSig", + "type": "bytes4" + } + ], + "name": "canCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "comptrollerExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "customInterestFeeRates", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "defaultInterestFeeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "constructorData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "becomeImplData", + "type": "bytes" + } + ], + "name": "deployCErc20", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "cErc20Delegate", + "type": "address" + } + ], + "name": "getCErc20DelegateExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + } + ], + "name": "getComptrollerExtensions", + "outputs": [ + { + "internalType": "contract DiamondExtension[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_ctoken", + "type": "address" + } + ], + "name": "getMinBorrowEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_defaultInterestFeeRate", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "interestFeeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "delegateType", + "type": "uint8" + } + ], + "name": "latestCErc20Delegate", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + } + ], + "name": "latestComptrollerImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldImplementation", + "type": "address" + } + ], + "name": "latestPluginImplementation", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "marketsCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxUtilizationRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minBorrowEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract AuthoritiesRegistry", + "name": "_ar", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xa29b8a2c913bda19287e5583abcf95529c94f79d69f3f36efe828733e8f83091", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x985a323A1CccA8Cd5fb8935590EE33FbcFE849d0", + "transactionIndex": 1, + "gasUsed": "4721972", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb76f58e777f0676505d8dcde40c715da704faac47b02579e81ae7c3a8a0cd933", + "transactionHash": "0xa29b8a2c913bda19287e5583abcf95529c94f79d69f3f36efe828733e8f83091", + "logs": [], + "blockNumber": 4134101, + "cumulativeGasUsed": "4765850", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 2, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"NewPendingOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_acceptOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"_callPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"_callPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"pool\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToAdd\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToReplace\",\"type\":\"address\"}],\"name\":\"_registerComptrollerExtension\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cErc20Delegate\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension[]\",\"name\":\"extensions\",\"type\":\"address[]\"}],\"name\":\"_setCErc20DelegateExtensions\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension[]\",\"name\":\"extensions\",\"type\":\"address[]\"}],\"name\":\"_setComptrollerExtensions\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"int256\",\"name\":\"rate\",\"type\":\"int256\"}],\"name\":\"_setCustomInterestFeeRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_defaultInterestFeeRate\",\"type\":\"uint256\"}],\"name\":\"_setDefaultInterestFeeRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"delegateType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"becomeImplementationData\",\"type\":\"bytes\"}],\"name\":\"_setLatestCErc20Delegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"_setLatestComptrollerImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"_setLatestPluginImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"_setPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minBorrowEth\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxUtilizationRate\",\"type\":\"uint256\"}],\"name\":\"_setPoolLimits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cDelegator\",\"type\":\"address\"}],\"name\":\"_upgradePluginToLatestImplementation\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"erc20Contract\",\"type\":\"address\"}],\"name\":\"_withdrawAssets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"authoritiesRegistry\",\"outputs\":[{\"internalType\":\"contract AuthoritiesRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"pool\",\"type\":\"address\"}],\"name\":\"autoUpgradePool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"cErc20DelegateExtensions\",\"outputs\":[{\"internalType\":\"contract DiamondExtension\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"functionSig\",\"type\":\"bytes4\"}],\"name\":\"canCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"comptrollerExtensions\",\"outputs\":[{\"internalType\":\"contract DiamondExtension\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"customInterestFeeRates\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"defaultInterestFeeRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"delegateType\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"constructorData\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"becomeImplData\",\"type\":\"bytes\"}],\"name\":\"deployCErc20\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"cErc20Delegate\",\"type\":\"address\"}],\"name\":\"getCErc20DelegateExtensions\",\"outputs\":[{\"internalType\":\"contract DiamondExtension[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getComptrollerExtensions\",\"outputs\":[{\"internalType\":\"contract DiamondExtension[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_ctoken\",\"type\":\"address\"}],\"name\":\"getMinBorrowEth\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_defaultInterestFeeRate\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"interestFeeRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"delegateType\",\"type\":\"uint8\"}],\"name\":\"latestCErc20Delegate\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"}],\"name\":\"latestComptrollerImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"}],\"name\":\"latestPluginImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketsCounter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxUtilizationRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minBorrowEth\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract AuthoritiesRegistry\",\"name\":\"_ar\",\"type\":\"address\"}],\"name\":\"reinitialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_acceptOwner()\":{\"details\":\"Owner function for pending owner to accept role and update owner\"},\"_callPool(address[],bytes)\":{\"details\":\"Sends data to a contract.\",\"params\":{\"data\":\"The data to be sent to each of `targets`.\",\"targets\":\"The contracts to which `data` will be sent.\"}},\"_callPool(address[],bytes[])\":{\"details\":\"Sends data to a contract.\",\"params\":{\"data\":\"The data to be sent to each of `targets`.\",\"targets\":\"The contracts to which `data` will be sent.\"}},\"_setCustomInterestFeeRate(address,int256)\":{\"details\":\"Sets the proportion of Ionic pool interest taken as a protocol fee.\",\"params\":{\"comptroller\":\"The Unitroller (Comptroller proxy) address.\",\"rate\":\"The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"}},\"_setDefaultInterestFeeRate(uint256)\":{\"details\":\"Sets the default proportion of Ionic pool interest taken as a protocol fee.\",\"params\":{\"_defaultInterestFeeRate\":\"The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"}},\"_setLatestCErc20Delegate(uint8,address,bytes)\":{\"details\":\"Sets the latest `CErc20Delegate` upgrade implementation address and data.\",\"params\":{\"becomeImplementationData\":\"Data passed to the new implementation via `becomeImplementation` after upgrade.\",\"delegateType\":\"The old `CErc20Delegate` implementation address to upgrade from.\",\"newImplementation\":\"Latest `CErc20Delegate` implementation address.\"}},\"_setLatestComptrollerImplementation(address,address)\":{\"details\":\"Sets the latest `Comptroller` upgrade implementation address.\",\"params\":{\"newImplementation\":\"Latest `Comptroller` implementation address.\",\"oldImplementation\":\"The old `Comptroller` implementation address to upgrade from.\"}},\"_setLatestPluginImplementation(address,address)\":{\"details\":\"Sets the latest plugin upgrade implementation address.\",\"params\":{\"newImplementation\":\"Latest plugin implementation address.\",\"oldImplementation\":\"The old plugin implementation address to upgrade from.\"}},\"_setPendingOwner(address)\":{\"details\":\"Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\",\"params\":{\"newPendingOwner\":\"New pending owner.\"}},\"_setPoolLimits(uint256,uint256)\":{\"details\":\"Sets the proportion of Ionic pool interest taken as a protocol fee.\",\"params\":{\"_maxUtilizationRate\":\"Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\",\"_minBorrowEth\":\"Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\"}},\"_upgradePluginToLatestImplementation(address)\":{\"details\":\"Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\",\"params\":{\"cDelegator\":\"the proxy address\"},\"returns\":{\"_0\":\"if the plugin was upgraded or not\"}},\"_withdrawAssets(address)\":{\"details\":\"Withdraws accrued fees on interest.\",\"params\":{\"erc20Contract\":\"The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\"}},\"deployCErc20(uint8,bytes,bytes)\":{\"details\":\"Deploys a CToken for an underlying ERC20\",\"params\":{\"constructorData\":\"Encoded construction data for `CToken initialize()`\"}},\"initialize(uint256)\":{\"details\":\"Initializer that sets initial values of state variables.\",\"params\":{\"_defaultInterestFeeRate\":\"The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"}},\"latestCErc20Delegate(uint8)\":{\"details\":\"Latest CErc20Delegate implementation for each existing implementation.\"},\"latestComptrollerImplementation(address)\":{\"details\":\"Latest Comptroller implementation for each existing implementation.\"},\"latestPluginImplementation(address)\":{\"details\":\"Latest Plugin implementation for each existing implementation.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"FeeDistributor\",\"version\":1},\"userdoc\":{\"events\":{\"NewOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is accepted, which means owner is updated\"},\"NewPendingOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is changed\"}},\"kind\":\"user\",\"methods\":{\"_acceptOwner()\":{\"notice\":\"Accepts transfer of owner rights. msg.sender must be pendingOwner\"},\"_setPendingOwner(address)\":{\"notice\":\"Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\"},\"customInterestFeeRates(address)\":{\"notice\":\"Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"},\"defaultInterestFeeRate()\":{\"notice\":\"The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"},\"interestFeeRate()\":{\"notice\":\"Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\"},\"pendingOwner()\":{\"notice\":\"Pending owner of this contract\"}},\"notice\":\"FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/FeeDistributor.sol\":\"FeeDistributor\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/FeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport { CErc20Delegator } from \\\"./compound/CErc20Delegator.sol\\\";\\nimport { CErc20PluginDelegate } from \\\"./compound/CErc20PluginDelegate.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { DiamondExtension, DiamondBase } from \\\"./ionic/DiamondExtension.sol\\\";\\nimport { AuthoritiesRegistry } from \\\"./ionic/AuthoritiesRegistry.sol\\\";\\n\\ncontract FeeDistributorStorage {\\n struct CDelegateUpgradeData {\\n address implementation;\\n bytes becomeImplementationData;\\n }\\n\\n /**\\n * @notice Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n * @dev A value of 0 means unset whereas a negative value means 0.\\n */\\n mapping(address => int256) public customInterestFeeRates;\\n\\n /**\\n * @dev Latest Comptroller implementation for each existing implementation.\\n */\\n mapping(address => address) internal _latestComptrollerImplementation;\\n\\n /**\\n * @dev Latest CErc20Delegate implementation for each existing implementation.\\n */\\n mapping(uint8 => CDelegateUpgradeData) internal _latestCErc20Delegate;\\n\\n /**\\n * @dev Latest Plugin implementation for each existing implementation.\\n */\\n mapping(address => address) internal _latestPluginImplementation;\\n\\n mapping(address => DiamondExtension[]) public comptrollerExtensions;\\n\\n mapping(address => DiamondExtension[]) public cErc20DelegateExtensions;\\n\\n AuthoritiesRegistry public authoritiesRegistry;\\n\\n /**\\n * @dev used as salt for the creation of new markets\\n */\\n uint256 public marketsCounter;\\n\\n /**\\n * @dev Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\\n */\\n uint256 public minBorrowEth;\\n\\n /**\\n * @dev Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\\n * No longer used as of `Rari-Capital/compound-protocol` version `fuse-v1.1.0`.\\n */\\n uint256 public maxUtilizationRate;\\n\\n /**\\n * @notice The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n */\\n uint256 public defaultInterestFeeRate;\\n}\\n\\n/**\\n * @title FeeDistributor\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\\n */\\ncontract FeeDistributor is SafeOwnableUpgradeable, FeeDistributorStorage {\\n using AddressUpgradeable for address;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n /**\\n * @dev Initializer that sets initial values of state variables.\\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n */\\n function initialize(uint256 _defaultInterestFeeRate) public initializer {\\n require(_defaultInterestFeeRate <= 1e18, \\\"Interest fee rate cannot be more than 100%.\\\");\\n __SafeOwnable_init(msg.sender);\\n defaultInterestFeeRate = _defaultInterestFeeRate;\\n maxUtilizationRate = type(uint256).max;\\n }\\n\\n function reinitialize(AuthoritiesRegistry _ar) public onlyOwnerOrAdmin {\\n authoritiesRegistry = _ar;\\n }\\n\\n /**\\n * @dev Sets the default proportion of Ionic pool interest taken as a protocol fee.\\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n */\\n function _setDefaultInterestFeeRate(uint256 _defaultInterestFeeRate) external onlyOwner {\\n require(_defaultInterestFeeRate <= 1e18, \\\"Interest fee rate cannot be more than 100%.\\\");\\n defaultInterestFeeRate = _defaultInterestFeeRate;\\n }\\n\\n /**\\n * @dev Withdraws accrued fees on interest.\\n * @param erc20Contract The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\\n */\\n function _withdrawAssets(address erc20Contract) external {\\n if (erc20Contract == address(0)) {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No balance available to withdraw.\\\");\\n (bool success, ) = owner().call{ value: balance }(\\\"\\\");\\n require(success, \\\"Failed to transfer ETH balance to msg.sender.\\\");\\n } else {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 balance = token.balanceOf(address(this));\\n require(balance > 0, \\\"No token balance available to withdraw.\\\");\\n token.safeTransfer(owner(), balance);\\n }\\n }\\n\\n /**\\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\\n * @param _minBorrowEth Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\\n * @param _maxUtilizationRate Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\\n */\\n function _setPoolLimits(uint256 _minBorrowEth, uint256 _maxUtilizationRate) external onlyOwner {\\n minBorrowEth = _minBorrowEth;\\n maxUtilizationRate = _maxUtilizationRate;\\n }\\n\\n function getMinBorrowEth(ICErc20 _ctoken) public view returns (uint256) {\\n (, , uint256 borrowBalance, ) = _ctoken.getAccountSnapshot(_msgSender());\\n if (borrowBalance == 0) return minBorrowEth;\\n IonicComptroller comptroller = IonicComptroller(address(_ctoken.comptroller()));\\n BasePriceOracle oracle = comptroller.oracle();\\n uint256 underlyingPriceEth = oracle.price(ICErc20(address(_ctoken)).underlying());\\n uint256 underlyingDecimals = _ctoken.decimals();\\n uint256 borrowBalanceEth = (underlyingPriceEth * borrowBalance) / 10**underlyingDecimals;\\n if (borrowBalanceEth > minBorrowEth) {\\n return 0;\\n }\\n return minBorrowEth - borrowBalanceEth;\\n }\\n\\n /**\\n * @dev Receives native fees.\\n */\\n receive() external payable {}\\n\\n /**\\n * @dev Sends data to a contract.\\n * @param targets The contracts to which `data` will be sent.\\n * @param data The data to be sent to each of `targets`.\\n */\\n function _callPool(address[] calldata targets, bytes[] calldata data) external onlyOwner {\\n require(targets.length > 0 && targets.length == data.length, \\\"Array lengths must be equal and greater than 0.\\\");\\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data[i]);\\n }\\n\\n /**\\n * @dev Sends data to a contract.\\n * @param targets The contracts to which `data` will be sent.\\n * @param data The data to be sent to each of `targets`.\\n */\\n function _callPool(address[] calldata targets, bytes calldata data) external onlyOwner {\\n require(targets.length > 0, \\\"No target addresses specified.\\\");\\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data);\\n }\\n\\n /**\\n * @dev Deploys a CToken for an underlying ERC20\\n * @param constructorData Encoded construction data for `CToken initialize()`\\n */\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address) {\\n // Make sure comptroller == msg.sender\\n (address underlying, address comptroller) = abi.decode(constructorData[0:64], (address, address));\\n require(comptroller == msg.sender, \\\"Comptroller is not sender.\\\");\\n\\n // Deploy CErc20Delegator using msg.sender, underlying, and block.number as a salt\\n bytes32 salt = keccak256(abi.encodePacked(msg.sender, underlying, ++marketsCounter));\\n\\n bytes memory cErc20DelegatorCreationCode = abi.encodePacked(type(CErc20Delegator).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(0, salt, cErc20DelegatorCreationCode);\\n\\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\\n DiamondExtension delegateAsExtension = DiamondExtension(data.implementation);\\n // register the first extension\\n DiamondBase(proxy)._registerExtension(delegateAsExtension, DiamondExtension(address(0)));\\n // derive and configure the other extensions\\n DiamondExtension[] memory ctokenExts = cErc20DelegateExtensions[address(delegateAsExtension)];\\n for (uint256 i = 0; i < ctokenExts.length; i++) {\\n if (ctokenExts[i] == delegateAsExtension) continue;\\n DiamondBase(proxy)._registerExtension(ctokenExts[i], DiamondExtension(address(0)));\\n }\\n CErc20PluginDelegate(address(proxy))._becomeImplementation(becomeImplData);\\n\\n return proxy;\\n }\\n\\n /**\\n * @dev Latest Comptroller implementation for each existing implementation.\\n */\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address) {\\n return\\n _latestComptrollerImplementation[oldImplementation] != address(0)\\n ? _latestComptrollerImplementation[oldImplementation]\\n : oldImplementation;\\n }\\n\\n /**\\n * @dev Sets the latest `Comptroller` upgrade implementation address.\\n * @param oldImplementation The old `Comptroller` implementation address to upgrade from.\\n * @param newImplementation Latest `Comptroller` implementation address.\\n */\\n function _setLatestComptrollerImplementation(address oldImplementation, address newImplementation)\\n external\\n onlyOwner\\n {\\n _latestComptrollerImplementation[oldImplementation] = newImplementation;\\n }\\n\\n /**\\n * @dev Latest CErc20Delegate implementation for each existing implementation.\\n */\\n function latestCErc20Delegate(uint8 delegateType) external view returns (address, bytes memory) {\\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\\n bytes memory emptyBytes;\\n return\\n data.implementation != address(0)\\n ? (data.implementation, data.becomeImplementationData)\\n : (address(0), emptyBytes);\\n }\\n\\n /**\\n * @dev Sets the latest `CErc20Delegate` upgrade implementation address and data.\\n * @param delegateType The old `CErc20Delegate` implementation address to upgrade from.\\n * @param newImplementation Latest `CErc20Delegate` implementation address.\\n * @param becomeImplementationData Data passed to the new implementation via `becomeImplementation` after upgrade.\\n */\\n function _setLatestCErc20Delegate(\\n uint8 delegateType,\\n address newImplementation,\\n bytes calldata becomeImplementationData\\n ) external onlyOwner {\\n _latestCErc20Delegate[delegateType] = CDelegateUpgradeData(newImplementation, becomeImplementationData);\\n }\\n\\n /**\\n * @dev Latest Plugin implementation for each existing implementation.\\n */\\n function latestPluginImplementation(address oldImplementation) external view returns (address) {\\n return\\n _latestPluginImplementation[oldImplementation] != address(0)\\n ? _latestPluginImplementation[oldImplementation]\\n : oldImplementation;\\n }\\n\\n /**\\n * @dev Sets the latest plugin upgrade implementation address.\\n * @param oldImplementation The old plugin implementation address to upgrade from.\\n * @param newImplementation Latest plugin implementation address.\\n */\\n function _setLatestPluginImplementation(address oldImplementation, address newImplementation) external onlyOwner {\\n _latestPluginImplementation[oldImplementation] = newImplementation;\\n }\\n\\n /**\\n * @dev Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\\n * @param cDelegator the proxy address\\n * @return if the plugin was upgraded or not\\n */\\n function _upgradePluginToLatestImplementation(address cDelegator) external onlyOwner returns (bool) {\\n CErc20PluginDelegate market = CErc20PluginDelegate(cDelegator);\\n\\n address oldPluginAddress = address(market.plugin());\\n market._updatePlugin(_latestPluginImplementation[oldPluginAddress]);\\n address newPluginAddress = address(market.plugin());\\n\\n return newPluginAddress != oldPluginAddress;\\n }\\n\\n /**\\n * @notice Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n */\\n function interestFeeRate() external view returns (uint256) {\\n (bool success, bytes memory data) = msg.sender.staticcall(abi.encodeWithSignature(\\\"comptroller()\\\"));\\n\\n if (success && data.length == 32) {\\n address comptroller = abi.decode(data, (address));\\n int256 customRate = customInterestFeeRates[comptroller];\\n if (customRate > 0) return uint256(customRate);\\n if (customRate < 0) return 0;\\n }\\n\\n return defaultInterestFeeRate;\\n }\\n\\n /**\\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\\n * @param comptroller The Unitroller (Comptroller proxy) address.\\n * @param rate The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\\n */\\n function _setCustomInterestFeeRate(address comptroller, int256 rate) external onlyOwner {\\n require(rate <= 1e18, \\\"Interest fee rate cannot be more than 100%.\\\");\\n customInterestFeeRates[comptroller] = rate;\\n }\\n\\n function getComptrollerExtensions(address comptroller) external view returns (DiamondExtension[] memory) {\\n return comptrollerExtensions[comptroller];\\n }\\n\\n function _setComptrollerExtensions(address comptroller, DiamondExtension[] calldata extensions) external onlyOwner {\\n comptrollerExtensions[comptroller] = extensions;\\n }\\n\\n function _registerComptrollerExtension(\\n address payable pool,\\n DiamondExtension extensionToAdd,\\n DiamondExtension extensionToReplace\\n ) external onlyOwner {\\n DiamondBase(pool)._registerExtension(extensionToAdd, extensionToReplace);\\n }\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (DiamondExtension[] memory) {\\n return cErc20DelegateExtensions[cErc20Delegate];\\n }\\n\\n function _setCErc20DelegateExtensions(address cErc20Delegate, DiamondExtension[] calldata extensions)\\n external\\n onlyOwner\\n {\\n cErc20DelegateExtensions[cErc20Delegate] = extensions;\\n }\\n\\n function autoUpgradePool(IonicComptroller pool) external onlyOwner {\\n ICErc20[] memory markets = pool.getAllMarkets();\\n\\n // auto upgrade the pool\\n pool._upgrade();\\n\\n for (uint8 i = 0; i < markets.length; i++) {\\n // upgrade the market\\n markets[i]._upgrade();\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n return authoritiesRegistry.canCall(pool, user, target, functionSig);\\n }\\n}\\n\",\"keccak256\":\"0x5785c93499f16642fef38aa423cacf7c9d286f6ec0e4873d75165279fdab72c7\",\"license\":\"UNLICENSED\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicUniV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV3FlashCallback.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV3Pool.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\nimport { IUniswapV3Quoter } from \\\"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"./ionic/IFlashLoanReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicUniV3Liquidator\\n * @author Veliko Minkov (https://github.com/vminkov)\\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\\n */\\ncontract IonicUniV3Liquidator is\\n OwnableUpgradeable,\\n ILiquidator,\\n IUniswapV3FlashCallback,\\n IExpressRelayFeeReceiver,\\n IFlashLoanReceiver\\n{\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n\\n address public W_NATIVE_ADDRESS;\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n IUniswapV3Quoter public quoter;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(address _wtoken, address _quoter) external initializer {\\n __Ownable_init();\\n W_NATIVE_ADDRESS = _wtoken;\\n quoter = IUniswapV3Quoter(_quoter);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n underlying.approve(address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateToTokensWithFlashLoan(\\n LiquidateToTokensWithFlashSwapVars calldata vars\\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\\n flashSwapPool.flash(\\n address(this),\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n\\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(\\n LiquidateToTokensWithFlashSwapVars memory vars,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\\n uint256 flashSwapReturnAmount = _flashSwapAmount;\\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\\n flashSwapReturnAmount += fee0;\\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\\n flashSwapReturnAmount += fee1;\\n } else {\\n revert(\\\"wrong pool or _flashSwapToken\\\");\\n }\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay the borrowed asset directly\\n collateralRequired = flashSwapReturnAmount;\\n\\n // Repay flashloan\\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\\n } else {\\n // TODO swap within the same pool and then repay the FL to the pool\\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\\n\\n {\\n collateralRequired = quoter.quoteExactOutputSingle(\\n zeroForOne ? pool.token0() : pool.token1(),\\n zeroForOne ? pool.token1() : pool.token0(),\\n pool.fee(),\\n _flashSwapAmount,\\n 0 // sqrtPriceLimitX96\\n );\\n }\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n\\n // Repay flashloan\\n pool.swap(\\n address(pool),\\n zeroForOne,\\n int256(collateralRequired),\\n 0, // sqrtPriceLimitX96\\n \\\"\\\"\\n );\\n }\\n\\n return address(underlyingCollateral);\\n } else {\\n revert(\\\"the redemptions strategy did not swap to the flash swapped pool assets\\\");\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n bool[] calldata whitelisted\\n ) external onlyOwner {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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\":\"0x03ad15c5d4e63fbc8d4df554ce3172f4e0611843a326a8e29ec39870e5ddbd72\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20Delegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CToken.sol\\\";\\n\\n/**\\n * @title Compound's CErc20Delegate Contract\\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\\n * @author Compound\\n */\\ncontract CErc20Delegate is CErc20 {\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 3;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n */\\n function _becomeImplementation(bytes memory) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 1;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20Delegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x64f72d66ae0f29c8400dd922cf2d5f453c1de98a72d7041fa8b39ec2aba25402\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20Delegator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ComptrollerInterface.sol\\\";\\nimport \\\"./InterestRateModel.sol\\\";\\nimport \\\"../ionic/DiamondExtension.sol\\\";\\nimport { CErc20DelegatorBase, CDelegateInterface } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\n\\n/**\\n * @title Compound's CErc20Delegator Contract\\n * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation\\n * @author Compound\\n */\\ncontract CErc20Delegator is CErc20DelegatorBase, DiamondBase {\\n /**\\n * @notice Emitted when implementation is changed\\n */\\n event NewImplementation(address oldImplementation, address newImplementation);\\n\\n /**\\n * @notice Initialize the new money market\\n * @param underlying_ The address of the underlying asset\\n * @param comptroller_ The address of the Comptroller\\n * @param ionicAdmin_ The FeeDistributor contract address.\\n * @param interestRateModel_ The address of the interest rate model\\n * @param name_ ERC-20 name of this token\\n * @param symbol_ ERC-20 symbol of this token\\n */\\n constructor(\\n address underlying_,\\n IonicComptroller comptroller_,\\n address payable ionicAdmin_,\\n InterestRateModel interestRateModel_,\\n string memory name_,\\n string memory symbol_,\\n uint256 reserveFactorMantissa_,\\n uint256 adminFeeMantissa_\\n ) {\\n require(msg.sender == ionicAdmin_, \\\"!admin\\\");\\n uint8 decimals_ = EIP20Interface(underlying_).decimals();\\n {\\n ionicAdmin = ionicAdmin_;\\n\\n // Set initial exchange rate\\n initialExchangeRateMantissa = 0.2e18;\\n\\n // Set the comptroller\\n comptroller = comptroller_;\\n\\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\\n accrualBlockNumber = block.number;\\n borrowIndex = 1e18;\\n\\n // Set the interest rate model (depends on block number / borrow index)\\n require(interestRateModel_.isInterestRateModel(), \\\"!notIrm\\\");\\n interestRateModel = interestRateModel_;\\n emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);\\n\\n name = name_;\\n symbol = symbol_;\\n decimals = decimals_;\\n\\n // Set reserve factor\\n // Check newReserveFactor \\u2264 maxReserveFactor\\n require(\\n reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\\n \\\"!rf:set\\\"\\n );\\n reserveFactorMantissa = reserveFactorMantissa_;\\n emit NewReserveFactor(0, reserveFactorMantissa_);\\n\\n // Set admin fee\\n // Sanitize adminFeeMantissa_\\n if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;\\n // Get latest Ionic fee\\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\\n require(\\n reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\\n \\\"!adminFee:set\\\"\\n );\\n adminFeeMantissa = adminFeeMantissa_;\\n emit NewAdminFee(0, adminFeeMantissa_);\\n ionicFeeMantissa = newIonicFeeMantissa;\\n emit NewIonicFee(0, newIonicFeeMantissa);\\n\\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\\n _notEntered = true;\\n }\\n\\n // Set underlying and sanity check it\\n underlying = underlying_;\\n EIP20Interface(underlying).totalSupply();\\n }\\n\\n function implementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"delegateType()\\\"))));\\n }\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {\\n // Check admin rights\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Set implementation\\n _setImplementationInternal(implementation_, becomeImplementationData);\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self or admin\\\");\\n\\n (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature(\\\"delegateType()\\\"));\\n require(success, \\\"no delegate type\\\");\\n\\n uint8 currentDelegateType = abi.decode(data, (uint8));\\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)\\n .latestCErc20Delegate(currentDelegateType);\\n\\n address currentDelegate = implementation();\\n if (currentDelegate != latestCErc20Delegate) {\\n _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);\\n } else {\\n // only update the extensions without reinitializing with becomeImplementationData\\n _updateExtensions(currentDelegate);\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(msg.sender == address(ionicAdmin), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n\\n /**\\n * @dev Internal function to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {\\n address delegateBefore = implementation();\\n _updateExtensions(implementation_);\\n\\n _functionCall(\\n address(this),\\n abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),\\n \\\"!become impl\\\"\\n );\\n\\n emit NewImplementation(delegateBefore, implementation_);\\n }\\n\\n function _updateExtensions(address newDelegate) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n}\\n\",\"keccak256\":\"0x3844a222bf350de1ae1e28d7d9dad173c8f8299077ea97c5328cc414cb812d16\",\"license\":\"UNLICENSED\"},\"contracts/compound/CErc20PluginDelegate.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CErc20Delegate.sol\\\";\\nimport \\\"./EIP20Interface.sol\\\";\\nimport \\\"./IERC4626.sol\\\";\\nimport \\\"../external/uniswap/IUniswapV2Pair.sol\\\";\\n\\n/**\\n * @title Rari's CErc20Plugin's Contract\\n * @notice CToken which outsources token logic to a plugin\\n * @author Joey Santoro\\n *\\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\\n */\\ncontract CErc20PluginDelegate is CErc20Delegate {\\n event NewPluginImplementation(address oldImpl, address newImpl);\\n\\n /**\\n * @notice Plugin address\\n */\\n IERC4626 public plugin;\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 2;\\n\\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\\n\\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\\n functionSelectors[i] = superFunctionSelectors[i];\\n }\\n\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /**\\n * @notice Delegate interface to become the implementation\\n * @param data The encoded arguments for becoming\\n */\\n function _becomeImplementation(bytes memory data) public virtual override {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"only self and admins can call _becomeImplementation\\\");\\n\\n address _plugin = abi.decode(data, (address));\\n\\n if (_plugin == address(0) && address(plugin) != address(0)) {\\n // if no new plugin address is given, use the latest implementation\\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\\n }\\n\\n if (_plugin != address(0) && _plugin != address(plugin)) {\\n _updatePlugin(_plugin);\\n }\\n }\\n\\n /**\\n * @notice Update the plugin implementation to a whitelisted implementation\\n * @param _plugin The address of the plugin implementation to use\\n */\\n function _updatePlugin(address _plugin) public {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"only self and admins can call _updatePlugin\\\");\\n\\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\\n\\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\\n }\\n\\n plugin = IERC4626(_plugin);\\n\\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\\n\\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\\n if (amount != 0) {\\n deposit(amount);\\n }\\n\\n emit NewPluginImplementation(oldImplementation, _plugin);\\n }\\n\\n /*** CToken Overrides ***/\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of the plugin in terms of the underlying\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view override returns (uint256) {\\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\\n }\\n\\n /**\\n * @notice Transfer the underlying to the cToken and trigger a deposit\\n * @param from Address to transfer funds from\\n * @param amount Amount of underlying to transfer\\n * @return The actual amount that is transferred\\n */\\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\\n // Perform the EIP-20 transfer in\\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \\\"send\\\");\\n\\n deposit(amount);\\n return amount;\\n }\\n\\n function deposit(uint256 amount) internal {\\n plugin.deposit(amount, address(this));\\n }\\n\\n /**\\n * @notice Transfer the underlying from plugin to destination\\n * @param to Address to transfer funds to\\n * @param amount Amount of underlying to transfer\\n */\\n function doTransferOut(address to, uint256 amount) internal override {\\n plugin.withdraw(amount, to, address(this));\\n }\\n\\n function delegateType() public pure virtual override returns (uint8) {\\n return 2;\\n }\\n\\n function contractType() external pure virtual override returns (string memory) {\\n return \\\"CErc20PluginDelegate\\\";\\n }\\n}\\n\",\"keccak256\":\"0x095cc54097ac06a9b6232222c5197df72c4cc4a0f2c69261bf22ebba2dfead3f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CToken.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { CTokenSecondExtensionBase, ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { TokenErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { CTokenOracleProtected } from \\\"./CTokenOracleProtected.sol\\\";\\n\\nimport { DiamondExtension, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { PoolLens } from \\\"../PoolLens.sol\\\";\\nimport { IonicUniV3Liquidator } from \\\"../IonicUniV3Liquidator.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\n/**\\n * @title Compound's CErc20 Contract\\n * @notice CTokens which wrap an EIP-20 underlying\\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\\n * @author Compound\\n */\\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\\n modifier isAuthorized() {\\n require(\\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\\n \\\"not authorized\\\"\\n );\\n _;\\n }\\n\\n modifier isMinHFThresholdExceeded(address borrower) {\\n PoolLens lens = PoolLens(ap.getAddress(\\\"PoolLens\\\"));\\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\\\"IonicUniV3Liquidator\\\")));\\n\\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\\n require(msg.sender == address(liquidator), \\\"Health factor not low enough for non-permissioned liquidations\\\");\\n _;\\n } else {\\n _;\\n }\\n }\\n\\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\\n uint8 fnsCount = 13;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.mint.selector;\\n functionSelectors[--fnsCount] = this.redeem.selector;\\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\\n functionSelectors[--fnsCount] = this.borrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\\n functionSelectors[--fnsCount] = this.getCash.selector;\\n functionSelectors[--fnsCount] = this.seize.selector;\\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*** User Interface ***/\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = mintInternal(mintAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemInternal(redeemTokens);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to redeem\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return redeemUnderlyingInternal(redeemAmount);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n return borrowInternal(borrowAmount);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowInternal(repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\\n return err;\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\\n return err;\\n }\\n\\n /**\\n * @notice Get cash balance of this cToken in the underlying asset\\n * @return The quantity of underlying asset owned by this contract\\n */\\n function getCash() external view override returns (uint256) {\\n return getCashInternal();\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Will fail unless called by another cToken during the process of liquidation.\\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\\n }\\n\\n function selfTransferOut(address to, uint256 amount) external override {\\n require(msg.sender == address(this), \\\"!self\\\");\\n doTransferOut(to, amount);\\n }\\n\\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\\n require(msg.sender == address(this), \\\"!self\\\");\\n return doTransferIn(from, amount);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\\n }\\n\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalIonicFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\\n totalIonicFees = totalIonicFeesNew;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(address(ionicAdmin), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accrues interest and reduces admin fees by transferring to admin\\n * @param withdrawAmount Amount of fees to withdraw\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\\n }\\n\\n // Fail gracefully if protocol has insufficient underlying cash\\n if (getCashInternal() < withdrawAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\\n }\\n\\n if (withdrawAmount > totalAdminFees) {\\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n totalAdminFees = totalAdminFees - withdrawAmount;\\n\\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Safe Token ***/\\n\\n /**\\n * @notice Gets balance of this contract in terms of the underlying\\n * @dev This excludes the value of the current message, if any\\n * @return The quantity of underlying tokens owned by this contract\\n */\\n function getCashInternal() internal view virtual returns (uint256) {\\n return EIP20Interface(underlying).balanceOf(address(this));\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\\n * This will revert due to insufficient balance or insufficient allowance.\\n * This function returns the actual amount received,\\n * which may be less than `amount` if there is a fee attached to the transfer.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\\n \\\"TOKEN_TRANSFER_IN_FAILED\\\"\\n );\\n\\n // Calculate the amount that was *actually* transferred\\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\\n require(balanceAfter >= balanceBefore, \\\"TOKEN_TRANSFER_IN_OVERFLOW\\\");\\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\\n }\\n\\n /**\\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\\n * it is >= amount, this should not revert in normal conditions.\\n *\\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\\n */\\n function doTransferOut(address to, uint256 amount) internal virtual {\\n _callOptionalReturn(\\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\\n \\\"TOKEN_TRANSFER_OUT_FAILED\\\"\\n );\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\\n }\\n\\n /**\\n * @notice Sender supplies assets into the market and receives cTokens in exchange\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\\n return mintFresh(msg.sender, mintAmount);\\n }\\n\\n struct MintLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 mintTokens;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n uint256 actualMintAmount;\\n }\\n\\n /**\\n * @notice User supplies assets into the market and receives cTokens in exchange\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param minter The address of the account which is supplying the assets\\n * @param mintAmount The amount of the underlying asset to supply\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\\n */\\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\\n /* Fail if mint not allowed */\\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\\n }\\n\\n MintLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n // Check max supply\\n // unused function\\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\\n } */\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call `doTransferIn` for the minter and the mintAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\\n * side-effects occurred. The function returns the amount actually transferred,\\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\\n * of cash.\\n */\\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\\n\\n /*\\n * We get the current exchange rate and calculate the number of cTokens to be minted:\\n * mintTokens = actualMintAmount / exchangeRate\\n */\\n\\n // mintTokens is rounded down here - correct\\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\\n vars.actualMintAmount,\\n Exp({ mantissa: vars.exchangeRateMantissa })\\n );\\n require(vars.mathErr == MathError.NO_ERROR, \\\"MINT_EXCHANGE_CALCULATION_FAILED\\\");\\n require(vars.mintTokens > 0, \\\"MINT_ZERO_CTOKENS_REJECTED\\\");\\n\\n /*\\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\\n * totalSupplyNew = totalSupply + mintTokens\\n * accountTokensNew = accountTokens[minter] + mintTokens\\n */\\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\\n\\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[minter] = vars.accountTokensNew;\\n\\n /* We emit a Mint event, and a Transfer event */\\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\\n emit Transfer(address(this), minter, vars.mintTokens);\\n\\n /* We call the defense hook */\\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\\n\\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for the underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemTokens The number of cTokens to redeem into underlying\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, redeemTokens, 0);\\n }\\n\\n /**\\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\\n return redeemFresh(msg.sender, 0, redeemAmount);\\n }\\n\\n struct RedeemLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 exchangeRateMantissa;\\n uint256 redeemTokens;\\n uint256 redeemAmount;\\n uint256 totalSupplyNew;\\n uint256 accountTokensNew;\\n }\\n\\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\\n res = (x * 1e18) / y;\\n if (x % y != 0) res += 1;\\n }\\n\\n /**\\n * @notice User redeems cTokens in exchange for the underlying asset\\n * @dev Assumes interest has already been accrued up to the current block\\n * @param redeemer The address of the account which is redeeming the tokens\\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function redeemFresh(\\n address redeemer,\\n uint256 redeemTokensIn,\\n uint256 redeemAmountIn\\n ) internal returns (uint256) {\\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \\\"!redeem tokens or amount\\\");\\n\\n RedeemLocalVars memory vars;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n if (redeemTokensIn > 0) {\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\\n\\n /*\\n * We calculate the exchange rate and the amount of underlying to be redeemed:\\n * redeemTokens = redeemTokensIn\\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\\n */\\n vars.redeemTokens = redeemTokensIn;\\n\\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n redeemTokensIn\\n );\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n } else {\\n if (redeemAmountIn == type(uint256).max) {\\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\\n }\\n\\n // don't allow dust tokens/assets to be left after\\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\\n\\n /*\\n * We get the current exchange rate and calculate the amount to be redeemed:\\n * redeemTokens = redeemAmountIn / exchangeRate\\n * redeemAmount = redeemAmountIn\\n */\\n\\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\\n\\n // don't allow dust tokens/assets to be left after\\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\\n\\n vars.redeemAmount = redeemAmountIn;\\n }\\n\\n /* Fail if redeem not allowed */\\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\\n }\\n\\n /*\\n * We calculate the new total supply and redeemer balance, checking for underflow:\\n * totalSupplyNew = totalSupply - redeemTokens\\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\\n */\\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /* Fail gracefully if protocol has insufficient cash */\\n if (getCashInternal() < vars.redeemAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write previously calculated values into storage */\\n totalSupply = vars.totalSupplyNew;\\n accountTokens[redeemer] = vars.accountTokensNew;\\n\\n /*\\n * We invoke doTransferOut for the redeemer and the redeemAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken has redeemAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(redeemer, vars.redeemAmount);\\n\\n /* We emit a Transfer event, and a Redeem event */\\n emit Transfer(redeemer, address(this), vars.redeemTokens);\\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n /* We call the defense hook */\\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender borrows assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\\n asCTokenExtension().accrueInterest();\\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\\n return borrowFresh(msg.sender, borrowAmount);\\n }\\n\\n struct BorrowLocalVars {\\n MathError mathErr;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n }\\n\\n /**\\n * @notice Users borrow assets from the protocol to their own address\\n * @param borrowAmount The amount of the underlying asset to borrow\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\\n /* Fail if borrow not allowed */\\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\\n }\\n\\n /* Fail gracefully if protocol has insufficient underlying cash */\\n uint256 cashPrior = getCashInternal();\\n\\n if (cashPrior < borrowAmount) {\\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\\n }\\n\\n BorrowLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on overflow:\\n * accountBorrowsNew = accountBorrows + borrowAmount\\n * totalBorrowsNew = totalBorrows + borrowAmount\\n */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(\\n Error.MATH_ERROR,\\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n uint256(vars.mathErr)\\n );\\n }\\n\\n // Check min borrow for this user for this asset\\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return\\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /*\\n * We invoke doTransferOut for the borrower and the borrowAmount.\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken borrowAmount less of cash.\\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n */\\n doTransferOut(borrower, borrowAmount);\\n\\n /* We emit a Borrow event */\\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sender repays their own borrow\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\\n }\\n\\n /**\\n * @notice Sender repays a borrow belonging to borrower\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount The amount to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\\n internal\\n nonReentrant(false)\\n returns (uint256, uint256)\\n {\\n asCTokenExtension().accrueInterest();\\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\\n }\\n\\n struct RepayBorrowLocalVars {\\n Error err;\\n MathError mathErr;\\n uint256 repayAmount;\\n uint256 borrowerIndex;\\n uint256 accountBorrows;\\n uint256 accountBorrowsNew;\\n uint256 totalBorrowsNew;\\n uint256 actualRepayAmount;\\n }\\n\\n /**\\n * @notice Borrows are repaid by another user (possibly the borrower).\\n * @param payer the account paying off the borrow\\n * @param borrower the account with the debt being payed off\\n * @param repayAmount the amount of undelrying tokens being returned\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function repayBorrowFresh(\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) internal returns (uint256, uint256) {\\n /* Fail if repayBorrow not allowed */\\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\\n }\\n\\n RepayBorrowLocalVars memory vars;\\n\\n /* We remember the original borrowerIndex for verification purposes */\\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\\n\\n /* We fetch the amount the borrower owes, with accumulated interest */\\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\\n\\n /* If repayAmount == -1, repayAmount = accountBorrows */\\n if (repayAmount == type(uint256).max) {\\n vars.repayAmount = vars.accountBorrows;\\n } else {\\n vars.repayAmount = repayAmount;\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /*\\n * We call doTransferIn for the payer and the repayAmount\\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\\n * On success, the cToken holds an additional repayAmount of cash.\\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\\n * it returns the amount actually transferred, in case of a fee.\\n */\\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\\n\\n /*\\n * We calculate the new borrower and total borrow balances, failing on underflow:\\n * accountBorrowsNew = accountBorrows - actualRepayAmount\\n * totalBorrowsNew = totalBorrows - actualRepayAmount\\n */\\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\\\");\\n\\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\\n require(vars.mathErr == MathError.NO_ERROR, \\\"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\\\");\\n\\n /* We write the previously calculated values into storage */\\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\\n accountBorrows[borrower].interestIndex = borrowIndex;\\n totalBorrows = vars.totalBorrowsNew;\\n\\n /* We emit a RepayBorrow event */\\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\\n\\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\\n }\\n\\n /**\\n * @notice The sender liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowInternal(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal nonReentrant(false) returns (uint256, uint256) {\\n asCTokenExtension().accrueInterest();\\n ICErc20(cTokenCollateral).accrueInterest();\\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\\n }\\n\\n /**\\n * @notice The liquidator liquidates the borrowers collateral.\\n * The collateral seized is transferred to the liquidator.\\n * @param borrower The borrower of this cToken to be liquidated\\n * @param liquidator The address repaying the borrow and seizing collateral\\n * @param cTokenCollateral The market in which to seize collateral from the borrower\\n * @param repayAmount The amount of the underlying borrowed asset to repay\\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\\n */\\n function liquidateBorrowFresh(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) internal returns (uint256, uint256) {\\n /* Fail if liquidate not allowed */\\n uint256 allowed = comptroller.liquidateBorrowAllowed(\\n address(this),\\n cTokenCollateral,\\n liquidator,\\n borrower,\\n repayAmount\\n );\\n if (allowed != 0) {\\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\\n }\\n\\n /* Verify market's block number equals current block number */\\n if (accrualBlockNumber != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Verify cTokenCollateral market's block number equals current block number */\\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\\n }\\n\\n /* Fail if repayAmount = 0 */\\n if (repayAmount == 0) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\\n }\\n\\n /* Fail if repayAmount = -1 */\\n if (repayAmount == type(uint256).max) {\\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\\n }\\n\\n /* Fail if repayBorrow fails */\\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We calculate the number of collateral tokens that will be seized */\\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\\n address(this),\\n cTokenCollateral,\\n actualRepayAmount\\n );\\n require(amountSeizeError == uint256(Error.NO_ERROR), \\\"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\\\");\\n\\n /* Revert if borrower collateral token balance < seizeTokens */\\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \\\"LIQUIDATE_SEIZE_TOO_MUCH\\\");\\n\\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\\n uint256 seizeError;\\n if (cTokenCollateral == address(this)) {\\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\\n } else {\\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\\n }\\n\\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\\n require(seizeError == uint256(Error.NO_ERROR), \\\"!seize\\\");\\n\\n /* We emit a LiquidateBorrow event */\\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\\n\\n return (uint256(Error.NO_ERROR), actualRepayAmount);\\n }\\n\\n struct SeizeInternalLocalVars {\\n MathError mathErr;\\n uint256 borrowerTokensNew;\\n uint256 liquidatorTokensNew;\\n uint256 liquidatorSeizeTokens;\\n uint256 protocolSeizeTokens;\\n uint256 protocolSeizeAmount;\\n uint256 exchangeRateMantissa;\\n uint256 totalReservesNew;\\n uint256 totalIonicFeeNew;\\n uint256 totalSupplyNew;\\n uint256 feeSeizeTokens;\\n uint256 feeSeizeAmount;\\n }\\n\\n /**\\n * @notice Transfers collateral tokens (this market) to the liquidator.\\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\\n * @param liquidator The account receiving seized collateral\\n * @param borrower The account having collateral seized\\n * @param seizeTokens The number of cTokens to seize\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function seizeInternal(\\n address seizerToken,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) internal returns (uint256) {\\n /* Fail if seize not allowed */\\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n if (allowed != 0) {\\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\\n }\\n\\n /* Fail if borrower = liquidator */\\n if (borrower == liquidator) {\\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\\n }\\n\\n SeizeInternalLocalVars memory vars;\\n\\n /*\\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\\n */\\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n\\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\\n\\n vars.protocolSeizeAmount = mul_ScalarTruncate(\\n Exp({ mantissa: vars.exchangeRateMantissa }),\\n vars.protocolSeizeTokens\\n );\\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\\n\\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\\n\\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\\n if (vars.mathErr != MathError.NO_ERROR) {\\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\\n }\\n\\n /////////////////////////\\n // EFFECTS & INTERACTIONS\\n // (No safe failures beyond this point)\\n\\n /* We write the previously calculated values into storage */\\n totalReserves = vars.totalReservesNew;\\n totalSupply = vars.totalSupplyNew;\\n totalIonicFees = vars.totalIonicFeeNew;\\n\\n accountTokens[borrower] = vars.borrowerTokensNew;\\n accountTokens[liquidator] = vars.liquidatorTokensNew;\\n\\n /* Emit a Transfer event */\\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\\n\\n /* We call the defense hook */\\n // unused function\\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function asCTokenExtension() internal view returns (ICErc20) {\\n return ICErc20(address(this));\\n }\\n\\n /*** Reentrancy Guard ***/\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n */\\n modifier nonReentrant(bool localOnly) {\\n _beforeNonReentrant(localOnly);\\n _;\\n _afterNonReentrant(localOnly);\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\\n */\\n function _beforeNonReentrant(bool localOnly) private {\\n require(_notEntered, \\\"re-entered\\\");\\n if (!localOnly) comptroller._beforeNonReentrant();\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\\n * Saves space because function modifier code is \\\"inlined\\\" into every function with the modifier).\\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\\n */\\n function _afterNonReentrant(bool localOnly) private {\\n _notEntered = true; // get a gas-refund post-Istanbul\\n if (!localOnly) comptroller._afterNonReentrant();\\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 * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\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 * @param data The call data (encoded using abi.encode or one of its variants).\\n * @param errorMessage The revert string to return on failure.\\n */\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n}\\n\",\"keccak256\":\"0x308ca2ce334910ef9ece96a98a4a899eaa802051051dc89bf6f8732242000b7b\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenOracleProtected.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.22;\\n\\nimport { CErc20Storage } from \\\"./CTokenInterfaces.sol\\\";\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\n\\ncontract CTokenOracleProtected is CErc20Storage {\\n error InteractionNotAllowed();\\n error CallerIsNotEOA();\\n\\n modifier onlyOracleApproved() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyOracleApprovedAllowEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n if (tx.origin == msg.sender) {\\n _;\\n return;\\n }\\n\\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\\n _;\\n }\\n\\n modifier onlyNotBlacklistedEOA() {\\n address oracleAddress = ap.getAddress(\\\"HYPERNATIVE_ORACLE\\\");\\n\\n if (oracleAddress == address(0)) {\\n _;\\n return;\\n }\\n\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n if (msg.sender != tx.origin) {\\n revert CallerIsNotEOA();\\n }\\n oracle.validateBlacklistedAccountInteraction(msg.sender);\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x42b99e4fbc5880f64a6f1d8b02f3b061b0d3a6c312f47d83e88593eefaf71304\",\"license\":\"Unlicense\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/EIP20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ERC 20 Token Standard Interface\\n * https://eips.ethereum.org/EIPS/eip-20\\n */\\ninterface EIP20Interface {\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n /**\\n * @notice Get the total number of tokens in circulation\\n * @return uint256 The supply of tokens\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @notice Gets the balance of the specified address\\n * @param owner The address from which the balance will be retrieved\\n * @return balance uint256 The balance\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transfer(address dst, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Transfer `amount` tokens from `src` to `dst`\\n * @param src The address of the source account\\n * @param dst The address of the destination account\\n * @param amount The number of tokens to transfer\\n * @return success bool Whether or not the transfer succeeded\\n */\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool success);\\n\\n /**\\n * @notice Approve `spender` to transfer up to `amount` from `src`\\n * @dev This will overwrite the approval amount for `spender`\\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\\n * @param spender The address of the account which may transfer tokens\\n * @param amount The number of tokens that are approved (-1 means infinite)\\n * @return success bool Whether or not the approval succeeded\\n */\\n function approve(address spender, uint256 amount) external returns (bool success);\\n\\n /**\\n * @notice Get the current allowance from `owner` for `spender`\\n * @param owner The address of the account which owns the tokens to be spent\\n * @param spender The address of the account which may transfer tokens\\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\\n */\\n function allowance(address owner, address spender) external view returns (uint256 remaining);\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n}\\n\",\"keccak256\":\"0xcea1d290397e1c8eac89c96738e7ec55259a575f878152eeccf33c0cf6d008e5\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IERC4626.sol\":{\"content\":\"pragma solidity >=0.8.0;\\npragma experimental ABIEncoderV2;\\n\\nimport { EIP20Interface } from \\\"./EIP20Interface.sol\\\";\\n\\ninterface IERC4626 is EIP20Interface {\\n /*----------------------------------------------------------------\\n Events\\n ----------------------------------------------------------------*/\\n\\n event Deposit(address indexed from, address indexed to, uint256 value);\\n\\n event Withdraw(address indexed from, address indexed to, uint256 value);\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n /**\\n @notice Deposit a specific amount of underlying tokens.\\n @param underlyingAmount The amount of the underlying token to deposit.\\n @param to The address to receive shares corresponding to the deposit\\n @return shares The shares in the vault credited to `to`\\n */\\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\\n\\n /**\\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\\n @param shareAmount The amount of vault shares to mint.\\n @param to The address to receive shares corresponding to the mint.\\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\\n */\\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\\n\\n /**\\n @notice Withdraw a specific amount of underlying tokens.\\n @param underlyingAmount The amount of the underlying token to withdraw.\\n @param to The address to receive underlying corresponding to the withdrawal.\\n @param from The address to burn shares from corresponding to the withdrawal.\\n @return shares The shares in the vault burned from sender\\n */\\n function withdraw(\\n uint256 underlyingAmount,\\n address to,\\n address from\\n ) external returns (uint256 shares);\\n\\n /**\\n @notice Redeem a specific amount of shares for underlying tokens.\\n @param shareAmount The amount of shares to redeem.\\n @param to The address to receive underlying corresponding to the redemption.\\n @param from The address to burn shares from corresponding to the redemption.\\n @return value The underlying amount transferred to `to`.\\n */\\n function redeem(\\n uint256 shareAmount,\\n address to,\\n address from\\n ) external returns (uint256 value);\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n /** \\n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n @return the address of the asset\\n */\\n function asset() external view returns (address);\\n\\n /** \\n @notice Returns a user's Vault balance in underlying tokens.\\n @param user The user to get the underlying balance of.\\n @return balance The user's Vault balance in underlying tokens.\\n */\\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\\n\\n /** \\n @notice Calculates the total amount of underlying tokens the Vault manages.\\n @return The total amount of underlying tokens the Vault manages.\\n */\\n function totalAssets() external view returns (uint256);\\n\\n /** \\n @notice Returns the value in underlying terms of one vault token. \\n */\\n function exchangeRate() external view returns (uint256);\\n\\n /**\\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\\n @param underlyingAmount the input amount of underlying tokens\\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\\n */\\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\\n\\n /**\\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\\n @param shareAmount the amount of shares from a mint call.\\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\\n */\\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\\n\\n /**\\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\\n @param underlyingAmount the input amount of underlying tokens\\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\\n */\\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\\n\\n /**\\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\\n @param shareAmount the amount of shares from a redeem call.\\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\\n */\\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\\n}\\n\",\"keccak256\":\"0x1dc7b6dc2f1202ca16bff4eb488bb5bfcd6a48202996663a7220a888b261d7cb\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3FlashCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#flash\\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\\ninterface IUniswapV3FlashCallback {\\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\\n function uniswapV3FlashCallback(\\n uint256 fee0,\\n uint256 fee1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc26730db16259a49c30bd7bd880bb7e48ad94853087a373ba787e406ca969f3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061549f806100206000396000f3fe608060405260043610620002635760003560e01c8063a71d085d1162000147578063e35a480111620000b9578063fa7cc72d1162000078578063fa7cc72d1462000778578063fc4d33f9146200079d578063fc773d3314620007b5578063fdb25fb114620007da578063fe4b84df14620007f257600080fd5b8063e35a480114620006bf578063e95600be14620006e4578063eab8a3881462000709578063f2fde38b146200072e578063f7e7d1fd146200075357600080fd5b8063cbc505f81162000106578063cbc505f81462000623578063dd86fea11462000648578063df595cb81462000660578063dfcb48bd1462000685578063e30c3978146200069d57600080fd5b8063a71d085d146200055b578063aa84161c1462000573578063b01b86fd14620005a8578063bbcdd6d314620005cd578063c5232b4714620005f257600080fd5b8063642843a511620001e157806384651d7311620001a057806384651d7314620004b757806388457be114620004cf5780638aac2f0c14620004f45780638da5cb5b1462000516578063930d2438146200053657600080fd5b8063642843a514620003fa5780636e96dfd7146200041f578063715018a614620004445780637a1133d6146200045c57806381218ea9146200049257600080fd5b80632203abb5116200022e5780632203abb514620003285780632acbff3914620003665780633465b6e1146200038b5780633ddd836d14620003b057806351f02d6a14620003d557600080fd5b806306bc461114620002705780630b2a2394146200029757806311a0e21714620002cf5780631259821c146200030357600080fd5b366200026b57005b600080fd5b3480156200027d57600080fd5b50620002956200028f36600462002825565b62000817565b005b348015620002a457600080fd5b50620002bc620002b636600462002854565b62000871565b6040519081526020015b60405180910390f35b348015620002dc57600080fd5b50620002f4620002ee36600462002854565b62000b86565b604051620002c6919062002874565b3480156200031057600080fd5b506200029562000322366004620028c3565b62000bfe565b3480156200033557600080fd5b506200034d6200034736600462002825565b62000c36565b6040516001600160a01b039091168152602001620002c6565b3480156200037357600080fd5b50620002956200038536600462002950565b62000c6f565b3480156200039857600080fd5b5062000295620003aa36600462002854565b62000dab565b348015620003bd57600080fd5b5062000295620003cf366004620029c3565b62000fe8565b348015620003e257600080fd5b506200034d620003f436600462002a6a565b6200105c565b3480156200040757600080fd5b50620002956200041936600462002af6565b620014a2565b3480156200042c57600080fd5b50620002956200043e36600462002854565b620014b7565b3480156200045157600080fd5b506200029562001523565b3480156200046957600080fd5b50620004816200047b36600462002854565b62001569565b6040519015158152602001620002c6565b3480156200049f57600080fd5b506200034d620004b136600462002854565b620016de565b348015620004c457600080fd5b50620002bc60705481565b348015620004dc57600080fd5b5062000295620004ee36600462002b19565b62001729565b3480156200050157600080fd5b50606c546200034d906001600160a01b031681565b3480156200052357600080fd5b506033546001600160a01b03166200034d565b3480156200054357600080fd5b506200029562000555366004620028c3565b620017cb565b3480156200056857600080fd5b50620002bc606d5481565b3480156200058057600080fd5b50620005986200059236600462002b7a565b62001803565b604051620002c692919062002bee565b348015620005b557600080fd5b5062000295620005c736600462002c14565b62001905565b348015620005da57600080fd5b506200034d620005ec36600462002854565b620019c6565b348015620005ff57600080fd5b50620002bc6200061136600462002854565b60666020526000908152604090205481565b3480156200063057600080fd5b50620002f46200064236600462002854565b62001a0e565b3480156200065557600080fd5b50620002bc62001a84565b3480156200066d57600080fd5b50620004816200067f36600462002c7b565b62001b85565b3480156200069257600080fd5b50620002bc606f5481565b348015620006aa57600080fd5b506065546200034d906001600160a01b031681565b348015620006cc57600080fd5b5062000295620006de36600462002cec565b62001c22565b348015620006f157600080fd5b50620002956200070336600462002d06565b62001c5c565b3480156200071657600080fd5b50620002956200072836600462002d06565b62001c91565b3480156200073b57600080fd5b50620002956200074d36600462002854565b62001cc0565b3480156200076057600080fd5b50620002956200077236600462002854565b62001d33565b3480156200078557600080fd5b50620002956200079736600462002854565b62001e19565b348015620007aa57600080fd5b506200029562001f7f565b348015620007c257600080fd5b506200034d620007d436600462002825565b62002099565b348015620007e757600080fd5b50620002bc606e5481565b348015620007ff57600080fd5b50620002956200081136600462002cec565b620020b6565b6200082162002205565b670de0b6b3a7640000811315620008555760405162461bcd60e51b81526004016200084c9062002d61565b60405180910390fd5b6001600160a01b03909116600090815260666020526040902055565b6000806001600160a01b03831663c37f68e2336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401608060405180830381865afa158015620008c9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008ef919062002dac565b50925050508060000362000907575050606e54919050565b6000836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000948573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200096e919062002de3565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015620009b1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009d7919062002de3565b90506000816001600160a01b031663aea91078876001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000a29573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a4f919062002de3565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801562000a94573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000aba919062002e03565b90506000866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000afd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b23919062002e1d565b60ff169050600062000b3782600a62002f50565b62000b43878562002f5e565b62000b4f919062002f78565b9050606e5481111562000b6a57506000979650505050505050565b80606e5462000b7a919062002f9b565b98975050505050505050565b6001600160a01b0381166000908152606b602090815260409182902080548351818402810184019094528084526060939283018282801562000bf257602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162000bd3575b50505050509050919050565b62000c0862002205565b6001600160a01b03918216600090815260696020526040902080546001600160a01b03191691909216179055565b606b602052816000526040600020818154811062000c5357600080fd5b6000918252602090912001546001600160a01b03169150829050565b62000c7962002205565b821580159062000c8857508281145b62000cee5760405162461bcd60e51b815260206004820152602f60248201527f4172726179206c656e67746873206d75737420626520657175616c20616e642060448201526e33b932b0ba32b9103a3430b710181760891b60648201526084016200084c565b60005b8381101562000da45762000d9a83838381811062000d135762000d1362002fb1565b905060200281019062000d27919062002fc7565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525089925088915085905081811062000d735762000d7362002fb1565b905060200201602081019062000d8a919062002854565b6001600160a01b03169062002263565b5060010162000cf1565b5050505050565b6001600160a01b03811662000ee857478062000e145760405162461bcd60e51b815260206004820152602160248201527f4e6f2062616c616e636520617661696c61626c6520746f2077697468647261776044820152601760f91b60648201526084016200084c565b600062000e296033546001600160a01b031690565b6001600160a01b03168260405160006040518083038185875af1925050503d806000811462000e75576040519150601f19603f3d011682016040523d82523d6000602084013e62000e7a565b606091505b505090508062000ee35760405162461bcd60e51b815260206004820152602d60248201527f4661696c656420746f207472616e73666572204554482062616c616e6365207460448201526c379036b9b39739b2b73232b91760991b60648201526084016200084c565b505050565b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801562000f32573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f58919062002e03565b90506000811162000fbc5760405162461bcd60e51b815260206004820152602760248201527f4e6f20746f6b656e2062616c616e636520617661696c61626c6520746f2077696044820152663a34323930bb9760c91b60648201526084016200084c565b62000ee362000fd36033546001600160a01b031690565b6001600160a01b0384169083620022b0565b50565b62000ff262002205565b6040516389cd985560e01b81526001600160a01b03838116600483015282811660248301528416906389cd985590604401600060405180830381600087803b1580156200103e57600080fd5b505af115801562001053573d6000803e3d6000fd5b50505050505050565b600080806200106f604082888a62003011565b8101906200107e9190620028c3565b90925090506001600160a01b0381163314620010dd5760405162461bcd60e51b815260206004820152601a60248201527f436f6d7074726f6c6c6572206973206e6f742073656e6465722e00000000000060448201526064016200084c565b60003383606d60008154620010f2906200303d565b91829055506040516bffffffffffffffffffffffff19606094851b811660208301529290931b90911660348301526048820152606801604051602081830303815290604052805190602001209050600060405180602001620011549062002782565b601f1982820381018352601f9091011660408190526200117c91908b908b9060200162003059565b604051602081830303815290604052905060006200119d6000848462002304565b60ff8c166000908152606860209081526040808320815180830190925280546001600160a01b03168252600181018054959650939491939092840191620011e49062003083565b80601f0160208091040260200160405190810160405280929190818152602001828054620012129062003083565b8015620012635780601f10620012375761010080835404028352916020019162001263565b820191906000526020600020905b8154815290600101906020018083116200124557829003601f168201915b50505091909252505081516040516389cd985560e01b81526001600160a01b038083166004830152600060248301529394509092851691506389cd985590604401600060405180830381600087803b158015620012bf57600080fd5b505af1158015620012d4573d6000803e3d6000fd5b505050506001600160a01b0381166000908152606b60209081526040808320805482518185028101850190935280835291929091908301828280156200134457602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162001325575b5050505050905060005b81518110156200142a57826001600160a01b031682828151811062001377576200137762002fb1565b60200260200101516001600160a01b031603156200142157846001600160a01b03166389cd9855838381518110620013b357620013b362002fb1565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260006024820152604401600060405180830381600087803b1580156200140757600080fd5b505af11580156200141c573d6000803e3d6000fd5b505050505b6001016200134e565b50604051630adccee560e31b81526001600160a01b038516906356e67728906200145b908e908e90600401620030bf565b600060405180830381600087803b1580156200147657600080fd5b505af11580156200148b573d6000803e3d6000fd5b50959a505050505050505050505095945050505050565b620014ac62002205565b606e91909155606f55565b620014c162002205565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b6200152d62002205565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064016200084c565b60006200157562002205565b60008290506000816001600160a01b031663ef01df4f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620015bb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015e1919062002de3565b6001600160a01b038181166000908152606960205260409081902054905163033e92d960e31b815290821660048201529192508316906319f496c890602401600060405180830381600087803b1580156200163b57600080fd5b505af115801562001650573d6000803e3d6000fd5b505050506000826001600160a01b031663ef01df4f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001695573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016bb919062002de3565b9050816001600160a01b0316816001600160a01b0316141593505050505b919050565b6001600160a01b0381811660009081526069602052604081205490911662001707578162001723565b6001600160a01b03808316600090815260696020526040902054165b92915050565b6200173362002205565b6040518060400160405280846001600160a01b0316815260200183838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093909452505060ff87168152606860209081526040909120835181546001600160a01b0319166001600160a01b0390911617815590830151909150600182019062001053908262003158565b620017d562002205565b6001600160a01b03918216600090815260676020526040902080546001600160a01b03191691909216179055565b60ff81166000908152606860209081526040808320815180830190925280546001600160a01b031682526001810180546060948694939290840191620018499062003083565b80601f0160208091040260200160405190810160405280929190818152602001828054620018779062003083565b8015620018c85780601f106200189c57610100808354040283529160200191620018c8565b820191906000526020600020905b815481529060010190602001808311620018aa57829003601f168201915b50505091909252505081519192506060916001600160a01b03169050620018f257600081620018fa565b815160208301515b935093505050915091565b6200190f62002205565b826200195e5760405162461bcd60e51b815260206004820152601e60248201527f4e6f2074617267657420616464726573736573207370656369666965642e000060448201526064016200084c565b60005b8381101562000da457620019bc83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525089925088915085905081811062000d735762000d7362002fb1565b5060010162001961565b6001600160a01b03818116600090815260676020526040812054909116620019ef578162001723565b506001600160a01b039081166000908152606760205260409020541690565b6001600160a01b0381166000908152606a602090815260409182902080548351818402810184019094528084526060939283018282801562000bf2576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831162000bd35750505050509050919050565b60408051600481526024810182526020810180516001600160e01b0316635fe3b56760e01b179052905160009182918291339162001ac3919062003225565b600060405180830381855afa9150503d806000811462001b00576040519150601f19603f3d011682016040523d82523d6000602084013e62001b05565b606091505b509150915081801562001b19575080516020145b1562001b7b5760008180602001905181019062001b37919062002de3565b6001600160a01b03811660009081526066602052604081205491925081131562001b6357949350505050565b600081121562001b7857600094505050505090565b50505b6070549250505090565b606c54604051631beb2b9760e31b81526001600160a01b038681166004830152858116602483015284811660448301526001600160e01b031984166064830152600092169063df595cb890608401602060405180830381865afa15801562001bf1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001c17919062003243565b90505b949350505050565b62001c2c62002205565b670de0b6b3a764000081111562001c575760405162461bcd60e51b81526004016200084c9062002d61565b607055565b62001c6662002205565b6001600160a01b0383166000908152606a6020526040902062001c8b90838362002790565b50505050565b62001c9b62002205565b6001600160a01b0383166000908152606b6020526040902062001c8b90838362002790565b62001cca62002205565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633148062001df657600062001d7b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b90506001600160a01b03811633148062001df35760405162461bcd60e51b815260206004820152603260248201527f4f776e61626c653a2063616c6c6572206973206e65697468657220746865206f6044820152713bb732b9103737b9103a34329030b236b4b760711b60648201526084016200084c565b50505b50606c80546001600160a01b0319166001600160a01b0392909216919091179055565b62001e2362002205565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801562001e64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262001e8e919081019062003274565b9050816001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801562001ecc57600080fd5b505af115801562001ee1573d6000803e3d6000fd5b5050505060005b81518160ff16101562000ee357818160ff168151811062001f0d5762001f0d62002fb1565b60200260200101516001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801562001f5057600080fd5b505af115801562001f65573d6000803e3d6000fd5b50505050808062001f76906200333b565b91505062001ee8565b6065546001600160a01b0316331462001fd35760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b60448201526064016200084c565b600062001fe86033546001600160a01b031690565b6065549091506001600160a01b031662002002816200240e565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910162001517565b606a602052816000526040600020818154811062000c5357600080fd5b600054610100900460ff1615808015620020d75750600054600160ff909116105b80620020f35750303b158015620020f3575060005460ff166001145b620021585760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016200084c565b6000805460ff1916600117905580156200217c576000805461ff0019166101001790555b670de0b6b3a7640000821115620021a75760405162461bcd60e51b81526004016200084c9062002d61565b620021b23362002460565b6070829055600019606f55801562002201576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200162001517565b5050565b6033546001600160a01b03163314620022615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016200084c565b565b6060620022a9838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c656400008152506200249f565b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905262000ee390849062002582565b600083471015620023585760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064016200084c565b8151600003620023ab5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016200084c565b8282516020840186f590506001600160a01b038116620022a95760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016200084c565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166200248a5760405162461bcd60e51b81526004016200084c906200335d565b620024946200265b565b62000fe5816200240e565b606082471015620025025760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200084c565b600080866001600160a01b0316858760405162002520919062003225565b60006040518083038185875af1925050503d80600081146200255f576040519150601f19603f3d011682016040523d82523d6000602084013e62002564565b606091505b509150915062002577878383876200268f565b979650505050505050565b6000620025d9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200270f9092919063ffffffff16565b80519091501562000ee35780806020019051810190620025fa919062003243565b62000ee35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200084c565b600054610100900460ff16620026855760405162461bcd60e51b81526004016200084c906200335d565b6200226162002720565b6060831562002703578251600003620026fb576001600160a01b0385163b620026fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200084c565b508162001c1a565b62001c1a838362002755565b606062001c1a84846000856200249f565b600054610100900460ff166200274a5760405162461bcd60e51b81526004016200084c906200335d565b62002261336200240e565b815115620027665781518083602001fd5b8060405162461bcd60e51b81526004016200084c9190620033a8565b6120ac80620033be83390190565b828054828255906000526020600020908101928215620027e6579160200282015b82811115620027e65781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190620027b1565b50620027f4929150620027f8565b5090565b5b80821115620027f45760008155600101620027f9565b6001600160a01b038116811462000fe557600080fd5b600080604083850312156200283957600080fd5b823562002846816200280f565b946020939093013593505050565b6000602082840312156200286757600080fd5b8135620022a9816200280f565b6020808252825182820181905260009190848201906040850190845b81811015620028b75783516001600160a01b03168352928401929184019160010162002890565b50909695505050505050565b60008060408385031215620028d757600080fd5b8235620028e4816200280f565b91506020830135620028f6816200280f565b809150509250929050565b60008083601f8401126200291457600080fd5b50813567ffffffffffffffff8111156200292d57600080fd5b6020830191508360208260051b85010111156200294957600080fd5b9250929050565b600080600080604085870312156200296757600080fd5b843567ffffffffffffffff808211156200298057600080fd5b6200298e8883890162002901565b90965094506020870135915080821115620029a857600080fd5b50620029b78782880162002901565b95989497509550505050565b600080600060608486031215620029d957600080fd5b8335620029e6816200280f565b92506020840135620029f8816200280f565b9150604084013562002a0a816200280f565b809150509250925092565b60ff8116811462000fe557600080fd5b60008083601f84011262002a3857600080fd5b50813567ffffffffffffffff81111562002a5157600080fd5b6020830191508360208285010111156200294957600080fd5b60008060008060006060868803121562002a8357600080fd5b853562002a908162002a15565b9450602086013567ffffffffffffffff8082111562002aae57600080fd5b62002abc89838a0162002a25565b9096509450604088013591508082111562002ad657600080fd5b5062002ae58882890162002a25565b969995985093965092949392505050565b6000806040838503121562002b0a57600080fd5b50508035926020909101359150565b6000806000806060858703121562002b3057600080fd5b843562002b3d8162002a15565b9350602085013562002b4f816200280f565b9250604085013567ffffffffffffffff81111562002b6c57600080fd5b620029b78782880162002a25565b60006020828403121562002b8d57600080fd5b8135620022a98162002a15565b60005b8381101562002bb757818101518382015260200162002b9d565b50506000910152565b6000815180845262002bda81602086016020860162002b9a565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009062001c1a9083018462002bc0565b6000806000806040858703121562002c2b57600080fd5b843567ffffffffffffffff8082111562002c4457600080fd5b62002c528883890162002901565b9096509450602087013591508082111562002c6c57600080fd5b50620029b78782880162002a25565b6000806000806080858703121562002c9257600080fd5b843562002c9f816200280f565b9350602085013562002cb1816200280f565b9250604085013562002cc3816200280f565b915060608501356001600160e01b03198116811462002ce157600080fd5b939692955090935050565b60006020828403121562002cff57600080fd5b5035919050565b60008060006040848603121562002d1c57600080fd5b833562002d29816200280f565b9250602084013567ffffffffffffffff81111562002d4657600080fd5b62002d548682870162002901565b9497909650939450505050565b6020808252602b908201527f496e7465726573742066656520726174652063616e6e6f74206265206d6f726560408201526a103a3430b710189818129760a91b606082015260800190565b6000806000806080858703121562002dc357600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121562002df657600080fd5b8151620022a9816200280f565b60006020828403121562002e1657600080fd5b5051919050565b60006020828403121562002e3057600080fd5b8151620022a98162002a15565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111562002e9457816000190482111562002e785762002e7862002e3d565b8085161562002e8657918102915b93841c939080029062002e58565b509250929050565b60008262002ead5750600162001723565b8162002ebc5750600062001723565b816001811462002ed5576002811462002ee05762002f00565b600191505062001723565b60ff84111562002ef45762002ef462002e3d565b50506001821b62001723565b5060208310610133831016604e8410600b841016171562002f25575081810a62001723565b62002f31838362002e53565b806000190482111562002f485762002f4862002e3d565b029392505050565b6000620022a9838362002e9c565b808202811582820484141762001723576200172362002e3d565b60008262002f9657634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111562001723576200172362002e3d565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811262002fdf57600080fd5b83018035915067ffffffffffffffff82111562002ffb57600080fd5b6020019150368190038213156200294957600080fd5b600080858511156200302257600080fd5b838611156200303057600080fd5b5050820193919092039150565b60006001820162003052576200305262002e3d565b5060010190565b600084516200306d81846020890162002b9a565b8201838582376000930192835250909392505050565b600181811c908216806200309857607f821691505b602082108103620030b957634e487b7160e01b600052602260045260246000fd5b50919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b634e487b7160e01b600052604160045260246000fd5b601f82111562000ee3576000816000526020600020601f850160051c810160208610156200312f5750805b601f850160051c820191505b8181101562003150578281556001016200313b565b505050505050565b815167ffffffffffffffff811115620031755762003175620030ee565b6200318d8162003186845462003083565b8462003104565b602080601f831160018114620031c55760008415620031ac5750858301515b600019600386901b1c1916600185901b17855562003150565b600085815260208120601f198616915b82811015620031f657888601518255948401946001909101908401620031d5565b5085821015620032155787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082516200323981846020870162002b9a565b9190910192915050565b6000602082840312156200325657600080fd5b81518015158114620022a957600080fd5b8051620016d9816200280f565b600060208083850312156200328857600080fd5b825167ffffffffffffffff80821115620032a157600080fd5b818501915085601f830112620032b657600080fd5b815181811115620032cb57620032cb620030ee565b8060051b604051601f19603f83011681018181108582111715620032f357620032f3620030ee565b6040529182528482019250838101850191888311156200331257600080fd5b938501935b8285101562000b7a576200332b8562003267565b8452938501939285019262003317565b600060ff821660ff810362003354576200335462002e3d565b60010192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b602081526000620022a9602083018462002bc056fe60806040523480156200001157600080fd5b50604051620020ac380380620020ac8339810160408190526200003491620005f7565b336001600160a01b038716146200007b5760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064015b60405180910390fd5b6000886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000e29190620006ca565b600080546001600160a01b0319166001600160a01b038a8116919091179091556702c68af0bb14000060055560038054610100600160a81b0319166101008c84160217905543600955670de0b6b3a7640000600a55604080516310c8fc9560e11b8152905192935090881691632191f92a916004808201926020929091908290030181865afa1580156200017a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a09190620006f6565b620001d85760405162461bcd60e51b8152602060048201526007602482015266216e6f7449726d60c81b604482015260640162000072565b600480546001600160a01b0319166001600160a01b038816908117909155604080516000815260208101929092527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926910160405180910390a160016200023f8682620007ab565b5060026200024e8582620007ab565b506003805460ff191660ff8316179055600754600654670de0b6b3a764000091906200027b908662000877565b62000287919062000877565b1115620002c15760405162461bcd60e51b8152602060048201526007602482015266085c998e9cd95d60ca1b604482015260640162000072565b60088390556040805160008152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460910160405180910390a16000198203620003105760065491505b60008060009054906101000a90046001600160a01b03166001600160a01b031663dd86fea16040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000365573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200038b91906200089f565b9050670de0b6b3a76400008184600854620003a7919062000877565b620003b3919062000877565b1115620003f35760405162461bcd60e51b815260206004820152600d60248201526c0858591b5a5b9199594e9cd95d609a1b604482015260640162000072565b60068390556040805160008152602081018590527fcdd0b588250e1398549f79cfdb8217c186688822905d6715b0834ea1c865594a910160405180910390a160078190556040805160008152602081018390527fedec4b9c99c2cdb231e7fd036f861e0445b015916700f41b9835f984cb9be4cb910160405180910390a1506000805460ff60a01b1916600160a01b179055601380546001600160a01b038b166001600160a01b03199091168117909155604080516318160ddd60e01b815290516318160ddd916004808201926020929091908290030181865afa158015620004e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200050691906200089f565b50505050505050505050620008b9565b6001600160a01b03811681146200052c57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200055757600080fd5b81516001600160401b03808211156200057457620005746200052f565b604051601f8301601f19908116603f011681019082821181831017156200059f576200059f6200052f565b8160405283815260209250866020858801011115620005bd57600080fd5b600091505b83821015620005e15785820183015181830184015290820190620005c2565b6000602085830101528094505050505092915050565b600080600080600080600080610100898b0312156200061557600080fd5b8851620006228162000516565b60208a0151909850620006358162000516565b60408a0151909750620006488162000516565b60608a01519096506200065b8162000516565b60808a01519095506001600160401b03808211156200067957600080fd5b620006878c838d0162000545565b955060a08b01519150808211156200069e57600080fd5b50620006ad8b828c0162000545565b60c08b015160e0909b0151999c989b509699959894979350505050565b600060208284031215620006dd57600080fd5b815160ff81168114620006ef57600080fd5b9392505050565b6000602082840312156200070957600080fd5b81518015158114620006ef57600080fd5b600181811c908216806200072f57607f821691505b6020821081036200075057634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620007a6576000816000526020600020601f850160051c81016020861015620007815750805b601f850160051c820191505b81811015620007a2578281556001016200078d565b5050505b505050565b81516001600160401b03811115620007c757620007c76200052f565b620007df81620007d884546200071a565b8462000756565b602080601f831160018114620008175760008415620007fe5750858301515b600019600386901b1c1916600185901b178555620007a2565b600085815260208120601f198616915b82811015620008485788860151825594840194600190910190840162000827565b5085821015620008675787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200089957634e487b7160e01b600052601160045260246000fd5b92915050565b600060208284031215620008b257600080fd5b5051919050565b6117e380620008c96000396000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c80636f307dc3116100de578063aa5af0fd11610097578063c3bf11cd11610071578063c3bf11cd1461033b578063c91a424f14610344578063e207afe214610357578063f3fdb15a1461036a57610173565b8063aa5af0fd1461031b578063ba49f54a14610324578063be99f1191461032c57610173565b80636f307dc3146102d257806389cd9855146102e55780638d02d9a1146102f85780638f840ddd1461030157806395d89b411461030a5780639826394b1461031257610173565b80635c60da1b116101305780635c60da1b1461027d5780635fe3b5671461028557806361feacff1461029d5780636333d001146102a65780636752e702146102bb5780636c540baf146102c957610173565b806306fdde03146101ec578063173b99041461020a57806318160ddd14610221578063313ce5671461022a5780633c4f743c1461024957806347bd371814610274575b600061018a6000356001600160e01b03191661037d565b90506001600160a01b0381166101c657604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156101e5573d6000f35b3d6000fd5b005b6101f461039d565b604051610201919061129c565b60405180910390f35b61021360085481565b604051908152602001610201565b610213600f5481565b6003546102379060ff1681565b60405160ff9091168152602001610201565b60145461025c906001600160a01b031681565b6040516001600160a01b039091168152602001610201565b610213600b5481565b61025c61042b565b60035461025c9061010090046001600160a01b031681565b610213600d5481565b6102ae610481565b60405161020191906112b6565b610213666379da05b6000081565b61021360095481565b60135461025c906001600160a01b031681565b6101ea6102f336600461131b565b61048b565b61021360065481565b610213600c5481565b6101f46104e3565b610213600e5481565b610213600a5481565b6101ea6104f0565b61021367016345785d8a000081565b61021360075481565b60005461025c906001600160a01b031681565b6101ea610365366004611354565b6106d5565b60045461025c906001600160a01b031681565b60006103978260008051602061178e833981519152610757565b92915050565b600180546103aa906113d9565b80601f01602080910402602001604051908101604052809291908181526020018280546103d6906113d9565b80156104235780601f106103f857610100808354040283529160200191610423565b820191906000526020600020905b81548152906001019060200180831161040657829003601f168201915b505050505081565b60408051808201909152600e81526d64656c656761746554797065282960901b602090910152600061047c7f2c436e5bba88e403c36d7a2822cd2b39b360d5c6296839bbf72c5a05167fd3ff61037d565b905090565b606061047c6107f2565b6000546001600160a01b031633146104d55760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b60448201526064016101bd565b6104df8282610864565b5050565b600280546103aa906113d9565b333014806105015750610501610885565b61053e5760405162461bcd60e51b815260206004820152600e60248201526d10b9b2b6331037b91030b236b4b760911b60448201526064016101bd565b60408051600481526024810182526020810180516001600160e01b0316632c436e5b60e01b17905290516000918291309161057891611413565b600060405180830381855afa9150503d80600081146105b3576040519150601f19603f3d011682016040523d82523d6000602084013e6105b8565b606091505b5091509150816105fd5760405162461bcd60e51b815260206004820152601060248201526f6e6f2064656c6567617465207479706560801b60448201526064016101bd565b600081806020019051810190610613919061142f565b60008054604051632aa1058760e21b815260ff84166004820152929350909182916001600160a01b03169063aa84161c90602401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c9190810190611499565b91509150600061069a61042b565b9050826001600160a01b0316816001600160a01b0316146106c4576106bf8383610a02565b6106cd565b6106cd81610ada565b505050505050565b6106dd610885565b6107125760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064016101bd565b6107528383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610a0292505050565b505050565b8054600090815b818110156107e757846001600160e01b03191684600001828154811061078657610786611543565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036107df578360000181815481106107c0576107c0611543565b6000918252602090912001546001600160a01b03169250610397915050565b60010161075e565b506000949350505050565b606060008051602061178e83398151915260010180548060200260200160405190810160405280929190818152602001828054801561085a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161083c575b5050505050905090565b6001600160a01b0381161561087c5761087c81610bce565b6104df82610cfd565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109029190611559565b6001600160a01b0316336001600160a01b031614801561097f5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561095b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097f9190611576565b806109fc57506000546001600160a01b0316331480156109fc5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fc9190611576565b91505090565b6000610a0c61042b565b9050610a1783610ada565b610a91306356e6772860e01b84604051602401610a34919061129c565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280600c81526020016b08589958dbdb59481a5b5c1b60a21b815250610df4565b50604080516001600160a01b038084168252851660208201527fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a910160405180910390a1505050565b600080546040516311a0e21760e01b81526001600160a01b038481166004830152909116906311a0e21790602401600060405180830381865afa158015610b25573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b4d91908101906115bc565b90506000610b596107f2565b905060005b8151811015610b9157610b89828281518110610b7c57610b7c611543565b6020026020010151610bce565b600101610b5e565b5060005b8251811015610bc857610bc0838281518110610bb357610bb3611543565b6020026020010151610cfd565b600101610b95565b50505050565b60008051602061178e833981519152610be682610e90565b60005b600182015460ff8216101561075257826001600160a01b0316826001018260ff1681548110610c1a57610c1a611543565b6000918252602090912001546001600160a01b031603610ceb57600180830180549091610c4691611671565b81548110610c5657610c56611543565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610c8757610c87611543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610cc857610cc8611684565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610cf58161169a565b915050610be9565b60008051602061178e83398151915260005b600182015460ff82161015610db457826001600160a01b0316826001018260ff1681548110610d4057610d40611543565b6000918252602090912001546001600160a01b031603610da25760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016101bd565b80610dac8161169a565b915050610d0f565b50610dbe8261104f565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b031685604051610e119190611413565b6000604051808303816000865af19150503d8060008114610e4e576040519150601f19603f3d011682016040523d82523d6000602084013e610e53565b606091505b509150915081610e8757805115610e6d5780518082602001fd5b8360405162461bcd60e51b81526004016101bd919061129c565b95945050505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ed0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ef891908101906116b9565b905060008051602061178e83398151915260005b82518161ffff161015610bc8576000838261ffff1681518110610f3157610f31611543565b60200260200101519050610f458184610757565b6001600160a01b0316856001600160a01b031614610f6557610f65611756565b6000610f7182856111cf565b84549091508490610f8490600190611671565b81548110610f9457610f94611543565b90600052602060002001846000018261ffff1681548110610fb757610fb7611543565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff16909102179055835484908061101857611018611684565b600082815260209020810160001990810180546001600160c01b0319169055019055508190506110478161176c565b915050610f0c565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561108f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110b791908101906116b9565b60008051602061178e83398151915280549192509060005b83518110156111c85760008482815181106110ec576110ec611543565b6020026020010151905060006111028286610757565b90506001600160a01b0381161561114757604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016101bd565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836111b78161176c565b945050600190920191506110cf9050565b5050505050565b8054600090815b8161ffff168161ffff16101561124057846001600160e01b031916846000018261ffff168154811061120a5761120a611543565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036112385791506103979050565b6001016111d6565b5061ffff949350505050565b60005b8381101561126757818101518382015260200161124f565b50506000910152565b6000815180845261128881602086016020860161124c565b601f01601f19169290920160200192915050565b6020815260006112af6020830184611270565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156112f75783516001600160a01b0316835292840192918401916001016112d2565b50909695505050505050565b6001600160a01b038116811461131857600080fd5b50565b6000806040838503121561132e57600080fd5b823561133981611303565b9150602083013561134981611303565b809150509250929050565b60008060006040848603121561136957600080fd5b833561137481611303565b9250602084013567ffffffffffffffff8082111561139157600080fd5b818601915086601f8301126113a557600080fd5b8135818111156113b457600080fd5b8760208285010111156113c657600080fd5b6020830194508093505050509250925092565b600181811c908216806113ed57607f821691505b60208210810361140d57634e487b7160e01b600052602260045260246000fd5b50919050565b6000825161142581846020870161124c565b9190910192915050565b60006020828403121561144157600080fd5b815160ff811681146112af57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561149157611491611452565b604052919050565b600080604083850312156114ac57600080fd5b82516114b781611303565b602084015190925067ffffffffffffffff808211156114d557600080fd5b818501915085601f8301126114e957600080fd5b8151818111156114fb576114fb611452565b61150e601f8201601f1916602001611468565b915080825286602082850101111561152557600080fd5b61153681602084016020860161124c565b5080925050509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561156b57600080fd5b81516112af81611303565b60006020828403121561158857600080fd5b815180151581146112af57600080fd5b600067ffffffffffffffff8211156115b2576115b2611452565b5060051b60200190565b600060208083850312156115cf57600080fd5b825167ffffffffffffffff8111156115e657600080fd5b8301601f810185136115f757600080fd5b805161160a61160582611598565b611468565b81815260059190911b8201830190838101908783111561162957600080fd5b928401925b8284101561165057835161164181611303565b8252928401929084019061162e565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156103975761039761165b565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff81036116b0576116b061165b565b60010192915050565b600060208083850312156116cc57600080fd5b825167ffffffffffffffff8111156116e357600080fd5b8301601f810185136116f457600080fd5b805161170261160582611598565b81815260059190911b8201830190838101908783111561172157600080fd5b928401925b828410156116505783516001600160e01b0319811681146117475760008081fd5b82529284019290840190611726565b634e487b7160e01b600052600160045260246000fd5b600061ffff8083168181036117835761178361165b565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a26469706673582212202b3a4905878ec4941d46ab71c8a44c155d4ee381195d800391967da531df697264736f6c63430008160033a2646970667358221220414bf225b2c4e4e2fee5ad9baf99c038189835fe2e78ef4e7d7b908e86ad3aa564736f6c63430008160033", + "deployedBytecode": "0x608060405260043610620002635760003560e01c8063a71d085d1162000147578063e35a480111620000b9578063fa7cc72d1162000078578063fa7cc72d1462000778578063fc4d33f9146200079d578063fc773d3314620007b5578063fdb25fb114620007da578063fe4b84df14620007f257600080fd5b8063e35a480114620006bf578063e95600be14620006e4578063eab8a3881462000709578063f2fde38b146200072e578063f7e7d1fd146200075357600080fd5b8063cbc505f81162000106578063cbc505f81462000623578063dd86fea11462000648578063df595cb81462000660578063dfcb48bd1462000685578063e30c3978146200069d57600080fd5b8063a71d085d146200055b578063aa84161c1462000573578063b01b86fd14620005a8578063bbcdd6d314620005cd578063c5232b4714620005f257600080fd5b8063642843a511620001e157806384651d7311620001a057806384651d7314620004b757806388457be114620004cf5780638aac2f0c14620004f45780638da5cb5b1462000516578063930d2438146200053657600080fd5b8063642843a514620003fa5780636e96dfd7146200041f578063715018a614620004445780637a1133d6146200045c57806381218ea9146200049257600080fd5b80632203abb5116200022e5780632203abb514620003285780632acbff3914620003665780633465b6e1146200038b5780633ddd836d14620003b057806351f02d6a14620003d557600080fd5b806306bc461114620002705780630b2a2394146200029757806311a0e21714620002cf5780631259821c146200030357600080fd5b366200026b57005b600080fd5b3480156200027d57600080fd5b50620002956200028f36600462002825565b62000817565b005b348015620002a457600080fd5b50620002bc620002b636600462002854565b62000871565b6040519081526020015b60405180910390f35b348015620002dc57600080fd5b50620002f4620002ee36600462002854565b62000b86565b604051620002c6919062002874565b3480156200031057600080fd5b506200029562000322366004620028c3565b62000bfe565b3480156200033557600080fd5b506200034d6200034736600462002825565b62000c36565b6040516001600160a01b039091168152602001620002c6565b3480156200037357600080fd5b50620002956200038536600462002950565b62000c6f565b3480156200039857600080fd5b5062000295620003aa36600462002854565b62000dab565b348015620003bd57600080fd5b5062000295620003cf366004620029c3565b62000fe8565b348015620003e257600080fd5b506200034d620003f436600462002a6a565b6200105c565b3480156200040757600080fd5b50620002956200041936600462002af6565b620014a2565b3480156200042c57600080fd5b50620002956200043e36600462002854565b620014b7565b3480156200045157600080fd5b506200029562001523565b3480156200046957600080fd5b50620004816200047b36600462002854565b62001569565b6040519015158152602001620002c6565b3480156200049f57600080fd5b506200034d620004b136600462002854565b620016de565b348015620004c457600080fd5b50620002bc60705481565b348015620004dc57600080fd5b5062000295620004ee36600462002b19565b62001729565b3480156200050157600080fd5b50606c546200034d906001600160a01b031681565b3480156200052357600080fd5b506033546001600160a01b03166200034d565b3480156200054357600080fd5b506200029562000555366004620028c3565b620017cb565b3480156200056857600080fd5b50620002bc606d5481565b3480156200058057600080fd5b50620005986200059236600462002b7a565b62001803565b604051620002c692919062002bee565b348015620005b557600080fd5b5062000295620005c736600462002c14565b62001905565b348015620005da57600080fd5b506200034d620005ec36600462002854565b620019c6565b348015620005ff57600080fd5b50620002bc6200061136600462002854565b60666020526000908152604090205481565b3480156200063057600080fd5b50620002f46200064236600462002854565b62001a0e565b3480156200065557600080fd5b50620002bc62001a84565b3480156200066d57600080fd5b50620004816200067f36600462002c7b565b62001b85565b3480156200069257600080fd5b50620002bc606f5481565b348015620006aa57600080fd5b506065546200034d906001600160a01b031681565b348015620006cc57600080fd5b5062000295620006de36600462002cec565b62001c22565b348015620006f157600080fd5b50620002956200070336600462002d06565b62001c5c565b3480156200071657600080fd5b50620002956200072836600462002d06565b62001c91565b3480156200073b57600080fd5b50620002956200074d36600462002854565b62001cc0565b3480156200076057600080fd5b50620002956200077236600462002854565b62001d33565b3480156200078557600080fd5b50620002956200079736600462002854565b62001e19565b348015620007aa57600080fd5b506200029562001f7f565b348015620007c257600080fd5b506200034d620007d436600462002825565b62002099565b348015620007e757600080fd5b50620002bc606e5481565b348015620007ff57600080fd5b50620002956200081136600462002cec565b620020b6565b6200082162002205565b670de0b6b3a7640000811315620008555760405162461bcd60e51b81526004016200084c9062002d61565b60405180910390fd5b6001600160a01b03909116600090815260666020526040902055565b6000806001600160a01b03831663c37f68e2336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401608060405180830381865afa158015620008c9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008ef919062002dac565b50925050508060000362000907575050606e54919050565b6000836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000948573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200096e919062002de3565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015620009b1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009d7919062002de3565b90506000816001600160a01b031663aea91078876001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000a29573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a4f919062002de3565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801562000a94573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000aba919062002e03565b90506000866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000afd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b23919062002e1d565b60ff169050600062000b3782600a62002f50565b62000b43878562002f5e565b62000b4f919062002f78565b9050606e5481111562000b6a57506000979650505050505050565b80606e5462000b7a919062002f9b565b98975050505050505050565b6001600160a01b0381166000908152606b602090815260409182902080548351818402810184019094528084526060939283018282801562000bf257602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162000bd3575b50505050509050919050565b62000c0862002205565b6001600160a01b03918216600090815260696020526040902080546001600160a01b03191691909216179055565b606b602052816000526040600020818154811062000c5357600080fd5b6000918252602090912001546001600160a01b03169150829050565b62000c7962002205565b821580159062000c8857508281145b62000cee5760405162461bcd60e51b815260206004820152602f60248201527f4172726179206c656e67746873206d75737420626520657175616c20616e642060448201526e33b932b0ba32b9103a3430b710181760891b60648201526084016200084c565b60005b8381101562000da45762000d9a83838381811062000d135762000d1362002fb1565b905060200281019062000d27919062002fc7565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525089925088915085905081811062000d735762000d7362002fb1565b905060200201602081019062000d8a919062002854565b6001600160a01b03169062002263565b5060010162000cf1565b5050505050565b6001600160a01b03811662000ee857478062000e145760405162461bcd60e51b815260206004820152602160248201527f4e6f2062616c616e636520617661696c61626c6520746f2077697468647261776044820152601760f91b60648201526084016200084c565b600062000e296033546001600160a01b031690565b6001600160a01b03168260405160006040518083038185875af1925050503d806000811462000e75576040519150601f19603f3d011682016040523d82523d6000602084013e62000e7a565b606091505b505090508062000ee35760405162461bcd60e51b815260206004820152602d60248201527f4661696c656420746f207472616e73666572204554482062616c616e6365207460448201526c379036b9b39739b2b73232b91760991b60648201526084016200084c565b505050565b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801562000f32573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f58919062002e03565b90506000811162000fbc5760405162461bcd60e51b815260206004820152602760248201527f4e6f20746f6b656e2062616c616e636520617661696c61626c6520746f2077696044820152663a34323930bb9760c91b60648201526084016200084c565b62000ee362000fd36033546001600160a01b031690565b6001600160a01b0384169083620022b0565b50565b62000ff262002205565b6040516389cd985560e01b81526001600160a01b03838116600483015282811660248301528416906389cd985590604401600060405180830381600087803b1580156200103e57600080fd5b505af115801562001053573d6000803e3d6000fd5b50505050505050565b600080806200106f604082888a62003011565b8101906200107e9190620028c3565b90925090506001600160a01b0381163314620010dd5760405162461bcd60e51b815260206004820152601a60248201527f436f6d7074726f6c6c6572206973206e6f742073656e6465722e00000000000060448201526064016200084c565b60003383606d60008154620010f2906200303d565b91829055506040516bffffffffffffffffffffffff19606094851b811660208301529290931b90911660348301526048820152606801604051602081830303815290604052805190602001209050600060405180602001620011549062002782565b601f1982820381018352601f9091011660408190526200117c91908b908b9060200162003059565b604051602081830303815290604052905060006200119d6000848462002304565b60ff8c166000908152606860209081526040808320815180830190925280546001600160a01b03168252600181018054959650939491939092840191620011e49062003083565b80601f0160208091040260200160405190810160405280929190818152602001828054620012129062003083565b8015620012635780601f10620012375761010080835404028352916020019162001263565b820191906000526020600020905b8154815290600101906020018083116200124557829003601f168201915b50505091909252505081516040516389cd985560e01b81526001600160a01b038083166004830152600060248301529394509092851691506389cd985590604401600060405180830381600087803b158015620012bf57600080fd5b505af1158015620012d4573d6000803e3d6000fd5b505050506001600160a01b0381166000908152606b60209081526040808320805482518185028101850190935280835291929091908301828280156200134457602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162001325575b5050505050905060005b81518110156200142a57826001600160a01b031682828151811062001377576200137762002fb1565b60200260200101516001600160a01b031603156200142157846001600160a01b03166389cd9855838381518110620013b357620013b362002fb1565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260006024820152604401600060405180830381600087803b1580156200140757600080fd5b505af11580156200141c573d6000803e3d6000fd5b505050505b6001016200134e565b50604051630adccee560e31b81526001600160a01b038516906356e67728906200145b908e908e90600401620030bf565b600060405180830381600087803b1580156200147657600080fd5b505af11580156200148b573d6000803e3d6000fd5b50959a505050505050505050505095945050505050565b620014ac62002205565b606e91909155606f55565b620014c162002205565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b6200152d62002205565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064016200084c565b60006200157562002205565b60008290506000816001600160a01b031663ef01df4f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620015bb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015e1919062002de3565b6001600160a01b038181166000908152606960205260409081902054905163033e92d960e31b815290821660048201529192508316906319f496c890602401600060405180830381600087803b1580156200163b57600080fd5b505af115801562001650573d6000803e3d6000fd5b505050506000826001600160a01b031663ef01df4f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001695573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016bb919062002de3565b9050816001600160a01b0316816001600160a01b0316141593505050505b919050565b6001600160a01b0381811660009081526069602052604081205490911662001707578162001723565b6001600160a01b03808316600090815260696020526040902054165b92915050565b6200173362002205565b6040518060400160405280846001600160a01b0316815260200183838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093909452505060ff87168152606860209081526040909120835181546001600160a01b0319166001600160a01b0390911617815590830151909150600182019062001053908262003158565b620017d562002205565b6001600160a01b03918216600090815260676020526040902080546001600160a01b03191691909216179055565b60ff81166000908152606860209081526040808320815180830190925280546001600160a01b031682526001810180546060948694939290840191620018499062003083565b80601f0160208091040260200160405190810160405280929190818152602001828054620018779062003083565b8015620018c85780601f106200189c57610100808354040283529160200191620018c8565b820191906000526020600020905b815481529060010190602001808311620018aa57829003601f168201915b50505091909252505081519192506060916001600160a01b03169050620018f257600081620018fa565b815160208301515b935093505050915091565b6200190f62002205565b826200195e5760405162461bcd60e51b815260206004820152601e60248201527f4e6f2074617267657420616464726573736573207370656369666965642e000060448201526064016200084c565b60005b8381101562000da457620019bc83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525089925088915085905081811062000d735762000d7362002fb1565b5060010162001961565b6001600160a01b03818116600090815260676020526040812054909116620019ef578162001723565b506001600160a01b039081166000908152606760205260409020541690565b6001600160a01b0381166000908152606a602090815260409182902080548351818402810184019094528084526060939283018282801562000bf2576020028201919060005260206000209081546001600160a01b0316815260019091019060200180831162000bd35750505050509050919050565b60408051600481526024810182526020810180516001600160e01b0316635fe3b56760e01b179052905160009182918291339162001ac3919062003225565b600060405180830381855afa9150503d806000811462001b00576040519150601f19603f3d011682016040523d82523d6000602084013e62001b05565b606091505b509150915081801562001b19575080516020145b1562001b7b5760008180602001905181019062001b37919062002de3565b6001600160a01b03811660009081526066602052604081205491925081131562001b6357949350505050565b600081121562001b7857600094505050505090565b50505b6070549250505090565b606c54604051631beb2b9760e31b81526001600160a01b038681166004830152858116602483015284811660448301526001600160e01b031984166064830152600092169063df595cb890608401602060405180830381865afa15801562001bf1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001c17919062003243565b90505b949350505050565b62001c2c62002205565b670de0b6b3a764000081111562001c575760405162461bcd60e51b81526004016200084c9062002d61565b607055565b62001c6662002205565b6001600160a01b0383166000908152606a6020526040902062001c8b90838362002790565b50505050565b62001c9b62002205565b6001600160a01b0383166000908152606b6020526040902062001c8b90838362002790565b62001cca62002205565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633148062001df657600062001d7b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031690565b90506001600160a01b03811633148062001df35760405162461bcd60e51b815260206004820152603260248201527f4f776e61626c653a2063616c6c6572206973206e65697468657220746865206f6044820152713bb732b9103737b9103a34329030b236b4b760711b60648201526084016200084c565b50505b50606c80546001600160a01b0319166001600160a01b0392909216919091179055565b62001e2362002205565b6000816001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801562001e64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262001e8e919081019062003274565b9050816001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801562001ecc57600080fd5b505af115801562001ee1573d6000803e3d6000fd5b5050505060005b81518160ff16101562000ee357818160ff168151811062001f0d5762001f0d62002fb1565b60200260200101516001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801562001f5057600080fd5b505af115801562001f65573d6000803e3d6000fd5b50505050808062001f76906200333b565b91505062001ee8565b6065546001600160a01b0316331462001fd35760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b60448201526064016200084c565b600062001fe86033546001600160a01b031690565b6065549091506001600160a01b031662002002816200240e565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910162001517565b606a602052816000526040600020818154811062000c5357600080fd5b600054610100900460ff1615808015620020d75750600054600160ff909116105b80620020f35750303b158015620020f3575060005460ff166001145b620021585760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016200084c565b6000805460ff1916600117905580156200217c576000805461ff0019166101001790555b670de0b6b3a7640000821115620021a75760405162461bcd60e51b81526004016200084c9062002d61565b620021b23362002460565b6070829055600019606f55801562002201576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200162001517565b5050565b6033546001600160a01b03163314620022615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016200084c565b565b6060620022a9838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c656400008152506200249f565b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905262000ee390849062002582565b600083471015620023585760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064016200084c565b8151600003620023ab5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016200084c565b8282516020840186f590506001600160a01b038116620022a95760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016200084c565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166200248a5760405162461bcd60e51b81526004016200084c906200335d565b620024946200265b565b62000fe5816200240e565b606082471015620025025760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200084c565b600080866001600160a01b0316858760405162002520919062003225565b60006040518083038185875af1925050503d80600081146200255f576040519150601f19603f3d011682016040523d82523d6000602084013e62002564565b606091505b509150915062002577878383876200268f565b979650505050505050565b6000620025d9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200270f9092919063ffffffff16565b80519091501562000ee35780806020019051810190620025fa919062003243565b62000ee35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200084c565b600054610100900460ff16620026855760405162461bcd60e51b81526004016200084c906200335d565b6200226162002720565b6060831562002703578251600003620026fb576001600160a01b0385163b620026fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200084c565b508162001c1a565b62001c1a838362002755565b606062001c1a84846000856200249f565b600054610100900460ff166200274a5760405162461bcd60e51b81526004016200084c906200335d565b62002261336200240e565b815115620027665781518083602001fd5b8060405162461bcd60e51b81526004016200084c9190620033a8565b6120ac80620033be83390190565b828054828255906000526020600020908101928215620027e6579160200282015b82811115620027e65781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190620027b1565b50620027f4929150620027f8565b5090565b5b80821115620027f45760008155600101620027f9565b6001600160a01b038116811462000fe557600080fd5b600080604083850312156200283957600080fd5b823562002846816200280f565b946020939093013593505050565b6000602082840312156200286757600080fd5b8135620022a9816200280f565b6020808252825182820181905260009190848201906040850190845b81811015620028b75783516001600160a01b03168352928401929184019160010162002890565b50909695505050505050565b60008060408385031215620028d757600080fd5b8235620028e4816200280f565b91506020830135620028f6816200280f565b809150509250929050565b60008083601f8401126200291457600080fd5b50813567ffffffffffffffff8111156200292d57600080fd5b6020830191508360208260051b85010111156200294957600080fd5b9250929050565b600080600080604085870312156200296757600080fd5b843567ffffffffffffffff808211156200298057600080fd5b6200298e8883890162002901565b90965094506020870135915080821115620029a857600080fd5b50620029b78782880162002901565b95989497509550505050565b600080600060608486031215620029d957600080fd5b8335620029e6816200280f565b92506020840135620029f8816200280f565b9150604084013562002a0a816200280f565b809150509250925092565b60ff8116811462000fe557600080fd5b60008083601f84011262002a3857600080fd5b50813567ffffffffffffffff81111562002a5157600080fd5b6020830191508360208285010111156200294957600080fd5b60008060008060006060868803121562002a8357600080fd5b853562002a908162002a15565b9450602086013567ffffffffffffffff8082111562002aae57600080fd5b62002abc89838a0162002a25565b9096509450604088013591508082111562002ad657600080fd5b5062002ae58882890162002a25565b969995985093965092949392505050565b6000806040838503121562002b0a57600080fd5b50508035926020909101359150565b6000806000806060858703121562002b3057600080fd5b843562002b3d8162002a15565b9350602085013562002b4f816200280f565b9250604085013567ffffffffffffffff81111562002b6c57600080fd5b620029b78782880162002a25565b60006020828403121562002b8d57600080fd5b8135620022a98162002a15565b60005b8381101562002bb757818101518382015260200162002b9d565b50506000910152565b6000815180845262002bda81602086016020860162002b9a565b601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009062001c1a9083018462002bc0565b6000806000806040858703121562002c2b57600080fd5b843567ffffffffffffffff8082111562002c4457600080fd5b62002c528883890162002901565b9096509450602087013591508082111562002c6c57600080fd5b50620029b78782880162002a25565b6000806000806080858703121562002c9257600080fd5b843562002c9f816200280f565b9350602085013562002cb1816200280f565b9250604085013562002cc3816200280f565b915060608501356001600160e01b03198116811462002ce157600080fd5b939692955090935050565b60006020828403121562002cff57600080fd5b5035919050565b60008060006040848603121562002d1c57600080fd5b833562002d29816200280f565b9250602084013567ffffffffffffffff81111562002d4657600080fd5b62002d548682870162002901565b9497909650939450505050565b6020808252602b908201527f496e7465726573742066656520726174652063616e6e6f74206265206d6f726560408201526a103a3430b710189818129760a91b606082015260800190565b6000806000806080858703121562002dc357600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121562002df657600080fd5b8151620022a9816200280f565b60006020828403121562002e1657600080fd5b5051919050565b60006020828403121562002e3057600080fd5b8151620022a98162002a15565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111562002e9457816000190482111562002e785762002e7862002e3d565b8085161562002e8657918102915b93841c939080029062002e58565b509250929050565b60008262002ead5750600162001723565b8162002ebc5750600062001723565b816001811462002ed5576002811462002ee05762002f00565b600191505062001723565b60ff84111562002ef45762002ef462002e3d565b50506001821b62001723565b5060208310610133831016604e8410600b841016171562002f25575081810a62001723565b62002f31838362002e53565b806000190482111562002f485762002f4862002e3d565b029392505050565b6000620022a9838362002e9c565b808202811582820484141762001723576200172362002e3d565b60008262002f9657634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111562001723576200172362002e3d565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811262002fdf57600080fd5b83018035915067ffffffffffffffff82111562002ffb57600080fd5b6020019150368190038213156200294957600080fd5b600080858511156200302257600080fd5b838611156200303057600080fd5b5050820193919092039150565b60006001820162003052576200305262002e3d565b5060010190565b600084516200306d81846020890162002b9a565b8201838582376000930192835250909392505050565b600181811c908216806200309857607f821691505b602082108103620030b957634e487b7160e01b600052602260045260246000fd5b50919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b634e487b7160e01b600052604160045260246000fd5b601f82111562000ee3576000816000526020600020601f850160051c810160208610156200312f5750805b601f850160051c820191505b8181101562003150578281556001016200313b565b505050505050565b815167ffffffffffffffff811115620031755762003175620030ee565b6200318d8162003186845462003083565b8462003104565b602080601f831160018114620031c55760008415620031ac5750858301515b600019600386901b1c1916600185901b17855562003150565b600085815260208120601f198616915b82811015620031f657888601518255948401946001909101908401620031d5565b5085821015620032155787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082516200323981846020870162002b9a565b9190910192915050565b6000602082840312156200325657600080fd5b81518015158114620022a957600080fd5b8051620016d9816200280f565b600060208083850312156200328857600080fd5b825167ffffffffffffffff80821115620032a157600080fd5b818501915085601f830112620032b657600080fd5b815181811115620032cb57620032cb620030ee565b8060051b604051601f19603f83011681018181108582111715620032f357620032f3620030ee565b6040529182528482019250838101850191888311156200331257600080fd5b938501935b8285101562000b7a576200332b8562003267565b8452938501939285019262003317565b600060ff821660ff810362003354576200335462002e3d565b60010192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b602081526000620022a9602083018462002bc056fe60806040523480156200001157600080fd5b50604051620020ac380380620020ac8339810160408190526200003491620005f7565b336001600160a01b038716146200007b5760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064015b60405180910390fd5b6000886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000e29190620006ca565b600080546001600160a01b0319166001600160a01b038a8116919091179091556702c68af0bb14000060055560038054610100600160a81b0319166101008c84160217905543600955670de0b6b3a7640000600a55604080516310c8fc9560e11b8152905192935090881691632191f92a916004808201926020929091908290030181865afa1580156200017a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a09190620006f6565b620001d85760405162461bcd60e51b8152602060048201526007602482015266216e6f7449726d60c81b604482015260640162000072565b600480546001600160a01b0319166001600160a01b038816908117909155604080516000815260208101929092527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926910160405180910390a160016200023f8682620007ab565b5060026200024e8582620007ab565b506003805460ff191660ff8316179055600754600654670de0b6b3a764000091906200027b908662000877565b62000287919062000877565b1115620002c15760405162461bcd60e51b8152602060048201526007602482015266085c998e9cd95d60ca1b604482015260640162000072565b60088390556040805160008152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460910160405180910390a16000198203620003105760065491505b60008060009054906101000a90046001600160a01b03166001600160a01b031663dd86fea16040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000365573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200038b91906200089f565b9050670de0b6b3a76400008184600854620003a7919062000877565b620003b3919062000877565b1115620003f35760405162461bcd60e51b815260206004820152600d60248201526c0858591b5a5b9199594e9cd95d609a1b604482015260640162000072565b60068390556040805160008152602081018590527fcdd0b588250e1398549f79cfdb8217c186688822905d6715b0834ea1c865594a910160405180910390a160078190556040805160008152602081018390527fedec4b9c99c2cdb231e7fd036f861e0445b015916700f41b9835f984cb9be4cb910160405180910390a1506000805460ff60a01b1916600160a01b179055601380546001600160a01b038b166001600160a01b03199091168117909155604080516318160ddd60e01b815290516318160ddd916004808201926020929091908290030181865afa158015620004e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200050691906200089f565b50505050505050505050620008b9565b6001600160a01b03811681146200052c57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200055757600080fd5b81516001600160401b03808211156200057457620005746200052f565b604051601f8301601f19908116603f011681019082821181831017156200059f576200059f6200052f565b8160405283815260209250866020858801011115620005bd57600080fd5b600091505b83821015620005e15785820183015181830184015290820190620005c2565b6000602085830101528094505050505092915050565b600080600080600080600080610100898b0312156200061557600080fd5b8851620006228162000516565b60208a0151909850620006358162000516565b60408a0151909750620006488162000516565b60608a01519096506200065b8162000516565b60808a01519095506001600160401b03808211156200067957600080fd5b620006878c838d0162000545565b955060a08b01519150808211156200069e57600080fd5b50620006ad8b828c0162000545565b60c08b015160e0909b0151999c989b509699959894979350505050565b600060208284031215620006dd57600080fd5b815160ff81168114620006ef57600080fd5b9392505050565b6000602082840312156200070957600080fd5b81518015158114620006ef57600080fd5b600181811c908216806200072f57607f821691505b6020821081036200075057634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620007a6576000816000526020600020601f850160051c81016020861015620007815750805b601f850160051c820191505b81811015620007a2578281556001016200078d565b5050505b505050565b81516001600160401b03811115620007c757620007c76200052f565b620007df81620007d884546200071a565b8462000756565b602080601f831160018114620008175760008415620007fe5750858301515b600019600386901b1c1916600185901b178555620007a2565b600085815260208120601f198616915b82811015620008485788860151825594840194600190910190840162000827565b5085821015620008675787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200089957634e487b7160e01b600052601160045260246000fd5b92915050565b600060208284031215620008b257600080fd5b5051919050565b6117e380620008c96000396000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c80636f307dc3116100de578063aa5af0fd11610097578063c3bf11cd11610071578063c3bf11cd1461033b578063c91a424f14610344578063e207afe214610357578063f3fdb15a1461036a57610173565b8063aa5af0fd1461031b578063ba49f54a14610324578063be99f1191461032c57610173565b80636f307dc3146102d257806389cd9855146102e55780638d02d9a1146102f85780638f840ddd1461030157806395d89b411461030a5780639826394b1461031257610173565b80635c60da1b116101305780635c60da1b1461027d5780635fe3b5671461028557806361feacff1461029d5780636333d001146102a65780636752e702146102bb5780636c540baf146102c957610173565b806306fdde03146101ec578063173b99041461020a57806318160ddd14610221578063313ce5671461022a5780633c4f743c1461024957806347bd371814610274575b600061018a6000356001600160e01b03191661037d565b90506001600160a01b0381166101c657604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156101e5573d6000f35b3d6000fd5b005b6101f461039d565b604051610201919061129c565b60405180910390f35b61021360085481565b604051908152602001610201565b610213600f5481565b6003546102379060ff1681565b60405160ff9091168152602001610201565b60145461025c906001600160a01b031681565b6040516001600160a01b039091168152602001610201565b610213600b5481565b61025c61042b565b60035461025c9061010090046001600160a01b031681565b610213600d5481565b6102ae610481565b60405161020191906112b6565b610213666379da05b6000081565b61021360095481565b60135461025c906001600160a01b031681565b6101ea6102f336600461131b565b61048b565b61021360065481565b610213600c5481565b6101f46104e3565b610213600e5481565b610213600a5481565b6101ea6104f0565b61021367016345785d8a000081565b61021360075481565b60005461025c906001600160a01b031681565b6101ea610365366004611354565b6106d5565b60045461025c906001600160a01b031681565b60006103978260008051602061178e833981519152610757565b92915050565b600180546103aa906113d9565b80601f01602080910402602001604051908101604052809291908181526020018280546103d6906113d9565b80156104235780601f106103f857610100808354040283529160200191610423565b820191906000526020600020905b81548152906001019060200180831161040657829003601f168201915b505050505081565b60408051808201909152600e81526d64656c656761746554797065282960901b602090910152600061047c7f2c436e5bba88e403c36d7a2822cd2b39b360d5c6296839bbf72c5a05167fd3ff61037d565b905090565b606061047c6107f2565b6000546001600160a01b031633146104d55760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b60448201526064016101bd565b6104df8282610864565b5050565b600280546103aa906113d9565b333014806105015750610501610885565b61053e5760405162461bcd60e51b815260206004820152600e60248201526d10b9b2b6331037b91030b236b4b760911b60448201526064016101bd565b60408051600481526024810182526020810180516001600160e01b0316632c436e5b60e01b17905290516000918291309161057891611413565b600060405180830381855afa9150503d80600081146105b3576040519150601f19603f3d011682016040523d82523d6000602084013e6105b8565b606091505b5091509150816105fd5760405162461bcd60e51b815260206004820152601060248201526f6e6f2064656c6567617465207479706560801b60448201526064016101bd565b600081806020019051810190610613919061142f565b60008054604051632aa1058760e21b815260ff84166004820152929350909182916001600160a01b03169063aa84161c90602401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c9190810190611499565b91509150600061069a61042b565b9050826001600160a01b0316816001600160a01b0316146106c4576106bf8383610a02565b6106cd565b6106cd81610ada565b505050505050565b6106dd610885565b6107125760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064016101bd565b6107528383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610a0292505050565b505050565b8054600090815b818110156107e757846001600160e01b03191684600001828154811061078657610786611543565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036107df578360000181815481106107c0576107c0611543565b6000918252602090912001546001600160a01b03169250610397915050565b60010161075e565b506000949350505050565b606060008051602061178e83398151915260010180548060200260200160405190810160405280929190818152602001828054801561085a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161083c575b5050505050905090565b6001600160a01b0381161561087c5761087c81610bce565b6104df82610cfd565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109029190611559565b6001600160a01b0316336001600160a01b031614801561097f5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561095b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097f9190611576565b806109fc57506000546001600160a01b0316331480156109fc5750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fc9190611576565b91505090565b6000610a0c61042b565b9050610a1783610ada565b610a91306356e6772860e01b84604051602401610a34919061129c565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280600c81526020016b08589958dbdb59481a5b5c1b60a21b815250610df4565b50604080516001600160a01b038084168252851660208201527fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a910160405180910390a1505050565b600080546040516311a0e21760e01b81526001600160a01b038481166004830152909116906311a0e21790602401600060405180830381865afa158015610b25573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b4d91908101906115bc565b90506000610b596107f2565b905060005b8151811015610b9157610b89828281518110610b7c57610b7c611543565b6020026020010151610bce565b600101610b5e565b5060005b8251811015610bc857610bc0838281518110610bb357610bb3611543565b6020026020010151610cfd565b600101610b95565b50505050565b60008051602061178e833981519152610be682610e90565b60005b600182015460ff8216101561075257826001600160a01b0316826001018260ff1681548110610c1a57610c1a611543565b6000918252602090912001546001600160a01b031603610ceb57600180830180549091610c4691611671565b81548110610c5657610c56611543565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610c8757610c87611543565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610cc857610cc8611684565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610cf58161169a565b915050610be9565b60008051602061178e83398151915260005b600182015460ff82161015610db457826001600160a01b0316826001018260ff1681548110610d4057610d40611543565b6000918252602090912001546001600160a01b031603610da25760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016101bd565b80610dac8161169a565b915050610d0f565b50610dbe8261104f565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b031685604051610e119190611413565b6000604051808303816000865af19150503d8060008114610e4e576040519150601f19603f3d011682016040523d82523d6000602084013e610e53565b606091505b509150915081610e8757805115610e6d5780518082602001fd5b8360405162461bcd60e51b81526004016101bd919061129c565b95945050505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ed0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ef891908101906116b9565b905060008051602061178e83398151915260005b82518161ffff161015610bc8576000838261ffff1681518110610f3157610f31611543565b60200260200101519050610f458184610757565b6001600160a01b0316856001600160a01b031614610f6557610f65611756565b6000610f7182856111cf565b84549091508490610f8490600190611671565b81548110610f9457610f94611543565b90600052602060002001846000018261ffff1681548110610fb757610fb7611543565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff16909102179055835484908061101857611018611684565b600082815260209020810160001990810180546001600160c01b0319169055019055508190506110478161176c565b915050610f0c565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561108f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110b791908101906116b9565b60008051602061178e83398151915280549192509060005b83518110156111c85760008482815181106110ec576110ec611543565b6020026020010151905060006111028286610757565b90506001600160a01b0381161561114757604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016101bd565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836111b78161176c565b945050600190920191506110cf9050565b5050505050565b8054600090815b8161ffff168161ffff16101561124057846001600160e01b031916846000018261ffff168154811061120a5761120a611543565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036112385791506103979050565b6001016111d6565b5061ffff949350505050565b60005b8381101561126757818101518382015260200161124f565b50506000910152565b6000815180845261128881602086016020860161124c565b601f01601f19169290920160200192915050565b6020815260006112af6020830184611270565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156112f75783516001600160a01b0316835292840192918401916001016112d2565b50909695505050505050565b6001600160a01b038116811461131857600080fd5b50565b6000806040838503121561132e57600080fd5b823561133981611303565b9150602083013561134981611303565b809150509250929050565b60008060006040848603121561136957600080fd5b833561137481611303565b9250602084013567ffffffffffffffff8082111561139157600080fd5b818601915086601f8301126113a557600080fd5b8135818111156113b457600080fd5b8760208285010111156113c657600080fd5b6020830194508093505050509250925092565b600181811c908216806113ed57607f821691505b60208210810361140d57634e487b7160e01b600052602260045260246000fd5b50919050565b6000825161142581846020870161124c565b9190910192915050565b60006020828403121561144157600080fd5b815160ff811681146112af57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561149157611491611452565b604052919050565b600080604083850312156114ac57600080fd5b82516114b781611303565b602084015190925067ffffffffffffffff808211156114d557600080fd5b818501915085601f8301126114e957600080fd5b8151818111156114fb576114fb611452565b61150e601f8201601f1916602001611468565b915080825286602082850101111561152557600080fd5b61153681602084016020860161124c565b5080925050509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561156b57600080fd5b81516112af81611303565b60006020828403121561158857600080fd5b815180151581146112af57600080fd5b600067ffffffffffffffff8211156115b2576115b2611452565b5060051b60200190565b600060208083850312156115cf57600080fd5b825167ffffffffffffffff8111156115e657600080fd5b8301601f810185136115f757600080fd5b805161160a61160582611598565b611468565b81815260059190911b8201830190838101908783111561162957600080fd5b928401925b8284101561165057835161164181611303565b8252928401929084019061162e565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156103975761039761165b565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff81036116b0576116b061165b565b60010192915050565b600060208083850312156116cc57600080fd5b825167ffffffffffffffff8111156116e357600080fd5b8301601f810185136116f457600080fd5b805161170261160582611598565b81815260059190911b8201830190838101908783111561172157600080fd5b928401925b828410156116505783516001600160e01b0319811681146117475760008081fd5b82529284019290840190611726565b634e487b7160e01b600052600160045260246000fd5b600061ffff8083168181036117835761178361165b565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a26469706673582212202b3a4905878ec4941d46ab71c8a44c155d4ee381195d800391967da531df697264736f6c63430008160033a2646970667358221220414bf225b2c4e4e2fee5ad9baf99c038189835fe2e78ef4e7d7b908e86ad3aa564736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_acceptOwner()": { + "details": "Owner function for pending owner to accept role and update owner" + }, + "_callPool(address[],bytes)": { + "details": "Sends data to a contract.", + "params": { + "data": "The data to be sent to each of `targets`.", + "targets": "The contracts to which `data` will be sent." + } + }, + "_callPool(address[],bytes[])": { + "details": "Sends data to a contract.", + "params": { + "data": "The data to be sent to each of `targets`.", + "targets": "The contracts to which `data` will be sent." + } + }, + "_setCustomInterestFeeRate(address,int256)": { + "details": "Sets the proportion of Ionic pool interest taken as a protocol fee.", + "params": { + "comptroller": "The Unitroller (Comptroller proxy) address.", + "rate": "The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + } + }, + "_setDefaultInterestFeeRate(uint256)": { + "details": "Sets the default proportion of Ionic pool interest taken as a protocol fee.", + "params": { + "_defaultInterestFeeRate": "The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + } + }, + "_setLatestCErc20Delegate(uint8,address,bytes)": { + "details": "Sets the latest `CErc20Delegate` upgrade implementation address and data.", + "params": { + "becomeImplementationData": "Data passed to the new implementation via `becomeImplementation` after upgrade.", + "delegateType": "The old `CErc20Delegate` implementation address to upgrade from.", + "newImplementation": "Latest `CErc20Delegate` implementation address." + } + }, + "_setLatestComptrollerImplementation(address,address)": { + "details": "Sets the latest `Comptroller` upgrade implementation address.", + "params": { + "newImplementation": "Latest `Comptroller` implementation address.", + "oldImplementation": "The old `Comptroller` implementation address to upgrade from." + } + }, + "_setLatestPluginImplementation(address,address)": { + "details": "Sets the latest plugin upgrade implementation address.", + "params": { + "newImplementation": "Latest plugin implementation address.", + "oldImplementation": "The old plugin implementation address to upgrade from." + } + }, + "_setPendingOwner(address)": { + "details": "Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.", + "params": { + "newPendingOwner": "New pending owner." + } + }, + "_setPoolLimits(uint256,uint256)": { + "details": "Sets the proportion of Ionic pool interest taken as a protocol fee.", + "params": { + "_maxUtilizationRate": "Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).", + "_minBorrowEth": "Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions)." + } + }, + "_upgradePluginToLatestImplementation(address)": { + "details": "Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation", + "params": { + "cDelegator": "the proxy address" + }, + "returns": { + "_0": "if the plugin was upgraded or not" + } + }, + "_withdrawAssets(address)": { + "details": "Withdraws accrued fees on interest.", + "params": { + "erc20Contract": "The ERC20 token address to withdraw. Set to the zero address to withdraw ETH." + } + }, + "deployCErc20(uint8,bytes,bytes)": { + "details": "Deploys a CToken for an underlying ERC20", + "params": { + "constructorData": "Encoded construction data for `CToken initialize()`" + } + }, + "initialize(uint256)": { + "details": "Initializer that sets initial values of state variables.", + "params": { + "_defaultInterestFeeRate": "The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + } + }, + "latestCErc20Delegate(uint8)": { + "details": "Latest CErc20Delegate implementation for each existing implementation." + }, + "latestComptrollerImplementation(address)": { + "details": "Latest Comptroller implementation for each existing implementation." + }, + "latestPluginImplementation(address)": { + "details": "Latest Plugin implementation for each existing implementation." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "FeeDistributor", + "version": 1 + }, + "userdoc": { + "events": { + "NewOwner(address,address)": { + "notice": "Emitted when pendingOwner is accepted, which means owner is updated" + }, + "NewPendingOwner(address,address)": { + "notice": "Emitted when pendingOwner is changed" + } + }, + "kind": "user", + "methods": { + "_acceptOwner()": { + "notice": "Accepts transfer of owner rights. msg.sender must be pendingOwner" + }, + "_setPendingOwner(address)": { + "notice": "Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer." + }, + "customInterestFeeRates(address)": { + "notice": "Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + }, + "defaultInterestFeeRate()": { + "notice": "The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + }, + "interestFeeRate()": { + "notice": "Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18)." + }, + "pendingOwner()": { + "notice": "Pending owner of this contract" + } + }, + "notice": "FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 128290, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 128293, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 130641, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 127994, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 128114, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 40386, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 2438, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "customInterestFeeRates", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_address,t_int256)" + }, + { + "astId": 2443, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_latestComptrollerImplementation", + "offset": 0, + "slot": "103", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 2449, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_latestCErc20Delegate", + "offset": 0, + "slot": "104", + "type": "t_mapping(t_uint8,t_struct(CDelegateUpgradeData)2433_storage)" + }, + { + "astId": 2454, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "_latestPluginImplementation", + "offset": 0, + "slot": "105", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 2460, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "comptrollerExtensions", + "offset": 0, + "slot": "106", + "type": "t_mapping(t_address,t_array(t_contract(DiamondExtension)38850)dyn_storage)" + }, + { + "astId": 2466, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "cErc20DelegateExtensions", + "offset": 0, + "slot": "107", + "type": "t_mapping(t_address,t_array(t_contract(DiamondExtension)38850)dyn_storage)" + }, + { + "astId": 2469, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "authoritiesRegistry", + "offset": 0, + "slot": "108", + "type": "t_contract(AuthoritiesRegistry)38315" + }, + { + "astId": 2472, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "marketsCounter", + "offset": 0, + "slot": "109", + "type": "t_uint256" + }, + { + "astId": 2475, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "minBorrowEth", + "offset": 0, + "slot": "110", + "type": "t_uint256" + }, + { + "astId": 2478, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "maxUtilizationRate", + "offset": 0, + "slot": "111", + "type": "t_uint256" + }, + { + "astId": 2481, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "defaultInterestFeeRate", + "offset": 0, + "slot": "112", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_contract(DiamondExtension)38850)dyn_storage": { + "base": "t_contract(DiamondExtension)38850", + "encoding": "dynamic_array", + "label": "contract DiamondExtension[]", + "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_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes_storage": { + "encoding": "bytes", + "label": "bytes", + "numberOfBytes": "32" + }, + "t_contract(AuthoritiesRegistry)38315": { + "encoding": "inplace", + "label": "contract AuthoritiesRegistry", + "numberOfBytes": "20" + }, + "t_contract(DiamondExtension)38850": { + "encoding": "inplace", + "label": "contract DiamondExtension", + "numberOfBytes": "20" + }, + "t_int256": { + "encoding": "inplace", + "label": "int256", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_array(t_contract(DiamondExtension)38850)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract DiamondExtension[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(DiamondExtension)38850)dyn_storage" + }, + "t_mapping(t_address,t_int256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => int256)", + "numberOfBytes": "32", + "value": "t_int256" + }, + "t_mapping(t_uint8,t_struct(CDelegateUpgradeData)2433_storage)": { + "encoding": "mapping", + "key": "t_uint8", + "label": "mapping(uint8 => struct FeeDistributorStorage.CDelegateUpgradeData)", + "numberOfBytes": "32", + "value": "t_struct(CDelegateUpgradeData)2433_storage" + }, + "t_struct(CDelegateUpgradeData)2433_storage": { + "encoding": "inplace", + "label": "struct FeeDistributorStorage.CDelegateUpgradeData", + "members": [ + { + "astId": 2430, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "implementation", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2432, + "contract": "contracts/FeeDistributor.sol:FeeDistributor", + "label": "becomeImplementationData", + "offset": 0, + "slot": "1", + "type": "t_bytes_storage" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/FeeDistributor_Proxy.json b/packages/contracts/deployments/superseed/FeeDistributor_Proxy.json new file mode 100644 index 0000000000..ba94be459c --- /dev/null +++ b/packages/contracts/deployments/superseed/FeeDistributor_Proxy.json @@ -0,0 +1,275 @@ +{ + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "transactionIndex": 1, + "gasUsed": "816791", + "logsBloom": "0x00000000000000000020000000000000400000000000000000800000000200020000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000100000400000000000001000000040000000000000000000000080000000000000c00000000000000000000000000000010400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc", + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000141ed81ba9f0a70b03ff545711c931e69dab1b7b" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + }, + { + "transactionIndex": 1, + "blockNumber": 3212544, + "transactionHash": "0x89d3dc1db0768432e41874c9e5832c59067a07febc86833247b15f933d3ba098", + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x062aa5266f403bc72ac792ac6e71c8b015843a40742973a3e6aeb53c5b8348cc" + } + ], + "blockNumber": 3212544, + "cumulativeGasUsed": "860681", + "status": 1, + "byzantium": true + }, + "args": [ + "0x141eD81BA9f0a70B03FF545711C931E69DAb1b7B", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xfe4b84df000000000000000000000000000000000000000000000000016345785d8a0000" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/FixedNativePriceOracle.json b/packages/contracts/deployments/superseed/FixedNativePriceOracle.json new file mode 100644 index 0000000000..59257f1314 --- /dev/null +++ b/packages/contracts/deployments/superseed/FixedNativePriceOracle.json @@ -0,0 +1,97 @@ +{ + "address": "0x431C87E08e2636733a945D742d25Ba77577ED480", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underlying", + "type": "address" + } + ], + "name": "price", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xe97c2f53d60ddb60803b1935cc0b4e8729f52843f20d28f3c74d481bdb902585", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x431C87E08e2636733a945D742d25Ba77577ED480", + "transactionIndex": 1, + "gasUsed": "98137", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x53e0e565836dbe08ef71a43b4f89c3ebb6bd2c041a07d3e2534076e7145164bd", + "transactionHash": "0xe97c2f53d60ddb60803b1935cc0b4e8729f52843f20d28f3c74d481bdb902585", + "logs": [], + "blockNumber": 4135326, + "cumulativeGasUsed": "142015", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"underlying\",\"type\":\"address\"}],\"name\":\"price\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"details\":\"Implements `PriceOracle` and `BasePriceOracle`.\",\"kind\":\"dev\",\"methods\":{\"getUnderlyingPrice(address)\":{\"details\":\"Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\",\"returns\":{\"_0\":\"Price in native token of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\"}},\"price(address)\":{\"details\":\"Returns the price in native token of `underlying` (implements `BasePriceOracle`).\"}},\"title\":\"FixedEthPriceOracle\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getUnderlyingPrice(address)\":{\"notice\":\"Returns the price in native token of the token underlying `cToken`.\"}},\"notice\":\"Returns fixed prices of 1 denominated in the chain's native token for all tokens (expected to be used under a `MasterPriceOracle`).\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/default/FixedNativePriceOracle.sol\":\"FixedNativePriceOracle\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/default/FixedNativePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport \\\"../BasePriceOracle.sol\\\";\\n\\n/**\\n * @title FixedEthPriceOracle\\n * @notice Returns fixed prices of 1 denominated in the chain's native token for all tokens (expected to be used under a `MasterPriceOracle`).\\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract FixedNativePriceOracle is BasePriceOracle {\\n /**\\n * @dev Returns the price in native token of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) external view override returns (uint256) {\\n return 1e18;\\n }\\n\\n /**\\n * @notice Returns the price in native token of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in native token of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n return 1e18;\\n }\\n}\\n\",\"keccak256\":\"0x8c03761765330065bd349ba59bb607a0e8d93c6afa4858ee2dca8ce9aaecdff9\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5060cf8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063aea91078146037578063fc57d4df146037575b600080fd5b604f60423660046078565b50670de0b6b3a764000090565b60405190815260200160405180910390f35b6001600160a01b0381168114607557600080fd5b50565b600060208284031215608957600080fd5b81356092816061565b939250505056fea2646970667358221220c532fb8d537ad82d7a94d9a87d23135bcb1c1fa3c7b4d9ab153bb7d5cc1a4d3564736f6c63430008160033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c8063aea91078146037578063fc57d4df146037575b600080fd5b604f60423660046078565b50670de0b6b3a764000090565b60405190815260200160405180910390f35b6001600160a01b0381168114607557600080fd5b50565b600060208284031215608957600080fd5b81356092816061565b939250505056fea2646970667358221220c532fb8d537ad82d7a94d9a87d23135bcb1c1fa3c7b4d9ab153bb7d5cc1a4d3564736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "details": "Implements `PriceOracle` and `BasePriceOracle`.", + "kind": "dev", + "methods": { + "getUnderlyingPrice(address)": { + "details": "Implements the `PriceOracle` interface for Ionic pools (and Compound v2).", + "returns": { + "_0": "Price in native token of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`." + } + }, + "price(address)": { + "details": "Returns the price in native token of `underlying` (implements `BasePriceOracle`)." + } + }, + "title": "FixedEthPriceOracle", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getUnderlyingPrice(address)": { + "notice": "Returns the price in native token of the token underlying `cToken`." + } + }, + "notice": "Returns fixed prices of 1 denominated in the chain's native token for all tokens (expected to be used under a `MasterPriceOracle`).", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/GlobalPauser.json b/packages/contracts/deployments/superseed/GlobalPauser.json new file mode 100644 index 0000000000..445b8ac4e0 --- /dev/null +++ b/packages/contracts/deployments/superseed/GlobalPauser.json @@ -0,0 +1,289 @@ +{ + "address": "0x02140fd77e463137D41b35aec304178DbdbFA8D9", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_poolDirectory", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pauseGuardian", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolDirectory", + "outputs": [ + { + "internalType": "contract IPoolDirectory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pauseGuardian", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isPauseGuardian", + "type": "bool" + } + ], + "name": "setPauseGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xb3f8a010899d17aecf0a7462cd0c8323e38228ae2eecb1d7021181e261839aa5", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x02140fd77e463137D41b35aec304178DbdbFA8D9", + "transactionIndex": 1, + "gasUsed": "737530", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000001000000200000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000400000040000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x6d45b1a6dedb0105133f515fab570fb876561dd29075a87ee54fab72b9117375", + "transactionHash": "0xb3f8a010899d17aecf0a7462cd0c8323e38228ae2eecb1d7021181e261839aa5", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159574, + "transactionHash": "0xb3f8a010899d17aecf0a7462cd0c8323e38228ae2eecb1d7021181e261839aa5", + "address": "0x02140fd77e463137D41b35aec304178DbdbFA8D9", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x6d45b1a6dedb0105133f515fab570fb876561dd29075a87ee54fab72b9117375" + } + ], + "blockNumber": 4159574, + "cumulativeGasUsed": "781372", + "status": 1, + "byzantium": true + }, + "args": [ + "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd" + ], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolDirectory\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pauseGuardian\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolDirectory\",\"outputs\":[{\"internalType\":\"contract IPoolDirectory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pauseGuardian\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"_isPauseGuardian\",\"type\":\"bool\"}],\"name\":\"setPauseGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/GlobalPauser.sol\":\"GlobalPauser\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/GlobalPauser.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport { Ownable2Step } from \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\ninterface IPoolDirectory {\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n function getActivePools() external view returns (uint256, Pool[] memory);\\n}\\n\\ncontract GlobalPauser is Ownable2Step {\\n IPoolDirectory public poolDirectory;\\n mapping(address => bool) public pauseGuardian;\\n\\n modifier onlyPauseGuardian() {\\n require(pauseGuardian[msg.sender], \\\"!guardian\\\");\\n _;\\n }\\n\\n constructor(address _poolDirectory) Ownable2Step() {\\n poolDirectory = IPoolDirectory(_poolDirectory);\\n }\\n\\n function setPauseGuardian(address _pauseGuardian, bool _isPauseGuardian) external onlyOwner {\\n pauseGuardian[_pauseGuardian] = _isPauseGuardian;\\n }\\n\\n function pauseAll() external onlyPauseGuardian {\\n (, IPoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\\n for (uint256 i = 0; i < pools.length; i++) {\\n ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();\\n for (uint256 j = 0; j < markets.length; j++) {\\n bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));\\n if (!isPaused) {\\n IonicComptroller(pools[i].comptroller)._setBorrowPaused(markets[j], true);\\n }\\n\\n isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));\\n if (!isPaused) {\\n IonicComptroller(pools[i].comptroller)._setMintPaused(markets[j], true);\\n }\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8cf2287bac0ff71d6758dade8f4bacef0df97ad546ec3f9352c9e192412ab7f5\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051610c76380380610c7683398101604081905261002f916100c9565b6100383361005d565b600280546001600160a01b0319166001600160a01b03929092169190911790556100f9565b600180546001600160a01b031916905561007681610079565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100db57600080fd5b81516001600160a01b03811681146100f257600080fd5b9392505050565b610b6e806101086000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063715018a611610066578063715018a61461011857806379ba5097146101205780638da5cb5b14610128578063e30c397814610139578063f2fde38b1461014a57600080fd5b80633557796214610098578063364c426e146100ad578063550ddfd7146100dd578063595c6a6714610110575b600080fd5b6100ab6100a63660046107d6565b61015d565b005b6002546100c0906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101006100eb36600461080f565b60036020526000908152604090205460ff1681565b60405190151581526020016100d4565b6100ab610190565b6100ab6105f6565b6100ab61060a565b6000546001600160a01b03166100c0565b6001546001600160a01b03166100c0565b6100ab61015836600461080f565b610684565b6101656106f5565b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b3360009081526003602052604090205460ff166101e05760405162461bcd60e51b815260206004820152600960248201526810b3bab0b93234b0b760b91b60448201526064015b60405180910390fd5b600254604080516323b020d560e21b815290516000926001600160a01b031691638ec0835491600480830192869291908290030181865afa158015610229573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261025191908101906108d7565b91505060005b81518110156105f257600082828151811061027457610274610a6b565b6020026020010151604001516001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156102bd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102e59190810190610a81565b905060005b81518110156105e857600084848151811061030757610307610a6b565b6020026020010151604001516001600160a01b0316636d154ea584848151811061033357610333610a6b565b60200260200101516040518263ffffffff1660e01b815260040161036691906001600160a01b0391909116815260200190565b602060405180830381865afa158015610383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a79190610b1b565b90508061046a578484815181106103c0576103c0610a6b565b6020026020010151604001516001600160a01b03166318c882a58484815181106103ec576103ec610a6b565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b039091166004820152600160248201526044016020604051808303816000875af1158015610444573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104689190610b1b565b505b84848151811061047c5761047c610a6b565b6020026020010151604001516001600160a01b031663731f0c2b8484815181106104a8576104a8610a6b565b60200260200101516040518263ffffffff1660e01b81526004016104db91906001600160a01b0391909116815260200190565b602060405180830381865afa1580156104f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051c9190610b1b565b9050806105df5784848151811061053557610535610a6b565b6020026020010151604001516001600160a01b0316633bcf7ec184848151811061056157610561610a6b565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b039091166004820152600160248201526044016020604051808303816000875af11580156105b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105dd9190610b1b565b505b506001016102ea565b5050600101610257565b5050565b6105fe6106f5565b610608600061074f565b565b60015433906001600160a01b031681146106785760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016101d7565b6106818161074f565b50565b61068c6106f5565b600180546001600160a01b0383166001600160a01b031990911681179091556106bd6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146106085760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101d7565b600180546001600160a01b031916905561068181600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461068157600080fd5b801515811461068157600080fd5b600080604083850312156107e957600080fd5b82356107f4816107b3565b91506020830135610804816107c8565b809150509250929050565b60006020828403121561082157600080fd5b813561082c816107b3565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561086c5761086c610833565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561089b5761089b610833565b604052919050565b600067ffffffffffffffff8211156108bd576108bd610833565b5060051b60200190565b80516108d2816107b3565b919050565b600080604083850312156108ea57600080fd5b8251915060208084015167ffffffffffffffff8082111561090a57600080fd5b818601915086601f83011261091e57600080fd5b815161093161092c826108a3565b610872565b81815260059190911b8301840190848101908983111561095057600080fd5b8585015b83811015610a5a5780518581111561096b57600080fd5b8601601f1960a0828e038201121561098257600080fd5b61098a610849565b898301518881111561099b57600080fd5b8301603f81018f136109ac57600080fd5b8a810151898111156109c0576109c0610833565b6109d08c85601f84011601610872565b93508084528f60408284010111156109e757600080fd5b60005b81811015610a0657828101604001518582018e01528c016109ea565b5060009084018c015250818152610a1f604084016108c7565b8a820152610a2f606084016108c7565b6040820152608083810151606083015260a09093015192810192909252508352918601918601610954565b508096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215610a9457600080fd5b825167ffffffffffffffff811115610aab57600080fd5b8301601f81018513610abc57600080fd5b8051610aca61092c826108a3565b81815260059190911b82018301908381019087831115610ae957600080fd5b928401925b82841015610b10578351610b01816107b3565b82529284019290840190610aee565b979650505050505050565b600060208284031215610b2d57600080fd5b815161082c816107c856fea26469706673582212202b7b74d99b715ee26a39908cc4ebf482ab4bf099540d68ff6ce0b6b88564acee64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063715018a611610066578063715018a61461011857806379ba5097146101205780638da5cb5b14610128578063e30c397814610139578063f2fde38b1461014a57600080fd5b80633557796214610098578063364c426e146100ad578063550ddfd7146100dd578063595c6a6714610110575b600080fd5b6100ab6100a63660046107d6565b61015d565b005b6002546100c0906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101006100eb36600461080f565b60036020526000908152604090205460ff1681565b60405190151581526020016100d4565b6100ab610190565b6100ab6105f6565b6100ab61060a565b6000546001600160a01b03166100c0565b6001546001600160a01b03166100c0565b6100ab61015836600461080f565b610684565b6101656106f5565b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b3360009081526003602052604090205460ff166101e05760405162461bcd60e51b815260206004820152600960248201526810b3bab0b93234b0b760b91b60448201526064015b60405180910390fd5b600254604080516323b020d560e21b815290516000926001600160a01b031691638ec0835491600480830192869291908290030181865afa158015610229573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261025191908101906108d7565b91505060005b81518110156105f257600082828151811061027457610274610a6b565b6020026020010151604001516001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156102bd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102e59190810190610a81565b905060005b81518110156105e857600084848151811061030757610307610a6b565b6020026020010151604001516001600160a01b0316636d154ea584848151811061033357610333610a6b565b60200260200101516040518263ffffffff1660e01b815260040161036691906001600160a01b0391909116815260200190565b602060405180830381865afa158015610383573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a79190610b1b565b90508061046a578484815181106103c0576103c0610a6b565b6020026020010151604001516001600160a01b03166318c882a58484815181106103ec576103ec610a6b565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b039091166004820152600160248201526044016020604051808303816000875af1158015610444573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104689190610b1b565b505b84848151811061047c5761047c610a6b565b6020026020010151604001516001600160a01b031663731f0c2b8484815181106104a8576104a8610a6b565b60200260200101516040518263ffffffff1660e01b81526004016104db91906001600160a01b0391909116815260200190565b602060405180830381865afa1580156104f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051c9190610b1b565b9050806105df5784848151811061053557610535610a6b565b6020026020010151604001516001600160a01b0316633bcf7ec184848151811061056157610561610a6b565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b039091166004820152600160248201526044016020604051808303816000875af11580156105b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105dd9190610b1b565b505b506001016102ea565b5050600101610257565b5050565b6105fe6106f5565b610608600061074f565b565b60015433906001600160a01b031681146106785760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016101d7565b6106818161074f565b50565b61068c6106f5565b600180546001600160a01b0383166001600160a01b031990911681179091556106bd6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146106085760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101d7565b600180546001600160a01b031916905561068181600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038116811461068157600080fd5b801515811461068157600080fd5b600080604083850312156107e957600080fd5b82356107f4816107b3565b91506020830135610804816107c8565b809150509250929050565b60006020828403121561082157600080fd5b813561082c816107b3565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561086c5761086c610833565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561089b5761089b610833565b604052919050565b600067ffffffffffffffff8211156108bd576108bd610833565b5060051b60200190565b80516108d2816107b3565b919050565b600080604083850312156108ea57600080fd5b8251915060208084015167ffffffffffffffff8082111561090a57600080fd5b818601915086601f83011261091e57600080fd5b815161093161092c826108a3565b610872565b81815260059190911b8301840190848101908983111561095057600080fd5b8585015b83811015610a5a5780518581111561096b57600080fd5b8601601f1960a0828e038201121561098257600080fd5b61098a610849565b898301518881111561099b57600080fd5b8301603f81018f136109ac57600080fd5b8a810151898111156109c0576109c0610833565b6109d08c85601f84011601610872565b93508084528f60408284010111156109e757600080fd5b60005b81811015610a0657828101604001518582018e01528c016109ea565b5060009084018c015250818152610a1f604084016108c7565b8a820152610a2f606084016108c7565b6040820152608083810151606083015260a09093015192810192909252508352918601918601610954565b508096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215610a9457600080fd5b825167ffffffffffffffff811115610aab57600080fd5b8301601f81018513610abc57600080fd5b8051610aca61092c826108a3565b81815260059190911b82018301908381019087831115610ae957600080fd5b928401925b82841015610b10578351610b01816107b3565b82529284019290840190610aee565b979650505050505050565b600060208284031215610b2d57600080fd5b815161082c816107c856fea26469706673582212202b7b74d99b715ee26a39908cc4ebf482ab4bf099540d68ff6ce0b6b88564acee64736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2741, + "contract": "contracts/GlobalPauser.sol:GlobalPauser", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2854, + "contract": "contracts/GlobalPauser.sol:GlobalPauser", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 9530, + "contract": "contracts/GlobalPauser.sol:GlobalPauser", + "label": "poolDirectory", + "offset": 0, + "slot": "2", + "type": "t_contract(IPoolDirectory)9525" + }, + { + "astId": 9534, + "contract": "contracts/GlobalPauser.sol:GlobalPauser", + "label": "pauseGuardian", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IPoolDirectory)9525": { + "encoding": "inplace", + "label": "contract IPoolDirectory", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/IonicFlywheelLensRouter.json b/packages/contracts/deployments/superseed/IonicFlywheelLensRouter.json new file mode 100644 index 0000000000..0142d9a69c --- /dev/null +++ b/packages/contracts/deployments/superseed/IonicFlywheelLensRouter.json @@ -0,0 +1,449 @@ +{ + "address": "0x7AABEfD7d8d2576Dc932EbE97bE8Ba90299a4ee4", + "abi": [ + { + "inputs": [ + { + "internalType": "contract PoolDirectory", + "name": "_fpd", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "claimAllRewardTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "contract ERC20", + "name": "market", + "type": "address" + }, + { + "internalType": "contract IonicFlywheelCore[]", + "name": "flywheels", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "accrue", + "type": "bool[]" + } + ], + "name": "claimRewardsForMarket", + "outputs": [ + { + "internalType": "contract IonicFlywheelCore[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "rewardTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "rewards", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "contract ERC20[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "contract IonicFlywheelCore[]", + "name": "flywheels", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "accrue", + "type": "bool[]" + } + ], + "name": "claimRewardsForMarkets", + "outputs": [ + { + "internalType": "contract IonicFlywheelCore[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "rewardTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "rewards", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "claimRewardsForPool", + "outputs": [ + { + "internalType": "contract IonicFlywheelCore[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "name": "claimRewardsOfRewardToken", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardsClaimed", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "fpd", + "outputs": [ + { + "internalType": "contract PoolDirectory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "int256", + "name": "blocksPerYear", + "type": "int256" + }, + { + "internalType": "address[]", + "name": "offchainRewardsAprMarkets", + "type": "address[]" + }, + { + "internalType": "int256[]", + "name": "offchainRewardsAprs", + "type": "int256[]" + } + ], + "name": "getAdjustedUserNetApr", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAllRewardTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "uniqueRewardTokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20[]", + "name": "markets", + "type": "address[]" + } + ], + "name": "getMarketRewardsInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "market", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "rewardSpeedPerSecondPerToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "formattedAPR", + "type": "uint256" + }, + { + "internalType": "address", + "name": "flywheel", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "internalType": "struct IonicFlywheelLensRouter.RewardsInfo[]", + "name": "rewardsInfo", + "type": "tuple[]" + } + ], + "internalType": "struct IonicFlywheelLensRouter.MarketRewardsInfo[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getPoolMarketRewardsInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "market", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "rewardSpeedPerSecondPerToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardTokenPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "formattedAPR", + "type": "uint256" + }, + { + "internalType": "address", + "name": "flywheel", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardToken", + "type": "address" + } + ], + "internalType": "struct IonicFlywheelLensRouter.RewardsInfo[]", + "name": "rewardsInfo", + "type": "tuple[]" + } + ], + "internalType": "struct IonicFlywheelLensRouter.MarketRewardsInfo[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "int256", + "name": "blocksPerYear", + "type": "int256" + } + ], + "name": "getUserNetApr", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x7f5009db108c8475c8283706e29bb6a42d1cc2897b6931036c23b7917bb8db44", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x7AABEfD7d8d2576Dc932EbE97bE8Ba90299a4ee4", + "transactionIndex": 1, + "gasUsed": "3540258", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb1a8289c92efc8cf1f4977a656850bb9238d09309d4475f2edb86cb3692b1d68", + "transactionHash": "0x7f5009db108c8475c8283706e29bb6a42d1cc2897b6931036c23b7917bb8db44", + "logs": [], + "blockNumber": 4135320, + "cumulativeGasUsed": "3584136", + "status": 1, + "byzantium": true + }, + "args": [ + "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd" + ], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"_fpd\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"claimAllRewardTokens\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"contract ERC20\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"contract IonicFlywheelCore[]\",\"name\":\"flywheels\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"accrue\",\"type\":\"bool[]\"}],\"name\":\"claimRewardsForMarket\",\"outputs\":[{\"internalType\":\"contract IonicFlywheelCore[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"rewardTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"rewards\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"contract ERC20[]\",\"name\":\"markets\",\"type\":\"address[]\"},{\"internalType\":\"contract IonicFlywheelCore[]\",\"name\":\"flywheels\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"accrue\",\"type\":\"bool[]\"}],\"name\":\"claimRewardsForMarkets\",\"outputs\":[{\"internalType\":\"contract IonicFlywheelCore[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"rewardTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"rewards\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"claimRewardsForPool\",\"outputs\":[{\"internalType\":\"contract IonicFlywheelCore[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"}],\"name\":\"claimRewardsOfRewardToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"rewardsClaimed\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fpd\",\"outputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"int256\",\"name\":\"blocksPerYear\",\"type\":\"int256\"},{\"internalType\":\"address[]\",\"name\":\"offchainRewardsAprMarkets\",\"type\":\"address[]\"},{\"internalType\":\"int256[]\",\"name\":\"offchainRewardsAprs\",\"type\":\"int256[]\"}],\"name\":\"getAdjustedUserNetApr\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllRewardTokens\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"uniqueRewardTokens\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"markets\",\"type\":\"address[]\"}],\"name\":\"getMarketRewardsInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"underlyingPrice\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"market\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"rewardSpeedPerSecondPerToken\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardTokenPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"formattedAPR\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"flywheel\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"}],\"internalType\":\"struct IonicFlywheelLensRouter.RewardsInfo[]\",\"name\":\"rewardsInfo\",\"type\":\"tuple[]\"}],\"internalType\":\"struct IonicFlywheelLensRouter.MarketRewardsInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getPoolMarketRewardsInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"underlyingPrice\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"market\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"rewardSpeedPerSecondPerToken\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardTokenPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"formattedAPR\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"flywheel\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardToken\",\"type\":\"address\"}],\"internalType\":\"struct IonicFlywheelLensRouter.RewardsInfo[]\",\"name\":\"rewardsInfo\",\"type\":\"tuple[]\"}],\"internalType\":\"struct IonicFlywheelLensRouter.MarketRewardsInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"int256\",\"name\":\"blocksPerYear\",\"type\":\"int256\"}],\"name\":\"getUserNetApr\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\":\"IonicFlywheelLensRouter\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\n\\n/**\\n @title Balance Booster Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \\n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\\n \\n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\\n\\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\\n*/\\ninterface IFlywheelBooster {\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdab1b4b5662148d74acc3491a810d263ec509f9f81a267e9f6c1542ba15eabc\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/utils/SafeTransferLib.sol\\\";\\nimport { SafeCastLib } from \\\"solmate/utils/SafeCastLib.sol\\\";\\n\\nimport { IFlywheelRewards } from \\\"./rewards/IFlywheelRewards.sol\\\";\\nimport { IFlywheelBooster } from \\\"./IFlywheelBooster.sol\\\";\\n\\nimport { SafeOwnableUpgradeable } from \\\"../../../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\\n using SafeTransferLib for ERC20;\\n using SafeCastLib for uint256;\\n\\n /// @notice How much rewardsToken will be send to treasury\\n uint256 public performanceFee;\\n\\n /// @notice Address that gets rewardsToken accrued by performanceFee\\n address public feeRecipient;\\n\\n /// @notice The token to reward\\n ERC20 public rewardToken;\\n\\n /// @notice append-only list of strategies added\\n ERC20[] public allStrategies;\\n\\n /// @notice the rewards contract for managing streams\\n IFlywheelRewards public flywheelRewards;\\n\\n /// @notice optional booster module for calculating virtual balances on strategies\\n IFlywheelBooster public flywheelBooster;\\n\\n /// @notice The accrued but not yet transferred rewards for each user\\n mapping(address => uint256) internal _rewardsAccrued;\\n\\n /// @notice The strategy index and last updated per strategy\\n mapping(ERC20 => RewardsState) internal _strategyState;\\n\\n /// @notice user index per strategy\\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\\n\\n constructor() {\\n // prevents the misusage of the implementation contract\\n _disableInitializers();\\n }\\n\\n function initialize(\\n ERC20 _rewardToken,\\n IFlywheelRewards _flywheelRewards,\\n IFlywheelBooster _flywheelBooster,\\n address _owner\\n ) public initializer {\\n __SafeOwnable_init(msg.sender);\\n\\n rewardToken = _rewardToken;\\n flywheelRewards = _flywheelRewards;\\n flywheelBooster = _flywheelBooster;\\n\\n _transferOwnership(_owner);\\n\\n performanceFee = 10e16; // 10%\\n feeRecipient = _owner;\\n }\\n\\n /*----------------------------------------------------------------\\n ACCRUE/CLAIM LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a user's rewards accrue to a given strategy.\\n @param strategy the updated rewards strategy\\n @param user the user of the rewards\\n @param rewardsDelta how many new rewards accrued to the user\\n @param rewardsIndex the market index for rewards per token accrued\\n */\\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\\n\\n /** \\n @notice Emitted when a user claims accrued rewards.\\n @param user the user of the rewards\\n @param amount the amount of rewards claimed\\n */\\n event ClaimRewards(address indexed user, uint256 amount);\\n\\n /** \\n @notice accrue rewards for a single user on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the user to be accrued\\n @return the cumulative amount of rewards accrued to user (including prior)\\n */\\n function accrue(ERC20 strategy, address user) public returns (uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return 0;\\n\\n state = accrueStrategy(strategy, state);\\n return accrueUser(strategy, user, state);\\n }\\n\\n /** \\n @notice accrue rewards for a two users on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the first user to be accrued\\n @param user the second user to be accrued\\n @return the cumulative amount of rewards accrued to the first user (including prior)\\n @return the cumulative amount of rewards accrued to the second user (including prior)\\n */\\n function accrue(\\n ERC20 strategy,\\n address user,\\n address secondUser\\n ) public returns (uint256, uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return (0, 0);\\n\\n state = accrueStrategy(strategy, state);\\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\\n }\\n\\n /** \\n @notice claim rewards for a given user\\n @param user the user claiming rewards\\n @dev this function is public, and all rewards transfer to the user\\n */\\n function claimRewards(address user) external {\\n uint256 accrued = rewardsAccrued(user);\\n\\n if (accrued != 0) {\\n _rewardsAccrued[user] = 0;\\n\\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\\n\\n emit ClaimRewards(user, accrued);\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n ADMIN LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a new strategy is added to flywheel by the admin\\n @param newStrategy the new added strategy\\n */\\n event AddStrategy(address indexed newStrategy);\\n\\n /// @notice initialize a new strategy\\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n function _addStrategyForRewards(ERC20 strategy) internal {\\n (uint224 index, ) = strategyState(strategy);\\n require(index == 0, \\\"strategy\\\");\\n _strategyState[strategy] = RewardsState({\\n index: (10**rewardToken.decimals()).safeCastTo224(),\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n\\n allStrategies.push(strategy);\\n emit AddStrategy(address(strategy));\\n }\\n\\n function getAllStrategies() external view returns (ERC20[] memory) {\\n return allStrategies;\\n }\\n\\n /** \\n @notice Emitted when the rewards module changes\\n @param newFlywheelRewards the new rewards module\\n */\\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\\n\\n /// @notice swap out the flywheel rewards contract\\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\\n if (address(flywheelRewards) != address(0)) {\\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\\n if (oldRewardBalance > 0) {\\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\\n }\\n }\\n\\n flywheelRewards = newFlywheelRewards;\\n\\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\\n }\\n\\n /** \\n @notice Emitted when the booster module changes\\n @param newBooster the new booster module\\n */\\n event FlywheelBoosterUpdate(address indexed newBooster);\\n\\n /// @notice swap out the flywheel booster contract\\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\\n flywheelBooster = newBooster;\\n\\n emit FlywheelBoosterUpdate(address(newBooster));\\n }\\n\\n event UpdatedFeeSettings(\\n uint256 oldPerformanceFee,\\n uint256 newPerformanceFee,\\n address oldFeeRecipient,\\n address newFeeRecipient\\n );\\n\\n /**\\n * @notice Update performanceFee and/or feeRecipient\\n * @dev Claim rewards first from the previous feeRecipient before changing it\\n */\\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\\n _updateFeeSettings(_performanceFee, _feeRecipient);\\n }\\n\\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\\n\\n if (feeRecipient != _feeRecipient) {\\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\\n _rewardsAccrued[feeRecipient] = 0;\\n }\\n performanceFee = _performanceFee;\\n feeRecipient = _feeRecipient;\\n }\\n\\n /*----------------------------------------------------------------\\n INTERNAL ACCOUNTING LOGIC\\n ----------------------------------------------------------------*/\\n\\n struct RewardsState {\\n /// @notice The strategy's last updated index\\n uint224 index;\\n /// @notice The timestamp the index was last updated at\\n uint32 lastUpdatedTimestamp;\\n }\\n\\n /// @notice accumulate global rewards on a strategy\\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\\n private\\n returns (RewardsState memory rewardsState)\\n {\\n // calculate accrued rewards through module\\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\\n\\n rewardsState = state;\\n\\n if (strategyRewardsAccrued > 0) {\\n // use the booster or token supply to calculate reward index denominator\\n uint256 supplyTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedTotalSupply(strategy)\\n : strategy.totalSupply();\\n\\n // 100% = 100e16\\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\\n\\n _rewardsAccrued[feeRecipient] += accruedFees;\\n strategyRewardsAccrued -= accruedFees;\\n\\n uint224 deltaIndex;\\n\\n if (supplyTokens != 0)\\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\\n\\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\\n rewardsState = RewardsState({\\n index: state.index + deltaIndex,\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n _strategyState[strategy] = rewardsState;\\n }\\n }\\n\\n /// @notice accumulate rewards on a strategy for a specific user\\n function accrueUser(\\n ERC20 strategy,\\n address user,\\n RewardsState memory state\\n ) private returns (uint256) {\\n // load indices\\n uint224 strategyIndex = state.index;\\n uint224 supplierIndex = userIndex(strategy, user);\\n\\n // sync user index to global\\n _userIndex[strategy][user] = strategyIndex;\\n\\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\\n // zero balances will have no effect other than syncing to global index\\n if (supplierIndex == 0) {\\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\\n }\\n\\n uint224 deltaIndex = strategyIndex - supplierIndex;\\n // use the booster or token balance to calculate reward balance multiplier\\n uint256 supplierTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedBalanceOf(strategy, user)\\n : strategy.balanceOf(user);\\n\\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\\n\\n _rewardsAccrued[user] = supplierAccrued;\\n\\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\\n\\n return supplierAccrued;\\n }\\n\\n function rewardsAccrued(address user) public virtual returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\\n return _userIndex[strategy][user];\\n }\\n\\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0xbd54c90dbc7f93cad52016f14eb5f9b634f98d18da083ef443951deebc5f82aa\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\nimport { IonicFlywheelCore } from \\\"./IonicFlywheelCore.sol\\\";\\nimport { IonicComptroller } from \\\"../../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../../compound/CTokenInterfaces.sol\\\";\\nimport { BasePriceOracle } from \\\"../../../oracles/BasePriceOracle.sol\\\";\\nimport { PoolDirectory } from \\\"../../../PoolDirectory.sol\\\";\\n\\ninterface IPriceOracle_IFLR {\\n function getUnderlyingPrice(ERC20 cToken) external view returns (uint256);\\n\\n function price(address underlying) external view returns (uint256);\\n}\\n\\ncontract IonicFlywheelLensRouter {\\n PoolDirectory public fpd;\\n\\n constructor(PoolDirectory _fpd) {\\n fpd = _fpd;\\n }\\n\\n struct MarketRewardsInfo {\\n /// @dev comptroller oracle price of market underlying\\n uint256 underlyingPrice;\\n ICErc20 market;\\n RewardsInfo[] rewardsInfo;\\n }\\n\\n struct RewardsInfo {\\n /// @dev rewards in `rewardToken` paid per underlying staked token in `market` per second\\n uint256 rewardSpeedPerSecondPerToken;\\n /// @dev comptroller oracle price of reward token\\n uint256 rewardTokenPrice;\\n /// @dev APR scaled by 1e18. Calculated as rewardSpeedPerSecondPerToken * rewardTokenPrice * 365.25 days / underlyingPrice * 1e18 / market.exchangeRate\\n uint256 formattedAPR;\\n address flywheel;\\n address rewardToken;\\n }\\n\\n function getPoolMarketRewardsInfo(IonicComptroller comptroller) external returns (MarketRewardsInfo[] memory) {\\n ICErc20[] memory markets = comptroller.getAllMarkets();\\n return _getMarketRewardsInfo(markets, comptroller);\\n }\\n\\n function getMarketRewardsInfo(ICErc20[] memory markets) external returns (MarketRewardsInfo[] memory) {\\n IonicComptroller pool;\\n for (uint256 i = 0; i < markets.length; i++) {\\n ICErc20 asMarket = ICErc20(address(markets[i]));\\n if (address(pool) == address(0)) pool = asMarket.comptroller();\\n else require(asMarket.comptroller() == pool);\\n }\\n return _getMarketRewardsInfo(markets, pool);\\n }\\n\\n function _getMarketRewardsInfo(ICErc20[] memory markets, IonicComptroller comptroller)\\n internal\\n returns (MarketRewardsInfo[] memory)\\n {\\n if (address(comptroller) == address(0) || markets.length == 0) return new MarketRewardsInfo[](0);\\n\\n address[] memory flywheels = comptroller.getAccruingFlywheels();\\n address[] memory rewardTokens = new address[](flywheels.length);\\n uint256[] memory rewardTokenPrices = new uint256[](flywheels.length);\\n uint256[] memory rewardTokenDecimals = new uint256[](flywheels.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n MarketRewardsInfo[] memory infoList = new MarketRewardsInfo[](markets.length);\\n for (uint256 i = 0; i < markets.length; i++) {\\n RewardsInfo[] memory rewardsInfo = new RewardsInfo[](flywheels.length);\\n\\n ICErc20 market = ICErc20(address(markets[i]));\\n uint256 price = oracle.price(market.underlying()); // scaled to 1e18\\n\\n if (i == 0) {\\n for (uint256 j = 0; j < flywheels.length; j++) {\\n ERC20 rewardToken = IonicFlywheelCore(flywheels[j]).rewardToken();\\n rewardTokens[j] = address(rewardToken);\\n rewardTokenPrices[j] = oracle.price(address(rewardToken)); // scaled to 1e18\\n rewardTokenDecimals[j] = uint256(rewardToken.decimals());\\n }\\n }\\n\\n for (uint256 j = 0; j < flywheels.length; j++) {\\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\\n\\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\\n flywheel,\\n market,\\n rewardTokenDecimals[j]\\n );\\n uint256 apr = getApr(\\n rewardSpeedPerSecondPerToken,\\n rewardTokenPrices[j],\\n price, \\n market.exchangeRateCurrent(),\\n address(flywheel.flywheelBooster()) != address(0)\\n );\\n\\n rewardsInfo[j] = RewardsInfo({\\n rewardSpeedPerSecondPerToken: rewardSpeedPerSecondPerToken, // scaled in 1e18\\n rewardTokenPrice: rewardTokenPrices[j],\\n formattedAPR: apr, // scaled in 1e18\\n flywheel: address(flywheel),\\n rewardToken: rewardTokens[j]\\n });\\n }\\n\\n infoList[i] = MarketRewardsInfo({ market: market, rewardsInfo: rewardsInfo, underlyingPrice: price });\\n }\\n\\n return infoList;\\n }\\n\\n function scaleIndexDiff(uint256 indexDiff, uint256 decimals) internal pure returns (uint256) {\\n return decimals <= 18 ? uint256(indexDiff) * (10**(18 - decimals)) : uint256(indexDiff) / (10**(decimals - 18));\\n }\\n\\n function getRewardSpeedPerSecondPerToken(\\n IonicFlywheelCore flywheel,\\n ICErc20 market,\\n uint256 decimals\\n ) internal returns (uint256 rewardSpeedPerSecondPerToken) {\\n ERC20 strategy = ERC20(address(market));\\n (uint224 indexBefore, uint32 lastUpdatedTimestampBefore) = flywheel.strategyState(strategy);\\n flywheel.accrue(strategy, address(0));\\n (uint224 indexAfter, uint32 lastUpdatedTimestampAfter) = flywheel.strategyState(strategy);\\n if (lastUpdatedTimestampAfter > lastUpdatedTimestampBefore) {\\n rewardSpeedPerSecondPerToken =\\n scaleIndexDiff((indexAfter - indexBefore), decimals) /\\n (lastUpdatedTimestampAfter - lastUpdatedTimestampBefore);\\n }\\n }\\n\\n function getApr(\\n uint256 rewardSpeedPerSecondPerToken,\\n uint256 rewardTokenPrice,\\n uint256 underlyingPrice,\\n uint256 exchangeRate,\\n bool isBorrow\\n ) internal pure returns (uint256) {\\n if (rewardSpeedPerSecondPerToken == 0) return 0;\\n uint256 nativeSpeedPerSecondPerCToken = rewardSpeedPerSecondPerToken * rewardTokenPrice; // scaled to 1e36\\n uint256 nativeSpeedPerYearPerCToken = nativeSpeedPerSecondPerCToken * 365.25 days; // scaled to 1e36\\n uint256 assetSpeedPerYearPerCToken = nativeSpeedPerYearPerCToken / underlyingPrice; // scaled to 1e18\\n uint256 assetSpeedPerYearPerCTokenScaled = assetSpeedPerYearPerCToken * 1e18; // scaled to 1e36\\n uint256 apr = assetSpeedPerYearPerCTokenScaled;\\n if (!isBorrow) {\\n // if not borrowing, use exchange rate to scale\\n apr = assetSpeedPerYearPerCTokenScaled / exchangeRate; // scaled to 1e18\\n } else {\\n apr = assetSpeedPerYearPerCTokenScaled / 1e18; // scaled to 1e18\\n }\\n return apr;\\n }\\n\\n function getRewardsAprForMarket(ICErc20 market) internal returns (int256 totalMarketRewardsApr) {\\n IonicComptroller comptroller = market.comptroller();\\n BasePriceOracle oracle = comptroller.oracle();\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(market);\\n\\n address[] memory flywheels = comptroller.getAccruingFlywheels();\\n for (uint256 j = 0; j < flywheels.length; j++) {\\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\\n ERC20 rewardToken = flywheel.rewardToken();\\n\\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\\n flywheel,\\n market,\\n uint256(rewardToken.decimals())\\n );\\n\\n uint256 marketApr = getApr(\\n rewardSpeedPerSecondPerToken,\\n oracle.price(address(rewardToken)),\\n underlyingPrice,\\n market.exchangeRateCurrent(),\\n address(flywheel.flywheelBooster()) != address(0)\\n );\\n\\n totalMarketRewardsApr += int256(marketApr);\\n }\\n }\\n\\n function getUserNetValueDeltaForMarket(\\n address user,\\n ICErc20 market,\\n int256 offchainApr,\\n int256 blocksPerYear\\n ) internal returns (int256) {\\n IonicComptroller comptroller = market.comptroller();\\n BasePriceOracle oracle = comptroller.oracle();\\n int256 netApr = getRewardsAprForMarket(market) +\\n getUserInterestAprForMarket(user, market, blocksPerYear) +\\n offchainApr;\\n return (netApr * int256(market.balanceOfUnderlying(user)) * int256(oracle.getUnderlyingPrice(market))) / 1e36;\\n }\\n\\n function getUserInterestAprForMarket(\\n address user,\\n ICErc20 market,\\n int256 blocksPerYear\\n ) internal returns (int256) {\\n uint256 borrows = market.borrowBalanceCurrent(user);\\n uint256 supplied = market.balanceOfUnderlying(user);\\n uint256 supplyRatePerBlock = market.supplyRatePerBlock();\\n uint256 borrowRatePerBlock = market.borrowRatePerBlock();\\n\\n IonicComptroller comptroller = market.comptroller();\\n BasePriceOracle oracle = comptroller.oracle();\\n uint256 assetPrice = oracle.getUnderlyingPrice(market);\\n uint256 collateralValue = (supplied * assetPrice) / 1e18;\\n uint256 borrowsValue = (borrows * assetPrice) / 1e18;\\n\\n uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;\\n uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;\\n\\n if (collateralValue == 0) return 0;\\n return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);\\n }\\n\\n struct AdjustedUserNetAprVars {\\n int256 userNetAssetsValue;\\n int256 userNetValueDelta;\\n BasePriceOracle oracle;\\n ICErc20[] markets;\\n IonicComptroller pool;\\n }\\n\\n function getAdjustedUserNetApr(\\n address user,\\n int256 blocksPerYear,\\n address[] memory offchainRewardsAprMarkets,\\n int256[] memory offchainRewardsAprs\\n ) public returns (int256) {\\n AdjustedUserNetAprVars memory vars;\\n\\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\\n vars.oracle = pool.oracle();\\n vars.markets = pool.getAllMarkets();\\n for (uint256 j = 0; j < vars.markets.length; j++) {\\n int256 offchainRewardsApr = 0;\\n for (uint256 k = 0; k < offchainRewardsAprMarkets.length; k++) {\\n if (offchainRewardsAprMarkets[k] == address(vars.markets[j])) offchainRewardsApr = offchainRewardsAprs[k];\\n }\\n vars.userNetAssetsValue +=\\n int256(vars.markets[j].balanceOfUnderlying(user) * vars.oracle.getUnderlyingPrice(vars.markets[j])) /\\n 1e18;\\n vars.userNetValueDelta += getUserNetValueDeltaForMarket(\\n user,\\n vars.markets[j],\\n offchainRewardsApr,\\n blocksPerYear\\n );\\n }\\n }\\n\\n if (vars.userNetAssetsValue == 0) return 0;\\n else return (vars.userNetValueDelta * 1e18) / vars.userNetAssetsValue;\\n }\\n\\n function getUserNetApr(address user, int256 blocksPerYear) external returns (int256) {\\n address[] memory emptyAddrArray = new address[](0);\\n int256[] memory emptyIntArray = new int256[](0);\\n return getAdjustedUserNetApr(user, blocksPerYear, emptyAddrArray, emptyIntArray);\\n }\\n\\n function getAllRewardTokens() public view returns (address[] memory uniqueRewardTokens) {\\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\\n\\n uint256 rewardTokensCounter;\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\\n address[] memory fws = pool.getRewardsDistributors();\\n\\n rewardTokensCounter += fws.length;\\n }\\n\\n address[] memory rewardTokens = new address[](rewardTokensCounter);\\n\\n uint256 uniqueRewardTokensCounter = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\\n address[] memory fws = pool.getRewardsDistributors();\\n\\n for (uint256 j = 0; j < fws.length; j++) {\\n address rwToken = address(IonicFlywheelCore(fws[j]).rewardToken());\\n if (rwToken == address(0)) break;\\n\\n bool added;\\n for (uint256 k = 0; k < rewardTokens.length; k++) {\\n if (rwToken == rewardTokens[k]) {\\n added = true;\\n break;\\n }\\n }\\n if (!added) rewardTokens[uniqueRewardTokensCounter++] = rwToken;\\n }\\n }\\n\\n uniqueRewardTokens = new address[](uniqueRewardTokensCounter);\\n for (uint256 i = 0; i < uniqueRewardTokensCounter; i++) {\\n uniqueRewardTokens[i] = rewardTokens[i];\\n }\\n }\\n\\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory) {\\n address[] memory rewardTokens = getAllRewardTokens();\\n uint256[] memory rewardsClaimedForToken = new uint256[](rewardTokens.length);\\n\\n for (uint256 i = 0; i < rewardTokens.length; i++) {\\n rewardsClaimedForToken[i] = claimRewardsOfRewardToken(user, rewardTokens[i]);\\n }\\n\\n return (rewardTokens, rewardsClaimedForToken);\\n }\\n\\n function claimRewardsOfRewardToken(address user, address rewardToken) public returns (uint256 rewardsClaimed) {\\n uint256 balanceBefore = ERC20(rewardToken).balanceOf(user);\\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\\n ERC20[] memory markets;\\n {\\n ICErc20[] memory cerc20s = pool.getAllMarkets();\\n markets = new ERC20[](cerc20s.length);\\n for (uint256 j = 0; j < cerc20s.length; j++) {\\n markets[j] = ERC20(address(cerc20s[j]));\\n }\\n }\\n\\n address[] memory flywheelAddresses = pool.getAccruingFlywheels();\\n for (uint256 k = 0; k < flywheelAddresses.length; k++) {\\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);\\n if (address(flywheel.rewardToken()) == rewardToken) {\\n for (uint256 m = 0; m < markets.length; m++) {\\n flywheel.accrue(markets[m], user);\\n }\\n flywheel.claimRewards(user);\\n }\\n }\\n }\\n\\n uint256 balanceAfter = ERC20(rewardToken).balanceOf(user);\\n return balanceAfter - balanceBefore;\\n }\\n\\n function claimRewardsForMarket(\\n address user,\\n ERC20 market,\\n IonicFlywheelCore[] calldata flywheels,\\n bool[] calldata accrue\\n )\\n external\\n returns (\\n IonicFlywheelCore[] memory,\\n address[] memory rewardTokens,\\n uint256[] memory rewards\\n )\\n {\\n uint256 size = flywheels.length;\\n rewards = new uint256[](size);\\n rewardTokens = new address[](size);\\n\\n for (uint256 i = 0; i < size; i++) {\\n uint256 newRewards;\\n if (accrue[i]) {\\n newRewards = flywheels[i].accrue(market, user);\\n } else {\\n newRewards = flywheels[i].rewardsAccrued(user);\\n }\\n\\n // Take the max, because rewards are cumulative.\\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\\n\\n flywheels[i].claimRewards(user);\\n rewardTokens[i] = address(flywheels[i].rewardToken());\\n }\\n\\n return (flywheels, rewardTokens, rewards);\\n }\\n\\n function claimRewardsForPool(address user, IonicComptroller comptroller)\\n public\\n returns (\\n IonicFlywheelCore[] memory,\\n address[] memory,\\n uint256[] memory\\n )\\n {\\n ICErc20[] memory cerc20s = comptroller.getAllMarkets();\\n ERC20[] memory markets = new ERC20[](cerc20s.length);\\n address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();\\n IonicFlywheelCore[] memory flywheels = new IonicFlywheelCore[](flywheelAddresses.length);\\n bool[] memory accrue = new bool[](flywheelAddresses.length);\\n\\n for (uint256 j = 0; j < flywheelAddresses.length; j++) {\\n flywheels[j] = IonicFlywheelCore(flywheelAddresses[j]);\\n accrue[j] = true;\\n }\\n\\n for (uint256 j = 0; j < cerc20s.length; j++) {\\n markets[j] = ERC20(address(cerc20s[j]));\\n }\\n\\n return claimRewardsForMarkets(user, markets, flywheels, accrue);\\n }\\n\\n function claimRewardsForMarkets(\\n address user,\\n ERC20[] memory markets,\\n IonicFlywheelCore[] memory flywheels,\\n bool[] memory accrue\\n )\\n public\\n returns (\\n IonicFlywheelCore[] memory,\\n address[] memory rewardTokens,\\n uint256[] memory rewards\\n )\\n {\\n rewards = new uint256[](flywheels.length);\\n rewardTokens = new address[](flywheels.length);\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n for (uint256 j = 0; j < markets.length; j++) {\\n ERC20 market = markets[j];\\n\\n uint256 newRewards;\\n if (accrue[i]) {\\n newRewards = flywheels[i].accrue(market, user);\\n } else {\\n newRewards = flywheels[i].rewardsAccrued(user);\\n }\\n\\n // Take the max, because rewards are cumulative.\\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\\n }\\n\\n flywheels[i].claimRewards(user);\\n rewardTokens[i] = address(flywheels[i].rewardToken());\\n }\\n\\n return (flywheels, rewardTokens, rewards);\\n }\\n}\\n\",\"keccak256\":\"0x04887f3bf815356017a6a323cfe975ee852085e9dd854e2f220a28b405ca57ce\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\nimport {IonicFlywheelCore} from \\\"../IonicFlywheelCore.sol\\\";\\n\\n/**\\n @title Rewards Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Rewards module is responsible for:\\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\\n * actually holding rewards that are yet to be claimed\\n\\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\\n\\n Different module strategies include:\\n * a static reward rate per second\\n * a decaying reward rate\\n * a dynamic just-in-time reward stream\\n * liquid governance reward delegation (Curve Gauge style)\\n\\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\\n */\\ninterface IFlywheelRewards {\\n /**\\n @notice calculate the rewards amount accrued to a strategy since the last update.\\n @param strategy the strategy to accrue rewards for.\\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\\n @return rewards the amount of rewards accrued to the market\\n */\\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\\n\\n /// @notice return the flywheel core address\\n function flywheel() external view returns (IonicFlywheelCore);\\n\\n /// @notice return the reward token associated with flywheel core.\\n function rewardToken() external view returns (ERC20);\\n}\\n\",\"keccak256\":\"0x7e966a0e7cc80f799ee7cb3611027381847dafb92b8d8c0f3e96500ecbe217f7\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeCastLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Safe unsigned integer casting library that reverts on overflow.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\\nlibrary SafeCastLib {\\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\\n require(x < 1 << 248);\\n\\n y = uint248(x);\\n }\\n\\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\\n require(x < 1 << 224);\\n\\n y = uint224(x);\\n }\\n\\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\\n require(x < 1 << 192);\\n\\n y = uint192(x);\\n }\\n\\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\\n require(x < 1 << 160);\\n\\n y = uint160(x);\\n }\\n\\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\\n require(x < 1 << 128);\\n\\n y = uint128(x);\\n }\\n\\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\\n require(x < 1 << 96);\\n\\n y = uint96(x);\\n }\\n\\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\\n require(x < 1 << 64);\\n\\n y = uint64(x);\\n }\\n\\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\\n require(x < 1 << 32);\\n\\n y = uint32(x);\\n }\\n\\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\\n require(x < 1 << 24);\\n\\n y = uint24(x);\\n }\\n\\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\\n require(x < 1 << 16);\\n\\n y = uint16(x);\\n }\\n\\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\\n require(x < 1 << 8);\\n\\n y = uint8(x);\\n }\\n}\\n\",\"keccak256\":\"0xb784a14411858036491124e677aecde6d500e695b7a70c74aa8f1001bda2ccab\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), from) // Append the \\\"from\\\" argument.\\n mstore(add(freeMemoryPointer, 36), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 68), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x333b56bef66ff71e3838910781df214acbeb6c2d6ace27a04ebb510f0e669300\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162003f3d38038062003f3d83398101604081905262000034916200005a565b600080546001600160a01b0319166001600160a01b03929092169190911790556200008c565b6000602082840312156200006d57600080fd5b81516001600160a01b03811681146200008557600080fd5b9392505050565b613ea1806200009c6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80637e70aa49116100715780637e70aa49146101315780638260a696146101515780639cf1fd5314610164578063bdfc183914610185578063d1040bae14610198578063de858c63146101ab57600080fd5b80630d9d7fdc146100ae57806312edb24c146100d45780633610c407146100e95780634f471e6d1461010b5780637d3cab4c1461011e575b600080fd5b6100c16100bc366004613041565b6101d6565b6040519081526020015b60405180910390f35b6100dc610204565b6040516100cb91906130b2565b6100fc6100f73660046130c5565b6105fa565b6040516100cb9392919061312f565b6100fc6101193660046131e6565b6108a4565b6100c161012c36600461337a565b610c95565b61014461013f366004613459565b6110d7565b6040516100cb91906134f2565b6100fc61015f3660046136b3565b611221565b6101776101723660046137a1565b6115ca565b6040516100cb9291906137be565b6100c16101933660046130c5565b61167f565b6101446101a63660046137a1565b611b65565b6000546101be906001600160a01b031681565b6040516001600160a01b0390911681526020016100cb565b60408051600080825260208201818152828401909352916101f985858484610c95565b925050505b92915050565b60008054604080516323b020d560e21b81529051606093926001600160a01b031691638ec0835491600480830192869291908290030181865afa15801561024f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102779190810190613956565b915060009050805b825181101561032d57600083828151811061029c5761029c613a11565b60200260200101516040015190506000816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156102ea573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103129190810190613a27565b90508051846103219190613acb565b9350505060010161027f565b506000816001600160401b038111156103485761034861327a565b604051908082528060200260200182016040528015610371578160200160208202803683370190505b5090506000805b845181101561055657600085828151811061039557610395613a11565b60200260200101516040015190506000816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156103e3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261040b9190810190613a27565b905060005b815181101561054b57600082828151811061042d5761042d613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104969190613ade565b90506001600160a01b0381166104ac575061054b565b6000805b88518110156104fc578881815181106104cb576104cb613a11565b60200260200101516001600160a01b0316836001600160a01b0316036104f457600191506104fc565b6001016104b0565b50806105415781888861050e81613afb565b99508151811061052057610520613a11565b60200260200101906001600160a01b031690816001600160a01b0316815250505b5050600101610410565b505050600101610378565b50806001600160401b0381111561056f5761056f61327a565b604051908082528060200260200182016040528015610598578160200160208202803683370190505b50945060005b818110156105f2578281815181106105b8576105b8613a11565b60200260200101518682815181106105d2576105d2613a11565b6001600160a01b039092166020928302919091019091015260010161059e565b505050505090565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561063f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106679190810190613b14565b9050600081516001600160401b038111156106845761068461327a565b6040519080825280602002602001820160405280156106ad578160200160208202803683370190505b5090506000866001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa1580156106f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107189190810190613a27565b9050600081516001600160401b038111156107355761073561327a565b60405190808252806020026020018201604052801561075e578160200160208202803683370190505b509050600082516001600160401b0381111561077c5761077c61327a565b6040519080825280602002602001820160405280156107a5578160200160208202803683370190505b50905060005b835181101561082c578381815181106107c6576107c6613a11565b60200260200101518382815181106107e0576107e0613a11565b60200260200101906001600160a01b031690816001600160a01b031681525050600182828151811061081457610814613a11565b911515602092830291909101909101526001016107ab565b5060005b85518110156108855785818151811061084b5761084b613a11565b602002602001015185828151811061086557610865613a11565b6001600160a01b0390921660209283029190910190910152600101610830565b506108928a858484611221565b97509750975050505050509250925092565b6060808085806001600160401b038111156108c1576108c161327a565b6040519080825280602002602001820160405280156108ea578160200160208202803683370190505b509150806001600160401b038111156109055761090561327a565b60405190808252806020026020018201604052801561092e578160200160208202803683370190505b50925060005b81811015610c4557600087878381811061095057610950613a11565b90506020020160208101906109659190613ba2565b15610a0e5789898381811061097c5761097c613a11565b905060200201602081019061099191906137a1565b604051632e6f912b60e21b81526001600160a01b038d811660048301528e81166024830152919091169063b9be44ac906044016020604051808303816000875af11580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a079190613bbd565b9050610aa6565b898983818110610a2057610a20613a11565b9050602002016020810190610a3591906137a1565b604051630ff6b5a760e31b81526001600160a01b038e811660048301529190911690637fb5ad38906024016020604051808303816000875af1158015610a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa39190613bbd565b90505b80848381518110610ab957610ab9613a11565b60200260200101511015610acd5780610ae8565b838281518110610adf57610adf613a11565b60200260200101515b848381518110610afa57610afa613a11565b602002602001018181525050898983818110610b1857610b18613a11565b9050602002016020810190610b2d91906137a1565b604051633bd73ee360e21b81526001600160a01b038e81166004830152919091169063ef5cfb8c90602401600060405180830381600087803b158015610b7257600080fd5b505af1158015610b86573d6000803e3d6000fd5b50505050898983818110610b9c57610b9c613a11565b9050602002016020810190610bb191906137a1565b6001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c129190613ade565b858381518110610c2457610c24613a11565b6001600160a01b039092166020928302919091019091015250600101610934565b5087878484838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929a5093985091965050505050505096509650969350505050565b6040805160a0810182526000808252602082018190529181018290526060808201526080810182905260008060009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d12573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d3a9190810190613956565b91505060005b8151811015611092576000828281518110610d5d57610d5d613a11565b6020026020010151604001519050806001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcd9190613ade565b84604001906001600160a01b031690816001600160a01b031681525050806001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e28573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e509190810190613b14565b606085015260005b846060015151811015611088576000805b8951811015610ee65786606001518381518110610e8857610e88613a11565b60200260200101516001600160a01b03168a8281518110610eab57610eab613a11565b60200260200101516001600160a01b031603610ede57888181518110610ed357610ed3613a11565b602002602001015191505b600101610e69565b50670de0b6b3a764000086604001516001600160a01b031663fc57d4df88606001518581518110610f1957610f19613a11565b60200260200101516040518263ffffffff1660e01b8152600401610f4c91906001600160a01b0391909116815260200190565b602060405180830381865afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613bbd565b87606001518481518110610fa357610fa3613a11565b6020908102919091010151604051633af9e66960e01b81526001600160a01b038f8116600483015290911690633af9e66990602401602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110199190613bbd565b6110239190613bd6565b61102d9190613c03565b8651879061103c908390613c31565b9052506060860151805161106b918d918590811061105c5761105c613a11565b6020026020010151838d611bdb565b8660200181815161107c9190613c31565b90525050600101610e58565b5050600101610d40565b5081516000036110a7576000925050506110cf565b815160208301516110c090670de0b6b3a7640000613c59565b6110ca9190613c03565b925050505b949350505050565b60606000805b835181101561120f5760008482815181106110fa576110fa613a11565b6020026020010151905060006001600160a01b0316836001600160a01b03160361118757806001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111809190613ade565b9250611206565b826001600160a01b0316816001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f39190613ade565b6001600160a01b03161461120657600080fd5b506001016110dd565b5061121a8382611de5565b9392505050565b606080606084516001600160401b0381111561123f5761123f61327a565b604051908082528060200260200182016040528015611268578160200160208202803683370190505b50905084516001600160401b038111156112845761128461327a565b6040519080825280602002602001820160405280156112ad578160200160208202803683370190505b50915060005b85518110156115bd5760005b87518110156114965760008882815181106112dc576112dc613a11565b6020026020010151905060008784815181106112fa576112fa613a11565b6020026020010151156113a05788848151811061131957611319613a11565b6020908102919091010151604051632e6f912b60e21b81526001600160a01b0384811660048301528d811660248301529091169063b9be44ac906044016020604051808303816000875af1158015611375573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113999190613bbd565b905061142d565b8884815181106113b2576113b2613a11565b6020908102919091010151604051630ff6b5a760e31b81526001600160a01b038d8116600483015290911690637fb5ad38906024016020604051808303816000875af1158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142a9190613bbd565b90505b8085858151811061144057611440613a11565b60200260200101511015611454578061146f565b84848151811061146657611466613a11565b60200260200101515b85858151811061148157611481613a11565b602090810291909101015250506001016112bf565b508581815181106114a9576114a9613a11565b6020908102919091010151604051633bd73ee360e21b81526001600160a01b038a811660048301529091169063ef5cfb8c90602401600060405180830381600087803b1580156114f857600080fd5b505af115801561150c573d6000803e3d6000fd5b5050505085818151811061152257611522613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158b9190613ade565b83828151811061159d5761159d613a11565b6001600160a01b03909216602092830291909101909101526001016112b3565b5093969095509293505050565b60608060006115d7610204565b9050600081516001600160401b038111156115f4576115f461327a565b60405190808252806020026020018201604052801561161d578160200160208202803683370190505b50905060005b82518110156116745761164f8684838151811061164257611642613a11565b602002602001015161167f565b82828151811061166157611661613a11565b6020908102919091010152600101611623565b509094909350915050565b6040516370a0823160e01b81526001600160a01b03838116600483015260009182918416906370a0823190602401602060405180830381865afa1580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee9190613bbd565b905060008060009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611744573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261176c9190810190613956565b91505060005b8151811015611ae057600082828151811061178f5761178f613a11565b602002602001015160400151905060606000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156117df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118079190810190613b14565b905080516001600160401b038111156118225761182261327a565b60405190808252806020026020018201604052801561184b578160200160208202803683370190505b50915060005b81518110156118a65781818151811061186c5761186c613a11565b602002602001015183828151811061188657611886613a11565b6001600160a01b0390921660209283029190910190910152600101611851565b50506000826001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa1580156118e8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119109190810190613a27565b905060005b8151811015611ad057600082828151811061193257611932613a11565b60200260200101519050896001600160a01b0316816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a89190613ade565b6001600160a01b031603611ac75760005b8451811015611a6a57816001600160a01b031663b9be44ac8683815181106119e3576119e3613a11565b60200260200101518e6040518363ffffffff1660e01b8152600401611a1e9291906001600160a01b0392831681529116602082015260400190565b6020604051808303816000875af1158015611a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a619190613bbd565b506001016119b9565b50604051633bd73ee360e21b81526001600160a01b038c8116600483015282169063ef5cfb8c90602401600060405180830381600087803b158015611aae57600080fd5b505af1158015611ac2573d6000803e3d6000fd5b505050505b50600101611915565b5050600190920191506117729050565b506040516370a0823160e01b81526001600160a01b038681166004830152600091908616906370a0823190602401602060405180830381865afa158015611b2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4f9190613bbd565b9050611b5b8382613c89565b9695505050505050565b60606000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ba7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bcf9190810190613b14565b905061121a8184611de5565b600080846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c409190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca69190613ade565b9050600085611cb6898988612603565b611cbf89612999565b611cc99190613c31565b611cd39190613c31565b60405163fc57d4df60e01b81526001600160a01b0389811660048301529192506ec097ce7bc90715b34b9f10000000009184169063fc57d4df90602401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d519190613bbd565b604051633af9e66960e01b81526001600160a01b038b811660048301528a1690633af9e66990602401602060405180830381865afa158015611d97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbb9190613bbd565b611dc59084613c59565b611dcf9190613c59565b611dd99190613c03565b98975050505050505050565b60606001600160a01b0382161580611dfc57508251155b15611e4e576040805160008082526020820190925290611e46565b60408051606080820183526000808352602083015291810191909152815260200190600190039081611e175790505b5090506101fe565b6000826001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa158015611e8e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eb69190810190613a27565b9050600081516001600160401b03811115611ed357611ed361327a565b604051908082528060200260200182016040528015611efc578160200160208202803683370190505b509050600082516001600160401b03811115611f1a57611f1a61327a565b604051908082528060200260200182016040528015611f43578160200160208202803683370190505b509050600083516001600160401b03811115611f6157611f6161327a565b604051908082528060200260200182016040528015611f8a578160200160208202803683370190505b5090506000866001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff19190613ade565b9050600088516001600160401b0381111561200e5761200e61327a565b60405190808252806020026020018201604052801561205b57816020015b6040805160608082018352600080835260208301529181019190915281526020019060019003908161202c5790505b50905060005b89518110156125f657600087516001600160401b038111156120855761208561327a565b6040519080825280602002602001820160405280156120fa57816020015b6120e76040518060a0016040528060008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b8152602001906001900390816120a35790505b50905060008b838151811061211157612111613a11565b602002602001015190506000856001600160a01b031663aea91078836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561216a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218e9190613ade565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156121d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f69190613bbd565b9050836000036123c25760005b8a518110156123c05760008b828151811061222057612220613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612265573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122899190613ade565b9050808b838151811061229e5761229e613a11565b6001600160a01b0392831660209182029290920101526040516315d5220f60e31b815282821660048201529089169063aea9107890602401602060405180830381865afa1580156122f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123179190613bbd565b8a838151811061232957612329613a11565b602002602001018181525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612373573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123979190613c9c565b60ff168983815181106123ac576123ac613a11565b602090810291909101015250600101612203565b505b60005b8a518110156125a95760008b82815181106123e2576123e2613a11565b60200260200101519050600061241282868c868151811061240557612405613a11565b6020026020010151612d8b565b90506000612514828d868151811061242c5761242c613a11565b602002602001015187896001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612473573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124979190613bbd565b60006001600160a01b0316886001600160a01b031663ab5497d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125049190613ade565b6001600160a01b03161415612f47565b90506040518060a001604052808381526020018d868151811061253957612539613a11565b60200260200101518152602001828152602001846001600160a01b031681526020018e868151811061256d5761256d613a11565b60200260200101516001600160a01b031681525087858151811061259357612593613a11565b60209081029190910101525050506001016123c5565b506040518060600160405280828152602001836001600160a01b03168152602001848152508585815181106125e0576125e0613a11565b6020908102919091010152505050600101612061565b5098975050505050505050565b6040516305eff7ef60e21b81526001600160a01b03848116600483015260009182918516906317bfdfbc90602401602060405180830381865afa15801561264e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126729190613bbd565b604051633af9e66960e01b81526001600160a01b038781166004830152919250600091861690633af9e66990602401602060405180830381865afa1580156126be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e29190613bbd565b90506000856001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612724573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127489190613bbd565b90506000866001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa15801561278a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ae9190613bbd565b90506000876001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128149190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612856573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287a9190613ade565b60405163fc57d4df60e01b81526001600160a01b038b8116600483015291925060009183169063fc57d4df90602401602060405180830381865afa1580156128c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ea9190613bbd565b90506000670de0b6b3a76400006129018389613bd6565b61290b9190613cbf565b90506000670de0b6b3a7640000612922848b613bd6565b61292c9190613cbf565b9050600061293a8884613bd6565b905060006129488884613bd6565b9050836000036129665760009b50505050505050505050505061121a565b838d6129728385613cd3565b61297c9190613c59565b6129869190613c03565b9f9e505050505050505050505050505050565b600080826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fe9190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a649190613ade565b60405163fc57d4df60e01b81526001600160a01b03868116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015612ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad49190613bbd565b90506000836001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa158015612b16573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b3e9190810190613a27565b905060005b8151811015612d81576000828281518110612b6057612b60613a11565b602002602001015190506000816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bce9190613ade565b90506000612c41838b846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c399190613c9c565b60ff16612d8b565b6040516315d5220f60e31b81526001600160a01b038481166004830152919250600091612d639184918b169063aea9107890602401602060405180830381865afa158015612c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb79190613bbd565b898e6001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1a9190613bbd565b60006001600160a01b0316896001600160a01b031663ab5497d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124e0573d6000803e3d6000fd5b9050612d6f818b613c31565b99505060019093019250612b43915050565b5050505050919050565b60405163dde684a560e01b81526001600160a01b03808416600483015260009184918391829188169063dde684a59060240160408051808303816000875af1158015612ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dff9190613cfa565b604051632e6f912b60e21b81526001600160a01b038681166004830152600060248301529294509092509088169063b9be44ac906044016020604051808303816000875af1158015612e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e799190613bbd565b5060405163dde684a560e01b81526001600160a01b03848116600483015260009182918a169063dde684a59060240160408051808303816000875af1158015612ec6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eea9190613cfa565b915091508263ffffffff168163ffffffff161115612f3b57612f0c8382613d3e565b63ffffffff16612f2e612f1f8685613d5b565b6001600160e01b031689612fd9565b612f389190613cbf565b95505b50505050509392505050565b600085600003612f5957506000612fd0565b6000612f658688613bd6565b90506000612f77826301e187e0613bd6565b90506000612f858783613cbf565b90506000612f9b82670de0b6b3a7640000613bd6565b90508086612fb457612fad8883613cbf565b9050612fc9565b612fc6670de0b6b3a764000083613cbf565b90505b9450505050505b95945050505050565b6000601282111561300957612fef601283613c89565b612ffa90600a613e5f565b6130049084613cbf565b61121a565b613014826012613c89565b61301f90600a613e5f565b61121a9084613bd6565b6001600160a01b038116811461303e57600080fd5b50565b6000806040838503121561305457600080fd5b823561305f81613029565b946020939093013593505050565b60008151808452602080850194506020840160005b838110156130a75781516001600160a01b031687529582019590820190600101613082565b509495945050505050565b60208152600061121a602083018461306d565b600080604083850312156130d857600080fd5b82356130e381613029565b915060208301356130f381613029565b809150509250929050565b60008151808452602080850194506020840160005b838110156130a757815187529582019590820190600101613113565b606080825284519082018190526000906020906080840190828801845b828110156131715781516001600160a01b03168452928401929084019060010161314c565b5050508381036020850152613186818761306d565b9150508281036040840152611b5b81856130fe565b60008083601f8401126131ad57600080fd5b5081356001600160401b038111156131c457600080fd5b6020830191508360208260051b85010111156131df57600080fd5b9250929050565b600080600080600080608087890312156131ff57600080fd5b863561320a81613029565b9550602087013561321a81613029565b945060408701356001600160401b038082111561323657600080fd5b6132428a838b0161319b565b9096509450606089013591508082111561325b57600080fd5b5061326889828a0161319b565b979a9699509497509295939492505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156132b2576132b261327a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156132e0576132e061327a565b604052919050565b60006001600160401b038211156133015761330161327a565b5060051b60200190565b600082601f83011261331c57600080fd5b8135602061333161332c836132e8565b6132b8565b8083825260208201915060208460051b87010193508684111561335357600080fd5b602086015b8481101561336f5780358352918301918301613358565b509695505050505050565b6000806000806080858703121561339057600080fd5b843561339b81613029565b9350602085810135935060408601356001600160401b03808211156133bf57600080fd5b818801915088601f8301126133d357600080fd5b81356133e161332c826132e8565b81815260059190911b8301840190848101908b83111561340057600080fd5b938501935b8285101561342757843561341881613029565b82529385019390850190613405565b96505050606088013592508083111561343f57600080fd5b505061344d8782880161330b565b91505092959194509250565b6000602080838503121561346c57600080fd5b82356001600160401b0381111561348257600080fd5b8301601f8101851361349357600080fd5b80356134a161332c826132e8565b81815260059190911b820183019083810190878311156134c057600080fd5b928401925b828410156134e75783356134d881613029565b825292840192908401906134c5565b979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156135c257888303603f19018552815180518452878101516001600160a01b03908116898601529087015160608886018190528151818701819052918a019290916080918288019160005b818110156135aa578651805185528e8101518f8601528d8101518e86015286810151841687860152850151831685850152958d019560a090930192600101613567565b505050978a0197955050509187019150600101613519565b509098975050505050505050565b600082601f8301126135e157600080fd5b813560206135f161332c836132e8565b8083825260208201915060208460051b87010193508684111561361357600080fd5b602086015b8481101561336f57803561362b81613029565b8352918301918301613618565b8035801515811461364857600080fd5b919050565b600082601f83011261365e57600080fd5b8135602061366e61332c836132e8565b8083825260208201915060208460051b87010193508684111561369057600080fd5b602086015b8481101561336f576136a681613638565b8352918301918301613695565b600080600080608085870312156136c957600080fd5b84356136d481613029565b93506020858101356001600160401b03808211156136f157600080fd5b818801915088601f83011261370557600080fd5b813561371361332c826132e8565b81815260059190911b8301840190848101908b83111561373257600080fd5b938501935b8285101561375957843561374a81613029565b82529385019390850190613737565b97505050604088013592508083111561377157600080fd5b61377d89848a016135d0565b9450606088013592508083111561379357600080fd5b505061344d8782880161364d565b6000602082840312156137b357600080fd5b813561121a81613029565b6040815260006137d1604083018561306d565b8281036020840152612fd081856130fe565b805161364881613029565b6000601f83601f84011261380157600080fd5b8251602061381161332c836132e8565b82815260059290921b8501810191818101908784111561383057600080fd5b8287015b8481101561394a5780516001600160401b03808211156138545760008081fd5b9089019060a0601f19838d03810182131561386f5760008081fd5b613877613290565b88850151848111156138895760008081fd5b8501603f81018f1361389b5760008081fd5b89810151858111156138af576138af61327a565b6138be8b858f840116016132b8565b9550808652604093508f848284010111156138d95760008081fd5b60005b818110156138f7578281018501518782018d01528b016138dc565b5060009086018b01525083815261390f8583016137e3565b89820152606093506139228486016137e3565b9181019190915260808481015193820193909352920151908201528352918301918301613834565b50979650505050505050565b6000806040838503121561396957600080fd5b82516001600160401b038082111561398057600080fd5b818501915085601f83011261399457600080fd5b815160206139a461332c836132e8565b82815260059290921b840181019181810190898411156139c357600080fd5b948201945b838610156139e1578551825294820194908201906139c8565b918801519196509093505050808211156139fa57600080fd5b50613a07858286016137ee565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215613a3a57600080fd5b82516001600160401b03811115613a5057600080fd5b8301601f81018513613a6157600080fd5b8051613a6f61332c826132e8565b81815260059190911b82018301908381019087831115613a8e57600080fd5b928401925b828410156134e7578351613aa681613029565b82529284019290840190613a93565b634e487b7160e01b600052601160045260246000fd5b808201808211156101fe576101fe613ab5565b600060208284031215613af057600080fd5b815161121a81613029565b600060018201613b0d57613b0d613ab5565b5060010190565b60006020808385031215613b2757600080fd5b82516001600160401b03811115613b3d57600080fd5b8301601f81018513613b4e57600080fd5b8051613b5c61332c826132e8565b81815260059190911b82018301908381019087831115613b7b57600080fd5b928401925b828410156134e7578351613b9381613029565b82529284019290840190613b80565b600060208284031215613bb457600080fd5b61121a82613638565b600060208284031215613bcf57600080fd5b5051919050565b80820281158282048414176101fe576101fe613ab5565b634e487b7160e01b600052601260045260246000fd5b600082613c1257613c12613bed565b600160ff1b821460001984141615613c2c57613c2c613ab5565b500590565b8082018281126000831280158216821582161715613c5157613c51613ab5565b505092915050565b80820260008212600160ff1b84141615613c7557613c75613ab5565b81810583148215176101fe576101fe613ab5565b818103818111156101fe576101fe613ab5565b600060208284031215613cae57600080fd5b815160ff8116811461121a57600080fd5b600082613cce57613cce613bed565b500490565b8181036000831280158383131683831282161715613cf357613cf3613ab5565b5092915050565b60008060408385031215613d0d57600080fd5b82516001600160e01b0381168114613d2457600080fd5b602084015190925063ffffffff811681146130f357600080fd5b63ffffffff828116828216039080821115613cf357613cf3613ab5565b6001600160e01b03828116828216039080821115613cf357613cf3613ab5565b600181815b80851115613db6578160001904821115613d9c57613d9c613ab5565b80851615613da957918102915b93841c9390800290613d80565b509250929050565b600082613dcd575060016101fe565b81613dda575060006101fe565b8160018114613df05760028114613dfa57613e16565b60019150506101fe565b60ff841115613e0b57613e0b613ab5565b50506001821b6101fe565b5060208310610133831016604e8410600b8410161715613e39575081810a6101fe565b613e438383613d7b565b8060001904821115613e5757613e57613ab5565b029392505050565b600061121a8383613dbe56fea264697066735822122098ddba7444777e92520955b1be2c8b1bfa70d335b780c159a946a414aeaa89bc64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80637e70aa49116100715780637e70aa49146101315780638260a696146101515780639cf1fd5314610164578063bdfc183914610185578063d1040bae14610198578063de858c63146101ab57600080fd5b80630d9d7fdc146100ae57806312edb24c146100d45780633610c407146100e95780634f471e6d1461010b5780637d3cab4c1461011e575b600080fd5b6100c16100bc366004613041565b6101d6565b6040519081526020015b60405180910390f35b6100dc610204565b6040516100cb91906130b2565b6100fc6100f73660046130c5565b6105fa565b6040516100cb9392919061312f565b6100fc6101193660046131e6565b6108a4565b6100c161012c36600461337a565b610c95565b61014461013f366004613459565b6110d7565b6040516100cb91906134f2565b6100fc61015f3660046136b3565b611221565b6101776101723660046137a1565b6115ca565b6040516100cb9291906137be565b6100c16101933660046130c5565b61167f565b6101446101a63660046137a1565b611b65565b6000546101be906001600160a01b031681565b6040516001600160a01b0390911681526020016100cb565b60408051600080825260208201818152828401909352916101f985858484610c95565b925050505b92915050565b60008054604080516323b020d560e21b81529051606093926001600160a01b031691638ec0835491600480830192869291908290030181865afa15801561024f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102779190810190613956565b915060009050805b825181101561032d57600083828151811061029c5761029c613a11565b60200260200101516040015190506000816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156102ea573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103129190810190613a27565b90508051846103219190613acb565b9350505060010161027f565b506000816001600160401b038111156103485761034861327a565b604051908082528060200260200182016040528015610371578160200160208202803683370190505b5090506000805b845181101561055657600085828151811061039557610395613a11565b60200260200101516040015190506000816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156103e3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261040b9190810190613a27565b905060005b815181101561054b57600082828151811061042d5761042d613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104969190613ade565b90506001600160a01b0381166104ac575061054b565b6000805b88518110156104fc578881815181106104cb576104cb613a11565b60200260200101516001600160a01b0316836001600160a01b0316036104f457600191506104fc565b6001016104b0565b50806105415781888861050e81613afb565b99508151811061052057610520613a11565b60200260200101906001600160a01b031690816001600160a01b0316815250505b5050600101610410565b505050600101610378565b50806001600160401b0381111561056f5761056f61327a565b604051908082528060200260200182016040528015610598578160200160208202803683370190505b50945060005b818110156105f2578281815181106105b8576105b8613a11565b60200260200101518682815181106105d2576105d2613a11565b6001600160a01b039092166020928302919091019091015260010161059e565b505050505090565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561063f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106679190810190613b14565b9050600081516001600160401b038111156106845761068461327a565b6040519080825280602002602001820160405280156106ad578160200160208202803683370190505b5090506000866001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa1580156106f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107189190810190613a27565b9050600081516001600160401b038111156107355761073561327a565b60405190808252806020026020018201604052801561075e578160200160208202803683370190505b509050600082516001600160401b0381111561077c5761077c61327a565b6040519080825280602002602001820160405280156107a5578160200160208202803683370190505b50905060005b835181101561082c578381815181106107c6576107c6613a11565b60200260200101518382815181106107e0576107e0613a11565b60200260200101906001600160a01b031690816001600160a01b031681525050600182828151811061081457610814613a11565b911515602092830291909101909101526001016107ab565b5060005b85518110156108855785818151811061084b5761084b613a11565b602002602001015185828151811061086557610865613a11565b6001600160a01b0390921660209283029190910190910152600101610830565b506108928a858484611221565b97509750975050505050509250925092565b6060808085806001600160401b038111156108c1576108c161327a565b6040519080825280602002602001820160405280156108ea578160200160208202803683370190505b509150806001600160401b038111156109055761090561327a565b60405190808252806020026020018201604052801561092e578160200160208202803683370190505b50925060005b81811015610c4557600087878381811061095057610950613a11565b90506020020160208101906109659190613ba2565b15610a0e5789898381811061097c5761097c613a11565b905060200201602081019061099191906137a1565b604051632e6f912b60e21b81526001600160a01b038d811660048301528e81166024830152919091169063b9be44ac906044016020604051808303816000875af11580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a079190613bbd565b9050610aa6565b898983818110610a2057610a20613a11565b9050602002016020810190610a3591906137a1565b604051630ff6b5a760e31b81526001600160a01b038e811660048301529190911690637fb5ad38906024016020604051808303816000875af1158015610a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa39190613bbd565b90505b80848381518110610ab957610ab9613a11565b60200260200101511015610acd5780610ae8565b838281518110610adf57610adf613a11565b60200260200101515b848381518110610afa57610afa613a11565b602002602001018181525050898983818110610b1857610b18613a11565b9050602002016020810190610b2d91906137a1565b604051633bd73ee360e21b81526001600160a01b038e81166004830152919091169063ef5cfb8c90602401600060405180830381600087803b158015610b7257600080fd5b505af1158015610b86573d6000803e3d6000fd5b50505050898983818110610b9c57610b9c613a11565b9050602002016020810190610bb191906137a1565b6001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c129190613ade565b858381518110610c2457610c24613a11565b6001600160a01b039092166020928302919091019091015250600101610934565b5087878484838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929a5093985091965050505050505096509650969350505050565b6040805160a0810182526000808252602082018190529181018290526060808201526080810182905260008060009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d12573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d3a9190810190613956565b91505060005b8151811015611092576000828281518110610d5d57610d5d613a11565b6020026020010151604001519050806001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcd9190613ade565b84604001906001600160a01b031690816001600160a01b031681525050806001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e28573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e509190810190613b14565b606085015260005b846060015151811015611088576000805b8951811015610ee65786606001518381518110610e8857610e88613a11565b60200260200101516001600160a01b03168a8281518110610eab57610eab613a11565b60200260200101516001600160a01b031603610ede57888181518110610ed357610ed3613a11565b602002602001015191505b600101610e69565b50670de0b6b3a764000086604001516001600160a01b031663fc57d4df88606001518581518110610f1957610f19613a11565b60200260200101516040518263ffffffff1660e01b8152600401610f4c91906001600160a01b0391909116815260200190565b602060405180830381865afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613bbd565b87606001518481518110610fa357610fa3613a11565b6020908102919091010151604051633af9e66960e01b81526001600160a01b038f8116600483015290911690633af9e66990602401602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110199190613bbd565b6110239190613bd6565b61102d9190613c03565b8651879061103c908390613c31565b9052506060860151805161106b918d918590811061105c5761105c613a11565b6020026020010151838d611bdb565b8660200181815161107c9190613c31565b90525050600101610e58565b5050600101610d40565b5081516000036110a7576000925050506110cf565b815160208301516110c090670de0b6b3a7640000613c59565b6110ca9190613c03565b925050505b949350505050565b60606000805b835181101561120f5760008482815181106110fa576110fa613a11565b6020026020010151905060006001600160a01b0316836001600160a01b03160361118757806001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111809190613ade565b9250611206565b826001600160a01b0316816001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f39190613ade565b6001600160a01b03161461120657600080fd5b506001016110dd565b5061121a8382611de5565b9392505050565b606080606084516001600160401b0381111561123f5761123f61327a565b604051908082528060200260200182016040528015611268578160200160208202803683370190505b50905084516001600160401b038111156112845761128461327a565b6040519080825280602002602001820160405280156112ad578160200160208202803683370190505b50915060005b85518110156115bd5760005b87518110156114965760008882815181106112dc576112dc613a11565b6020026020010151905060008784815181106112fa576112fa613a11565b6020026020010151156113a05788848151811061131957611319613a11565b6020908102919091010151604051632e6f912b60e21b81526001600160a01b0384811660048301528d811660248301529091169063b9be44ac906044016020604051808303816000875af1158015611375573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113999190613bbd565b905061142d565b8884815181106113b2576113b2613a11565b6020908102919091010151604051630ff6b5a760e31b81526001600160a01b038d8116600483015290911690637fb5ad38906024016020604051808303816000875af1158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142a9190613bbd565b90505b8085858151811061144057611440613a11565b60200260200101511015611454578061146f565b84848151811061146657611466613a11565b60200260200101515b85858151811061148157611481613a11565b602090810291909101015250506001016112bf565b508581815181106114a9576114a9613a11565b6020908102919091010151604051633bd73ee360e21b81526001600160a01b038a811660048301529091169063ef5cfb8c90602401600060405180830381600087803b1580156114f857600080fd5b505af115801561150c573d6000803e3d6000fd5b5050505085818151811061152257611522613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158b9190613ade565b83828151811061159d5761159d613a11565b6001600160a01b03909216602092830291909101909101526001016112b3565b5093969095509293505050565b60608060006115d7610204565b9050600081516001600160401b038111156115f4576115f461327a565b60405190808252806020026020018201604052801561161d578160200160208202803683370190505b50905060005b82518110156116745761164f8684838151811061164257611642613a11565b602002602001015161167f565b82828151811061166157611661613a11565b6020908102919091010152600101611623565b509094909350915050565b6040516370a0823160e01b81526001600160a01b03838116600483015260009182918416906370a0823190602401602060405180830381865afa1580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee9190613bbd565b905060008060009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611744573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261176c9190810190613956565b91505060005b8151811015611ae057600082828151811061178f5761178f613a11565b602002602001015160400151905060606000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156117df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118079190810190613b14565b905080516001600160401b038111156118225761182261327a565b60405190808252806020026020018201604052801561184b578160200160208202803683370190505b50915060005b81518110156118a65781818151811061186c5761186c613a11565b602002602001015183828151811061188657611886613a11565b6001600160a01b0390921660209283029190910190910152600101611851565b50506000826001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa1580156118e8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119109190810190613a27565b905060005b8151811015611ad057600082828151811061193257611932613a11565b60200260200101519050896001600160a01b0316816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a89190613ade565b6001600160a01b031603611ac75760005b8451811015611a6a57816001600160a01b031663b9be44ac8683815181106119e3576119e3613a11565b60200260200101518e6040518363ffffffff1660e01b8152600401611a1e9291906001600160a01b0392831681529116602082015260400190565b6020604051808303816000875af1158015611a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a619190613bbd565b506001016119b9565b50604051633bd73ee360e21b81526001600160a01b038c8116600483015282169063ef5cfb8c90602401600060405180830381600087803b158015611aae57600080fd5b505af1158015611ac2573d6000803e3d6000fd5b505050505b50600101611915565b5050600190920191506117729050565b506040516370a0823160e01b81526001600160a01b038681166004830152600091908616906370a0823190602401602060405180830381865afa158015611b2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4f9190613bbd565b9050611b5b8382613c89565b9695505050505050565b60606000826001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ba7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bcf9190810190613b14565b905061121a8184611de5565b600080846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c409190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca69190613ade565b9050600085611cb6898988612603565b611cbf89612999565b611cc99190613c31565b611cd39190613c31565b60405163fc57d4df60e01b81526001600160a01b0389811660048301529192506ec097ce7bc90715b34b9f10000000009184169063fc57d4df90602401602060405180830381865afa158015611d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d519190613bbd565b604051633af9e66960e01b81526001600160a01b038b811660048301528a1690633af9e66990602401602060405180830381865afa158015611d97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbb9190613bbd565b611dc59084613c59565b611dcf9190613c59565b611dd99190613c03565b98975050505050505050565b60606001600160a01b0382161580611dfc57508251155b15611e4e576040805160008082526020820190925290611e46565b60408051606080820183526000808352602083015291810191909152815260200190600190039081611e175790505b5090506101fe565b6000826001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa158015611e8e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eb69190810190613a27565b9050600081516001600160401b03811115611ed357611ed361327a565b604051908082528060200260200182016040528015611efc578160200160208202803683370190505b509050600082516001600160401b03811115611f1a57611f1a61327a565b604051908082528060200260200182016040528015611f43578160200160208202803683370190505b509050600083516001600160401b03811115611f6157611f6161327a565b604051908082528060200260200182016040528015611f8a578160200160208202803683370190505b5090506000866001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff19190613ade565b9050600088516001600160401b0381111561200e5761200e61327a565b60405190808252806020026020018201604052801561205b57816020015b6040805160608082018352600080835260208301529181019190915281526020019060019003908161202c5790505b50905060005b89518110156125f657600087516001600160401b038111156120855761208561327a565b6040519080825280602002602001820160405280156120fa57816020015b6120e76040518060a0016040528060008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b8152602001906001900390816120a35790505b50905060008b838151811061211157612111613a11565b602002602001015190506000856001600160a01b031663aea91078836001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561216a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218e9190613ade565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156121d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f69190613bbd565b9050836000036123c25760005b8a518110156123c05760008b828151811061222057612220613a11565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612265573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122899190613ade565b9050808b838151811061229e5761229e613a11565b6001600160a01b0392831660209182029290920101526040516315d5220f60e31b815282821660048201529089169063aea9107890602401602060405180830381865afa1580156122f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123179190613bbd565b8a838151811061232957612329613a11565b602002602001018181525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612373573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123979190613c9c565b60ff168983815181106123ac576123ac613a11565b602090810291909101015250600101612203565b505b60005b8a518110156125a95760008b82815181106123e2576123e2613a11565b60200260200101519050600061241282868c868151811061240557612405613a11565b6020026020010151612d8b565b90506000612514828d868151811061242c5761242c613a11565b602002602001015187896001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612473573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124979190613bbd565b60006001600160a01b0316886001600160a01b031663ab5497d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125049190613ade565b6001600160a01b03161415612f47565b90506040518060a001604052808381526020018d868151811061253957612539613a11565b60200260200101518152602001828152602001846001600160a01b031681526020018e868151811061256d5761256d613a11565b60200260200101516001600160a01b031681525087858151811061259357612593613a11565b60209081029190910101525050506001016123c5565b506040518060600160405280828152602001836001600160a01b03168152602001848152508585815181106125e0576125e0613a11565b6020908102919091010152505050600101612061565b5098975050505050505050565b6040516305eff7ef60e21b81526001600160a01b03848116600483015260009182918516906317bfdfbc90602401602060405180830381865afa15801561264e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126729190613bbd565b604051633af9e66960e01b81526001600160a01b038781166004830152919250600091861690633af9e66990602401602060405180830381865afa1580156126be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e29190613bbd565b90506000856001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612724573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127489190613bbd565b90506000866001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa15801561278a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ae9190613bbd565b90506000876001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128149190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612856573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287a9190613ade565b60405163fc57d4df60e01b81526001600160a01b038b8116600483015291925060009183169063fc57d4df90602401602060405180830381865afa1580156128c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ea9190613bbd565b90506000670de0b6b3a76400006129018389613bd6565b61290b9190613cbf565b90506000670de0b6b3a7640000612922848b613bd6565b61292c9190613cbf565b9050600061293a8884613bd6565b905060006129488884613bd6565b9050836000036129665760009b50505050505050505050505061121a565b838d6129728385613cd3565b61297c9190613c59565b6129869190613c03565b9f9e505050505050505050505050505050565b600080826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fe9190613ade565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a649190613ade565b60405163fc57d4df60e01b81526001600160a01b03868116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015612ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad49190613bbd565b90506000836001600160a01b0316634a76e7276040518163ffffffff1660e01b8152600401600060405180830381865afa158015612b16573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b3e9190810190613a27565b905060005b8151811015612d81576000828281518110612b6057612b60613a11565b602002602001015190506000816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612baa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bce9190613ade565b90506000612c41838b846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c399190613c9c565b60ff16612d8b565b6040516315d5220f60e31b81526001600160a01b038481166004830152919250600091612d639184918b169063aea9107890602401602060405180830381865afa158015612c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb79190613bbd565b898e6001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1a9190613bbd565b60006001600160a01b0316896001600160a01b031663ab5497d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124e0573d6000803e3d6000fd5b9050612d6f818b613c31565b99505060019093019250612b43915050565b5050505050919050565b60405163dde684a560e01b81526001600160a01b03808416600483015260009184918391829188169063dde684a59060240160408051808303816000875af1158015612ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dff9190613cfa565b604051632e6f912b60e21b81526001600160a01b038681166004830152600060248301529294509092509088169063b9be44ac906044016020604051808303816000875af1158015612e55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e799190613bbd565b5060405163dde684a560e01b81526001600160a01b03848116600483015260009182918a169063dde684a59060240160408051808303816000875af1158015612ec6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eea9190613cfa565b915091508263ffffffff168163ffffffff161115612f3b57612f0c8382613d3e565b63ffffffff16612f2e612f1f8685613d5b565b6001600160e01b031689612fd9565b612f389190613cbf565b95505b50505050509392505050565b600085600003612f5957506000612fd0565b6000612f658688613bd6565b90506000612f77826301e187e0613bd6565b90506000612f858783613cbf565b90506000612f9b82670de0b6b3a7640000613bd6565b90508086612fb457612fad8883613cbf565b9050612fc9565b612fc6670de0b6b3a764000083613cbf565b90505b9450505050505b95945050505050565b6000601282111561300957612fef601283613c89565b612ffa90600a613e5f565b6130049084613cbf565b61121a565b613014826012613c89565b61301f90600a613e5f565b61121a9084613bd6565b6001600160a01b038116811461303e57600080fd5b50565b6000806040838503121561305457600080fd5b823561305f81613029565b946020939093013593505050565b60008151808452602080850194506020840160005b838110156130a75781516001600160a01b031687529582019590820190600101613082565b509495945050505050565b60208152600061121a602083018461306d565b600080604083850312156130d857600080fd5b82356130e381613029565b915060208301356130f381613029565b809150509250929050565b60008151808452602080850194506020840160005b838110156130a757815187529582019590820190600101613113565b606080825284519082018190526000906020906080840190828801845b828110156131715781516001600160a01b03168452928401929084019060010161314c565b5050508381036020850152613186818761306d565b9150508281036040840152611b5b81856130fe565b60008083601f8401126131ad57600080fd5b5081356001600160401b038111156131c457600080fd5b6020830191508360208260051b85010111156131df57600080fd5b9250929050565b600080600080600080608087890312156131ff57600080fd5b863561320a81613029565b9550602087013561321a81613029565b945060408701356001600160401b038082111561323657600080fd5b6132428a838b0161319b565b9096509450606089013591508082111561325b57600080fd5b5061326889828a0161319b565b979a9699509497509295939492505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156132b2576132b261327a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156132e0576132e061327a565b604052919050565b60006001600160401b038211156133015761330161327a565b5060051b60200190565b600082601f83011261331c57600080fd5b8135602061333161332c836132e8565b6132b8565b8083825260208201915060208460051b87010193508684111561335357600080fd5b602086015b8481101561336f5780358352918301918301613358565b509695505050505050565b6000806000806080858703121561339057600080fd5b843561339b81613029565b9350602085810135935060408601356001600160401b03808211156133bf57600080fd5b818801915088601f8301126133d357600080fd5b81356133e161332c826132e8565b81815260059190911b8301840190848101908b83111561340057600080fd5b938501935b8285101561342757843561341881613029565b82529385019390850190613405565b96505050606088013592508083111561343f57600080fd5b505061344d8782880161330b565b91505092959194509250565b6000602080838503121561346c57600080fd5b82356001600160401b0381111561348257600080fd5b8301601f8101851361349357600080fd5b80356134a161332c826132e8565b81815260059190911b820183019083810190878311156134c057600080fd5b928401925b828410156134e75783356134d881613029565b825292840192908401906134c5565b979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156135c257888303603f19018552815180518452878101516001600160a01b03908116898601529087015160608886018190528151818701819052918a019290916080918288019160005b818110156135aa578651805185528e8101518f8601528d8101518e86015286810151841687860152850151831685850152958d019560a090930192600101613567565b505050978a0197955050509187019150600101613519565b509098975050505050505050565b600082601f8301126135e157600080fd5b813560206135f161332c836132e8565b8083825260208201915060208460051b87010193508684111561361357600080fd5b602086015b8481101561336f57803561362b81613029565b8352918301918301613618565b8035801515811461364857600080fd5b919050565b600082601f83011261365e57600080fd5b8135602061366e61332c836132e8565b8083825260208201915060208460051b87010193508684111561369057600080fd5b602086015b8481101561336f576136a681613638565b8352918301918301613695565b600080600080608085870312156136c957600080fd5b84356136d481613029565b93506020858101356001600160401b03808211156136f157600080fd5b818801915088601f83011261370557600080fd5b813561371361332c826132e8565b81815260059190911b8301840190848101908b83111561373257600080fd5b938501935b8285101561375957843561374a81613029565b82529385019390850190613737565b97505050604088013592508083111561377157600080fd5b61377d89848a016135d0565b9450606088013592508083111561379357600080fd5b505061344d8782880161364d565b6000602082840312156137b357600080fd5b813561121a81613029565b6040815260006137d1604083018561306d565b8281036020840152612fd081856130fe565b805161364881613029565b6000601f83601f84011261380157600080fd5b8251602061381161332c836132e8565b82815260059290921b8501810191818101908784111561383057600080fd5b8287015b8481101561394a5780516001600160401b03808211156138545760008081fd5b9089019060a0601f19838d03810182131561386f5760008081fd5b613877613290565b88850151848111156138895760008081fd5b8501603f81018f1361389b5760008081fd5b89810151858111156138af576138af61327a565b6138be8b858f840116016132b8565b9550808652604093508f848284010111156138d95760008081fd5b60005b818110156138f7578281018501518782018d01528b016138dc565b5060009086018b01525083815261390f8583016137e3565b89820152606093506139228486016137e3565b9181019190915260808481015193820193909352920151908201528352918301918301613834565b50979650505050505050565b6000806040838503121561396957600080fd5b82516001600160401b038082111561398057600080fd5b818501915085601f83011261399457600080fd5b815160206139a461332c836132e8565b82815260059290921b840181019181810190898411156139c357600080fd5b948201945b838610156139e1578551825294820194908201906139c8565b918801519196509093505050808211156139fa57600080fd5b50613a07858286016137ee565b9150509250929050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215613a3a57600080fd5b82516001600160401b03811115613a5057600080fd5b8301601f81018513613a6157600080fd5b8051613a6f61332c826132e8565b81815260059190911b82018301908381019087831115613a8e57600080fd5b928401925b828410156134e7578351613aa681613029565b82529284019290840190613a93565b634e487b7160e01b600052601160045260246000fd5b808201808211156101fe576101fe613ab5565b600060208284031215613af057600080fd5b815161121a81613029565b600060018201613b0d57613b0d613ab5565b5060010190565b60006020808385031215613b2757600080fd5b82516001600160401b03811115613b3d57600080fd5b8301601f81018513613b4e57600080fd5b8051613b5c61332c826132e8565b81815260059190911b82018301908381019087831115613b7b57600080fd5b928401925b828410156134e7578351613b9381613029565b82529284019290840190613b80565b600060208284031215613bb457600080fd5b61121a82613638565b600060208284031215613bcf57600080fd5b5051919050565b80820281158282048414176101fe576101fe613ab5565b634e487b7160e01b600052601260045260246000fd5b600082613c1257613c12613bed565b600160ff1b821460001984141615613c2c57613c2c613ab5565b500590565b8082018281126000831280158216821582161715613c5157613c51613ab5565b505092915050565b80820260008212600160ff1b84141615613c7557613c75613ab5565b81810583148215176101fe576101fe613ab5565b818103818111156101fe576101fe613ab5565b600060208284031215613cae57600080fd5b815160ff8116811461121a57600080fd5b600082613cce57613cce613bed565b500490565b8181036000831280158383131683831282161715613cf357613cf3613ab5565b5092915050565b60008060408385031215613d0d57600080fd5b82516001600160e01b0381168114613d2457600080fd5b602084015190925063ffffffff811681146130f357600080fd5b63ffffffff828116828216039080821115613cf357613cf3613ab5565b6001600160e01b03828116828216039080821115613cf357613cf3613ab5565b600181815b80851115613db6578160001904821115613d9c57613d9c613ab5565b80851615613da957918102915b93841c9390800290613d80565b509250929050565b600082613dcd575060016101fe565b81613dda575060006101fe565b8160018114613df05760028114613dfa57613e16565b60019150506101fe565b60ff841115613e0b57613e0b613ab5565b50506001821b6101fe565b5060208310610133831016604e8410600b8410161715613e39575081810a6101fe565b613e438383613d7b565b8060001904821115613e5757613e57613ab5565b029392505050565b600061121a8383613dbe56fea264697066735822122098ddba7444777e92520955b1be2c8b1bfa70d335b780c159a946a414aeaa89bc64736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 62489, + "contract": "contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol:IonicFlywheelLensRouter", + "label": "fpd", + "offset": 0, + "slot": "0", + "type": "t_contract(PoolDirectory)14768" + } + ], + "types": { + "t_contract(PoolDirectory)14768": { + "encoding": "inplace", + "label": "contract PoolDirectory", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/IonicLiquidator_Implementation.json b/packages/contracts/deployments/superseed/IonicLiquidator_Implementation.json new file mode 100644 index 0000000000..6ae0d006ba --- /dev/null +++ b/packages/contracts/deployments/superseed/IonicLiquidator_Implementation.json @@ -0,0 +1,905 @@ +{ + "address": "0xeC7D0330E86485474C13A2152Fa867ddd41Bb12B", + "abi": [ + { + "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": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "VaultReceivedETH", + "type": "event" + }, + { + "inputs": [], + "name": "UNISWAP_V2_ROUTER_02", + "outputs": [ + { + "internalType": "contract IUniswapV2Router02", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "W_NATIVE_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "_becomeImplementation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "whitelisted", + "type": "bool[]" + } + ], + "name": "_whitelistRedemptionStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategy", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_whitelistRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "expressRelay", + "outputs": [ + { + "internalType": "contract IExpressRelay", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "flashSwapFee", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "healthFactorThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_wtoken", + "type": "address" + }, + { + "internalType": "address", + "name": "_uniswapV2router", + "type": "address" + }, + { + "internalType": "uint8", + "name": "_flashSwapFee", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lens", + "outputs": [ + { + "internalType": "contract PoolLens", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "moraswapCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "pancakeCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "receiveAuctionProceedings", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlyingBorrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "receiveFlashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidatePyth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "flashSwapContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minProfitAmount", + "type": "uint256" + }, + { + "internalType": "contract IRedemptionStrategy[]", + "name": "redemptionStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "strategyData", + "type": "bytes[]" + }, + { + "internalType": "contract IFundsConversionStrategy[]", + "name": "debtFundingStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "debtFundingStrategiesData", + "type": "bytes[]" + } + ], + "internalType": "struct ILiquidator.LiquidateToTokensWithFlashSwapVars", + "name": "vars", + "type": "tuple" + } + ], + "name": "safeLiquidateToTokensWithFlashLoan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "aggregatorTarget", + "type": "address" + }, + { + "internalType": "bytes", + "name": "aggregatorData", + "type": "bytes" + } + ], + "name": "safeLiquidateWithAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_expressRelay", + "type": "address" + } + ], + "name": "setExpressRelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_healthFactorThreshold", + "type": "uint256" + } + ], + "name": "setHealthFactorThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolLens", + "type": "address" + } + ], + "name": "setPoolLens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "uniswapV2Call", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xac14a79c245a7510c5169ca06ff901ff62eb1d74705aef8dd023d8cf7742ff15", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xeC7D0330E86485474C13A2152Fa867ddd41Bb12B", + "transactionIndex": 1, + "gasUsed": "3965832", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf98d33eedf1b13277b25042fa0819cf574fb06eb0fab6aa059c6ef1ecda5b519", + "transactionHash": "0xac14a79c245a7510c5169ca06ff901ff62eb1d74705aef8dd023d8cf7742ff15", + "logs": [], + "blockNumber": 4159435, + "cumulativeGasUsed": "4009674", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"permissionKey\",\"type\":\"bytes\"}],\"name\":\"VaultReceivedETH\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"UNISWAP_V2_ROUTER_02\",\"outputs\":[{\"internalType\":\"contract IUniswapV2Router02\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"W_NATIVE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"_becomeImplementation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"whitelisted\",\"type\":\"bool[]\"}],\"name\":\"_whitelistRedemptionStrategies\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_whitelistRedemptionStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"expressRelay\",\"outputs\":[{\"internalType\":\"contract IExpressRelay\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"flashSwapFee\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"healthFactorThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wtoken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_uniswapV2router\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"_flashSwapFee\",\"type\":\"uint8\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lens\",\"outputs\":[{\"internalType\":\"contract PoolLens\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"moraswapCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"pancakeCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"permissionKey\",\"type\":\"bytes\"}],\"name\":\"receiveAuctionProceedings\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_underlyingBorrow\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"receiveFlashLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minOutputAmount\",\"type\":\"uint256\"}],\"name\":\"safeLiquidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minOutputAmount\",\"type\":\"uint256\"}],\"name\":\"safeLiquidatePyth\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"flashSwapContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minProfitAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"redemptionStrategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"strategyData\",\"type\":\"bytes[]\"},{\"internalType\":\"contract IFundsConversionStrategy[]\",\"name\":\"debtFundingStrategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"debtFundingStrategiesData\",\"type\":\"bytes[]\"}],\"internalType\":\"struct ILiquidator.LiquidateToTokensWithFlashSwapVars\",\"name\":\"vars\",\"type\":\"tuple\"}],\"name\":\"safeLiquidateToTokensWithFlashLoan\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"aggregatorTarget\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"aggregatorData\",\"type\":\"bytes\"}],\"name\":\"safeLiquidateWithAggregator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_expressRelay\",\"type\":\"address\"}],\"name\":\"setExpressRelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_healthFactorThreshold\",\"type\":\"uint256\"}],\"name\":\"setHealthFactorThreshold\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolLens\",\"type\":\"address\"}],\"name\":\"setPoolLens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"uniswapV2Call\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"details\":\"Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_whitelistRedemptionStrategies(address[],bool[])\":{\"details\":\"for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\"},\"_whitelistRedemptionStrategy(address,bool)\":{\"details\":\"for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pancakeCall(address,uint256,uint256,bytes)\":{\"details\":\"Callback function for PCS flashloans.\"},\"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.\"},\"safeLiquidateToTokensWithFlashLoan((address,uint256,address,address,address,uint256,address[],bytes[],address[],bytes[]))\":{\"params\":{\"vars\":\"@see LiquidateToTokensWithFlashSwapVars.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"uniswapV2Call(address,uint256,uint256,bytes)\":{\"details\":\"Callback function for Uniswap flashloans.\"}},\"stateVariables\":{\"UNISWAP_V2_ROUTER_02\":{\"details\":\"UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)\"},\"W_NATIVE_ADDRESS\":{\"details\":\"W_NATIVE contract address.\"},\"_flashSwapAmount\":{\"details\":\"Cached flash swap amount. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\"},\"_flashSwapToken\":{\"details\":\"Cached flash swap token. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\"},\"_liquidatorProfitExchangeSource\":{\"details\":\"Cached liquidator profit exchange source. ERC20 token address or the zero address for NATIVE. For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\"},\"expressRelay\":{\"details\":\"Addres of Pyth Express Relay for preventing value leakage in liquidations.\"},\"flashSwapFee\":{\"details\":\"Percentage of the flash swap fee, measured in basis points.\"},\"healthFactorThreshold\":{\"details\":\"Health Factor below which PER permissioning is bypassed.\"},\"lens\":{\"details\":\"Pool Lens.\"}},\"title\":\"IonicLiquidator\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"receiveAuctionProceedings(bytes)\":{\"notice\":\"receiveAuctionProceedings function - receives native token from the express relay You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\"},\"safeLiquidateToTokensWithFlashLoan((address,uint256,address,address,address,uint256,address[],bytes[],address[],bytes[]))\":{\"notice\":\"Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.\"}},\"notice\":\"IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/IonicLiquidator.sol\":\"IonicLiquidator\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicLiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./utils/IW_NATIVE.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV2Router02.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV2Pair.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV2Callee.sol\\\";\\nimport \\\"./external/uniswap/UniswapV2Library.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicLiquidator\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).\\n * @dev Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.\\n */\\ncontract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, IExpressRelayFeeReceiver {\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n\\n /**\\n * @dev W_NATIVE contract address.\\n */\\n address public W_NATIVE_ADDRESS;\\n\\n /**\\n * @dev UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)\\n */\\n IUniswapV2Router02 public UNISWAP_V2_ROUTER_02;\\n\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n /**\\n * @dev Percentage of the flash swap fee, measured in basis points.\\n */\\n uint8 public flashSwapFee;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(\\n address _wtoken,\\n address _uniswapV2router,\\n uint8 _flashSwapFee\\n ) external initializer {\\n __Ownable_init();\\n require(_uniswapV2router != address(0), \\\"_uniswapV2router not defined.\\\");\\n W_NATIVE_ADDRESS = _wtoken;\\n UNISWAP_V2_ROUTER_02 = IUniswapV2Router02(_uniswapV2router);\\n flashSwapFee = _flashSwapFee;\\n }\\n\\n function _becomeImplementation(bytes calldata data) external {}\\n\\n /**\\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address to,\\n uint256 minAmount\\n ) private {\\n uint256 allowance = token.allowance(address(this), to);\\n\\n if (allowance < minAmount) {\\n if (allowance > 0) token.safeApprove(to, 0);\\n token.safeApprove(to, type(uint256).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function to approve\\n */\\n function justApprove(\\n IERC20Upgradeable token,\\n address to,\\n uint256 amount\\n ) private {\\n token.approve(to, amount);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n justApprove(underlying, address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.\\n * @param vars @see LiquidateToTokensWithFlashSwapVars.\\n */\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n onlyLowHF(vars.borrower, vars.cTokenCollateral)\\n returns (uint256)\\n {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV2Pair flashSwapPair = IUniswapV2Pair(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPair.token0() == address(fundingToken);\\n flashSwapPair.swap(\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n address(this),\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n function uniswapV2Call(\\n address,\\n uint256,\\n uint256,\\n bytes calldata data\\n ) public override {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars);\\n }\\n\\n /**\\n * @dev Callback function for PCS flashloans.\\n */\\n function pancakeCall(\\n address sender,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external {\\n uniswapV2Call(sender, amount0, amount1, data);\\n }\\n\\n function moraswapCall(\\n address sender,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external {\\n uniswapV2Call(sender, amount0, amount1, data);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(LiquidateToTokensWithFlashSwapVars memory vars) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n justApprove(IERC20Upgradeable(underlyingBorrow), address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData\\n ) private returns (address) {\\n // Calculate flashloan return amount\\n uint256 flashSwapReturnAmount = (_flashSwapAmount * 10000) / (10000 - flashSwapFee);\\n if ((_flashSwapAmount * 10000) % (10000 - flashSwapFee) > 0) flashSwapReturnAmount++; // Round up if division resulted in a remainder\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n IUniswapV2Pair pair = IUniswapV2Pair(msg.sender);\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pair.token0() || address(underlyingCollateral) == pair.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay amount for the borrow side\\n collateralRequired = flashSwapReturnAmount;\\n } else {\\n // repay amount for the non-borrow side\\n collateralRequired = UniswapV2Library.getAmountsIn(\\n UNISWAP_V2_ROUTER_02.factory(),\\n _flashSwapAmount, //flashSwapReturnAmount,\\n array(address(underlyingCollateral), _flashSwapToken),\\n flashSwapFee\\n )[0];\\n }\\n\\n // Repay flashloan\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n require(\\n underlyingCollateral.transfer(msg.sender, collateralRequired),\\n \\\"Failed to repay token flashloan on borrow side.\\\"\\n );\\n\\n return address(underlyingCollateral);\\n } else {\\n // exchange the collateral to W_NATIVE to repay the borrow side\\n uint256 wethRequired;\\n if (_flashSwapToken == W_NATIVE_ADDRESS) {\\n wethRequired = flashSwapReturnAmount;\\n } else {\\n // Get W_NATIVE required to repay flashloan\\n wethRequired = UniswapV2Library.getAmountsIn(\\n UNISWAP_V2_ROUTER_02.factory(),\\n flashSwapReturnAmount,\\n array(W_NATIVE_ADDRESS, _flashSwapToken),\\n flashSwapFee\\n )[0];\\n }\\n\\n if (address(underlyingCollateral) != W_NATIVE_ADDRESS) {\\n // Approve to Uniswap router\\n justApprove(underlyingCollateral, address(UNISWAP_V2_ROUTER_02), underlyingCollateralSeized);\\n\\n // Swap collateral tokens for W_NATIVE to be repaid via Uniswap router\\n UNISWAP_V2_ROUTER_02.swapTokensForExactTokens(\\n wethRequired,\\n underlyingCollateralSeized,\\n array(address(underlyingCollateral), W_NATIVE_ADDRESS),\\n address(this),\\n block.timestamp\\n );\\n }\\n\\n // Repay flashloan\\n require(\\n wethRequired <= IERC20Upgradeable(W_NATIVE_ADDRESS).balanceOf(address(this)),\\n \\\"Not enough W_NATIVE exchanged from seized collateral to repay flashloan.\\\"\\n );\\n require(\\n IW_NATIVE(W_NATIVE_ADDRESS).transfer(msg.sender, wethRequired),\\n \\\"Failed to repay Uniswap flashloan with W_NATIVE exchanged from seized collateral.\\\"\\n );\\n\\n // Return the profited token (underlying collateral if same as exchangeProfitTo; otherwise, W_NATIVE)\\n return address(underlyingCollateral);\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external\\n onlyOwner\\n {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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 /**\\n * @dev Returns an array containing the parameters supplied.\\n */\\n function array(address a, address b) private pure returns (address[] memory) {\\n address[] memory arr = new address[](2);\\n arr[0] = a;\\n arr[1] = b;\\n return arr;\\n }\\n}\\n\",\"keccak256\":\"0x233342998d0f884cf7a533b23940e81357e2269f75e36305d403d86d4f9930ae\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV2Callee.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Callee {\\n function uniswapV2Call(\\n address sender,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xf03775d505749a6d8ffd4b50e19478cacfe83c8e6fb0881e1b442505f958029a\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV2Factory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Factory {\\n event PairCreated(address indexed token0, address indexed token1, address pair, uint256);\\n\\n function feeTo() external view returns (address);\\n\\n function feeToSetter() external view returns (address);\\n\\n function getPair(address tokenA, address tokenB) external view returns (address pair);\\n\\n function allPairs(uint256) external view returns (address pair);\\n\\n function allPairsLength() external view returns (uint256);\\n\\n function createPair(address tokenA, address tokenB) external returns (address pair);\\n\\n function setFeeTo(address) external;\\n\\n function setFeeToSetter(address) external;\\n}\\n\",\"keccak256\":\"0xcad1373d47c15a77f0fe29698181bb643d4eb4cc870fdeb40b7e081ebffb598a\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV2Router01.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n )\\n external\\n returns (\\n uint256 amountA,\\n uint256 amountB,\\n uint256 liquidity\\n );\\n\\n function addLiquidityETH(\\n address token,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n )\\n external\\n payable\\n returns (\\n uint256 amountToken,\\n uint256 amountETH,\\n uint256 liquidity\\n );\\n\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n function removeLiquidityETH(\\n address token,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline,\\n bool approveMax,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline,\\n bool approveMax,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapTokensForExactTokens(\\n uint256 amountOut,\\n uint256 amountInMax,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n function swapTokensForExactETH(\\n uint256 amountOut,\\n uint256 amountInMax,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapETHForExactTokens(\\n uint256 amountOut,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n function quote(\\n uint256 amountA,\\n uint256 reserveA,\\n uint256 reserveB\\n ) external pure returns (uint256 amountB);\\n\\n function getAmountOut(\\n uint256 amountIn,\\n uint256 reserveIn,\\n uint256 reserveOut\\n ) external pure returns (uint256 amountOut);\\n\\n function getAmountIn(\\n uint256 amountOut,\\n uint256 reserveIn,\\n uint256 reserveOut\\n ) external pure returns (uint256 amountIn);\\n\\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\\n\\n function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0x62d8aba76a668ee9cc44e89f8b5bca363bd9682e725bf0c8780b0473daec590b\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV2Router02.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV2Router01.sol\\\";\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountETH);\\n\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline,\\n bool approveMax,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external returns (uint256 amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external;\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n address referrer,\\n uint256 deadline\\n ) external;\\n\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable;\\n\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0xa183606e548c9ad611f9670cdc0b07455867ffd4792159a2a8741f8eac720561\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/UniswapV2Library.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV2Pair.sol\\\";\\nimport \\\"./IUniswapV2Factory.sol\\\";\\n\\nlibrary UniswapV2Library {\\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\\n require(tokenA != tokenB, \\\"UniswapV2Library: IDENTICAL_ADDRESSES\\\");\\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\\n require(token0 != address(0), \\\"UniswapV2Library: ZERO_ADDRESS\\\");\\n }\\n\\n function pairFor(\\n address factory,\\n address tokenA,\\n address tokenB\\n ) internal view returns (address pair) {\\n return IUniswapV2Factory(factory).getPair(tokenA, tokenB);\\n }\\n\\n // fetches and sorts the reserves for a pair\\n function getReserves(\\n address factory,\\n address tokenA,\\n address tokenB\\n ) internal view returns (uint256 reserveA, uint256 reserveB) {\\n (address token0, ) = sortTokens(tokenA, tokenB);\\n (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();\\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\\n }\\n\\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\\n function quote(\\n uint256 amountA,\\n uint256 reserveA,\\n uint256 reserveB\\n ) internal pure returns (uint256 amountB) {\\n require(amountA > 0, \\\"UniswapV2Library: INSUFFICIENT_AMOUNT\\\");\\n require(reserveA > 0 && reserveB > 0, \\\"UniswapV2Library: INSUFFICIENT_LIQUIDITY\\\");\\n amountB = (amountA * reserveB) / reserveA;\\n }\\n\\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\\n function getAmountOut(\\n uint256 amountIn,\\n uint256 reserveIn,\\n uint256 reserveOut,\\n uint8 flashSwapFee\\n ) internal pure returns (uint256 amountOut) {\\n require(amountIn > 0, \\\"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\\\");\\n require(reserveIn > 0 && reserveOut > 0, \\\"UniswapV2Library: INSUFFICIENT_LIQUIDITY\\\");\\n uint256 amountInWithFee = amountIn * (10000 - flashSwapFee);\\n uint256 numerator = amountInWithFee * reserveOut;\\n uint256 denominator = reserveIn * 10000 + amountInWithFee;\\n amountOut = numerator / denominator;\\n }\\n\\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\\n function getAmountIn(\\n uint256 amountOut,\\n uint256 reserveIn,\\n uint256 reserveOut,\\n uint8 flashSwapFee\\n ) internal pure returns (uint256 amountIn) {\\n require(amountOut > 0, \\\"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\\\");\\n require(reserveIn > 0 && reserveOut > 0, \\\"UniswapV2Library: INSUFFICIENT_LIQUIDITY\\\");\\n uint256 numerator = reserveIn * amountOut * 10000;\\n uint256 denominator = (reserveOut - amountOut) * (10000 - flashSwapFee);\\n amountIn = numerator / denominator + 1;\\n }\\n\\n // performs chained getAmountOut calculations on any number of pairs\\n function getAmountsOut(\\n address factory,\\n uint256 amountIn,\\n address[] memory path,\\n uint8 flashSwapFee\\n ) internal view returns (uint256[] memory amounts) {\\n require(path.length >= 2, \\\"UniswapV2Library: INVALID_PATH\\\");\\n amounts = new uint256[](path.length);\\n amounts[0] = amountIn;\\n for (uint256 i; i < path.length - 1; i++) {\\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);\\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut, flashSwapFee);\\n }\\n }\\n\\n // performs chained getAmountIn calculations on any number of pairs\\n function getAmountsIn(\\n address factory,\\n uint256 amountOut,\\n address[] memory path,\\n uint8 flashSwapFee\\n ) internal view returns (uint256[] memory amounts) {\\n require(path.length >= 2, \\\"UniswapV2Library: INVALID_PATH\\\");\\n amounts = new uint256[](path.length);\\n amounts[amounts.length - 1] = amountOut;\\n for (uint256 i = path.length - 1; i > 0; i--) {\\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);\\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut, flashSwapFee);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7581213474c355aca228660a5b111454cbd367bbffb46ef2c47438eedfc7a5fc\",\"license\":\"GPL-3.0-only\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"contracts/utils/IW_NATIVE.sol\":{\"content\":\"// SPDX-License-Identifier: agpl-3.0\\npragma solidity >=0.8.0;\\n\\ninterface IW_NATIVE {\\n function deposit() external payable;\\n\\n function withdraw(uint256 amount) external;\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n\\n function balanceOf(address) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x653aeec5b76d23dad1efd9cddc6f675fa45b11666a6d2a613eb7ef4ff404c9f5\",\"license\":\"agpl-3.0\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506146c2806100206000396000f3fe6080604052600436106101a05760003560e01c806373ed8653116100ec5780638da5cb5b1161008a578063c2ebfdc111610064578063c2ebfdc1146104e7578063c92cb8cc1461051a578063f2fde38b1461053a578063fced70811461055a57600080fd5b80638da5cb5b14610489578063958fa280146104a7578063ba8bca5a146104c757600080fd5b806384800812116100c657806384800812146103d4578063853828b61461043457806389232a00146104495780638a0b90901461046957600080fd5b806373ed8653146103d45780637c95ba9f146103f457806381738f131461041457600080fd5b80632c89aa2e116101595780635a431365116101335780635a4313651461033f5780635b6723711461035f5780636f6c04471461039f578063715018a6146103bf57600080fd5b80632c89aa2e146102ea57806355e9e8fe1461030057806356e677281461032057600080fd5b8063030e47df146101ff5780630add23ea1461021f57806310d1e85c1461023f578063112666b71461025f57806320b723251461029c57806329f269f4146102ca57600080fd5b366101fa57333b6101f85760405162461bcd60e51b815260206004820152601960248201527f53656e646572206973206e6f74206120636f6e74726163742e0000000000000060448201526064015b60405180910390fd5b005b600080fd5b34801561020b57600080fd5b506101f861021a36600461370c565b61056d565b34801561022b57600080fd5b506101f861023a366004613729565b610597565b34801561024b57600080fd5b506101f861025a366004613783565b6105fc565b34801561026b57600080fd5b50606c5461027f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102a857600080fd5b506102bc6102b73660046137ec565b61064b565b604051908152602001610293565b3480156102d657600080fd5b506101f86102e536600461370c565b610784565b3480156102f657600080fd5b506102bc606d5481565b34801561030c57600080fd5b506102bc61031b366004613847565b6107ae565b34801561032c57600080fd5b506101f861033b366004613882565b5050565b34801561034b57600080fd5b506101f861035a3660046138d1565b610d28565b34801561036b57600080fd5b5061038f61037a36600461370c565b60686020526000908152604090205460ff1681565b6040519015158152602001610293565b3480156103ab57600080fd5b50606b5461027f906001600160a01b031681565b3480156103cb57600080fd5b506101f8610d5b565b3480156103e057600080fd5b506101f86103ef366004613783565b610d6f565b34801561040057600080fd5b506101f861040f3660046139e8565b610d83565b34801561042057600080fd5b5060655461027f906001600160a01b031681565b34801561044057600080fd5b506101f8610e34565b34801561045557600080fd5b506101f8610464366004613a77565b610f19565b34801561047557600080fd5b506101f8610484366004613b0c565b6110cd565b34801561049557600080fd5b506033546001600160a01b031661027f565b3480156104b357600080fd5b506101f86104c2366004613b77565b6111e2565b3480156104d357600080fd5b5060665461027f906001600160a01b031681565b3480156104f357600080fd5b50606a5461050890600160a01b900460ff1681565b60405160ff9091168152602001610293565b34801561052657600080fd5b506102bc6105353660046137ec565b611837565b34801561054657600080fd5b506101f861055536600461370c565b611922565b6101f8610568366004613882565b61199b565b6105756119dc565b606b80546001600160a01b0319166001600160a01b0392909216919091179055565b61059f6119dc565b670de0b6b3a76400008111156105f75760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964204865616c746820466163746f72205468726573686f6c640060448201526064016101ef565b606d55565b600061060b8260048186613bc6565b8101906106189190613d72565b905061062381611a36565b606780546001600160a01b0319166001600160a01b0392909216919091179055505050505050565b600085836000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d89190613ea9565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190613ec6565b9050606d54811061076a5760405162461bcd60e51b81526004016101ef90613edf565b6107778989898989611e35565b9998505050505050505050565b61078c6119dc565b606c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006107bd602083018361370c565b6107cd608084016060850161370c565b6000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108569190613ea9565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156108a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c59190613ec6565b9050606d5481106108e85760405162461bcd60e51b81526004016101ef90613edf565b60008560200135116109485760405162461bcd60e51b8152602060048201526024808201527f526570617920616d6f756e74206d7573742062652067726561746572207468616044820152633710181760e11b60648201526084016101ef565b602085013560008061095e610100890189613f24565b90501115610b6957610974610120880188613f24565b9050610984610100890189613f24565b905014610a2e5760405162461bcd60e51b815260206004820152606660248201527f46756e64696e67204946756e6473436f6e76657273696f6e537472617465677960448201527f20636f6e747261637420617272617920616e642073747261746567792064617460648201527f61206279746573206172726179206d757374206265207468652073616d65206c60848201526532b733ba341760d11b60a482015260c4016101ef565b60005b610a3f610100890189613f24565b9050811015610b63576000610a586101208a018a613f24565b83818110610a6857610a68613f6d565b9050602002810190610a7a9190613f83565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450610abf925050506101008b018b613f24565b84818110610acf57610acf613f6d565b9050602002016020810190610ae4919061370c565b60405163180994cb60e11b81529091506001600160a01b03821690633013299690610b159088908690600401614019565b6040805180830381865afa158015610b31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b559190614032565b955093505050600101610a31565b50610bdd565b610b79606088016040890161370c565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bda9190613ea9565b90505b6069829055606a80546001600160a01b0319166001600160a01b0383161790556000610c0f60a0890160808a0161370c565b90506000826001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7f9190613ea9565b6001600160a01b0316149050816001600160a01b031663022c0d9f82610ca6576000610ca8565b855b8315610cb5576000610cb7565b865b306000366040518663ffffffff1660e01b8152600401610cdb959493929190614089565b600060405180830381600087803b158015610cf557600080fd5b505af1158015610d09573d6000803e3d6000fd5b505060675461077792506001600160a01b0316905060a08b01356120f6565b610d306119dc565b6001600160a01b03919091166000908152606860205260409020805460ff1916911515919091179055565b610d636119dc565b610d6d60006121ed565b565b610d7c85858585856105fc565b5050505050565b60008511610da35760405162461bcd60e51b81526004016101ef906140b7565b836001600160a01b0316633c3b4b8986888787878733604051602001610dce96959493929190614114565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610dfa929190614019565b600060405180830381600087803b158015610e1457600080fd5b505af1158015610e28573d6000803e3d6000fd5b50505050505050505050565b610e3c6119dc565b4780610e8a5760405162461bcd60e51b815260206004820152601960248201527f4e6f204574686572206c65667420746f2077697468647261770000000000000060448201526064016101ef565b604051600090339083908381818185875af1925050503d8060008114610ecc576040519150601f19603f3d011682016040523d82523d6000602084013e610ed1565b606091505b505090508061033b5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016101ef565b600054610100900460ff1615808015610f395750600054600160ff909116105b80610f535750303b158015610f53575060005460ff166001145b610fb65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101ef565b6000805460ff191660011790558015610fd9576000805461ff0019166101001790555b610fe161223f565b6001600160a01b0383166110375760405162461bcd60e51b815260206004820152601d60248201527f5f756e69737761705632726f75746572206e6f7420646566696e65642e00000060448201526064016101ef565b606580546001600160a01b038087166001600160a01b0319928316179092556066805492861692909116919091179055606a805460ff8416600160a01b0260ff60a01b1990911617905580156110c7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6110d56119dc565b82158015906110e357508281145b6111555760405162461bcd60e51b815260206004820152603f60248201527f6c697374206f66207374726174656769657320656d707479206f72207768697460448201527f656c69737420646f6573206e6f74206d6174636820697473206c656e6774680060648201526084016101ef565b60005b83811015610d7c5782828281811061117257611172613f6d565b90506020020160208101906111879190614164565b6068600087878581811061119d5761119d613f6d565b90506020020160208101906111b2919061370c565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611158565b600080808080806111f587890189614181565b60405163095ea7b360e01b8152959b509399509197509550935091508a906001600160a01b0382169063095ea7b3906112489089908e906004016001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b919061421b565b50604051637af1e23160e11b81526001600160a01b038881166004830152602482018c9052868116604483015287169063f5e3c462906064016020604051808303816000875af11580156112e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113079190613ec6565b156113245760405162461bcd60e51b81526004016101ef90614238565b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611364573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113889190613ea9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa1580156113d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f69190613ec6565b9050600081116114185760405162461bcd60e51b81526004016101ef90614265565b60405163db006a7560e01b8152600481018290526000906001600160a01b0389169063db006a75906024016020604051808303816000875af1158015611462573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114869190613ec6565b905080156114a65760405162461bcd60e51b81526004016101ef90614291565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115119190613ec6565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015611564573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611588919061421b565b506000886001600160a01b0316886040516115a391906142ef565b6000604051808303816000865af19150503d80600081146115e0576040519150601f19603f3d011682016040523d82523d6000602084013e6115e5565b606091505b505090508061162f5760405162461bcd60e51b81526020600482015260166024820152751059d9dc9959d85d1bdc8818d85b1b0819985a5b195960521b60448201526064016101ef565b50506040516370a0823160e01b8152306004820152600092506001600160a01b03851691506370a0823190602401602060405180830381865afa15801561167a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169e9190613ec6565b90508b8110156117035760405162461bcd60e51b815260206004820152602a60248201527f4e6f7420726563656976656420656e6f75676820636f6c6c61746572616c2061604482015269333a32b91039bbb0b81760b11b60648201526084016101ef565b600061170f8d83614321565b9050801561172b5761172b6001600160a01b038516868361226e565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611772573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117969190613ec6565b905080156117b2576117b26001600160a01b038516878361226e565b505060405163095ea7b360e01b81526001600160a01b038981166004830152602482018e90528416915063095ea7b3906044016020604051808303816000875af1158015611804573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611828919061421b565b50505050505050505050505050565b606b54604080516001600160a01b038881166020830152600093169163403e96f6913091016040516020818303038152906040526040518363ffffffff1660e01b8152600401611888929190614334565b602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c9919061421b565b61190b5760405162461bcd60e51b815260206004820152601360248201527234b73b30b634b2103634b8bab4b230ba34b7b760691b60448201526064016101ef565b6119188686868686611e35565b9695505050505050565b61192a6119dc565b6001600160a01b03811661198f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101ef565b611998816121ed565b50565b7f373bc109b9e1d2a0702bd463de500dfec960521e4498acc170fd65867e46041c333484846040516119d09493929190614358565b60405180910390a15050565b6033546001600160a01b03163314610d6d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ef565b606a54606954610100830151516000926001600160a01b0316919015611add57610100840151515b8015611adb57611ac48383876101000151600185611a7c9190614321565b81518110611a8c57611a8c613f6d565b6020026020010151886101200151600186611aa79190614321565b81518110611ab757611ab7613f6d565b60200260200101516122d6565b909350915080611ad381614380565b915050611a5e565b505b600084604001516001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b459190613ea9565b9050806001600160a01b0316836001600160a01b031614611be05760405162461bcd60e51b815260206004820152604960248201527f74686520646562742072657061796d656e742066756e64732073686f756c642060448201527f626520636f6e76657274656420746f2074686520756e6465726c79696e67206460648201526832b13a103a37b5b2b760b91b608482015260a4016101ef565b8460200151821015611c345760405162461bcd60e51b815260206004820181905260248201527f646562742072657061796d656e7420616d6f756e74206e6f7420656e6f75676860448201526064016101ef565b611c47818660400151876020015161238e565b6040858101518651602088015160608901519351637af1e23160e11b81526001600160a01b03928316600482015260248101919091529281166044840152169063f5e3c462906064016020604051808303816000875af1158015611caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd39190613ec6565b15611cf05760405162461bcd60e51b81526004016101ef90614238565b60608501516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5f9190613ec6565b905060008111611d815760405162461bcd60e51b81526004016101ef90614265565b606086015160405163db006a7560e01b8152600481018390526000916001600160a01b03169063db006a75906024016020604051808303816000875af1158015611dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df39190613ec6565b90508015611e135760405162461bcd60e51b81526004016101ef90614291565b505050611e2d84606001518560c001518660e00151612401565b949350505050565b6000808511611e565760405162461bcd60e51b81526004016101ef906140b7565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eba9190613ea9565b9050611ed16001600160a01b038216333089612d13565b611edc81868861238e565b604051637af1e23160e11b81526001600160a01b03888116600483015260248201889052858116604483015286169063f5e3c462906064016020604051808303816000875af1158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f579190613ec6565b15611f745760405162461bcd60e51b81526004016101ef90614238565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf9190613ec6565b9050600081116120015760405162461bcd60e51b81526004016101ef90614265565b60405163db006a7560e01b8152600481018290526000906001600160a01b0387169063db006a75906024016020604051808303816000875af115801561204b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206f9190613ec6565b9050801561208f5760405162461bcd60e51b81526004016101ef90614291565b610777866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f49190613ea9565b865b6040516370a0823160e01b8152306004820152600090839082906001600160a01b038316906370a0823190602401602060405180830381865afa158015612141573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121659190613ec6565b9050838110156121c95760405162461bcd60e51b815260206004820152602960248201527f4d696e696d756d20746f6b656e206f757470757420616d6f756e74206e6f742060448201526839b0ba34b334b2b21760b91b60648201526084016101ef565b80156121e3576121e36001600160a01b038316338361226e565b9150505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122665760405162461bcd60e51b81526004016101ef90614397565b610d6d612d4b565b6040516001600160a01b0383166024820152604481018290526122d190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d7b565b505050565b6001600160a01b038216600090815260686020526040812054819060ff166123105760405162461bcd60e51b81526004016101ef906143e2565b600061236a856389eabf0260e01b89898860405160240161233393929190614434565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e4d565b9050808060200190518101906123809190614032565b925092505094509492505050565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b3906044016020604051808303816000875af11580156123dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c7919061421b565b606a54600090819061241f90600160a01b900460ff1661271061445b565b61ffff16606954612710612433919061447d565b61243d91906144aa565b606a5490915060009061245c90600160a01b900460ff1661271061445b565b61ffff16606954612710612470919061447d565b61247a91906144be565b111561248e578061248a816144d2565b9150505b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f29190613ea9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125609190613ec6565b8651909150156126605784518651146126075760405162461bcd60e51b815260206004820152605b60248201527f49526564656d7074696f6e537472617465677920636f6e74726163742061727260448201527f617920616e64207374726174656779206461746120627974657320617272617960648201527f206d6e75737420746865207468652073616d65206c656e6774682e0000000000608482015260a4016101ef565b60005b865181101561265e57612651838389848151811061262a5761262a613f6d565b602002602001015189858151811061264457612644613f6d565b6020026020010151612f41565b909350915060010161260a565b505b6000339050806001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c79190613ea9565b6001600160a01b0316836001600160a01b031614806127585750806001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561271f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127439190613ea9565b6001600160a01b0316836001600160a01b0316145b1561298d57606a546000906001600160a01b039081169085160361277d575083612835565b6066546040805163c45a015560e01b81529051612818926001600160a01b03169163c45a01559160048083019260209291908290030181865afa1580156127c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ec9190613ea9565b606954606a546128069088906001600160a01b0316612f9e565b606a54600160a01b900460ff1661302b565b60008151811061282a5761282a613f6d565b602002602001015190505b828111156128ab5760405162461bcd60e51b815260206004820152603d60248201527f546f6b656e20666c6173686c6f616e2072657475726e20616d6f756e7420677260448201527f6561746572207468616e207365697a656420636f6c6c61746572616c2e00000060648201526084016101ef565b60405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0385169063a9059cbb906044016020604051808303816000875af11580156128f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291c919061421b565b6129805760405162461bcd60e51b815260206004820152602f60248201527f4661696c656420746f20726570617920746f6b656e20666c6173686c6f616e2060448201526e37b7103137b93937bb9039b4b2329760891b60648201526084016101ef565b8395505050505050612d0c565b606554606a546000916001600160a01b039081169116036129af575083612a59565b6066546040805163c45a015560e01b81529051612a3c926001600160a01b03169163c45a01559160048083019260209291908290030181865afa1580156129fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1e9190613ea9565b606554606a548891612806916001600160a01b039182169116612f9e565b600081518110612a4e57612a4e613f6d565b602002602001015190505b6065546001600160a01b03858116911614612b1957606654612a869085906001600160a01b03168561238e565b6066546065546001600160a01b0391821691638803dbee9184918791612aae918a9116612f9e565b30426040518663ffffffff1660e01b8152600401612ad09594939291906144eb565b6000604051808303816000875af1158015612aef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b17919081019061455e565b505b6065546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b859190613ec6565b811115612c0b5760405162461bcd60e51b815260206004820152604860248201527f4e6f7420656e6f75676820575f4e41544956452065786368616e67656420667260448201527f6f6d207365697a656420636f6c6c61746572616c20746f20726570617920666c60648201526730b9b43637b0b71760c11b608482015260a4016101ef565b60655460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015612c5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c80919061421b565b6129805760405162461bcd60e51b815260206004820152605160248201527f4661696c656420746f20726570617920556e697377617020666c6173686c6f6160448201527f6e207769746820575f4e41544956452065786368616e6765642066726f6d207360648201527032b4bd32b21031b7b63630ba32b930b61760791b608482015260a4016101ef565b9392505050565b6040516001600160a01b03808516602483015283166044820152606481018290526110c79085906323b872dd60e01b9060840161229a565b600054610100900460ff16612d725760405162461bcd60e51b81526004016101ef90614397565b610d6d336121ed565b6000612dd0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131c29092919063ffffffff16565b8051909150156122d15780806020019051810190612dee919061421b565b6122d15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101ef565b60606001600160a01b0383163b612eb55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016101ef565b600080846001600160a01b031684604051612ed091906142ef565b600060405180830381855af49150503d8060008114612f0b576040519150601f19603f3d011682016040523d82523d6000602084013e612f10565b606091505b5091509150612f388282604051806060016040528060278152602001614666602791396131d1565b95945050505050565b6001600160a01b038216600090815260686020526040812054819060ff16612f7b5760405162461bcd60e51b81526004016101ef906143e2565b600061236a856310badf4e60e01b89898860405160240161233393929190614434565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110612fd757612fd7613f6d565b60200260200101906001600160a01b031690816001600160a01b031681525050828160018151811061300b5761300b613f6d565b6001600160a01b0390921660209283029190910190910152905092915050565b606060028351101561307f5760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f50415448000060448201526064016101ef565b82516001600160401b038111156130985761309861390a565b6040519080825280602002602001820160405280156130c1578160200160208202803683370190505b5090508381600183516130d49190614321565b815181106130e4576130e4613f6d565b6020026020010181815250506000600184516131009190614321565b90505b80156131b957600080613153888761311c600187614321565b8151811061312c5761312c613f6d565b602002602001015188868151811061314657613146613f6d565b602002602001015161320a565b9150915061317c84848151811061316c5761316c613f6d565b60200260200101518383886132d4565b84613188600186614321565b8151811061319857613198613f6d565b602002602001018181525050505080806131b190614380565b915050613103565b50949350505050565b6060611e2d848460008561340c565b606083156131e0575081612d0c565b8251156131f05782518084602001fd5b8160405162461bcd60e51b81526004016101ef91906145e3565b600080600061321985856134dc565b50905060008061322a8888886135d3565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015613267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061328b919061460d565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b0316146132c25780826132c5565b81815b90999098509650505050505050565b600080851161333a5760405162461bcd60e51b815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201526b155514155517d05353d5539560a21b60648201526084016101ef565b60008411801561334a5750600083115b6133a75760405162461bcd60e51b815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c604482015267495155494449545960c01b60648201526084016101ef565b60006133b3868661447d565b6133bf9061271061447d565b905060006133d260ff851661271061445b565b61ffff166133e08887614321565b6133ea919061447d565b90506133f681836144aa565b613401906001614652565b979650505050505050565b60608247101561346d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101ef565b600080866001600160a01b0316858760405161348991906142ef565b60006040518083038185875af1925050503d80600081146134c6576040519150601f19603f3d011682016040523d82523d6000602084013e6134cb565b606091505b509150915061340187838387613649565b600080826001600160a01b0316846001600160a01b03160361354e5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b60648201526084016101ef565b826001600160a01b0316846001600160a01b03161061356e578284613571565b83835b90925090506001600160a01b0382166135cc5760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f41444452455353000060448201526064016101ef565b9250929050565b60405163e6a4390560e01b81526001600160a01b03838116600483015282811660248301526000919085169063e6a4390590604401602060405180830381865afa158015613625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2d9190613ea9565b606083156136b85782516000036136b1576001600160a01b0385163b6136b15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101ef565b5081611e2d565b611e2d83838151156136cd5781518083602001fd5b8060405162461bcd60e51b81526004016101ef91906145e3565b6001600160a01b038116811461199857600080fd5b8035613707816136e7565b919050565b60006020828403121561371e57600080fd5b8135612d0c816136e7565b60006020828403121561373b57600080fd5b5035919050565b60008083601f84011261375457600080fd5b5081356001600160401b0381111561376b57600080fd5b6020830191508360208285010111156135cc57600080fd5b60008060008060006080868803121561379b57600080fd5b85356137a6816136e7565b9450602086013593506040860135925060608601356001600160401b038111156137cf57600080fd5b6137db88828901613742565b969995985093965092949392505050565b600080600080600060a0868803121561380457600080fd5b853561380f816136e7565b9450602086013593506040860135613826816136e7565b92506060860135613836816136e7565b949793965091946080013592915050565b60006020828403121561385957600080fd5b81356001600160401b0381111561386f57600080fd5b82016101408185031215612d0c57600080fd5b6000806020838503121561389557600080fd5b82356001600160401b038111156138ab57600080fd5b6138b785828601613742565b90969095509350505050565b801515811461199857600080fd5b600080604083850312156138e457600080fd5b82356138ef816136e7565b915060208301356138ff816138c3565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156139435761394361390a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156139715761397161390a565b604052919050565b600082601f83011261398a57600080fd5b81356001600160401b038111156139a3576139a361390a565b6139b6601f8201601f1916602001613949565b8181528460208386010111156139cb57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c08789031215613a0157600080fd5b8635613a0c816136e7565b9550602087013594506040870135613a23816136e7565b93506060870135613a33816136e7565b92506080870135613a43816136e7565b915060a08701356001600160401b03811115613a5e57600080fd5b613a6a89828a01613979565b9150509295509295509295565b600080600060608486031215613a8c57600080fd5b8335613a97816136e7565b92506020840135613aa7816136e7565b9150604084013560ff81168114613abd57600080fd5b809150509250925092565b60008083601f840112613ada57600080fd5b5081356001600160401b03811115613af157600080fd5b6020830191508360208260051b85010111156135cc57600080fd5b60008060008060408587031215613b2257600080fd5b84356001600160401b0380821115613b3957600080fd5b613b4588838901613ac8565b90965094506020870135915080821115613b5e57600080fd5b50613b6b87828801613ac8565b95989497509550505050565b60008060008060608587031215613b8d57600080fd5b8435613b98816136e7565b93506020850135925060408501356001600160401b03811115613bba57600080fd5b613b6b87828801613742565b60008085851115613bd657600080fd5b83861115613be357600080fd5b5050820193919092039150565b60006001600160401b03821115613c0957613c0961390a565b5060051b60200190565b600082601f830112613c2457600080fd5b81356020613c39613c3483613bf0565b613949565b8083825260208201915060208460051b870101935086841115613c5b57600080fd5b602086015b84811015613c80578035613c73816136e7565b8352918301918301613c60565b509695505050505050565b600082601f830112613c9c57600080fd5b81356020613cac613c3483613bf0565b82815260059290921b84018101918181019086841115613ccb57600080fd5b8286015b84811015613c805780356001600160401b03811115613cee5760008081fd5b613cfc8986838b0101613979565b845250918301918301613ccf565b600082601f830112613d1b57600080fd5b81356020613d2b613c3483613bf0565b8083825260208201915060208460051b870101935086841115613d4d57600080fd5b602086015b84811015613c80578035613d65816136e7565b8352918301918301613d52565b600060208284031215613d8457600080fd5b81356001600160401b0380821115613d9b57600080fd5b908301906101408286031215613db057600080fd5b613db8613920565b613dc1836136fc565b815260208301356020820152613dd9604084016136fc565b6040820152613dea606084016136fc565b6060820152613dfb608084016136fc565b608082015260a083013560a082015260c083013582811115613e1c57600080fd5b613e2887828601613c13565b60c08301525060e083013582811115613e4057600080fd5b613e4c87828601613c8b565b60e0830152506101008084013583811115613e6657600080fd5b613e7288828701613d0a565b8284015250506101208084013583811115613e8c57600080fd5b613e9888828701613c8b565b918301919091525095945050505050565b600060208284031215613ebb57600080fd5b8151612d0c816136e7565b600060208284031215613ed857600080fd5b5051919050565b60208082526025908201527f4846206e6f74206c6f7720656e6f7567682c20726573657276696e6720666f72604082015264040a0b2a8960db1b606082015260800190565b6000808335601e19843603018112613f3b57600080fd5b8301803591506001600160401b03821115613f5557600080fd5b6020019150600581901b36038213156135cc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112613f9a57600080fd5b8301803591506001600160401b03821115613fb457600080fd5b6020019150368190038213156135cc57600080fd5b60005b83811015613fe4578181015183820152602001613fcc565b50506000910152565b60008151808452614005816020860160208601613fc9565b601f01601f19169290920160200192915050565b828152604060208201526000611e2d6040830184613fed565b6000806040838503121561404557600080fd5b8251614050816136e7565b6020939093015192949293505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815284602082015260018060a01b0384166040820152608060608201526000613401608083018486614060565b60208082526038908201527f526570617920616d6f756e7420287472616e73616374696f6e2076616c75652960408201527f206d7573742062652067726561746572207468616e20302e0000000000000000606082015260800190565b600060018060a01b03808916835280881660208401528087166040840152808616606084015260c0608084015261414e60c0840186613fed565b915080841660a084015250979650505050505050565b60006020828403121561417657600080fd5b8135612d0c816138c3565b60008060008060008060c0878903121561419a57600080fd5b86356141a5816136e7565b955060208701356141b5816136e7565b945060408701356141c5816136e7565b935060608701356141d5816136e7565b925060808701356001600160401b038111156141f057600080fd5b6141fc89828a01613979565b92505060a087013561420d816136e7565b809150509295509295509295565b60006020828403121561422d57600080fd5b8151612d0c816138c3565b6020808252601390820152722634b8bab4b230ba34b7b7103330b4b632b21760691b604082015260600190565b60208082526012908201527127379031aa37b5b2b7399039b2b4bd32b21760711b604082015260600190565b602080825260409082018190527f4572726f722063616c6c696e672072656465656d696e67207365697a65642063908201527f546f6b656e3a206572726f7220636f6465206e6f7420657175616c20746f2030606082015260800190565b60008251614301818460208701613fc9565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b818103818111156121e7576121e761430b565b6001600160a01b0383168152604060208201819052600090611e2d90830184613fed565b60018060a01b0385168152836020820152606060408201526000611918606083018486614060565b60008161438f5761438f61430b565b506000190190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f6f6e6c792077686974656c697374656420726564656d7074696f6e20737472616040820152711d1959da595cc818d85b881899481d5cd95960721b606082015260800190565b60018060a01b0384168152826020820152606060408201526000612f386060830184613fed565b61ffff8281168282160390808211156144765761447661430b565b5092915050565b80820281158282048414176121e7576121e761430b565b634e487b7160e01b600052601260045260246000fd5b6000826144b9576144b9614494565b500490565b6000826144cd576144cd614494565b500690565b6000600182016144e4576144e461430b565b5060010190565b600060a08201878352602087602085015260a0604085015281875180845260c08601915060208901935060005b8181101561453d5784516001600160a01b031683529383019391830191600101614518565b50506001600160a01b03969096166060850152505050608001529392505050565b6000602080838503121561457157600080fd5b82516001600160401b0381111561458757600080fd5b8301601f8101851361459857600080fd5b80516145a6613c3482613bf0565b81815260059190911b820183019083810190878311156145c557600080fd5b928401925b82841015613401578351825292840192908401906145ca565b602081526000612d0c6020830184613fed565b80516001600160701b038116811461370757600080fd5b60008060006060848603121561462257600080fd5b61462b846145f6565b9250614639602085016145f6565b9150604084015163ffffffff81168114613abd57600080fd5b808201808211156121e7576121e761430b56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a2fb990d2e30037177416e7c2b3a3028b7bbee3fb50d53c25cf253572227250f64736f6c63430008160033", + "deployedBytecode": "0x6080604052600436106101a05760003560e01c806373ed8653116100ec5780638da5cb5b1161008a578063c2ebfdc111610064578063c2ebfdc1146104e7578063c92cb8cc1461051a578063f2fde38b1461053a578063fced70811461055a57600080fd5b80638da5cb5b14610489578063958fa280146104a7578063ba8bca5a146104c757600080fd5b806384800812116100c657806384800812146103d4578063853828b61461043457806389232a00146104495780638a0b90901461046957600080fd5b806373ed8653146103d45780637c95ba9f146103f457806381738f131461041457600080fd5b80632c89aa2e116101595780635a431365116101335780635a4313651461033f5780635b6723711461035f5780636f6c04471461039f578063715018a6146103bf57600080fd5b80632c89aa2e146102ea57806355e9e8fe1461030057806356e677281461032057600080fd5b8063030e47df146101ff5780630add23ea1461021f57806310d1e85c1461023f578063112666b71461025f57806320b723251461029c57806329f269f4146102ca57600080fd5b366101fa57333b6101f85760405162461bcd60e51b815260206004820152601960248201527f53656e646572206973206e6f74206120636f6e74726163742e0000000000000060448201526064015b60405180910390fd5b005b600080fd5b34801561020b57600080fd5b506101f861021a36600461370c565b61056d565b34801561022b57600080fd5b506101f861023a366004613729565b610597565b34801561024b57600080fd5b506101f861025a366004613783565b6105fc565b34801561026b57600080fd5b50606c5461027f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102a857600080fd5b506102bc6102b73660046137ec565b61064b565b604051908152602001610293565b3480156102d657600080fd5b506101f86102e536600461370c565b610784565b3480156102f657600080fd5b506102bc606d5481565b34801561030c57600080fd5b506102bc61031b366004613847565b6107ae565b34801561032c57600080fd5b506101f861033b366004613882565b5050565b34801561034b57600080fd5b506101f861035a3660046138d1565b610d28565b34801561036b57600080fd5b5061038f61037a36600461370c565b60686020526000908152604090205460ff1681565b6040519015158152602001610293565b3480156103ab57600080fd5b50606b5461027f906001600160a01b031681565b3480156103cb57600080fd5b506101f8610d5b565b3480156103e057600080fd5b506101f86103ef366004613783565b610d6f565b34801561040057600080fd5b506101f861040f3660046139e8565b610d83565b34801561042057600080fd5b5060655461027f906001600160a01b031681565b34801561044057600080fd5b506101f8610e34565b34801561045557600080fd5b506101f8610464366004613a77565b610f19565b34801561047557600080fd5b506101f8610484366004613b0c565b6110cd565b34801561049557600080fd5b506033546001600160a01b031661027f565b3480156104b357600080fd5b506101f86104c2366004613b77565b6111e2565b3480156104d357600080fd5b5060665461027f906001600160a01b031681565b3480156104f357600080fd5b50606a5461050890600160a01b900460ff1681565b60405160ff9091168152602001610293565b34801561052657600080fd5b506102bc6105353660046137ec565b611837565b34801561054657600080fd5b506101f861055536600461370c565b611922565b6101f8610568366004613882565b61199b565b6105756119dc565b606b80546001600160a01b0319166001600160a01b0392909216919091179055565b61059f6119dc565b670de0b6b3a76400008111156105f75760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964204865616c746820466163746f72205468726573686f6c640060448201526064016101ef565b606d55565b600061060b8260048186613bc6565b8101906106189190613d72565b905061062381611a36565b606780546001600160a01b0319166001600160a01b0392909216919091179055505050505050565b600085836000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d89190613ea9565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190613ec6565b9050606d54811061076a5760405162461bcd60e51b81526004016101ef90613edf565b6107778989898989611e35565b9998505050505050505050565b61078c6119dc565b606c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006107bd602083018361370c565b6107cd608084016060850161370c565b6000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108569190613ea9565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156108a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c59190613ec6565b9050606d5481106108e85760405162461bcd60e51b81526004016101ef90613edf565b60008560200135116109485760405162461bcd60e51b8152602060048201526024808201527f526570617920616d6f756e74206d7573742062652067726561746572207468616044820152633710181760e11b60648201526084016101ef565b602085013560008061095e610100890189613f24565b90501115610b6957610974610120880188613f24565b9050610984610100890189613f24565b905014610a2e5760405162461bcd60e51b815260206004820152606660248201527f46756e64696e67204946756e6473436f6e76657273696f6e537472617465677960448201527f20636f6e747261637420617272617920616e642073747261746567792064617460648201527f61206279746573206172726179206d757374206265207468652073616d65206c60848201526532b733ba341760d11b60a482015260c4016101ef565b60005b610a3f610100890189613f24565b9050811015610b63576000610a586101208a018a613f24565b83818110610a6857610a68613f6d565b9050602002810190610a7a9190613f83565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450610abf925050506101008b018b613f24565b84818110610acf57610acf613f6d565b9050602002016020810190610ae4919061370c565b60405163180994cb60e11b81529091506001600160a01b03821690633013299690610b159088908690600401614019565b6040805180830381865afa158015610b31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b559190614032565b955093505050600101610a31565b50610bdd565b610b79606088016040890161370c565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bda9190613ea9565b90505b6069829055606a80546001600160a01b0319166001600160a01b0383161790556000610c0f60a0890160808a0161370c565b90506000826001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7f9190613ea9565b6001600160a01b0316149050816001600160a01b031663022c0d9f82610ca6576000610ca8565b855b8315610cb5576000610cb7565b865b306000366040518663ffffffff1660e01b8152600401610cdb959493929190614089565b600060405180830381600087803b158015610cf557600080fd5b505af1158015610d09573d6000803e3d6000fd5b505060675461077792506001600160a01b0316905060a08b01356120f6565b610d306119dc565b6001600160a01b03919091166000908152606860205260409020805460ff1916911515919091179055565b610d636119dc565b610d6d60006121ed565b565b610d7c85858585856105fc565b5050505050565b60008511610da35760405162461bcd60e51b81526004016101ef906140b7565b836001600160a01b0316633c3b4b8986888787878733604051602001610dce96959493929190614114565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610dfa929190614019565b600060405180830381600087803b158015610e1457600080fd5b505af1158015610e28573d6000803e3d6000fd5b50505050505050505050565b610e3c6119dc565b4780610e8a5760405162461bcd60e51b815260206004820152601960248201527f4e6f204574686572206c65667420746f2077697468647261770000000000000060448201526064016101ef565b604051600090339083908381818185875af1925050503d8060008114610ecc576040519150601f19603f3d011682016040523d82523d6000602084013e610ed1565b606091505b505090508061033b5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016101ef565b600054610100900460ff1615808015610f395750600054600160ff909116105b80610f535750303b158015610f53575060005460ff166001145b610fb65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101ef565b6000805460ff191660011790558015610fd9576000805461ff0019166101001790555b610fe161223f565b6001600160a01b0383166110375760405162461bcd60e51b815260206004820152601d60248201527f5f756e69737761705632726f75746572206e6f7420646566696e65642e00000060448201526064016101ef565b606580546001600160a01b038087166001600160a01b0319928316179092556066805492861692909116919091179055606a805460ff8416600160a01b0260ff60a01b1990911617905580156110c7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6110d56119dc565b82158015906110e357508281145b6111555760405162461bcd60e51b815260206004820152603f60248201527f6c697374206f66207374726174656769657320656d707479206f72207768697460448201527f656c69737420646f6573206e6f74206d6174636820697473206c656e6774680060648201526084016101ef565b60005b83811015610d7c5782828281811061117257611172613f6d565b90506020020160208101906111879190614164565b6068600087878581811061119d5761119d613f6d565b90506020020160208101906111b2919061370c565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611158565b600080808080806111f587890189614181565b60405163095ea7b360e01b8152959b509399509197509550935091508a906001600160a01b0382169063095ea7b3906112489089908e906004016001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b919061421b565b50604051637af1e23160e11b81526001600160a01b038881166004830152602482018c9052868116604483015287169063f5e3c462906064016020604051808303816000875af11580156112e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113079190613ec6565b156113245760405162461bcd60e51b81526004016101ef90614238565b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611364573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113889190613ea9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa1580156113d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f69190613ec6565b9050600081116114185760405162461bcd60e51b81526004016101ef90614265565b60405163db006a7560e01b8152600481018290526000906001600160a01b0389169063db006a75906024016020604051808303816000875af1158015611462573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114869190613ec6565b905080156114a65760405162461bcd60e51b81526004016101ef90614291565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115119190613ec6565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015611564573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611588919061421b565b506000886001600160a01b0316886040516115a391906142ef565b6000604051808303816000865af19150503d80600081146115e0576040519150601f19603f3d011682016040523d82523d6000602084013e6115e5565b606091505b505090508061162f5760405162461bcd60e51b81526020600482015260166024820152751059d9dc9959d85d1bdc8818d85b1b0819985a5b195960521b60448201526064016101ef565b50506040516370a0823160e01b8152306004820152600092506001600160a01b03851691506370a0823190602401602060405180830381865afa15801561167a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169e9190613ec6565b90508b8110156117035760405162461bcd60e51b815260206004820152602a60248201527f4e6f7420726563656976656420656e6f75676820636f6c6c61746572616c2061604482015269333a32b91039bbb0b81760b11b60648201526084016101ef565b600061170f8d83614321565b9050801561172b5761172b6001600160a01b038516868361226e565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611772573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117969190613ec6565b905080156117b2576117b26001600160a01b038516878361226e565b505060405163095ea7b360e01b81526001600160a01b038981166004830152602482018e90528416915063095ea7b3906044016020604051808303816000875af1158015611804573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611828919061421b565b50505050505050505050505050565b606b54604080516001600160a01b038881166020830152600093169163403e96f6913091016040516020818303038152906040526040518363ffffffff1660e01b8152600401611888929190614334565b602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c9919061421b565b61190b5760405162461bcd60e51b815260206004820152601360248201527234b73b30b634b2103634b8bab4b230ba34b7b760691b60448201526064016101ef565b6119188686868686611e35565b9695505050505050565b61192a6119dc565b6001600160a01b03811661198f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101ef565b611998816121ed565b50565b7f373bc109b9e1d2a0702bd463de500dfec960521e4498acc170fd65867e46041c333484846040516119d09493929190614358565b60405180910390a15050565b6033546001600160a01b03163314610d6d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ef565b606a54606954610100830151516000926001600160a01b0316919015611add57610100840151515b8015611adb57611ac48383876101000151600185611a7c9190614321565b81518110611a8c57611a8c613f6d565b6020026020010151886101200151600186611aa79190614321565b81518110611ab757611ab7613f6d565b60200260200101516122d6565b909350915080611ad381614380565b915050611a5e565b505b600084604001516001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b459190613ea9565b9050806001600160a01b0316836001600160a01b031614611be05760405162461bcd60e51b815260206004820152604960248201527f74686520646562742072657061796d656e742066756e64732073686f756c642060448201527f626520636f6e76657274656420746f2074686520756e6465726c79696e67206460648201526832b13a103a37b5b2b760b91b608482015260a4016101ef565b8460200151821015611c345760405162461bcd60e51b815260206004820181905260248201527f646562742072657061796d656e7420616d6f756e74206e6f7420656e6f75676860448201526064016101ef565b611c47818660400151876020015161238e565b6040858101518651602088015160608901519351637af1e23160e11b81526001600160a01b03928316600482015260248101919091529281166044840152169063f5e3c462906064016020604051808303816000875af1158015611caf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd39190613ec6565b15611cf05760405162461bcd60e51b81526004016101ef90614238565b60608501516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5f9190613ec6565b905060008111611d815760405162461bcd60e51b81526004016101ef90614265565b606086015160405163db006a7560e01b8152600481018390526000916001600160a01b03169063db006a75906024016020604051808303816000875af1158015611dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df39190613ec6565b90508015611e135760405162461bcd60e51b81526004016101ef90614291565b505050611e2d84606001518560c001518660e00151612401565b949350505050565b6000808511611e565760405162461bcd60e51b81526004016101ef906140b7565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eba9190613ea9565b9050611ed16001600160a01b038216333089612d13565b611edc81868861238e565b604051637af1e23160e11b81526001600160a01b03888116600483015260248201889052858116604483015286169063f5e3c462906064016020604051808303816000875af1158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f579190613ec6565b15611f745760405162461bcd60e51b81526004016101ef90614238565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf9190613ec6565b9050600081116120015760405162461bcd60e51b81526004016101ef90614265565b60405163db006a7560e01b8152600481018290526000906001600160a01b0387169063db006a75906024016020604051808303816000875af115801561204b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206f9190613ec6565b9050801561208f5760405162461bcd60e51b81526004016101ef90614291565b610777866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f49190613ea9565b865b6040516370a0823160e01b8152306004820152600090839082906001600160a01b038316906370a0823190602401602060405180830381865afa158015612141573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121659190613ec6565b9050838110156121c95760405162461bcd60e51b815260206004820152602960248201527f4d696e696d756d20746f6b656e206f757470757420616d6f756e74206e6f742060448201526839b0ba34b334b2b21760b91b60648201526084016101ef565b80156121e3576121e36001600160a01b038316338361226e565b9150505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122665760405162461bcd60e51b81526004016101ef90614397565b610d6d612d4b565b6040516001600160a01b0383166024820152604481018290526122d190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d7b565b505050565b6001600160a01b038216600090815260686020526040812054819060ff166123105760405162461bcd60e51b81526004016101ef906143e2565b600061236a856389eabf0260e01b89898860405160240161233393929190614434565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e4d565b9050808060200190518101906123809190614032565b925092505094509492505050565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b3906044016020604051808303816000875af11580156123dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c7919061421b565b606a54600090819061241f90600160a01b900460ff1661271061445b565b61ffff16606954612710612433919061447d565b61243d91906144aa565b606a5490915060009061245c90600160a01b900460ff1661271061445b565b61ffff16606954612710612470919061447d565b61247a91906144be565b111561248e578061248a816144d2565b9150505b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f29190613ea9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125609190613ec6565b8651909150156126605784518651146126075760405162461bcd60e51b815260206004820152605b60248201527f49526564656d7074696f6e537472617465677920636f6e74726163742061727260448201527f617920616e64207374726174656779206461746120627974657320617272617960648201527f206d6e75737420746865207468652073616d65206c656e6774682e0000000000608482015260a4016101ef565b60005b865181101561265e57612651838389848151811061262a5761262a613f6d565b602002602001015189858151811061264457612644613f6d565b6020026020010151612f41565b909350915060010161260a565b505b6000339050806001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c79190613ea9565b6001600160a01b0316836001600160a01b031614806127585750806001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561271f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127439190613ea9565b6001600160a01b0316836001600160a01b0316145b1561298d57606a546000906001600160a01b039081169085160361277d575083612835565b6066546040805163c45a015560e01b81529051612818926001600160a01b03169163c45a01559160048083019260209291908290030181865afa1580156127c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ec9190613ea9565b606954606a546128069088906001600160a01b0316612f9e565b606a54600160a01b900460ff1661302b565b60008151811061282a5761282a613f6d565b602002602001015190505b828111156128ab5760405162461bcd60e51b815260206004820152603d60248201527f546f6b656e20666c6173686c6f616e2072657475726e20616d6f756e7420677260448201527f6561746572207468616e207365697a656420636f6c6c61746572616c2e00000060648201526084016101ef565b60405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0385169063a9059cbb906044016020604051808303816000875af11580156128f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291c919061421b565b6129805760405162461bcd60e51b815260206004820152602f60248201527f4661696c656420746f20726570617920746f6b656e20666c6173686c6f616e2060448201526e37b7103137b93937bb9039b4b2329760891b60648201526084016101ef565b8395505050505050612d0c565b606554606a546000916001600160a01b039081169116036129af575083612a59565b6066546040805163c45a015560e01b81529051612a3c926001600160a01b03169163c45a01559160048083019260209291908290030181865afa1580156129fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1e9190613ea9565b606554606a548891612806916001600160a01b039182169116612f9e565b600081518110612a4e57612a4e613f6d565b602002602001015190505b6065546001600160a01b03858116911614612b1957606654612a869085906001600160a01b03168561238e565b6066546065546001600160a01b0391821691638803dbee9184918791612aae918a9116612f9e565b30426040518663ffffffff1660e01b8152600401612ad09594939291906144eb565b6000604051808303816000875af1158015612aef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b17919081019061455e565b505b6065546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b859190613ec6565b811115612c0b5760405162461bcd60e51b815260206004820152604860248201527f4e6f7420656e6f75676820575f4e41544956452065786368616e67656420667260448201527f6f6d207365697a656420636f6c6c61746572616c20746f20726570617920666c60648201526730b9b43637b0b71760c11b608482015260a4016101ef565b60655460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015612c5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c80919061421b565b6129805760405162461bcd60e51b815260206004820152605160248201527f4661696c656420746f20726570617920556e697377617020666c6173686c6f6160448201527f6e207769746820575f4e41544956452065786368616e6765642066726f6d207360648201527032b4bd32b21031b7b63630ba32b930b61760791b608482015260a4016101ef565b9392505050565b6040516001600160a01b03808516602483015283166044820152606481018290526110c79085906323b872dd60e01b9060840161229a565b600054610100900460ff16612d725760405162461bcd60e51b81526004016101ef90614397565b610d6d336121ed565b6000612dd0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131c29092919063ffffffff16565b8051909150156122d15780806020019051810190612dee919061421b565b6122d15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101ef565b60606001600160a01b0383163b612eb55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016101ef565b600080846001600160a01b031684604051612ed091906142ef565b600060405180830381855af49150503d8060008114612f0b576040519150601f19603f3d011682016040523d82523d6000602084013e612f10565b606091505b5091509150612f388282604051806060016040528060278152602001614666602791396131d1565b95945050505050565b6001600160a01b038216600090815260686020526040812054819060ff16612f7b5760405162461bcd60e51b81526004016101ef906143e2565b600061236a856310badf4e60e01b89898860405160240161233393929190614434565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110612fd757612fd7613f6d565b60200260200101906001600160a01b031690816001600160a01b031681525050828160018151811061300b5761300b613f6d565b6001600160a01b0390921660209283029190910190910152905092915050565b606060028351101561307f5760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f50415448000060448201526064016101ef565b82516001600160401b038111156130985761309861390a565b6040519080825280602002602001820160405280156130c1578160200160208202803683370190505b5090508381600183516130d49190614321565b815181106130e4576130e4613f6d565b6020026020010181815250506000600184516131009190614321565b90505b80156131b957600080613153888761311c600187614321565b8151811061312c5761312c613f6d565b602002602001015188868151811061314657613146613f6d565b602002602001015161320a565b9150915061317c84848151811061316c5761316c613f6d565b60200260200101518383886132d4565b84613188600186614321565b8151811061319857613198613f6d565b602002602001018181525050505080806131b190614380565b915050613103565b50949350505050565b6060611e2d848460008561340c565b606083156131e0575081612d0c565b8251156131f05782518084602001fd5b8160405162461bcd60e51b81526004016101ef91906145e3565b600080600061321985856134dc565b50905060008061322a8888886135d3565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015613267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061328b919061460d565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b0316146132c25780826132c5565b81815b90999098509650505050505050565b600080851161333a5760405162461bcd60e51b815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201526b155514155517d05353d5539560a21b60648201526084016101ef565b60008411801561334a5750600083115b6133a75760405162461bcd60e51b815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c604482015267495155494449545960c01b60648201526084016101ef565b60006133b3868661447d565b6133bf9061271061447d565b905060006133d260ff851661271061445b565b61ffff166133e08887614321565b6133ea919061447d565b90506133f681836144aa565b613401906001614652565b979650505050505050565b60608247101561346d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101ef565b600080866001600160a01b0316858760405161348991906142ef565b60006040518083038185875af1925050503d80600081146134c6576040519150601f19603f3d011682016040523d82523d6000602084013e6134cb565b606091505b509150915061340187838387613649565b600080826001600160a01b0316846001600160a01b03160361354e5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b60648201526084016101ef565b826001600160a01b0316846001600160a01b03161061356e578284613571565b83835b90925090506001600160a01b0382166135cc5760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f41444452455353000060448201526064016101ef565b9250929050565b60405163e6a4390560e01b81526001600160a01b03838116600483015282811660248301526000919085169063e6a4390590604401602060405180830381865afa158015613625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2d9190613ea9565b606083156136b85782516000036136b1576001600160a01b0385163b6136b15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101ef565b5081611e2d565b611e2d83838151156136cd5781518083602001fd5b8060405162461bcd60e51b81526004016101ef91906145e3565b6001600160a01b038116811461199857600080fd5b8035613707816136e7565b919050565b60006020828403121561371e57600080fd5b8135612d0c816136e7565b60006020828403121561373b57600080fd5b5035919050565b60008083601f84011261375457600080fd5b5081356001600160401b0381111561376b57600080fd5b6020830191508360208285010111156135cc57600080fd5b60008060008060006080868803121561379b57600080fd5b85356137a6816136e7565b9450602086013593506040860135925060608601356001600160401b038111156137cf57600080fd5b6137db88828901613742565b969995985093965092949392505050565b600080600080600060a0868803121561380457600080fd5b853561380f816136e7565b9450602086013593506040860135613826816136e7565b92506060860135613836816136e7565b949793965091946080013592915050565b60006020828403121561385957600080fd5b81356001600160401b0381111561386f57600080fd5b82016101408185031215612d0c57600080fd5b6000806020838503121561389557600080fd5b82356001600160401b038111156138ab57600080fd5b6138b785828601613742565b90969095509350505050565b801515811461199857600080fd5b600080604083850312156138e457600080fd5b82356138ef816136e7565b915060208301356138ff816138c3565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156139435761394361390a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156139715761397161390a565b604052919050565b600082601f83011261398a57600080fd5b81356001600160401b038111156139a3576139a361390a565b6139b6601f8201601f1916602001613949565b8181528460208386010111156139cb57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c08789031215613a0157600080fd5b8635613a0c816136e7565b9550602087013594506040870135613a23816136e7565b93506060870135613a33816136e7565b92506080870135613a43816136e7565b915060a08701356001600160401b03811115613a5e57600080fd5b613a6a89828a01613979565b9150509295509295509295565b600080600060608486031215613a8c57600080fd5b8335613a97816136e7565b92506020840135613aa7816136e7565b9150604084013560ff81168114613abd57600080fd5b809150509250925092565b60008083601f840112613ada57600080fd5b5081356001600160401b03811115613af157600080fd5b6020830191508360208260051b85010111156135cc57600080fd5b60008060008060408587031215613b2257600080fd5b84356001600160401b0380821115613b3957600080fd5b613b4588838901613ac8565b90965094506020870135915080821115613b5e57600080fd5b50613b6b87828801613ac8565b95989497509550505050565b60008060008060608587031215613b8d57600080fd5b8435613b98816136e7565b93506020850135925060408501356001600160401b03811115613bba57600080fd5b613b6b87828801613742565b60008085851115613bd657600080fd5b83861115613be357600080fd5b5050820193919092039150565b60006001600160401b03821115613c0957613c0961390a565b5060051b60200190565b600082601f830112613c2457600080fd5b81356020613c39613c3483613bf0565b613949565b8083825260208201915060208460051b870101935086841115613c5b57600080fd5b602086015b84811015613c80578035613c73816136e7565b8352918301918301613c60565b509695505050505050565b600082601f830112613c9c57600080fd5b81356020613cac613c3483613bf0565b82815260059290921b84018101918181019086841115613ccb57600080fd5b8286015b84811015613c805780356001600160401b03811115613cee5760008081fd5b613cfc8986838b0101613979565b845250918301918301613ccf565b600082601f830112613d1b57600080fd5b81356020613d2b613c3483613bf0565b8083825260208201915060208460051b870101935086841115613d4d57600080fd5b602086015b84811015613c80578035613d65816136e7565b8352918301918301613d52565b600060208284031215613d8457600080fd5b81356001600160401b0380821115613d9b57600080fd5b908301906101408286031215613db057600080fd5b613db8613920565b613dc1836136fc565b815260208301356020820152613dd9604084016136fc565b6040820152613dea606084016136fc565b6060820152613dfb608084016136fc565b608082015260a083013560a082015260c083013582811115613e1c57600080fd5b613e2887828601613c13565b60c08301525060e083013582811115613e4057600080fd5b613e4c87828601613c8b565b60e0830152506101008084013583811115613e6657600080fd5b613e7288828701613d0a565b8284015250506101208084013583811115613e8c57600080fd5b613e9888828701613c8b565b918301919091525095945050505050565b600060208284031215613ebb57600080fd5b8151612d0c816136e7565b600060208284031215613ed857600080fd5b5051919050565b60208082526025908201527f4846206e6f74206c6f7720656e6f7567682c20726573657276696e6720666f72604082015264040a0b2a8960db1b606082015260800190565b6000808335601e19843603018112613f3b57600080fd5b8301803591506001600160401b03821115613f5557600080fd5b6020019150600581901b36038213156135cc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112613f9a57600080fd5b8301803591506001600160401b03821115613fb457600080fd5b6020019150368190038213156135cc57600080fd5b60005b83811015613fe4578181015183820152602001613fcc565b50506000910152565b60008151808452614005816020860160208601613fc9565b601f01601f19169290920160200192915050565b828152604060208201526000611e2d6040830184613fed565b6000806040838503121561404557600080fd5b8251614050816136e7565b6020939093015192949293505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815284602082015260018060a01b0384166040820152608060608201526000613401608083018486614060565b60208082526038908201527f526570617920616d6f756e7420287472616e73616374696f6e2076616c75652960408201527f206d7573742062652067726561746572207468616e20302e0000000000000000606082015260800190565b600060018060a01b03808916835280881660208401528087166040840152808616606084015260c0608084015261414e60c0840186613fed565b915080841660a084015250979650505050505050565b60006020828403121561417657600080fd5b8135612d0c816138c3565b60008060008060008060c0878903121561419a57600080fd5b86356141a5816136e7565b955060208701356141b5816136e7565b945060408701356141c5816136e7565b935060608701356141d5816136e7565b925060808701356001600160401b038111156141f057600080fd5b6141fc89828a01613979565b92505060a087013561420d816136e7565b809150509295509295509295565b60006020828403121561422d57600080fd5b8151612d0c816138c3565b6020808252601390820152722634b8bab4b230ba34b7b7103330b4b632b21760691b604082015260600190565b60208082526012908201527127379031aa37b5b2b7399039b2b4bd32b21760711b604082015260600190565b602080825260409082018190527f4572726f722063616c6c696e672072656465656d696e67207365697a65642063908201527f546f6b656e3a206572726f7220636f6465206e6f7420657175616c20746f2030606082015260800190565b60008251614301818460208701613fc9565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b818103818111156121e7576121e761430b565b6001600160a01b0383168152604060208201819052600090611e2d90830184613fed565b60018060a01b0385168152836020820152606060408201526000611918606083018486614060565b60008161438f5761438f61430b565b506000190190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f6f6e6c792077686974656c697374656420726564656d7074696f6e20737472616040820152711d1959da595cc818d85b881899481d5cd95960721b606082015260800190565b60018060a01b0384168152826020820152606060408201526000612f386060830184613fed565b61ffff8281168282160390808211156144765761447661430b565b5092915050565b80820281158282048414176121e7576121e761430b565b634e487b7160e01b600052601260045260246000fd5b6000826144b9576144b9614494565b500490565b6000826144cd576144cd614494565b500690565b6000600182016144e4576144e461430b565b5060010190565b600060a08201878352602087602085015260a0604085015281875180845260c08601915060208901935060005b8181101561453d5784516001600160a01b031683529383019391830191600101614518565b50506001600160a01b03969096166060850152505050608001529392505050565b6000602080838503121561457157600080fd5b82516001600160401b0381111561458757600080fd5b8301601f8101851361459857600080fd5b80516145a6613c3482613bf0565b81815260059190911b820183019083810190878311156145c557600080fd5b928401925b82841015613401578351825292840192908401906145ca565b602081526000612d0c6020830184613fed565b80516001600160701b038116811461370757600080fd5b60008060006060848603121561462257600080fd5b61462b846145f6565b9250614639602085016145f6565b9150604084015163ffffffff81168114613abd57600080fd5b808201808211156121e7576121e761430b56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a2fb990d2e30037177416e7c2b3a3028b7bbee3fb50d53c25cf253572227250f64736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "details": "Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_whitelistRedemptionStrategies(address[],bool[])": { + "details": "for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`" + }, + "_whitelistRedemptionStrategy(address,bool)": { + "details": "for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`" + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pancakeCall(address,uint256,uint256,bytes)": { + "details": "Callback function for PCS flashloans." + }, + "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." + }, + "safeLiquidateToTokensWithFlashLoan((address,uint256,address,address,address,uint256,address[],bytes[],address[],bytes[]))": { + "params": { + "vars": "@see LiquidateToTokensWithFlashSwapVars." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "uniswapV2Call(address,uint256,uint256,bytes)": { + "details": "Callback function for Uniswap flashloans." + } + }, + "stateVariables": { + "UNISWAP_V2_ROUTER_02": { + "details": "UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)" + }, + "W_NATIVE_ADDRESS": { + "details": "W_NATIVE contract address." + }, + "_flashSwapAmount": { + "details": "Cached flash swap amount. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`." + }, + "_flashSwapToken": { + "details": "Cached flash swap token. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`." + }, + "_liquidatorProfitExchangeSource": { + "details": "Cached liquidator profit exchange source. ERC20 token address or the zero address for NATIVE. For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`." + }, + "expressRelay": { + "details": "Addres of Pyth Express Relay for preventing value leakage in liquidations." + }, + "flashSwapFee": { + "details": "Percentage of the flash swap fee, measured in basis points." + }, + "healthFactorThreshold": { + "details": "Health Factor below which PER permissioning is bypassed." + }, + "lens": { + "details": "Pool Lens." + } + }, + "title": "IonicLiquidator", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "receiveAuctionProceedings(bytes)": { + "notice": "receiveAuctionProceedings function - receives native token from the express relay You can use permission key to distribute the received funds to users who got liquidated, LPs, etc..." + }, + "safeLiquidateToTokensWithFlashLoan((address,uint256,address,address,address,uint256,address[],bytes[],address[],bytes[]))": { + "notice": "Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized." + } + }, + "notice": "IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 9849, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "W_NATIVE_ADDRESS", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 9853, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "UNISWAP_V2_ROUTER_02", + "offset": 0, + "slot": "102", + "type": "t_contract(IUniswapV2Router02)45906" + }, + { + "astId": 9856, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_liquidatorProfitExchangeSource", + "offset": 0, + "slot": "103", + "type": "t_address" + }, + { + "astId": 9860, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "redemptionStrategiesWhitelist", + "offset": 0, + "slot": "104", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 9863, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_flashSwapAmount", + "offset": 0, + "slot": "105", + "type": "t_uint256" + }, + { + "astId": 9866, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "_flashSwapToken", + "offset": 0, + "slot": "106", + "type": "t_address" + }, + { + "astId": 9869, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "flashSwapFee", + "offset": 20, + "slot": "106", + "type": "t_uint8" + }, + { + "astId": 9873, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "expressRelay", + "offset": 0, + "slot": "107", + "type": "t_contract(IExpressRelay)44080" + }, + { + "astId": 9877, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "lens", + "offset": 0, + "slot": "108", + "type": "t_contract(PoolLens)16806" + }, + { + "astId": 9880, + "contract": "contracts/IonicLiquidator.sol:IonicLiquidator", + "label": "healthFactorThreshold", + "offset": 0, + "slot": "109", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "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_contract(IExpressRelay)44080": { + "encoding": "inplace", + "label": "contract IExpressRelay", + "numberOfBytes": "20" + }, + "t_contract(IUniswapV2Router02)45906": { + "encoding": "inplace", + "label": "contract IUniswapV2Router02", + "numberOfBytes": "20" + }, + "t_contract(PoolLens)16806": { + "encoding": "inplace", + "label": "contract PoolLens", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/IonicUniV3Liquidator.json b/packages/contracts/deployments/superseed/IonicUniV3Liquidator.json new file mode 100644 index 0000000000..274205adb4 --- /dev/null +++ b/packages/contracts/deployments/superseed/IonicUniV3Liquidator.json @@ -0,0 +1,835 @@ +{ + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "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": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "VaultReceivedETH", + "type": "event" + }, + { + "inputs": [], + "name": "W_NATIVE_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "whitelisted", + "type": "bool[]" + } + ], + "name": "_whitelistRedemptionStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategy", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_whitelistRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "algebraFlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "expressRelay", + "outputs": [ + { + "internalType": "contract IExpressRelay", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "healthFactorThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_wtoken", + "type": "address" + }, + { + "internalType": "address", + "name": "_quoter", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lens", + "outputs": [ + { + "internalType": "contract PoolLens", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "quoter", + "outputs": [ + { + "internalType": "contract IUniswapV3Quoter", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "receiveAuctionProceedings", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlyingBorrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "receiveFlashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidatePyth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "flashSwapContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minProfitAmount", + "type": "uint256" + }, + { + "internalType": "contract IRedemptionStrategy[]", + "name": "redemptionStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "strategyData", + "type": "bytes[]" + }, + { + "internalType": "contract IFundsConversionStrategy[]", + "name": "debtFundingStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "debtFundingStrategiesData", + "type": "bytes[]" + } + ], + "internalType": "struct ILiquidator.LiquidateToTokensWithFlashSwapVars", + "name": "vars", + "type": "tuple" + } + ], + "name": "safeLiquidateToTokensWithFlashLoan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "aggregatorTarget", + "type": "address" + }, + { + "internalType": "bytes", + "name": "aggregatorData", + "type": "bytes" + } + ], + "name": "safeLiquidateWithAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_expressRelay", + "type": "address" + } + ], + "name": "setExpressRelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_healthFactorThreshold", + "type": "uint256" + } + ], + "name": "setHealthFactorThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolLens", + "type": "address" + } + ], + "name": "setPoolLens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "supV3FlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "uniswapV3FlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "transactionIndex": 1, + "gasUsed": "795237", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000008000000002000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000000000000280000000000000c00000000000000000000000000000000400000000000000000000000400000000000000000020000000000000000000040000200000000400000000000000000020000000000000000000000200000000000000000000000000000000000000000000", + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3", + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b0033576a9e444dd801d5b69e1b63dbc459a6115" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 2, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 3, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + } + ], + "blockNumber": 4159425, + "cumulativeGasUsed": "839079", + "status": 1, + "byzantium": true + }, + "args": [ + "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x485cc95500000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + "0x4200000000000000000000000000000000000006", + "0x0000000000000000000000000000000000000000" + ] + }, + "implementation": "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Implementation.json b/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Implementation.json new file mode 100644 index 0000000000..1fbb6b1f98 --- /dev/null +++ b/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Implementation.json @@ -0,0 +1,841 @@ +{ + "address": "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115", + "abi": [ + { + "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": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "VaultReceivedETH", + "type": "event" + }, + { + "inputs": [], + "name": "W_NATIVE_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "whitelisted", + "type": "bool[]" + } + ], + "name": "_whitelistRedemptionStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategy", + "type": "address" + }, + { + "internalType": "bool", + "name": "whitelisted", + "type": "bool" + } + ], + "name": "_whitelistRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "algebraFlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "expressRelay", + "outputs": [ + { + "internalType": "contract IExpressRelay", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "healthFactorThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_wtoken", + "type": "address" + }, + { + "internalType": "address", + "name": "_quoter", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lens", + "outputs": [ + { + "internalType": "contract PoolLens", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "quoter", + "outputs": [ + { + "internalType": "contract IUniswapV3Quoter", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "permissionKey", + "type": "bytes" + } + ], + "name": "receiveAuctionProceedings", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlyingBorrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "receiveFlashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minOutputAmount", + "type": "uint256" + } + ], + "name": "safeLiquidatePyth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "flashSwapContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minProfitAmount", + "type": "uint256" + }, + { + "internalType": "contract IRedemptionStrategy[]", + "name": "redemptionStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "strategyData", + "type": "bytes[]" + }, + { + "internalType": "contract IFundsConversionStrategy[]", + "name": "debtFundingStrategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "debtFundingStrategiesData", + "type": "bytes[]" + } + ], + "internalType": "struct ILiquidator.LiquidateToTokensWithFlashSwapVars", + "name": "vars", + "type": "tuple" + } + ], + "name": "safeLiquidateToTokensWithFlashLoan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "cErc20", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenCollateral", + "type": "address" + }, + { + "internalType": "address", + "name": "aggregatorTarget", + "type": "address" + }, + { + "internalType": "bytes", + "name": "aggregatorData", + "type": "bytes" + } + ], + "name": "safeLiquidateWithAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_expressRelay", + "type": "address" + } + ], + "name": "setExpressRelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_healthFactorThreshold", + "type": "uint256" + } + ], + "name": "setHealthFactorThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolLens", + "type": "address" + } + ], + "name": "setPoolLens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "supV3FlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "uniswapV3FlashCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x4ef9cc7d2c06bcc704a1b5d1fb4fd23f29a24eb53155d7563c891b2ed7d90525", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115", + "transactionIndex": 1, + "gasUsed": "3543359", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x0dfa2803093ca574132e263ffc16a0bdd2881b3acd51494c9d3a45a199c6d737", + "transactionHash": "0x4ef9cc7d2c06bcc704a1b5d1fb4fd23f29a24eb53155d7563c891b2ed7d90525", + "logs": [], + "blockNumber": 4135730, + "cumulativeGasUsed": "3587237", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"permissionKey\",\"type\":\"bytes\"}],\"name\":\"VaultReceivedETH\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"W_NATIVE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"whitelisted\",\"type\":\"bool[]\"}],\"name\":\"_whitelistRedemptionStrategies\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"_whitelistRedemptionStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"algebraFlashCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"expressRelay\",\"outputs\":[{\"internalType\":\"contract IExpressRelay\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"healthFactorThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wtoken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quoter\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lens\",\"outputs\":[{\"internalType\":\"contract PoolLens\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quoter\",\"outputs\":[{\"internalType\":\"contract IUniswapV3Quoter\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"permissionKey\",\"type\":\"bytes\"}],\"name\":\"receiveAuctionProceedings\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_underlyingBorrow\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"receiveFlashLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minOutputAmount\",\"type\":\"uint256\"}],\"name\":\"safeLiquidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minOutputAmount\",\"type\":\"uint256\"}],\"name\":\"safeLiquidatePyth\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"flashSwapContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minProfitAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"redemptionStrategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"strategyData\",\"type\":\"bytes[]\"},{\"internalType\":\"contract IFundsConversionStrategy[]\",\"name\":\"debtFundingStrategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"debtFundingStrategiesData\",\"type\":\"bytes[]\"}],\"internalType\":\"struct ILiquidator.LiquidateToTokensWithFlashSwapVars\",\"name\":\"vars\",\"type\":\"tuple\"}],\"name\":\"safeLiquidateToTokensWithFlashLoan\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cErc20\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenCollateral\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"aggregatorTarget\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"aggregatorData\",\"type\":\"bytes\"}],\"name\":\"safeLiquidateWithAggregator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_expressRelay\",\"type\":\"address\"}],\"name\":\"setExpressRelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_healthFactorThreshold\",\"type\":\"uint256\"}],\"name\":\"setHealthFactorThreshold\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolLens\",\"type\":\"address\"}],\"name\":\"setPoolLens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"supV3FlashCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee1\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"uniswapV3FlashCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"Veliko Minkov (https://github.com/vminkov)\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_whitelistRedemptionStrategies(address[],bool[])\":{\"details\":\"for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\"},\"_whitelistRedemptionStrategy(address,bool)\":{\"details\":\"for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\"},\"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.\"},\"supV3FlashCallback(uint256,uint256,bytes)\":{\"details\":\"Callback function for Uniswap flashloans.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"uniswapV3FlashCallback(uint256,uint256,bytes)\":{\"details\":\"In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\",\"params\":{\"data\":\"Any data passed through by the caller via the IUniswapV3PoolActions#flash call\",\"fee0\":\"The fee amount in token0 due to the pool by the end of the flash\",\"fee1\":\"The fee amount in token1 due to the pool by the end of the flash\"}}},\"stateVariables\":{\"_flashSwapAmount\":{\"details\":\"Cached flash swap amount. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\"},\"_flashSwapToken\":{\"details\":\"Cached flash swap token. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\"},\"_liquidatorProfitExchangeSource\":{\"details\":\"Cached liquidator profit exchange source. ERC20 token address or the zero address for NATIVE. For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\"},\"expressRelay\":{\"details\":\"Addres of Pyth Express Relay for preventing value leakage in liquidations.\"},\"healthFactorThreshold\":{\"details\":\"Health Factor below which PER permissioning is bypassed.\"},\"lens\":{\"details\":\"Pool Lens.\"}},\"title\":\"IonicUniV3Liquidator\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"receiveAuctionProceedings(bytes)\":{\"notice\":\"receiveAuctionProceedings function - receives native token from the express relay You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\"},\"uniswapV3FlashCallback(uint256,uint256,bytes)\":{\"notice\":\"Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\"}},\"notice\":\"IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/IonicUniV3Liquidator.sol\":\"IonicUniV3Liquidator\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/ILiquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\n\\ninterface ILiquidator {\\n /**\\n * borrower The borrower's Ethereum address.\\n * repayAmount The amount to repay to liquidate the unhealthy loan.\\n * cErc20 The borrowed CErc20 contract to repay.\\n * cTokenCollateral The cToken collateral contract to be liquidated.\\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\\n */\\n struct LiquidateToTokensWithFlashSwapVars {\\n address borrower;\\n uint256 repayAmount;\\n ICErc20 cErc20;\\n ICErc20 cTokenCollateral;\\n address flashSwapContract;\\n uint256 minProfitAmount;\\n IRedemptionStrategy[] redemptionStrategies;\\n bytes[] strategyData;\\n IFundsConversionStrategy[] debtFundingStrategies;\\n bytes[] debtFundingStrategiesData;\\n }\\n\\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256);\\n\\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\\n external\\n returns (uint256);\\n\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\\n\\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\\n external;\\n\\n function setExpressRelay(address _expressRelay) external;\\n\\n function setPoolLens(address _poolLens) external;\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\\n}\\n\",\"keccak256\":\"0x27f01b974199a9ab7e4e4d5df2a744d4c7465a3b56316d00829ca0f484efb67d\",\"license\":\"UNLICENSED\"},\"contracts/IonicUniV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\nimport \\\"./liquidators/IRedemptionStrategy.sol\\\";\\nimport \\\"./liquidators/IFundsConversionStrategy.sol\\\";\\nimport \\\"./ILiquidator.sol\\\";\\n\\nimport \\\"./external/uniswap/IUniswapV3FlashCallback.sol\\\";\\nimport \\\"./external/uniswap/IUniswapV3Pool.sol\\\";\\nimport \\\"./external/pyth/IExpressRelay.sol\\\";\\nimport \\\"./external/pyth/IExpressRelayFeeReceiver.sol\\\";\\nimport { IUniswapV3Quoter } from \\\"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"./ionic/IFlashLoanReceiver.sol\\\";\\n\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"./PoolLens.sol\\\";\\n\\n/**\\n * @title IonicUniV3Liquidator\\n * @author Veliko Minkov (https://github.com/vminkov)\\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\\n */\\ncontract IonicUniV3Liquidator is\\n OwnableUpgradeable,\\n ILiquidator,\\n IUniswapV3FlashCallback,\\n IExpressRelayFeeReceiver,\\n IFlashLoanReceiver\\n{\\n using AddressUpgradeable for address payable;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\\n /**\\n * @dev Cached liquidator profit exchange source.\\n * ERC20 token address or the zero address for NATIVE.\\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\\n */\\n address private _liquidatorProfitExchangeSource;\\n\\n /**\\n * @dev Cached flash swap amount.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n uint256 private _flashSwapAmount;\\n\\n /**\\n * @dev Cached flash swap token.\\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\\n */\\n address private _flashSwapToken;\\n\\n address public W_NATIVE_ADDRESS;\\n mapping(address => bool) public redemptionStrategiesWhitelist;\\n IUniswapV3Quoter public quoter;\\n\\n /**\\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\\n */\\n IExpressRelay public expressRelay;\\n /**\\n * @dev Pool Lens.\\n */\\n PoolLens public lens;\\n /**\\n * @dev Health Factor below which PER permissioning is bypassed.\\n */\\n uint256 public healthFactorThreshold;\\n\\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\\n require(currentHealthFactor < healthFactorThreshold, \\\"HF not low enough, reserving for PYTH\\\");\\n _;\\n }\\n\\n function initialize(address _wtoken, address _quoter) external initializer {\\n __Ownable_init();\\n W_NATIVE_ADDRESS = _wtoken;\\n quoter = IUniswapV3Quoter(_quoter);\\n }\\n\\n /**\\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\\n * @param borrower The borrower's Ethereum address.\\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\\n * @param cErc20 The borrowed cErc20 to repay.\\n * @param cTokenCollateral The cToken collateral to be liquidated.\\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\\n */\\n function _safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) internal returns (uint256) {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\\n underlying.approve(address(cErc20), repayAmount);\\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n\\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\\n }\\n\\n function safeLiquidate(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidatePyth(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n uint256 minOutputAmount\\n ) external returns (uint256) {\\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \\\"invalid liquidation\\\");\\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\\n }\\n\\n function safeLiquidateWithAggregator(\\n address borrower,\\n uint256 repayAmount,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData\\n ) external {\\n // Transfer tokens in, approve to cErc20, and liquidate borrow\\n require(repayAmount > 0, \\\"Repay amount (transaction value) must be greater than 0.\\\");\\n cErc20.flash(\\n repayAmount,\\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\\n );\\n }\\n\\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\\n (\\n address borrower,\\n ICErc20 cErc20,\\n ICErc20 cTokenCollateral,\\n address aggregatorTarget,\\n bytes memory aggregatorData,\\n address liquidator\\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\\n underlyingBorrow.approve(address(cErc20), amount);\\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \\\"Liquidation failed.\\\");\\n\\n // Redeem seized cTokens for underlying asset\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\\n {\\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\\n\\n // Call the aggregator\\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\\n (bool success, ) = aggregatorTarget.call(aggregatorData);\\n require(success, \\\"Aggregator call failed\\\");\\n }\\n\\n // receive profits\\n {\\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\\n require(receivedAmount >= amount, \\\"Not received enough collateral after swap.\\\");\\n uint256 profitBorrow = receivedAmount - amount;\\n if (profitBorrow > 0) {\\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\\n }\\n\\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\\n if (profitCollateral > 0) {\\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\\n }\\n }\\n\\n // pay back flashloan\\n underlyingBorrow.approve(address(cErc20), amount);\\n }\\n\\n /**\\n * @dev Transfers seized funds to the sender.\\n * @param erc20Contract The address of the token to transfer.\\n * @param minOutputAmount The minimum amount to transfer.\\n */\\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\\n uint256 seizedOutputAmount = token.balanceOf(address(this));\\n require(seizedOutputAmount >= minOutputAmount, \\\"Minimum token output amount not satified.\\\");\\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\\n\\n return seizedOutputAmount;\\n }\\n\\n function safeLiquidateToTokensWithFlashLoan(\\n LiquidateToTokensWithFlashSwapVars calldata vars\\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\\n // Input validation\\n require(vars.repayAmount > 0, \\\"Repay amount must be greater than 0.\\\");\\n\\n // we want to calculate the needed flashSwapAmount on-chain to\\n // avoid errors due to changing market conditions\\n // between the time of calculating and including the tx in a block\\n uint256 fundingAmount = vars.repayAmount;\\n IERC20Upgradeable fundingToken;\\n if (vars.debtFundingStrategies.length > 0) {\\n require(\\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\\n \\\"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\\\"\\n );\\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\\n }\\n } else {\\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\\n }\\n\\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\\n _flashSwapAmount = fundingAmount;\\n _flashSwapToken = address(fundingToken);\\n\\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\\n flashSwapPool.flash(\\n address(this),\\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\\n msg.data\\n );\\n\\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\\n }\\n\\n /**\\n * @dev Receives NATIVE from liquidations and flashloans.\\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\\n */\\n receive() external payable {\\n require(payable(msg.sender).isContract(), \\\"Sender is not a contract.\\\");\\n }\\n\\n /**\\n * @notice receiveAuctionProceedings function - receives native token from the express relay\\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\\n */\\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\\n }\\n\\n function withdrawAll() external onlyOwner {\\n uint256 balance = address(this).balance;\\n require(balance > 0, \\\"No Ether left to withdraw\\\");\\n\\n // Transfer all Ether to the owner\\n (bool sent, ) = msg.sender.call{ value: balance }(\\\"\\\");\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n\\n /**\\n * @dev Callback function for Uniswap flashloans.\\n */\\n\\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\\n uniswapV3FlashCallback(fee0, fee1, data);\\n }\\n\\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\\n // Decode params\\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\\n\\n // Post token flashloan\\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\\n }\\n\\n /**\\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\\n */\\n function postFlashLoanTokens(\\n LiquidateToTokensWithFlashSwapVars memory vars,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\\n uint256 debtRepaymentAmount = _flashSwapAmount;\\n\\n if (vars.debtFundingStrategies.length > 0) {\\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\\n debtRepaymentToken,\\n debtRepaymentAmount,\\n vars.debtFundingStrategies[i - 1],\\n vars.debtFundingStrategiesData[i - 1]\\n );\\n }\\n }\\n\\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\\n {\\n address underlyingBorrow = vars.cErc20.underlying();\\n require(\\n address(debtRepaymentToken) == underlyingBorrow,\\n \\\"the debt repayment funds should be converted to the underlying debt token\\\"\\n );\\n require(debtRepaymentAmount >= vars.repayAmount, \\\"debt repayment amount not enough\\\");\\n // Approve repayAmount to cErc20\\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\\n\\n // Liquidate borrow\\n require(\\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\\n \\\"Liquidation failed.\\\"\\n );\\n\\n // Redeem seized cTokens for underlying asset\\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\\n require(seizedCTokenAmount > 0, \\\"No cTokens seized.\\\");\\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\\n require(redeemResult == 0, \\\"Error calling redeeming seized cToken: error code not equal to 0\\\");\\n }\\n\\n // Repay flashloan\\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\\n }\\n\\n /**\\n * @dev Repays token flashloans.\\n */\\n function repayTokenFlashLoan(\\n ICErc20 cTokenCollateral,\\n IRedemptionStrategy[] memory redemptionStrategies,\\n bytes[] memory strategyData,\\n uint256 fee0,\\n uint256 fee1\\n ) private returns (address) {\\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\\n uint256 flashSwapReturnAmount = _flashSwapAmount;\\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\\n flashSwapReturnAmount += fee0;\\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\\n flashSwapReturnAmount += fee1;\\n } else {\\n revert(\\\"wrong pool or _flashSwapToken\\\");\\n }\\n\\n // Swap cTokenCollateral for cErc20 via Uniswap\\n // Check underlying collateral seized\\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\\n\\n // Redeem custom collateral if liquidation strategy is set\\n if (redemptionStrategies.length > 0) {\\n require(\\n redemptionStrategies.length == strategyData.length,\\n \\\"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\\\"\\n );\\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\\n underlyingCollateral,\\n underlyingCollateralSeized,\\n redemptionStrategies[i],\\n strategyData[i]\\n );\\n }\\n\\n // Check if we can repay directly one of the sides with collateral\\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\\n // Repay flashloan directly with collateral\\n uint256 collateralRequired;\\n if (address(underlyingCollateral) == _flashSwapToken) {\\n // repay the borrowed asset directly\\n collateralRequired = flashSwapReturnAmount;\\n\\n // Repay flashloan\\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\\n } else {\\n // TODO swap within the same pool and then repay the FL to the pool\\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\\n\\n {\\n collateralRequired = quoter.quoteExactOutputSingle(\\n zeroForOne ? pool.token0() : pool.token1(),\\n zeroForOne ? pool.token1() : pool.token0(),\\n pool.fee(),\\n _flashSwapAmount,\\n 0 // sqrtPriceLimitX96\\n );\\n }\\n require(\\n collateralRequired <= underlyingCollateralSeized,\\n \\\"Token flashloan return amount greater than seized collateral.\\\"\\n );\\n\\n // Repay flashloan\\n pool.swap(\\n address(pool),\\n zeroForOne,\\n int256(collateralRequired),\\n 0, // sqrtPriceLimitX96\\n \\\"\\\"\\n );\\n }\\n\\n return address(underlyingCollateral);\\n } else {\\n revert(\\\"the redemptions strategy did not swap to the flash swapped pool assets\\\");\\n }\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\\n }\\n\\n /**\\n * @dev for security reasons only whitelisted redemption strategies may be used.\\n * Each whitelisted redemption strategy has to be checked to not be able to\\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\\n */\\n function _whitelistRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n bool[] calldata whitelisted\\n ) external onlyOwner {\\n require(\\n strategies.length > 0 && strategies.length == whitelisted.length,\\n \\\"list of strategies empty or whitelist does not match its length\\\"\\n );\\n\\n for (uint256 i = 0; i < strategies.length; i++) {\\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\\n }\\n }\\n\\n function setExpressRelay(address _expressRelay) external onlyOwner {\\n expressRelay = IExpressRelay(_expressRelay);\\n }\\n\\n function setPoolLens(address _poolLens) external onlyOwner {\\n lens = PoolLens(_poolLens);\\n }\\n\\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\\n require(_healthFactorThreshold <= 1e18, \\\"Invalid Health Factor Threshold\\\");\\n healthFactorThreshold = _healthFactorThreshold;\\n }\\n\\n /**\\n * @dev Redeem \\\"special\\\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\\n */\\n function redeemCustomCollateral(\\n IERC20Upgradeable underlyingCollateral,\\n uint256 underlyingCollateralSeized,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IFundsConversionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n require(redemptionStrategiesWhitelist[address(strategy)], \\\"only whitelisted redemption strategies can be used\\\");\\n\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\\n */\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.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, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\\n */\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) 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\":\"0x03ad15c5d4e63fbc8d4df554ce3172f4e0611843a326a8e29ec39870e5ddbd72\",\"license\":\"UNLICENSED\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/pyth/IExpressRelay.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelay {\\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\\n // This will return true if and only if it's being called while executing the auction winner(s) call.\\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\\n // @param permissionId The id that represents the action being gated\\n // @return permissioned True if the permission is allowed, false otherwise\\n function isPermissioned(\\n address protocolFeeReceiver,\\n bytes calldata permissionId\\n ) external view returns (bool permissioned);\\n}\\n\",\"keccak256\":\"0xfcd165d263ba7372726637a004aca64177334e48f51c8c9ed27ce7a63ebec5e9\",\"license\":\"Apache 2\"},\"contracts/external/pyth/IExpressRelayFeeReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: Apache 2\\npragma solidity ^0.8.0;\\n\\ninterface IExpressRelayFeeReceiver {\\n // Receive the proceeds of an auction.\\n // @param permissionKey The permission key where the auction was conducted on.\\n function receiveAuctionProceedings(\\n bytes calldata permissionKey\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xc91591ca7c7e9a2659768a9142fa4dfbd7bd0494dabd853a915d72446a5f74a0\",\"license\":\"Apache 2\"},\"contracts/external/uniswap/IUniswapV3FlashCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#flash\\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\\ninterface IUniswapV3FlashCallback {\\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\\n function uniswapV3FlashCallback(\\n uint256 fee0,\\n uint256 fee1,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc26730db16259a49c30bd7bd880bb7e48ad94853087a373ba787e406ca969f3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50613f1f806100206000396000f3fe60806040526004361061016a5760003560e01c8063715018a6116100d1578063958fa2801161008a578063c92cb8cc11610064578063c92cb8cc14610472578063e9cbafb014610492578063f2fde38b146104b2578063fced7081146104d257600080fd5b8063958fa28014610432578063a60b0d3c1461034a578063c6bbd5a71461045257600080fd5b8063715018a61461038a5780637c95ba9f1461039f57806381738f13146103bf578063853828b6146103df5780638a0b9090146103f45780638da5cb5b1461041457600080fd5b8063485cc95511610123578063485cc955146102aa57806355e9e8fe146102ca5780635a431365146102ea5780635b6723711461030a578063673125291461034a5780636f6c04471461036a57600080fd5b8063030e47df146101c95780630add23ea146101e9578063112666b71461020957806320b723251461024657806329f269f4146102745780632c89aa2e1461029457600080fd5b366101c457333b6101c25760405162461bcd60e51b815260206004820152601960248201527f53656e646572206973206e6f74206120636f6e74726163742e0000000000000060448201526064015b60405180910390fd5b005b600080fd5b3480156101d557600080fd5b506101c26101e436600461314f565b6104e5565b3480156101f557600080fd5b506101c261020436600461316c565b61050f565b34801561021557600080fd5b50606c54610229906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561025257600080fd5b50610266610261366004613185565b610574565b60405190815260200161023d565b34801561028057600080fd5b506101c261028f36600461314f565b6106ad565b3480156102a057600080fd5b50610266606d5481565b3480156102b657600080fd5b506101c26102c53660046131e0565b6106d7565b3480156102d657600080fd5b506102666102e5366004613219565b61081a565b3480156102f657600080fd5b506101c2610305366004613262565b610d94565b34801561031657600080fd5b5061033a61032536600461314f565b60696020526000908152604090205460ff1681565b604051901515815260200161023d565b34801561035657600080fd5b506101c26103653660046132d8565b610dc7565b34801561037657600080fd5b50606b54610229906001600160a01b031681565b34801561039657600080fd5b506101c2610dd9565b3480156103ab57600080fd5b506101c26103ba366004613408565b610ded565b3480156103cb57600080fd5b50606854610229906001600160a01b031681565b3480156103eb57600080fd5b506101c2610e9e565b34801561040057600080fd5b506101c261040f3660046134db565b610f87565b34801561042057600080fd5b506033546001600160a01b0316610229565b34801561043e57600080fd5b506101c261044d36600461353a565b6110a3565b34801561045e57600080fd5b50606a54610229906001600160a01b031681565b34801561047e57600080fd5b5061026661048d366004613185565b6116f8565b34801561049e57600080fd5b506101c26104ad3660046132d8565b6117e5565b3480156104be57600080fd5b506101c26104cd36600461314f565b611835565b6101c26104e036600461357d565b6118ae565b6104ed6118ef565b606b80546001600160a01b0319166001600160a01b0392909216919091179055565b6105176118ef565b670de0b6b3a764000081111561056f5760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964204865616c746820466163746f72205468726573686f6c640060448201526064016101b9565b606d55565b600085836000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060191906135be565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561064c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067091906135db565b9050606d5481106106935760405162461bcd60e51b81526004016101b9906135f4565b6106a08989898989611949565b9998505050505050505050565b6106b56118ef565b606c80546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16158080156106f75750600054600160ff909116105b806107115750303b158015610711575060005460ff166001145b6107745760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101b9565b6000805460ff191660011790558015610797576000805461ff0019166101001790555b61079f611c77565b606880546001600160a01b038086166001600160a01b031992831617909255606a8054928516929091169190911790558015610815576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6000610829602083018361314f565b610839608084016060850161314f565b6000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561089e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c291906135be565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561090d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093191906135db565b9050606d5481106109545760405162461bcd60e51b81526004016101b9906135f4565b60008560200135116109b45760405162461bcd60e51b8152602060048201526024808201527f526570617920616d6f756e74206d7573742062652067726561746572207468616044820152633710181760e11b60648201526084016101b9565b60208501356000806109ca610100890189613639565b90501115610bd5576109e0610120880188613639565b90506109f0610100890189613639565b905014610a9a5760405162461bcd60e51b815260206004820152606660248201527f46756e64696e67204946756e6473436f6e76657273696f6e537472617465677960448201527f20636f6e747261637420617272617920616e642073747261746567792064617460648201527f61206279746573206172726179206d757374206265207468652073616d65206c60848201526532b733ba341760d11b60a482015260c4016101b9565b60005b610aab610100890189613639565b9050811015610bcf576000610ac46101208a018a613639565b83818110610ad457610ad4613682565b9050602002810190610ae69190613698565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450610b2b925050506101008b018b613639565b84818110610b3b57610b3b613682565b9050602002016020810190610b50919061314f565b60405163180994cb60e11b81529091506001600160a01b03821690633013299690610b81908890869060040161372e565b6040805180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc19190613747565b955093505050600101610a9d565b50610c49565b610be5606088016040890161314f565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4691906135be565b90505b6066829055606780546001600160a01b0319166001600160a01b0383161790556000610c7b60a0890160808a0161314f565b90506000826001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ceb91906135be565b6001600160a01b0316149050816001600160a01b031663490e6cbc3083610d13576000610d15565b865b8415610d22576000610d24565b875b6000366040518663ffffffff1660e01b8152600401610d4795949392919061379e565b600060405180830381600087803b158015610d6157600080fd5b505af1158015610d75573d6000803e3d6000fd5b50506065546106a092506001600160a01b0316905060a08b0135611ca6565b610d9c6118ef565b6001600160a01b03919091166000908152606960205260409020805460ff1916911515919091179055565b610dd3848484846117e5565b50505050565b610de16118ef565b610deb6000611d9d565b565b60008511610e0d5760405162461bcd60e51b81526004016101b9906137cc565b836001600160a01b0316633c3b4b8986888787878733604051602001610e3896959493929190613829565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610e6492919061372e565b600060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b50505050505050505050565b610ea66118ef565b4780610ef45760405162461bcd60e51b815260206004820152601960248201527f4e6f204574686572206c65667420746f2077697468647261770000000000000060448201526064016101b9565b604051600090339083908381818185875af1925050503d8060008114610f36576040519150601f19603f3d011682016040523d82523d6000602084013e610f3b565b606091505b5050905080610f835760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016101b9565b5050565b610f8f6118ef565b8215801590610f9d57508281145b61100f5760405162461bcd60e51b815260206004820152603f60248201527f6c697374206f66207374726174656769657320656d707479206f72207768697460448201527f656c69737420646f6573206e6f74206d6174636820697473206c656e6774680060648201526084016101b9565b60005b8381101561109c5782828281811061102c5761102c613682565b90506020020160208101906110419190613879565b6069600087878581811061105757611057613682565b905060200201602081019061106c919061314f565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611012565b5050505050565b600080808080806110b687890189613896565b60405163095ea7b360e01b8152959b509399509197509550935091508a906001600160a01b0382169063095ea7b3906111099089908e906004016001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114c9190613930565b50604051637af1e23160e11b81526001600160a01b038881166004830152602482018c9052868116604483015287169063f5e3c462906064016020604051808303816000875af11580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c891906135db565b156111e55760405162461bcd60e51b81526004016101b99061394d565b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611225573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124991906135be565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa158015611293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b791906135db565b9050600081116112d95760405162461bcd60e51b81526004016101b99061397a565b60405163db006a7560e01b8152600481018290526000906001600160a01b0389169063db006a75906024016020604051808303816000875af1158015611323573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134791906135db565b905080156113675760405162461bcd60e51b81526004016101b9906139a6565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d291906135db565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015611425573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114499190613930565b506000886001600160a01b0316886040516114649190613a04565b6000604051808303816000865af19150503d80600081146114a1576040519150601f19603f3d011682016040523d82523d6000602084013e6114a6565b606091505b50509050806114f05760405162461bcd60e51b81526020600482015260166024820152751059d9dc9959d85d1bdc8818d85b1b0819985a5b195960521b60448201526064016101b9565b50506040516370a0823160e01b8152306004820152600092506001600160a01b03851691506370a0823190602401602060405180830381865afa15801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f91906135db565b90508b8110156115c45760405162461bcd60e51b815260206004820152602a60248201527f4e6f7420726563656976656420656e6f75676820636f6c6c61746572616c2061604482015269333a32b91039bbb0b81760b11b60648201526084016101b9565b60006115d08d83613a36565b905080156115ec576115ec6001600160a01b0385168683611def565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611633573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165791906135db565b90508015611673576116736001600160a01b0385168783611def565b505060405163095ea7b360e01b81526001600160a01b038981166004830152602482018e90528416915063095ea7b3906044016020604051808303816000875af11580156116c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e99190613930565b50505050505050505050505050565b606b54604080516001600160a01b038881166020830152600093169163403e96f6913091016040516020818303038152906040526040518363ffffffff1660e01b8152600401611749929190613a49565b602060405180830381865afa158015611766573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178a9190613930565b6117cc5760405162461bcd60e51b815260206004820152601360248201527234b73b30b634b2103634b8bab4b230ba34b7b760691b60448201526064016101b9565b6117d98686868686611949565b90505b95945050505050565b60006117f48260048186613a6d565b8101906118019190613c19565b905061180e818686611e52565b606580546001600160a01b0319166001600160a01b03929092169190911790555050505050565b61183d6118ef565b6001600160a01b0381166118a25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101b9565b6118ab81611d9d565b50565b7f373bc109b9e1d2a0702bd463de500dfec960521e4498acc170fd65867e46041c333484846040516118e39493929190613d50565b60405180910390a15050565b6033546001600160a01b03163314610deb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101b9565b600080851161196a5760405162461bcd60e51b81526004016101b9906137cc565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ce91906135be565b90506119e56001600160a01b0382163330896122c3565b60405163095ea7b360e01b81526001600160a01b0386811660048301526024820188905282169063095ea7b3906044016020604051808303816000875af1158015611a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a589190613930565b50604051637af1e23160e11b81526001600160a01b03888116600483015260248201889052858116604483015286169063f5e3c462906064016020604051808303816000875af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad491906135db565b15611af15760405162461bcd60e51b81526004016101b99061394d565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015611b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5c91906135db565b905060008111611b7e5760405162461bcd60e51b81526004016101b99061397a565b60405163db006a7560e01b8152600481018290526000906001600160a01b0387169063db006a75906024016020604051808303816000875af1158015611bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bec91906135db565b90508015611c0c5760405162461bcd60e51b81526004016101b9906139a6565b6106a0866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7191906135be565b86611ca6565b600054610100900460ff16611c9e5760405162461bcd60e51b81526004016101b990613d78565b610deb6122fb565b6040516370a0823160e01b8152306004820152600090839082906001600160a01b038316906370a0823190602401602060405180830381865afa158015611cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1591906135db565b905083811015611d795760405162461bcd60e51b815260206004820152602960248201527f4d696e696d756d20746f6b656e206f757470757420616d6f756e74206e6f742060448201526839b0ba34b334b2b21760b91b60648201526084016101b9565b8015611d9357611d936001600160a01b0383163383611def565b9150505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b03831660248201526044810182905261081590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261232b565b606754606654610100850151516000926001600160a01b0316919015611ef957610100860151515b8015611ef757611ee08383896101000151600185611e989190613a36565b81518110611ea857611ea8613682565b60200260200101518a6101200151600186611ec39190613a36565b81518110611ed357611ed3613682565b60200260200101516123fd565b909350915080611eef81613dc3565b915050611e7a565b505b600086604001516001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6191906135be565b9050806001600160a01b0316836001600160a01b031614611ffc5760405162461bcd60e51b815260206004820152604960248201527f74686520646562742072657061796d656e742066756e64732073686f756c642060448201527f626520636f6e76657274656420746f2074686520756e6465726c79696e67206460648201526832b13a103a37b5b2b760b91b608482015260a4016101b9565b86602001518210156120505760405162461bcd60e51b815260206004820181905260248201527f646562742072657061796d656e7420616d6f756e74206e6f7420656e6f75676860448201526064016101b9565b6040808801516020890151915163095ea7b360e01b81526001600160a01b039182166004820152602481019290925282169063095ea7b3906044016020604051808303816000875af11580156120aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ce9190613930565b50604087810151885160208a015160608b01519351637af1e23160e11b81526001600160a01b03928316600482015260248101919091529281166044840152169063f5e3c462906064016020604051808303816000875af1158015612137573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215b91906135db565b156121785760405162461bcd60e51b81526004016101b99061394d565b60608701516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156121c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e791906135db565b9050600081116122095760405162461bcd60e51b81526004016101b99061397a565b606088015160405163db006a7560e01b8152600481018390526000916001600160a01b03169063db006a75906024016020604051808303816000875af1158015612257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227b91906135db565b9050801561229b5760405162461bcd60e51b81526004016101b9906139a6565b5050506122b786606001518760c001518860e0015188886124b5565b925050505b9392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610dd39085906323b872dd60e01b90608401611e1b565b600054610100900460ff166123225760405162461bcd60e51b81526004016101b990613d78565b610deb33611d9d565b6000612380826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e199092919063ffffffff16565b805190915015610815578080602001905181019061239e9190613930565b6108155760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101b9565b6001600160a01b038216600090815260696020526040812054819060ff166124375760405162461bcd60e51b81526004016101b990613dda565b6000612491856389eabf0260e01b89898860405160240161245a93929190613e2c565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e30565b9050808060200190518101906124a79190613747565b925092505094509492505050565b60665460675460408051630dfe168160e01b81529051600093339390926001600160a01b03909116918491630dfe16819160048083019260209291908290030181865afa15801561250a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252e91906135be565b6001600160a01b03160361254d576125468582613e53565b905061261c565b6067546040805163d21220a760e01b815290516001600160a01b0390921691339163d21220a79160048083019260209291908290030181865afa158015612598573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bc91906135be565b6001600160a01b0316036125d4576125468482613e53565b60405162461bcd60e51b815260206004820152601d60248201527f77726f6e6720706f6f6c206f72205f666c61736853776170546f6b656e00000060448201526064016101b9565b6000886001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561265c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268091906135be565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156126ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ee91906135db565b8951909150156127ee5787518951146127955760405162461bcd60e51b815260206004820152605b60248201527f49526564656d7074696f6e537472617465677920636f6e74726163742061727260448201527f617920616e64207374726174656779206461746120627974657320617272617960648201527f206d6e75737420746865207468652073616d65206c656e6774682e0000000000608482015260a4016101b9565b60005b89518110156127ec576127df83838c84815181106127b8576127b8613682565b60200260200101518c85815181106127d2576127d2613682565b6020026020010151612f1b565b9093509150600101612798565b505b836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285091906135be565b6001600160a01b0316826001600160a01b031614806128e15750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128cc91906135be565b6001600160a01b0316826001600160a01b0316145b15612d9c576067546000906001600160a01b039081169084160361297d575060675460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690528592169063a9059cbb906044016020604051808303816000875af1158015612953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129779190613930565b50612d8f565b6000856001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e191906135be565b606a546001600160a01b03918216868316149250166330d07f2182612a6757876001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6291906135be565b612ac9565b876001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac991906135be565b83612b3557886001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3091906135be565b612b97565b886001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9791906135be565b896001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf99190613e66565b6066546040516001600160e01b031960e087901b1681526001600160a01b03948516600482015293909216602484015262ffffff16604483015260648201526000608482015260a4016020604051808303816000875af1158015612c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8591906135db565b915082821115612cfd5760405162461bcd60e51b815260206004820152603d60248201527f546f6b656e20666c6173686c6f616e2072657475726e20616d6f756e7420677260448201527f6561746572207468616e207365697a656420636f6c6c61746572616c2e00000060648201526084016101b9565b604051630251596160e31b81526001600160a01b0387166004820181905282151560248301526044820184905260006064830181905260a0608484015260a48301529063128acb089060c40160408051808303816000875af1158015612d67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8b9190613e8b565b5050505b82955050505050506117dc565b60405162461bcd60e51b815260206004820152604660248201527f74686520726564656d7074696f6e7320737472617465677920646964206e6f7460448201527f207377617020746f2074686520666c617368207377617070656420706f6f6c2060648201526561737365747360d01b608482015260a4016101b9565b6060612e288484600085612f78565b949350505050565b60606001600160a01b0383163b612e985760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016101b9565b600080846001600160a01b031684604051612eb39190613a04565b600060405180830381855af49150503d8060008114612eee576040519150601f19603f3d011682016040523d82523d6000602084013e612ef3565b606091505b50915091506117dc8282604051806060016040528060278152602001613ec360279139613053565b6001600160a01b038216600090815260696020526040812054819060ff16612f555760405162461bcd60e51b81526004016101b990613dda565b6000612491856310badf4e60e01b89898860405160240161245a93929190613e2c565b606082471015612fd95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101b9565b600080866001600160a01b03168587604051612ff59190613a04565b60006040518083038185875af1925050503d8060008114613032576040519150601f19603f3d011682016040523d82523d6000602084013e613037565b606091505b50915091506130488783838761308c565b979650505050505050565b606083156130625750816122bc565b8251156130725782518084602001fd5b8160405162461bcd60e51b81526004016101b99190613eaf565b606083156130fb5782516000036130f4576001600160a01b0385163b6130f45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101b9565b5081612e28565b612e2883838151156131105781518083602001fd5b8060405162461bcd60e51b81526004016101b99190613eaf565b6001600160a01b03811681146118ab57600080fd5b803561314a8161312a565b919050565b60006020828403121561316157600080fd5b81356122bc8161312a565b60006020828403121561317e57600080fd5b5035919050565b600080600080600060a0868803121561319d57600080fd5b85356131a88161312a565b94506020860135935060408601356131bf8161312a565b925060608601356131cf8161312a565b949793965091946080013592915050565b600080604083850312156131f357600080fd5b82356131fe8161312a565b9150602083013561320e8161312a565b809150509250929050565b60006020828403121561322b57600080fd5b81356001600160401b0381111561324157600080fd5b820161014081850312156122bc57600080fd5b80151581146118ab57600080fd5b6000806040838503121561327557600080fd5b82356132808161312a565b9150602083013561320e81613254565b60008083601f8401126132a257600080fd5b5081356001600160401b038111156132b957600080fd5b6020830191508360208285010111156132d157600080fd5b9250929050565b600080600080606085870312156132ee57600080fd5b843593506020850135925060408501356001600160401b0381111561331257600080fd5b61331e87828801613290565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156133635761336361332a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156133915761339161332a565b604052919050565b600082601f8301126133aa57600080fd5b81356001600160401b038111156133c3576133c361332a565b6133d6601f8201601f1916602001613369565b8181528460208386010111156133eb57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c0878903121561342157600080fd5b863561342c8161312a565b95506020870135945060408701356134438161312a565b935060608701356134538161312a565b925060808701356134638161312a565b915060a08701356001600160401b0381111561347e57600080fd5b61348a89828a01613399565b9150509295509295509295565b60008083601f8401126134a957600080fd5b5081356001600160401b038111156134c057600080fd5b6020830191508360208260051b85010111156132d157600080fd5b600080600080604085870312156134f157600080fd5b84356001600160401b038082111561350857600080fd5b61351488838901613497565b9096509450602087013591508082111561352d57600080fd5b5061331e87828801613497565b6000806000806060858703121561355057600080fd5b843561355b8161312a565b93506020850135925060408501356001600160401b0381111561331257600080fd5b6000806020838503121561359057600080fd5b82356001600160401b038111156135a657600080fd5b6135b285828601613290565b90969095509350505050565b6000602082840312156135d057600080fd5b81516122bc8161312a565b6000602082840312156135ed57600080fd5b5051919050565b60208082526025908201527f4846206e6f74206c6f7720656e6f7567682c20726573657276696e6720666f72604082015264040a0b2a8960db1b606082015260800190565b6000808335601e1984360301811261365057600080fd5b8301803591506001600160401b0382111561366a57600080fd5b6020019150600581901b36038213156132d157600080fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126136af57600080fd5b8301803591506001600160401b038211156136c957600080fd5b6020019150368190038213156132d157600080fd5b60005b838110156136f95781810151838201526020016136e1565b50506000910152565b6000815180845261371a8160208601602086016136de565b601f01601f19169290920160200192915050565b828152604060208201526000612e286040830184613702565b6000806040838503121561375a57600080fd5b82516137658161312a565b6020939093015192949293505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60018060a01b0386168152846020820152836040820152608060608201526000613048608083018486613775565b60208082526038908201527f526570617920616d6f756e7420287472616e73616374696f6e2076616c75652960408201527f206d7573742062652067726561746572207468616e20302e0000000000000000606082015260800190565b600060018060a01b03808916835280881660208401528087166040840152808616606084015260c0608084015261386360c0840186613702565b915080841660a084015250979650505050505050565b60006020828403121561388b57600080fd5b81356122bc81613254565b60008060008060008060c087890312156138af57600080fd5b86356138ba8161312a565b955060208701356138ca8161312a565b945060408701356138da8161312a565b935060608701356138ea8161312a565b925060808701356001600160401b0381111561390557600080fd5b61391189828a01613399565b92505060a08701356139228161312a565b809150509295509295509295565b60006020828403121561394257600080fd5b81516122bc81613254565b6020808252601390820152722634b8bab4b230ba34b7b7103330b4b632b21760691b604082015260600190565b60208082526012908201527127379031aa37b5b2b7399039b2b4bd32b21760711b604082015260600190565b602080825260409082018190527f4572726f722063616c6c696e672072656465656d696e67207365697a65642063908201527f546f6b656e3a206572726f7220636f6465206e6f7420657175616c20746f2030606082015260800190565b60008251613a168184602087016136de565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611d9757611d97613a20565b6001600160a01b0383168152604060208201819052600090612e2890830184613702565b60008085851115613a7d57600080fd5b83861115613a8a57600080fd5b5050820193919092039150565b60006001600160401b03821115613ab057613ab061332a565b5060051b60200190565b600082601f830112613acb57600080fd5b81356020613ae0613adb83613a97565b613369565b8083825260208201915060208460051b870101935086841115613b0257600080fd5b602086015b84811015613b27578035613b1a8161312a565b8352918301918301613b07565b509695505050505050565b600082601f830112613b4357600080fd5b81356020613b53613adb83613a97565b82815260059290921b84018101918181019086841115613b7257600080fd5b8286015b84811015613b275780356001600160401b03811115613b955760008081fd5b613ba38986838b0101613399565b845250918301918301613b76565b600082601f830112613bc257600080fd5b81356020613bd2613adb83613a97565b8083825260208201915060208460051b870101935086841115613bf457600080fd5b602086015b84811015613b27578035613c0c8161312a565b8352918301918301613bf9565b600060208284031215613c2b57600080fd5b81356001600160401b0380821115613c4257600080fd5b908301906101408286031215613c5757600080fd5b613c5f613340565b613c688361313f565b815260208301356020820152613c806040840161313f565b6040820152613c916060840161313f565b6060820152613ca26080840161313f565b608082015260a083013560a082015260c083013582811115613cc357600080fd5b613ccf87828601613aba565b60c08301525060e083013582811115613ce757600080fd5b613cf387828601613b32565b60e0830152506101008084013583811115613d0d57600080fd5b613d1988828701613bb1565b8284015250506101208084013583811115613d3357600080fd5b613d3f88828701613b32565b918301919091525095945050505050565b60018060a01b03851681528360208201526060604082015260006117d9606083018486613775565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600081613dd257613dd2613a20565b506000190190565b60208082526032908201527f6f6e6c792077686974656c697374656420726564656d7074696f6e20737472616040820152711d1959da595cc818d85b881899481d5cd95960721b606082015260800190565b60018060a01b03841681528260208201526060604082015260006117dc6060830184613702565b80820180821115611d9757611d97613a20565b600060208284031215613e7857600080fd5b815162ffffff811681146122bc57600080fd5b60008060408385031215613e9e57600080fd5b505080516020909101519092909150565b6020815260006122bc602083018461370256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ff513b0774140e34a1a413b05a478fb4cca6c7b8c3e5fe25e8a691d804d0ddf64736f6c63430008160033", + "deployedBytecode": "0x60806040526004361061016a5760003560e01c8063715018a6116100d1578063958fa2801161008a578063c92cb8cc11610064578063c92cb8cc14610472578063e9cbafb014610492578063f2fde38b146104b2578063fced7081146104d257600080fd5b8063958fa28014610432578063a60b0d3c1461034a578063c6bbd5a71461045257600080fd5b8063715018a61461038a5780637c95ba9f1461039f57806381738f13146103bf578063853828b6146103df5780638a0b9090146103f45780638da5cb5b1461041457600080fd5b8063485cc95511610123578063485cc955146102aa57806355e9e8fe146102ca5780635a431365146102ea5780635b6723711461030a578063673125291461034a5780636f6c04471461036a57600080fd5b8063030e47df146101c95780630add23ea146101e9578063112666b71461020957806320b723251461024657806329f269f4146102745780632c89aa2e1461029457600080fd5b366101c457333b6101c25760405162461bcd60e51b815260206004820152601960248201527f53656e646572206973206e6f74206120636f6e74726163742e0000000000000060448201526064015b60405180910390fd5b005b600080fd5b3480156101d557600080fd5b506101c26101e436600461314f565b6104e5565b3480156101f557600080fd5b506101c261020436600461316c565b61050f565b34801561021557600080fd5b50606c54610229906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561025257600080fd5b50610266610261366004613185565b610574565b60405190815260200161023d565b34801561028057600080fd5b506101c261028f36600461314f565b6106ad565b3480156102a057600080fd5b50610266606d5481565b3480156102b657600080fd5b506101c26102c53660046131e0565b6106d7565b3480156102d657600080fd5b506102666102e5366004613219565b61081a565b3480156102f657600080fd5b506101c2610305366004613262565b610d94565b34801561031657600080fd5b5061033a61032536600461314f565b60696020526000908152604090205460ff1681565b604051901515815260200161023d565b34801561035657600080fd5b506101c26103653660046132d8565b610dc7565b34801561037657600080fd5b50606b54610229906001600160a01b031681565b34801561039657600080fd5b506101c2610dd9565b3480156103ab57600080fd5b506101c26103ba366004613408565b610ded565b3480156103cb57600080fd5b50606854610229906001600160a01b031681565b3480156103eb57600080fd5b506101c2610e9e565b34801561040057600080fd5b506101c261040f3660046134db565b610f87565b34801561042057600080fd5b506033546001600160a01b0316610229565b34801561043e57600080fd5b506101c261044d36600461353a565b6110a3565b34801561045e57600080fd5b50606a54610229906001600160a01b031681565b34801561047e57600080fd5b5061026661048d366004613185565b6116f8565b34801561049e57600080fd5b506101c26104ad3660046132d8565b6117e5565b3480156104be57600080fd5b506101c26104cd36600461314f565b611835565b6101c26104e036600461357d565b6118ae565b6104ed6118ef565b606b80546001600160a01b0319166001600160a01b0392909216919091179055565b6105176118ef565b670de0b6b3a764000081111561056f5760405162461bcd60e51b815260206004820152601f60248201527f496e76616c6964204865616c746820466163746f72205468726573686f6c640060448201526064016101b9565b606d55565b600085836000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060191906135be565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561064c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067091906135db565b9050606d5481106106935760405162461bcd60e51b81526004016101b9906135f4565b6106a08989898989611949565b9998505050505050505050565b6106b56118ef565b606c80546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16158080156106f75750600054600160ff909116105b806107115750303b158015610711575060005460ff166001145b6107745760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101b9565b6000805460ff191660011790558015610797576000805461ff0019166101001790555b61079f611c77565b606880546001600160a01b038086166001600160a01b031992831617909255606a8054928516929091169190911790558015610815576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6000610829602083018361314f565b610839608084016060850161314f565b6000606c60009054906101000a90046001600160a01b03166001600160a01b03166357c89a7d84846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561089e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c291906135be565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561090d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093191906135db565b9050606d5481106109545760405162461bcd60e51b81526004016101b9906135f4565b60008560200135116109b45760405162461bcd60e51b8152602060048201526024808201527f526570617920616d6f756e74206d7573742062652067726561746572207468616044820152633710181760e11b60648201526084016101b9565b60208501356000806109ca610100890189613639565b90501115610bd5576109e0610120880188613639565b90506109f0610100890189613639565b905014610a9a5760405162461bcd60e51b815260206004820152606660248201527f46756e64696e67204946756e6473436f6e76657273696f6e537472617465677960448201527f20636f6e747261637420617272617920616e642073747261746567792064617460648201527f61206279746573206172726179206d757374206265207468652073616d65206c60848201526532b733ba341760d11b60a482015260c4016101b9565b60005b610aab610100890189613639565b9050811015610bcf576000610ac46101208a018a613639565b83818110610ad457610ad4613682565b9050602002810190610ae69190613698565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450610b2b925050506101008b018b613639565b84818110610b3b57610b3b613682565b9050602002016020810190610b50919061314f565b60405163180994cb60e11b81529091506001600160a01b03821690633013299690610b81908890869060040161372e565b6040805180830381865afa158015610b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc19190613747565b955093505050600101610a9d565b50610c49565b610be5606088016040890161314f565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4691906135be565b90505b6066829055606780546001600160a01b0319166001600160a01b0383161790556000610c7b60a0890160808a0161314f565b90506000826001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ceb91906135be565b6001600160a01b0316149050816001600160a01b031663490e6cbc3083610d13576000610d15565b865b8415610d22576000610d24565b875b6000366040518663ffffffff1660e01b8152600401610d4795949392919061379e565b600060405180830381600087803b158015610d6157600080fd5b505af1158015610d75573d6000803e3d6000fd5b50506065546106a092506001600160a01b0316905060a08b0135611ca6565b610d9c6118ef565b6001600160a01b03919091166000908152606960205260409020805460ff1916911515919091179055565b610dd3848484846117e5565b50505050565b610de16118ef565b610deb6000611d9d565b565b60008511610e0d5760405162461bcd60e51b81526004016101b9906137cc565b836001600160a01b0316633c3b4b8986888787878733604051602001610e3896959493929190613829565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610e6492919061372e565b600060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b50505050505050505050565b610ea66118ef565b4780610ef45760405162461bcd60e51b815260206004820152601960248201527f4e6f204574686572206c65667420746f2077697468647261770000000000000060448201526064016101b9565b604051600090339083908381818185875af1925050503d8060008114610f36576040519150601f19603f3d011682016040523d82523d6000602084013e610f3b565b606091505b5050905080610f835760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016101b9565b5050565b610f8f6118ef565b8215801590610f9d57508281145b61100f5760405162461bcd60e51b815260206004820152603f60248201527f6c697374206f66207374726174656769657320656d707479206f72207768697460448201527f656c69737420646f6573206e6f74206d6174636820697473206c656e6774680060648201526084016101b9565b60005b8381101561109c5782828281811061102c5761102c613682565b90506020020160208101906110419190613879565b6069600087878581811061105757611057613682565b905060200201602081019061106c919061314f565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611012565b5050505050565b600080808080806110b687890189613896565b60405163095ea7b360e01b8152959b509399509197509550935091508a906001600160a01b0382169063095ea7b3906111099089908e906004016001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114c9190613930565b50604051637af1e23160e11b81526001600160a01b038881166004830152602482018c9052868116604483015287169063f5e3c462906064016020604051808303816000875af11580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c891906135db565b156111e55760405162461bcd60e51b81526004016101b99061394d565b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611225573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124991906135be565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa158015611293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b791906135db565b9050600081116112d95760405162461bcd60e51b81526004016101b99061397a565b60405163db006a7560e01b8152600481018290526000906001600160a01b0389169063db006a75906024016020604051808303816000875af1158015611323573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134791906135db565b905080156113675760405162461bcd60e51b81526004016101b9906139a6565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d291906135db565b60405163095ea7b360e01b81526001600160a01b038a81166004830152602482018390529192509085169063095ea7b3906044016020604051808303816000875af1158015611425573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114499190613930565b506000886001600160a01b0316886040516114649190613a04565b6000604051808303816000865af19150503d80600081146114a1576040519150601f19603f3d011682016040523d82523d6000602084013e6114a6565b606091505b50509050806114f05760405162461bcd60e51b81526020600482015260166024820152751059d9dc9959d85d1bdc8818d85b1b0819985a5b195960521b60448201526064016101b9565b50506040516370a0823160e01b8152306004820152600092506001600160a01b03851691506370a0823190602401602060405180830381865afa15801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f91906135db565b90508b8110156115c45760405162461bcd60e51b815260206004820152602a60248201527f4e6f7420726563656976656420656e6f75676820636f6c6c61746572616c2061604482015269333a32b91039bbb0b81760b11b60648201526084016101b9565b60006115d08d83613a36565b905080156115ec576115ec6001600160a01b0385168683611def565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611633573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165791906135db565b90508015611673576116736001600160a01b0385168783611def565b505060405163095ea7b360e01b81526001600160a01b038981166004830152602482018e90528416915063095ea7b3906044016020604051808303816000875af11580156116c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e99190613930565b50505050505050505050505050565b606b54604080516001600160a01b038881166020830152600093169163403e96f6913091016040516020818303038152906040526040518363ffffffff1660e01b8152600401611749929190613a49565b602060405180830381865afa158015611766573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178a9190613930565b6117cc5760405162461bcd60e51b815260206004820152601360248201527234b73b30b634b2103634b8bab4b230ba34b7b760691b60448201526064016101b9565b6117d98686868686611949565b90505b95945050505050565b60006117f48260048186613a6d565b8101906118019190613c19565b905061180e818686611e52565b606580546001600160a01b0319166001600160a01b03929092169190911790555050505050565b61183d6118ef565b6001600160a01b0381166118a25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101b9565b6118ab81611d9d565b50565b7f373bc109b9e1d2a0702bd463de500dfec960521e4498acc170fd65867e46041c333484846040516118e39493929190613d50565b60405180910390a15050565b6033546001600160a01b03163314610deb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101b9565b600080851161196a5760405162461bcd60e51b81526004016101b9906137cc565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ce91906135be565b90506119e56001600160a01b0382163330896122c3565b60405163095ea7b360e01b81526001600160a01b0386811660048301526024820188905282169063095ea7b3906044016020604051808303816000875af1158015611a34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a589190613930565b50604051637af1e23160e11b81526001600160a01b03888116600483015260248201889052858116604483015286169063f5e3c462906064016020604051808303816000875af1158015611ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ad491906135db565b15611af15760405162461bcd60e51b81526004016101b99061394d565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015611b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5c91906135db565b905060008111611b7e5760405162461bcd60e51b81526004016101b99061397a565b60405163db006a7560e01b8152600481018290526000906001600160a01b0387169063db006a75906024016020604051808303816000875af1158015611bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bec91906135db565b90508015611c0c5760405162461bcd60e51b81526004016101b9906139a6565b6106a0866001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7191906135be565b86611ca6565b600054610100900460ff16611c9e5760405162461bcd60e51b81526004016101b990613d78565b610deb6122fb565b6040516370a0823160e01b8152306004820152600090839082906001600160a01b038316906370a0823190602401602060405180830381865afa158015611cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1591906135db565b905083811015611d795760405162461bcd60e51b815260206004820152602960248201527f4d696e696d756d20746f6b656e206f757470757420616d6f756e74206e6f742060448201526839b0ba34b334b2b21760b91b60648201526084016101b9565b8015611d9357611d936001600160a01b0383163383611def565b9150505b92915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b03831660248201526044810182905261081590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261232b565b606754606654610100850151516000926001600160a01b0316919015611ef957610100860151515b8015611ef757611ee08383896101000151600185611e989190613a36565b81518110611ea857611ea8613682565b60200260200101518a6101200151600186611ec39190613a36565b81518110611ed357611ed3613682565b60200260200101516123fd565b909350915080611eef81613dc3565b915050611e7a565b505b600086604001516001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6191906135be565b9050806001600160a01b0316836001600160a01b031614611ffc5760405162461bcd60e51b815260206004820152604960248201527f74686520646562742072657061796d656e742066756e64732073686f756c642060448201527f626520636f6e76657274656420746f2074686520756e6465726c79696e67206460648201526832b13a103a37b5b2b760b91b608482015260a4016101b9565b86602001518210156120505760405162461bcd60e51b815260206004820181905260248201527f646562742072657061796d656e7420616d6f756e74206e6f7420656e6f75676860448201526064016101b9565b6040808801516020890151915163095ea7b360e01b81526001600160a01b039182166004820152602481019290925282169063095ea7b3906044016020604051808303816000875af11580156120aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ce9190613930565b50604087810151885160208a015160608b01519351637af1e23160e11b81526001600160a01b03928316600482015260248101919091529281166044840152169063f5e3c462906064016020604051808303816000875af1158015612137573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215b91906135db565b156121785760405162461bcd60e51b81526004016101b99061394d565b60608701516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156121c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e791906135db565b9050600081116122095760405162461bcd60e51b81526004016101b99061397a565b606088015160405163db006a7560e01b8152600481018390526000916001600160a01b03169063db006a75906024016020604051808303816000875af1158015612257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227b91906135db565b9050801561229b5760405162461bcd60e51b81526004016101b9906139a6565b5050506122b786606001518760c001518860e0015188886124b5565b925050505b9392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610dd39085906323b872dd60e01b90608401611e1b565b600054610100900460ff166123225760405162461bcd60e51b81526004016101b990613d78565b610deb33611d9d565b6000612380826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e199092919063ffffffff16565b805190915015610815578080602001905181019061239e9190613930565b6108155760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101b9565b6001600160a01b038216600090815260696020526040812054819060ff166124375760405162461bcd60e51b81526004016101b990613dda565b6000612491856389eabf0260e01b89898860405160240161245a93929190613e2c565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e30565b9050808060200190518101906124a79190613747565b925092505094509492505050565b60665460675460408051630dfe168160e01b81529051600093339390926001600160a01b03909116918491630dfe16819160048083019260209291908290030181865afa15801561250a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252e91906135be565b6001600160a01b03160361254d576125468582613e53565b905061261c565b6067546040805163d21220a760e01b815290516001600160a01b0390921691339163d21220a79160048083019260209291908290030181865afa158015612598573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bc91906135be565b6001600160a01b0316036125d4576125468482613e53565b60405162461bcd60e51b815260206004820152601d60248201527f77726f6e6720706f6f6c206f72205f666c61736853776170546f6b656e00000060448201526064016101b9565b6000886001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561265c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268091906135be565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156126ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ee91906135db565b8951909150156127ee5787518951146127955760405162461bcd60e51b815260206004820152605b60248201527f49526564656d7074696f6e537472617465677920636f6e74726163742061727260448201527f617920616e64207374726174656779206461746120627974657320617272617960648201527f206d6e75737420746865207468652073616d65206c656e6774682e0000000000608482015260a4016101b9565b60005b89518110156127ec576127df83838c84815181106127b8576127b8613682565b60200260200101518c85815181106127d2576127d2613682565b6020026020010151612f1b565b9093509150600101612798565b505b836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285091906135be565b6001600160a01b0316826001600160a01b031614806128e15750836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128cc91906135be565b6001600160a01b0316826001600160a01b0316145b15612d9c576067546000906001600160a01b039081169084160361297d575060675460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690528592169063a9059cbb906044016020604051808303816000875af1158015612953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129779190613930565b50612d8f565b6000856001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e191906135be565b606a546001600160a01b03918216868316149250166330d07f2182612a6757876001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6291906135be565b612ac9565b876001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac991906135be565b83612b3557886001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3091906135be565b612b97565b886001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9791906135be565b896001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf99190613e66565b6066546040516001600160e01b031960e087901b1681526001600160a01b03948516600482015293909216602484015262ffffff16604483015260648201526000608482015260a4016020604051808303816000875af1158015612c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8591906135db565b915082821115612cfd5760405162461bcd60e51b815260206004820152603d60248201527f546f6b656e20666c6173686c6f616e2072657475726e20616d6f756e7420677260448201527f6561746572207468616e207365697a656420636f6c6c61746572616c2e00000060648201526084016101b9565b604051630251596160e31b81526001600160a01b0387166004820181905282151560248301526044820184905260006064830181905260a0608484015260a48301529063128acb089060c40160408051808303816000875af1158015612d67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8b9190613e8b565b5050505b82955050505050506117dc565b60405162461bcd60e51b815260206004820152604660248201527f74686520726564656d7074696f6e7320737472617465677920646964206e6f7460448201527f207377617020746f2074686520666c617368207377617070656420706f6f6c2060648201526561737365747360d01b608482015260a4016101b9565b6060612e288484600085612f78565b949350505050565b60606001600160a01b0383163b612e985760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016101b9565b600080846001600160a01b031684604051612eb39190613a04565b600060405180830381855af49150503d8060008114612eee576040519150601f19603f3d011682016040523d82523d6000602084013e612ef3565b606091505b50915091506117dc8282604051806060016040528060278152602001613ec360279139613053565b6001600160a01b038216600090815260696020526040812054819060ff16612f555760405162461bcd60e51b81526004016101b990613dda565b6000612491856310badf4e60e01b89898860405160240161245a93929190613e2c565b606082471015612fd95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101b9565b600080866001600160a01b03168587604051612ff59190613a04565b60006040518083038185875af1925050503d8060008114613032576040519150601f19603f3d011682016040523d82523d6000602084013e613037565b606091505b50915091506130488783838761308c565b979650505050505050565b606083156130625750816122bc565b8251156130725782518084602001fd5b8160405162461bcd60e51b81526004016101b99190613eaf565b606083156130fb5782516000036130f4576001600160a01b0385163b6130f45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101b9565b5081612e28565b612e2883838151156131105781518083602001fd5b8060405162461bcd60e51b81526004016101b99190613eaf565b6001600160a01b03811681146118ab57600080fd5b803561314a8161312a565b919050565b60006020828403121561316157600080fd5b81356122bc8161312a565b60006020828403121561317e57600080fd5b5035919050565b600080600080600060a0868803121561319d57600080fd5b85356131a88161312a565b94506020860135935060408601356131bf8161312a565b925060608601356131cf8161312a565b949793965091946080013592915050565b600080604083850312156131f357600080fd5b82356131fe8161312a565b9150602083013561320e8161312a565b809150509250929050565b60006020828403121561322b57600080fd5b81356001600160401b0381111561324157600080fd5b820161014081850312156122bc57600080fd5b80151581146118ab57600080fd5b6000806040838503121561327557600080fd5b82356132808161312a565b9150602083013561320e81613254565b60008083601f8401126132a257600080fd5b5081356001600160401b038111156132b957600080fd5b6020830191508360208285010111156132d157600080fd5b9250929050565b600080600080606085870312156132ee57600080fd5b843593506020850135925060408501356001600160401b0381111561331257600080fd5b61331e87828801613290565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b03811182821017156133635761336361332a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156133915761339161332a565b604052919050565b600082601f8301126133aa57600080fd5b81356001600160401b038111156133c3576133c361332a565b6133d6601f8201601f1916602001613369565b8181528460208386010111156133eb57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c0878903121561342157600080fd5b863561342c8161312a565b95506020870135945060408701356134438161312a565b935060608701356134538161312a565b925060808701356134638161312a565b915060a08701356001600160401b0381111561347e57600080fd5b61348a89828a01613399565b9150509295509295509295565b60008083601f8401126134a957600080fd5b5081356001600160401b038111156134c057600080fd5b6020830191508360208260051b85010111156132d157600080fd5b600080600080604085870312156134f157600080fd5b84356001600160401b038082111561350857600080fd5b61351488838901613497565b9096509450602087013591508082111561352d57600080fd5b5061331e87828801613497565b6000806000806060858703121561355057600080fd5b843561355b8161312a565b93506020850135925060408501356001600160401b0381111561331257600080fd5b6000806020838503121561359057600080fd5b82356001600160401b038111156135a657600080fd5b6135b285828601613290565b90969095509350505050565b6000602082840312156135d057600080fd5b81516122bc8161312a565b6000602082840312156135ed57600080fd5b5051919050565b60208082526025908201527f4846206e6f74206c6f7720656e6f7567682c20726573657276696e6720666f72604082015264040a0b2a8960db1b606082015260800190565b6000808335601e1984360301811261365057600080fd5b8301803591506001600160401b0382111561366a57600080fd5b6020019150600581901b36038213156132d157600080fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126136af57600080fd5b8301803591506001600160401b038211156136c957600080fd5b6020019150368190038213156132d157600080fd5b60005b838110156136f95781810151838201526020016136e1565b50506000910152565b6000815180845261371a8160208601602086016136de565b601f01601f19169290920160200192915050565b828152604060208201526000612e286040830184613702565b6000806040838503121561375a57600080fd5b82516137658161312a565b6020939093015192949293505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60018060a01b0386168152846020820152836040820152608060608201526000613048608083018486613775565b60208082526038908201527f526570617920616d6f756e7420287472616e73616374696f6e2076616c75652960408201527f206d7573742062652067726561746572207468616e20302e0000000000000000606082015260800190565b600060018060a01b03808916835280881660208401528087166040840152808616606084015260c0608084015261386360c0840186613702565b915080841660a084015250979650505050505050565b60006020828403121561388b57600080fd5b81356122bc81613254565b60008060008060008060c087890312156138af57600080fd5b86356138ba8161312a565b955060208701356138ca8161312a565b945060408701356138da8161312a565b935060608701356138ea8161312a565b925060808701356001600160401b0381111561390557600080fd5b61391189828a01613399565b92505060a08701356139228161312a565b809150509295509295509295565b60006020828403121561394257600080fd5b81516122bc81613254565b6020808252601390820152722634b8bab4b230ba34b7b7103330b4b632b21760691b604082015260600190565b60208082526012908201527127379031aa37b5b2b7399039b2b4bd32b21760711b604082015260600190565b602080825260409082018190527f4572726f722063616c6c696e672072656465656d696e67207365697a65642063908201527f546f6b656e3a206572726f7220636f6465206e6f7420657175616c20746f2030606082015260800190565b60008251613a168184602087016136de565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611d9757611d97613a20565b6001600160a01b0383168152604060208201819052600090612e2890830184613702565b60008085851115613a7d57600080fd5b83861115613a8a57600080fd5b5050820193919092039150565b60006001600160401b03821115613ab057613ab061332a565b5060051b60200190565b600082601f830112613acb57600080fd5b81356020613ae0613adb83613a97565b613369565b8083825260208201915060208460051b870101935086841115613b0257600080fd5b602086015b84811015613b27578035613b1a8161312a565b8352918301918301613b07565b509695505050505050565b600082601f830112613b4357600080fd5b81356020613b53613adb83613a97565b82815260059290921b84018101918181019086841115613b7257600080fd5b8286015b84811015613b275780356001600160401b03811115613b955760008081fd5b613ba38986838b0101613399565b845250918301918301613b76565b600082601f830112613bc257600080fd5b81356020613bd2613adb83613a97565b8083825260208201915060208460051b870101935086841115613bf457600080fd5b602086015b84811015613b27578035613c0c8161312a565b8352918301918301613bf9565b600060208284031215613c2b57600080fd5b81356001600160401b0380821115613c4257600080fd5b908301906101408286031215613c5757600080fd5b613c5f613340565b613c688361313f565b815260208301356020820152613c806040840161313f565b6040820152613c916060840161313f565b6060820152613ca26080840161313f565b608082015260a083013560a082015260c083013582811115613cc357600080fd5b613ccf87828601613aba565b60c08301525060e083013582811115613ce757600080fd5b613cf387828601613b32565b60e0830152506101008084013583811115613d0d57600080fd5b613d1988828701613bb1565b8284015250506101208084013583811115613d3357600080fd5b613d3f88828701613b32565b918301919091525095945050505050565b60018060a01b03851681528360208201526060604082015260006117d9606083018486613775565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600081613dd257613dd2613a20565b506000190190565b60208082526032908201527f6f6e6c792077686974656c697374656420726564656d7074696f6e20737472616040820152711d1959da595cc818d85b881899481d5cd95960721b606082015260800190565b60018060a01b03841681528260208201526060604082015260006117dc6060830184613702565b80820180821115611d9757611d97613a20565b600060208284031215613e7857600080fd5b815162ffffff811681146122bc57600080fd5b60008060408385031215613e9e57600080fd5b505080516020909101519092909150565b6020815260006122bc602083018461370256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ff513b0774140e34a1a413b05a478fb4cca6c7b8c3e5fe25e8a691d804d0ddf64736f6c63430008160033", + "devdoc": { + "author": "Veliko Minkov (https://github.com/vminkov)", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_whitelistRedemptionStrategies(address[],bool[])": { + "details": "for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`" + }, + "_whitelistRedemptionStrategy(address,bool)": { + "details": "for security reasons only whitelisted redemption strategies may be used. Each whitelisted redemption strategy has to be checked to not be able to call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`" + }, + "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." + }, + "supV3FlashCallback(uint256,uint256,bytes)": { + "details": "Callback function for Uniswap flashloans." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "uniswapV3FlashCallback(uint256,uint256,bytes)": { + "details": "In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.", + "params": { + "data": "Any data passed through by the caller via the IUniswapV3PoolActions#flash call", + "fee0": "The fee amount in token0 due to the pool by the end of the flash", + "fee1": "The fee amount in token1 due to the pool by the end of the flash" + } + } + }, + "stateVariables": { + "_flashSwapAmount": { + "details": "Cached flash swap amount. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`." + }, + "_flashSwapToken": { + "details": "Cached flash swap token. For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`." + }, + "_liquidatorProfitExchangeSource": { + "details": "Cached liquidator profit exchange source. ERC20 token address or the zero address for NATIVE. For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`." + }, + "expressRelay": { + "details": "Addres of Pyth Express Relay for preventing value leakage in liquidations." + }, + "healthFactorThreshold": { + "details": "Health Factor below which PER permissioning is bypassed." + }, + "lens": { + "details": "Pool Lens." + } + }, + "title": "IonicUniV3Liquidator", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "receiveAuctionProceedings(bytes)": { + "notice": "receiveAuctionProceedings function - receives native token from the express relay You can use permission key to distribute the received funds to users who got liquidated, LPs, etc..." + }, + "uniswapV3FlashCallback(uint256,uint256,bytes)": { + "notice": "Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash." + } + }, + "notice": "IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 11647, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_liquidatorProfitExchangeSource", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 11650, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_flashSwapAmount", + "offset": 0, + "slot": "102", + "type": "t_uint256" + }, + { + "astId": 11653, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "_flashSwapToken", + "offset": 0, + "slot": "103", + "type": "t_address" + }, + { + "astId": 11655, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "W_NATIVE_ADDRESS", + "offset": 0, + "slot": "104", + "type": "t_address" + }, + { + "astId": 11659, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "redemptionStrategiesWhitelist", + "offset": 0, + "slot": "105", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 11662, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "quoter", + "offset": 0, + "slot": "106", + "type": "t_contract(IUniswapV3Quoter)48755" + }, + { + "astId": 11666, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "expressRelay", + "offset": 0, + "slot": "107", + "type": "t_contract(IExpressRelay)44080" + }, + { + "astId": 11670, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "lens", + "offset": 0, + "slot": "108", + "type": "t_contract(PoolLens)16806" + }, + { + "astId": 11673, + "contract": "contracts/IonicUniV3Liquidator.sol:IonicUniV3Liquidator", + "label": "healthFactorThreshold", + "offset": 0, + "slot": "109", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "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_contract(IExpressRelay)44080": { + "encoding": "inplace", + "label": "contract IExpressRelay", + "numberOfBytes": "20" + }, + "t_contract(IUniswapV3Quoter)48755": { + "encoding": "inplace", + "label": "contract IUniswapV3Quoter", + "numberOfBytes": "20" + }, + "t_contract(PoolLens)16806": { + "encoding": "inplace", + "label": "contract PoolLens", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Proxy.json b/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Proxy.json new file mode 100644 index 0000000000..5f244a8480 --- /dev/null +++ b/packages/contracts/deployments/superseed/IonicUniV3Liquidator_Proxy.json @@ -0,0 +1,261 @@ +{ + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "transactionIndex": 1, + "gasUsed": "795237", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000008000000002000000000000000002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000000000000280000000000000c00000000000000000000000000000000400000000000000000000000400000000000000000020000000000000000000040000200000000400000000000000000020000000000000000000000200000000000000000000000000000000000000000000", + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3", + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b0033576a9e444dd801d5b69e1b63dbc459a6115" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 2, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + }, + { + "transactionIndex": 1, + "blockNumber": 4159425, + "transactionHash": "0x8567c3b35eab23bc76634b0beeef622c39b42784f073c58c9f571c0b1f6dc8a1", + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 3, + "blockHash": "0x8e831f4e29d86f084e926b920740160133da26d3bdda01a9af10d3f97c89d3e3" + } + ], + "blockNumber": 4159425, + "cumulativeGasUsed": "839079", + "status": 1, + "byzantium": true + }, + "args": [ + "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x485cc95500000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/JumpRateModel.json b/packages/contracts/deployments/superseed/JumpRateModel.json new file mode 100644 index 0000000000..1dfd248c26 --- /dev/null +++ b/packages/contracts/deployments/superseed/JumpRateModel.json @@ -0,0 +1,413 @@ +{ + "address": "0xa6BA5F1164dc66F9C5bDCE33A6d2fC70bE8Da108", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRatePerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "multiplierPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "jumpMultiplierPerYear", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kink_", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "baseRatePerBlock", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "multiplierPerBlock", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "jumpMultiplierPerBlock", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "kink", + "type": "uint256" + } + ], + "name": "NewInterestParams", + "type": "event" + }, + { + "inputs": [], + "name": "baseRatePerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserves", + "type": "uint256" + } + ], + "name": "getBorrowRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserves", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactorMantissa", + "type": "uint256" + } + ], + "name": "getSupplyRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isInterestRateModel", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "jumpMultiplierPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "kink", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "multiplierPerBlock", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserves", + "type": "uint256" + } + ], + "name": "utilizationRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } + ], + "transactionHash": "0x47b91a6ea727545f60b08bfa2c1314e7e070bda9bd75f9caffaf8588e5eea909", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xa6BA5F1164dc66F9C5bDCE33A6d2fC70bE8Da108", + "transactionIndex": 1, + "gasUsed": "361607", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000080000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000200000000000000000000000000000000080000000000000", + "blockHash": "0x780eef616842972694ba44227cbd759b5fb3fab4eb4d3d5948765345e4edcf66", + "transactionHash": "0x47b91a6ea727545f60b08bfa2c1314e7e070bda9bd75f9caffaf8588e5eea909", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135349, + "transactionHash": "0x47b91a6ea727545f60b08bfa2c1314e7e070bda9bd75f9caffaf8588e5eea909", + "address": "0xa6BA5F1164dc66F9C5bDCE33A6d2fC70bE8Da108", + "topics": [ + "0x6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a86b16fa0000000000000000000000000000000000000000000000000000003b1068377e0000000000000000000000000000000000000000000000000b1a2bc2ec500000", + "logIndex": 0, + "blockHash": "0x780eef616842972694ba44227cbd759b5fb3fab4eb4d3d5948765345e4edcf66" + } + ], + "blockNumber": 4135349, + "cumulativeGasUsed": "405485", + "status": 1, + "byzantium": true + }, + "args": [ + 15768000, + "0", + "180000000000000000", + "4000000000000000000", + "800000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseRatePerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"multiplierPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"jumpMultiplierPerYear\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"kink_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseRatePerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"multiplierPerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"jumpMultiplierPerBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"kink\",\"type\":\"uint256\"}],\"name\":\"NewInterestParams\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"baseRatePerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"}],\"name\":\"getBorrowRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserveFactorMantissa\",\"type\":\"uint256\"}],\"name\":\"getSupplyRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isInterestRateModel\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"jumpMultiplierPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"kink\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"multiplierPerBlock\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"cash\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrows\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserves\",\"type\":\"uint256\"}],\"name\":\"utilizationRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Compound\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"_blocksPerYear\":\"The approximate number of blocks per year\",\"baseRatePerYear\":\"The approximate target base APR, as a mantissa (scaled by 1e18)\",\"jumpMultiplierPerYear\":\"The multiplierPerBlock after hitting a specified utilization point\",\"kink_\":\"The utilization point at which the jump multiplier is applied\",\"multiplierPerYear\":\"The rate of increase in interest rate wrt utilization (scaled by 1e18)\"}},\"getBorrowRate(uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserves\":\"The amount of reserves in the market\"},\"returns\":{\"_0\":\"The borrow rate percentage per block as a mantissa (scaled by 1e18)\"}},\"getSupplyRate(uint256,uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserveFactorMantissa\":\"The current reserve factor for the market\",\"reserves\":\"The amount of reserves in the market\"},\"returns\":{\"_0\":\"The supply rate percentage per block as a mantissa (scaled by 1e18)\"}},\"utilizationRate(uint256,uint256,uint256)\":{\"params\":{\"borrows\":\"The amount of borrows in the market\",\"cash\":\"The amount of cash in the market\",\"reserves\":\"The amount of reserves in the market (currently unused)\"},\"returns\":{\"_0\":\"The utilization rate as a mantissa between [0, 1e18]\"}}},\"title\":\"Compound's JumpRateModel Contract\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"baseRatePerBlock()\":{\"notice\":\"The base interest rate which is the y-intercept when utilization rate is 0\"},\"blocksPerYear()\":{\"notice\":\"The approximate number of blocks per year that is assumed by the interest rate model\"},\"constructor\":{\"notice\":\"Construct an interest rate model\"},\"getBorrowRate(uint256,uint256,uint256)\":{\"notice\":\"Calculates the current borrow rate per block, with the error code expected by the market\"},\"getSupplyRate(uint256,uint256,uint256,uint256)\":{\"notice\":\"Calculates the current supply rate per block\"},\"isInterestRateModel()\":{\"notice\":\"Indicator that this is an InterestRateModel contract (for inspection)\"},\"jumpMultiplierPerBlock()\":{\"notice\":\"The multiplierPerBlock after hitting a specified utilization point\"},\"kink()\":{\"notice\":\"The utilization point at which the jump multiplier is applied\"},\"multiplierPerBlock()\":{\"notice\":\"The multiplier of utilization rate that gives the slope of the interest rate\"},\"utilizationRate(uint256,uint256,uint256)\":{\"notice\":\"Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/compound/JumpRateModel.sol\":\"JumpRateModel\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/JumpRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./InterestRateModel.sol\\\";\\n\\n/**\\n * @title Compound's JumpRateModel Contract\\n * @author Compound\\n */\\ncontract JumpRateModel is InterestRateModel {\\n event NewInterestParams(\\n uint256 baseRatePerBlock,\\n uint256 multiplierPerBlock,\\n uint256 jumpMultiplierPerBlock,\\n uint256 kink\\n );\\n\\n /**\\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\\n */\\n uint256 public blocksPerYear;\\n\\n /**\\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\\n */\\n uint256 public multiplierPerBlock;\\n\\n /**\\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\\n */\\n uint256 public baseRatePerBlock;\\n\\n /**\\n * @notice The multiplierPerBlock after hitting a specified utilization point\\n */\\n uint256 public jumpMultiplierPerBlock;\\n\\n /**\\n * @notice The utilization point at which the jump multiplier is applied\\n */\\n uint256 public kink;\\n\\n /**\\n * @notice Construct an interest rate model\\n * @param _blocksPerYear The approximate number of blocks per year\\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\\n * @param kink_ The utilization point at which the jump multiplier is applied\\n */\\n constructor(\\n uint256 _blocksPerYear,\\n uint256 baseRatePerYear,\\n uint256 multiplierPerYear,\\n uint256 jumpMultiplierPerYear,\\n uint256 kink_\\n ) {\\n blocksPerYear = _blocksPerYear;\\n baseRatePerBlock = baseRatePerYear / blocksPerYear;\\n multiplierPerBlock = multiplierPerYear / blocksPerYear;\\n jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;\\n kink = kink_;\\n\\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\\n }\\n\\n /**\\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market (currently unused)\\n * @return The utilization rate as a mantissa between [0, 1e18]\\n */\\n function utilizationRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public pure returns (uint256) {\\n // Utilization rate is 0 when there are no borrows\\n if (borrows == 0) {\\n return 0;\\n }\\n\\n return (borrows * 1e18) / (cash + borrows - reserves);\\n }\\n\\n /**\\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market\\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view override returns (uint256) {\\n uint256 util = utilizationRate(cash, borrows, reserves);\\n\\n if (util <= kink) {\\n return ((util * multiplierPerBlock) / 1e18) + baseRatePerBlock;\\n } else {\\n uint256 normalRate = ((kink * multiplierPerBlock) / 1e18) + baseRatePerBlock;\\n uint256 excessUtil = util - kink;\\n return ((excessUtil * jumpMultiplierPerBlock) / 1e18) + normalRate;\\n }\\n }\\n\\n /**\\n * @notice Calculates the current supply rate per block\\n * @param cash The amount of cash in the market\\n * @param borrows The amount of borrows in the market\\n * @param reserves The amount of reserves in the market\\n * @param reserveFactorMantissa The current reserve factor for the market\\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual override returns (uint256) {\\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\\n }\\n}\\n\",\"keccak256\":\"0x58c22b251b5a400a582b65598e64e5005e850797dcb8e1afc3f32ece462ef2c3\",\"license\":\"UNLICENSED\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506040516104ff3803806104ff83398101604081905261002f916100c1565b600085905561003e8585610101565b60025560005461004e9084610101565b60015560005461005e9083610101565b60038190556004829055600254600154604080519283526020830191909152810191909152606081018290527f6960ab234c7ef4b0c9197100f5393cfcde7c453ac910a27bd2000aa1dd4c068d9060800160405180910390a15050505050610123565b600080600080600060a086880312156100d957600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b60008261011e57634e487b7160e01b600052601260045260246000fd5b500490565b6103cd806101326000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063a385fb9611610066578063a385fb96146100f2578063b8168816146100fb578063b9f9850a1461010e578063f14039de14610117578063fd2da3391461012057600080fd5b806315f24053146100985780632191f92a146100be5780636e71e2d8146100d65780638726bb89146100e9575b600080fd5b6100ab6100a63660046102be565b610129565b6040519081526020015b60405180910390f35b6100c6600181565b60405190151581526020016100b5565b6100ab6100e43660046102be565b6101f7565b6100ab60015481565b6100ab60005481565b6100ab6101093660046102ea565b610242565b6100ab60035481565b6100ab60025481565b6100ab60045481565b6000806101378585856101f7565b9050600454811161017857600254670de0b6b3a76400006001548361015c9190610332565b610166919061034f565b6101709190610371565b9150506101f0565b6000600254670de0b6b3a76400006001546004546101969190610332565b6101a0919061034f565b6101aa9190610371565b90506000600454836101bc9190610384565b905081670de0b6b3a7640000600354836101d69190610332565b6101e0919061034f565b6101ea9190610371565b93505050505b9392505050565b600082600003610209575060006101f0565b816102148486610371565b61021e9190610384565b61023084670de0b6b3a7640000610332565b61023a919061034f565b949350505050565b60008061025783670de0b6b3a7640000610384565b90506000610266878787610129565b90506000670de0b6b3a764000061027d8484610332565b610287919061034f565b9050670de0b6b3a76400008161029e8a8a8a6101f7565b6102a89190610332565b6102b2919061034f565b98975050505050505050565b6000806000606084860312156102d357600080fd5b505081359360208301359350604090920135919050565b6000806000806080858703121561030057600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103495761034961031c565b92915050565b60008261036c57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103495761034961031c565b818103818111156103495761034961031c56fea2646970667358221220d9523bc29ce1389226f0daa7ddc76abbbcc94cc76aa1c50504468b0045043f9564736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063a385fb9611610066578063a385fb96146100f2578063b8168816146100fb578063b9f9850a1461010e578063f14039de14610117578063fd2da3391461012057600080fd5b806315f24053146100985780632191f92a146100be5780636e71e2d8146100d65780638726bb89146100e9575b600080fd5b6100ab6100a63660046102be565b610129565b6040519081526020015b60405180910390f35b6100c6600181565b60405190151581526020016100b5565b6100ab6100e43660046102be565b6101f7565b6100ab60015481565b6100ab60005481565b6100ab6101093660046102ea565b610242565b6100ab60035481565b6100ab60025481565b6100ab60045481565b6000806101378585856101f7565b9050600454811161017857600254670de0b6b3a76400006001548361015c9190610332565b610166919061034f565b6101709190610371565b9150506101f0565b6000600254670de0b6b3a76400006001546004546101969190610332565b6101a0919061034f565b6101aa9190610371565b90506000600454836101bc9190610384565b905081670de0b6b3a7640000600354836101d69190610332565b6101e0919061034f565b6101ea9190610371565b93505050505b9392505050565b600082600003610209575060006101f0565b816102148486610371565b61021e9190610384565b61023084670de0b6b3a7640000610332565b61023a919061034f565b949350505050565b60008061025783670de0b6b3a7640000610384565b90506000610266878787610129565b90506000670de0b6b3a764000061027d8484610332565b610287919061034f565b9050670de0b6b3a76400008161029e8a8a8a6101f7565b6102a89190610332565b6102b2919061034f565b98975050505050505050565b6000806000606084860312156102d357600080fd5b505081359360208301359350604090920135919050565b6000806000806080858703121561030057600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103495761034961031c565b92915050565b60008261036c57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103495761034961031c565b818103818111156103495761034961031c56fea2646970667358221220d9523bc29ce1389226f0daa7ddc76abbbcc94cc76aa1c50504468b0045043f9564736f6c63430008160033", + "devdoc": { + "author": "Compound", + "kind": "dev", + "methods": { + "constructor": { + "params": { + "_blocksPerYear": "The approximate number of blocks per year", + "baseRatePerYear": "The approximate target base APR, as a mantissa (scaled by 1e18)", + "jumpMultiplierPerYear": "The multiplierPerBlock after hitting a specified utilization point", + "kink_": "The utilization point at which the jump multiplier is applied", + "multiplierPerYear": "The rate of increase in interest rate wrt utilization (scaled by 1e18)" + } + }, + "getBorrowRate(uint256,uint256,uint256)": { + "params": { + "borrows": "The amount of borrows in the market", + "cash": "The amount of cash in the market", + "reserves": "The amount of reserves in the market" + }, + "returns": { + "_0": "The borrow rate percentage per block as a mantissa (scaled by 1e18)" + } + }, + "getSupplyRate(uint256,uint256,uint256,uint256)": { + "params": { + "borrows": "The amount of borrows in the market", + "cash": "The amount of cash in the market", + "reserveFactorMantissa": "The current reserve factor for the market", + "reserves": "The amount of reserves in the market" + }, + "returns": { + "_0": "The supply rate percentage per block as a mantissa (scaled by 1e18)" + } + }, + "utilizationRate(uint256,uint256,uint256)": { + "params": { + "borrows": "The amount of borrows in the market", + "cash": "The amount of cash in the market", + "reserves": "The amount of reserves in the market (currently unused)" + }, + "returns": { + "_0": "The utilization rate as a mantissa between [0, 1e18]" + } + } + }, + "title": "Compound's JumpRateModel Contract", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "baseRatePerBlock()": { + "notice": "The base interest rate which is the y-intercept when utilization rate is 0" + }, + "blocksPerYear()": { + "notice": "The approximate number of blocks per year that is assumed by the interest rate model" + }, + "constructor": { + "notice": "Construct an interest rate model" + }, + "getBorrowRate(uint256,uint256,uint256)": { + "notice": "Calculates the current borrow rate per block, with the error code expected by the market" + }, + "getSupplyRate(uint256,uint256,uint256,uint256)": { + "notice": "Calculates the current supply rate per block" + }, + "isInterestRateModel()": { + "notice": "Indicator that this is an InterestRateModel contract (for inspection)" + }, + "jumpMultiplierPerBlock()": { + "notice": "The multiplierPerBlock after hitting a specified utilization point" + }, + "kink()": { + "notice": "The utilization point at which the jump multiplier is applied" + }, + "multiplierPerBlock()": { + "notice": "The multiplier of utilization rate that gives the slope of the interest rate" + }, + "utilizationRate(uint256,uint256,uint256)": { + "notice": "Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 36315, + "contract": "contracts/compound/JumpRateModel.sol:JumpRateModel", + "label": "blocksPerYear", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 36318, + "contract": "contracts/compound/JumpRateModel.sol:JumpRateModel", + "label": "multiplierPerBlock", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 36321, + "contract": "contracts/compound/JumpRateModel.sol:JumpRateModel", + "label": "baseRatePerBlock", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 36324, + "contract": "contracts/compound/JumpRateModel.sol:JumpRateModel", + "label": "jumpMultiplierPerBlock", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 36327, + "contract": "contracts/compound/JumpRateModel.sol:JumpRateModel", + "label": "kink", + "offset": 0, + "slot": "4", + "type": "t_uint256" + } + ], + "types": { + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionFactory.json b/packages/contracts/deployments/superseed/LeveredPositionFactory.json new file mode 100644 index 0000000000..8fa816f5e4 --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionFactory.json @@ -0,0 +1,548 @@ +{ + "address": "0x5d74800e977bFc8E14Eca28C9405BacbD091738E", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IFeeDistributor", + "name": "_feeDistributor", + "type": "address" + }, + { + "internalType": "contract ILiquidatorsRegistry", + "name": "_registry", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_blocksPerYear", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "_currentImpl", + "type": "address" + } + ], + "name": "FunctionAlreadyAdded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "FunctionNotFound", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "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" + }, + { + "stateMutability": "nonpayable", + "type": "fallback" + }, + { + "inputs": [], + "name": "_listExtensions", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract DiamondExtension", + "name": "extensionToAdd", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToReplace", + "type": "address" + } + ], + "name": "_registerExtension", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILiquidatorsRegistry", + "name": "_liquidatorsRegistry", + "type": "address" + } + ], + "name": "_setLiquidatorsRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "bool", + "name": "_whitelisted", + "type": "bool" + } + ], + "name": "_setPairWhitelisted", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeDistributor", + "outputs": [ + { + "internalType": "contract IFeeDistributor", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidatorsRegistry", + "outputs": [ + { + "internalType": "contract ILiquidatorsRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x04c9a9beb0aee7a23c67f408fc47b7d7ee98cac5e3c707ce4ff28a09ff0c0ae5", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x5d74800e977bFc8E14Eca28C9405BacbD091738E", + "transactionIndex": 1, + "gasUsed": "1143745", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000100020000000000000000000800000000000000000000000000400000400000000000000000000000000000100000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xfe43b045347d66b0b122de859dc0583a398ff4de7403592f8e55f6195a9962cb", + "transactionHash": "0x04c9a9beb0aee7a23c67f408fc47b7d7ee98cac5e3c707ce4ff28a09ff0c0ae5", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159538, + "transactionHash": "0x04c9a9beb0aee7a23c67f408fc47b7d7ee98cac5e3c707ce4ff28a09ff0c0ae5", + "address": "0x5d74800e977bFc8E14Eca28C9405BacbD091738E", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xfe43b045347d66b0b122de859dc0583a398ff4de7403592f8e55f6195a9962cb" + } + ], + "blockNumber": 4159538, + "cumulativeGasUsed": "1187587", + "status": 1, + "byzantium": true + }, + "args": [ + "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6", + "0x2DDF3DdFE856D1A4E5DBcb324194E2a622AeD83C", + 15768000 + ], + "numDeployments": 1, + "solcInputHash": "0e729d9c66e5b1bc1021561041d72a21", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IFeeDistributor\",\"name\":\"_feeDistributor\",\"type\":\"address\"},{\"internalType\":\"contract ILiquidatorsRegistry\",\"name\":\"_registry\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_blocksPerYear\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"_currentImpl\",\"type\":\"address\"}],\"name\":\"FunctionAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"}],\"name\":\"FunctionNotFound\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"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\"},{\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"_listExtensions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToAdd\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToReplace\",\"type\":\"address\"}],\"name\":\"_registerExtension\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ILiquidatorsRegistry\",\"name\":\"_liquidatorsRegistry\",\"type\":\"address\"}],\"name\":\"_setLiquidatorsRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"_whitelisted\",\"type\":\"bool\"}],\"name\":\"_setPairWhitelisted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeDistributor\",\"outputs\":[{\"internalType\":\"contract IFeeDistributor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidatorsRegistry\",\"outputs\":[{\"internalType\":\"contract ILiquidatorsRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_registerExtension(address,address)\":{\"details\":\"register a logic extension\",\"params\":{\"extensionToAdd\":\"the extension whose functions are to be added\",\"extensionToReplace\":\"the extension whose functions are to be removed/replaced\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/levered/LeveredPositionFactory.sol\":\"LeveredPositionFactory\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/LeveredPositionFactory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"../../oracles/BasePriceOracle.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { LeveredPositionFactoryStorage } from \\\"./LeveredPositionFactoryStorage.sol\\\";\\nimport { DiamondBase, DiamondExtension, LibDiamond } from \\\"../../ionic/DiamondExtension.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract LeveredPositionFactory is LeveredPositionFactoryStorage, DiamondBase {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /*----------------------------------------------------------------\\n Constructor\\n ----------------------------------------------------------------*/\\n\\n constructor(\\n IFeeDistributor _feeDistributor,\\n ILiquidatorsRegistry _registry,\\n uint256 _blocksPerYear\\n ) {\\n feeDistributor = _feeDistributor;\\n liquidatorsRegistry = _registry;\\n blocksPerYear = _blocksPerYear;\\n }\\n\\n /*----------------------------------------------------------------\\n Admin Functions\\n ----------------------------------------------------------------*/\\n\\n function _setPairWhitelisted(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n bool _whitelisted\\n ) external onlyOwner {\\n require(_collateralMarket.comptroller() == _stableMarket.comptroller(), \\\"markets not of the same pool\\\");\\n\\n if (_whitelisted) {\\n collateralMarkets.add(address(_collateralMarket));\\n borrowableMarketsByCollateral[_collateralMarket].add(address(_stableMarket));\\n } else {\\n borrowableMarketsByCollateral[_collateralMarket].remove(address(_stableMarket));\\n if (borrowableMarketsByCollateral[_collateralMarket].length() == 0)\\n collateralMarkets.remove(address(_collateralMarket));\\n }\\n }\\n\\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external onlyOwner {\\n liquidatorsRegistry = _liquidatorsRegistry;\\n }\\n\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\\n public\\n override\\n onlyOwner\\n {\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0x46b4b9c8b3b669d7a0af3165c6109fc87bce87074cb5b85c5511c7694c828516\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionFactoryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\\n EnumerableSet.AddressSet internal collateralMarkets;\\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\\n\\n IFeeDistributor public feeDistributor;\\n ILiquidatorsRegistry public liquidatorsRegistry;\\n uint256 public blocksPerYear;\\n\\n mapping(bytes4 => address) internal _positionsExtensions;\\n}\\n\",\"keccak256\":\"0x450b84adc8e60b2861c234154e7c137316d216787d5aca83251e77364e1c341f\",\"license\":\"GPL-3.0\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001348380380620013488339810160408190526200003491620000fc565b6200003f3362000078565b600980546001600160a01b039485166001600160a01b031991821617909155600a805493909416921691909117909155600b5562000144565b600180546001600160a01b0319169055620000938162000096565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200009357600080fd5b6000806000606084860312156200011257600080fd5b83516200011f81620000e6565b60208501519093506200013281620000e6565b80925050604084015190509250925092565b6111f480620001546000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638715b16b116100715780638715b16b146101a857806389cd9855146101bb5780638da5cb5b146101ce578063a385fb96146101df578063e30c3978146101f6578063f2fde38b14610207576100b4565b8063035d2a381461012d5780630d43e8ad1461014057806316bb997f146101705780636333d00114610183578063715018a61461019857806379ba5097146101a0575b60006100cb6000356001600160e01b03191661021a565b90506001600160a01b03811661010757604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e808015610126573d6000f35b3d6000fd5b005b61012b61013b366004610eeb565b61023a565b600954610153906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600a54610153906001600160a01b031681565b61018b6103fa565b6040516101679190610f3b565b61012b610409565b61012b610459565b61012b6101b6366004610f88565b6104d3565b61012b6101c9366004610fa5565b6104fd565b6000546001600160a01b0316610153565b6101e8600b5481565b604051908152602001610167565b6001546001600160a01b0316610153565b61012b610215366004610f88565b610513565b60006102348260008051602061119f833981519152610584565b92915050565b61024261061f565b816001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a49190610fde565b6001600160a01b0316836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030f9190610fde565b6001600160a01b0316146103655760405162461bcd60e51b815260206004820152601c60248201527f6d61726b657473206e6f74206f66207468652073616d6520706f6f6c0000000060448201526064016100fe565b801561039f5761037660058461067b565b506001600160a01b0383166000908152600760205260409020610399908361067b565b50505050565b6001600160a01b03831660009081526007602052604090206103c19083610697565b506001600160a01b03831660009081526007602052604090206103e3906106ac565b6000036103f557610399600584610697565b505050565b60606104046106b6565b905090565b61041161061f565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064016100fe565b60015433906001600160a01b031681146104c75760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016100fe565b6104d081610728565b50565b6104db61061f565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61050561061f565b61050f8282610741565b5050565b61051b61061f565b600180546001600160a01b0383166001600160a01b0319909116811790915561054c6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8054600090815b8181101561061457846001600160e01b0319168460000182815481106105b3576105b3610ffb565b600091825260209091200154600160a01b900460e01b6001600160e01b0319160361060c578360000181815481106105ed576105ed610ffb565b6000918252602090912001546001600160a01b03169250610234915050565b60010161058b565b506000949350505050565b6000546001600160a01b031633146106795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016100fe565b565b6000610690836001600160a01b038416610762565b9392505050565b6000610690836001600160a01b0384166107b1565b6000610234825490565b606060008051602061119f83398151915260010180548060200260200160405190810160405280929190818152602001828054801561071e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610700575b5050505050905090565b600180546001600160a01b03191690556104d0816108a4565b6001600160a01b0381161561075957610759816108f4565b61050f82610a23565b60008181526001830160205260408120546107a957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610234565b506000610234565b6000818152600183016020526040812054801561089a5760006107d5600183611027565b85549091506000906107e990600190611027565b905081811461084e57600086600001828154811061080957610809610ffb565b906000526020600020015490508087600001848154811061082c5761082c610ffb565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061085f5761085f61103a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610234565b6000915050610234565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008051602061119f83398151915261090c82610b1a565b60005b600182015460ff821610156103f557826001600160a01b0316826001018260ff168154811061094057610940610ffb565b6000918252602090912001546001600160a01b031603610a115760018083018054909161096c91611027565b8154811061097c5761097c610ffb565b6000918252602090912001546001830180546001600160a01b039092169160ff84169081106109ad576109ad610ffb565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550816001018054806109ee576109ee61103a565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610a1b81611050565b91505061090f565b60008051602061119f83398151915260005b600182015460ff82161015610ada57826001600160a01b0316826001018260ff1681548110610a6657610a66610ffb565b6000918252602090912001546001600160a01b031603610ac85760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016100fe565b80610ad281611050565b915050610a35565b50610ae482610cd9565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b5a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b8291908101906110a2565b905060008051602061119f83398151915260005b82518161ffff161015610399576000838261ffff1681518110610bbb57610bbb610ffb565b60200260200101519050610bcf8184610584565b6001600160a01b0316856001600160a01b031614610bef57610bef611167565b6000610bfb8285610e59565b84549091508490610c0e90600190611027565b81548110610c1e57610c1e610ffb565b90600052602060002001846000018261ffff1681548110610c4157610c41610ffb565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080610ca257610ca261103a565b600082815260209020810160001990810180546001600160c01b031916905501905550819050610cd18161117d565b915050610b96565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d19573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4191908101906110a2565b60008051602061119f83398151915280549192509060005b8351811015610e52576000848281518110610d7657610d76610ffb565b602002602001015190506000610d8c8286610584565b90506001600160a01b03811615610dd157604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016100fe565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b0319909216939092169290921791909117905583610e418161117d565b94505060019092019150610d599050565b5050505050565b8054600090815b8161ffff168161ffff161015610eca57846001600160e01b031916846000018261ffff1681548110610e9457610e94610ffb565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610ec25791506102349050565b600101610e60565b5061ffff949350505050565b6001600160a01b03811681146104d057600080fd5b600080600060608486031215610f0057600080fd5b8335610f0b81610ed6565b92506020840135610f1b81610ed6565b915060408401358015158114610f3057600080fd5b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015610f7c5783516001600160a01b031683529284019291840191600101610f57565b50909695505050505050565b600060208284031215610f9a57600080fd5b813561069081610ed6565b60008060408385031215610fb857600080fd5b8235610fc381610ed6565b91506020830135610fd381610ed6565b809150509250929050565b600060208284031215610ff057600080fd5b815161069081610ed6565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561023457610234611011565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff810361106657611066611011565b60010192915050565b634e487b7160e01b600052604160045260246000fd5b80516001600160e01b03198116811461109d57600080fd5b919050565b600060208083850312156110b557600080fd5b825167ffffffffffffffff808211156110cd57600080fd5b818501915085601f8301126110e157600080fd5b8151818111156110f3576110f361106f565b8060051b604051601f19603f830116810181811085821117156111185761111861106f565b60405291825284820192508381018501918883111561113657600080fd5b938501935b8285101561115b5761114c85611085565b8452938501939285019261113b565b98975050505050505050565b634e487b7160e01b600052600160045260246000fd5b600061ffff80831681810361119457611194611011565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a2646970667358221220e243e6b0c63b5d4b885a5c37acaf76a6af1b20434cc38879294d22a7ca411a8664736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638715b16b116100715780638715b16b146101a857806389cd9855146101bb5780638da5cb5b146101ce578063a385fb96146101df578063e30c3978146101f6578063f2fde38b14610207576100b4565b8063035d2a381461012d5780630d43e8ad1461014057806316bb997f146101705780636333d00114610183578063715018a61461019857806379ba5097146101a0575b60006100cb6000356001600160e01b03191661021a565b90506001600160a01b03811661010757604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e808015610126573d6000f35b3d6000fd5b005b61012b61013b366004610eeb565b61023a565b600954610153906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600a54610153906001600160a01b031681565b61018b6103fa565b6040516101679190610f3b565b61012b610409565b61012b610459565b61012b6101b6366004610f88565b6104d3565b61012b6101c9366004610fa5565b6104fd565b6000546001600160a01b0316610153565b6101e8600b5481565b604051908152602001610167565b6001546001600160a01b0316610153565b61012b610215366004610f88565b610513565b60006102348260008051602061119f833981519152610584565b92915050565b61024261061f565b816001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a49190610fde565b6001600160a01b0316836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030f9190610fde565b6001600160a01b0316146103655760405162461bcd60e51b815260206004820152601c60248201527f6d61726b657473206e6f74206f66207468652073616d6520706f6f6c0000000060448201526064016100fe565b801561039f5761037660058461067b565b506001600160a01b0383166000908152600760205260409020610399908361067b565b50505050565b6001600160a01b03831660009081526007602052604090206103c19083610697565b506001600160a01b03831660009081526007602052604090206103e3906106ac565b6000036103f557610399600584610697565b505050565b60606104046106b6565b905090565b61041161061f565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064016100fe565b60015433906001600160a01b031681146104c75760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016100fe565b6104d081610728565b50565b6104db61061f565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61050561061f565b61050f8282610741565b5050565b61051b61061f565b600180546001600160a01b0383166001600160a01b0319909116811790915561054c6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8054600090815b8181101561061457846001600160e01b0319168460000182815481106105b3576105b3610ffb565b600091825260209091200154600160a01b900460e01b6001600160e01b0319160361060c578360000181815481106105ed576105ed610ffb565b6000918252602090912001546001600160a01b03169250610234915050565b60010161058b565b506000949350505050565b6000546001600160a01b031633146106795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016100fe565b565b6000610690836001600160a01b038416610762565b9392505050565b6000610690836001600160a01b0384166107b1565b6000610234825490565b606060008051602061119f83398151915260010180548060200260200160405190810160405280929190818152602001828054801561071e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610700575b5050505050905090565b600180546001600160a01b03191690556104d0816108a4565b6001600160a01b0381161561075957610759816108f4565b61050f82610a23565b60008181526001830160205260408120546107a957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610234565b506000610234565b6000818152600183016020526040812054801561089a5760006107d5600183611027565b85549091506000906107e990600190611027565b905081811461084e57600086600001828154811061080957610809610ffb565b906000526020600020015490508087600001848154811061082c5761082c610ffb565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061085f5761085f61103a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610234565b6000915050610234565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008051602061119f83398151915261090c82610b1a565b60005b600182015460ff821610156103f557826001600160a01b0316826001018260ff168154811061094057610940610ffb565b6000918252602090912001546001600160a01b031603610a115760018083018054909161096c91611027565b8154811061097c5761097c610ffb565b6000918252602090912001546001830180546001600160a01b039092169160ff84169081106109ad576109ad610ffb565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550816001018054806109ee576109ee61103a565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610a1b81611050565b91505061090f565b60008051602061119f83398151915260005b600182015460ff82161015610ada57826001600160a01b0316826001018260ff1681548110610a6657610a66610ffb565b6000918252602090912001546001600160a01b031603610ac85760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016100fe565b80610ad281611050565b915050610a35565b50610ae482610cd9565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b5a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b8291908101906110a2565b905060008051602061119f83398151915260005b82518161ffff161015610399576000838261ffff1681518110610bbb57610bbb610ffb565b60200260200101519050610bcf8184610584565b6001600160a01b0316856001600160a01b031614610bef57610bef611167565b6000610bfb8285610e59565b84549091508490610c0e90600190611027565b81548110610c1e57610c1e610ffb565b90600052602060002001846000018261ffff1681548110610c4157610c41610ffb565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080610ca257610ca261103a565b600082815260209020810160001990810180546001600160c01b031916905501905550819050610cd18161117d565b915050610b96565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610d19573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d4191908101906110a2565b60008051602061119f83398151915280549192509060005b8351811015610e52576000848281518110610d7657610d76610ffb565b602002602001015190506000610d8c8286610584565b90506001600160a01b03811615610dd157604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016100fe565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b0319909216939092169290921791909117905583610e418161117d565b94505060019092019150610d599050565b5050505050565b8054600090815b8161ffff168161ffff161015610eca57846001600160e01b031916846000018261ffff1681548110610e9457610e94610ffb565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610ec25791506102349050565b600101610e60565b5061ffff949350505050565b6001600160a01b03811681146104d057600080fd5b600080600060608486031215610f0057600080fd5b8335610f0b81610ed6565b92506020840135610f1b81610ed6565b915060408401358015158114610f3057600080fd5b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015610f7c5783516001600160a01b031683529284019291840191600101610f57565b50909695505050505050565b600060208284031215610f9a57600080fd5b813561069081610ed6565b60008060408385031215610fb857600080fd5b8235610fc381610ed6565b91506020830135610fd381610ed6565b809150509250929050565b600060208284031215610ff057600080fd5b815161069081610ed6565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561023457610234611011565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff810361106657611066611011565b60010192915050565b634e487b7160e01b600052604160045260246000fd5b80516001600160e01b03198116811461109d57600080fd5b919050565b600060208083850312156110b557600080fd5b825167ffffffffffffffff808211156110cd57600080fd5b818501915085601f8301126110e157600080fd5b8151818111156110f3576110f361106f565b8060051b604051601f19603f830116810181811085821117156111185761111861106f565b60405291825284820192508381018501918883111561113657600080fd5b938501935b8285101561115b5761114c85611085565b8452938501939285019261113b565b98975050505050505050565b634e487b7160e01b600052600160045260246000fd5b600061ffff80831681810361119457611194611011565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a2646970667358221220e243e6b0c63b5d4b885a5c37acaf76a6af1b20434cc38879294d22a7ca411a8664736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_registerExtension(address,address)": { + "details": "register a logic extension", + "params": { + "extensionToAdd": "the extension whose functions are to be added", + "extensionToReplace": "the extension whose functions are to be removed/replaced" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 120, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 40384, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "accountsWithOpenPositions", + "offset": 0, + "slot": "2", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40389, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "positionsByAccount", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_address,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40392, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "collateralMarkets", + "offset": 0, + "slot": "5", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40398, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "borrowableMarketsByCollateral", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40406, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "__unused", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))" + }, + { + "astId": 40409, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "feeDistributor", + "offset": 0, + "slot": "9", + "type": "t_contract(IFeeDistributor)26285" + }, + { + "astId": 40412, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "liquidatorsRegistry", + "offset": 0, + "slot": "10", + "type": "t_contract(ILiquidatorsRegistry)47786" + }, + { + "astId": 40414, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "blocksPerYear", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 40418, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_positionsExtensions", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_bytes4,t_address)" + } + ], + "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_bytes4": { + "encoding": "inplace", + "label": "bytes4", + "numberOfBytes": "4" + }, + "t_contract(ICErc20)16956": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)93733": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IFeeDistributor)26285": { + "encoding": "inplace", + "label": "contract IFeeDistributor", + "numberOfBytes": "20" + }, + "t_contract(ILiquidatorsRegistry)47786": { + "encoding": "inplace", + "label": "contract ILiquidatorsRegistry", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes4,t_address)": { + "encoding": "mapping", + "key": "t_bytes4", + "label": "mapping(bytes4 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_contract(ICErc20)16956", + "label": "mapping(contract ICErc20 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)2039_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 2038, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)1724_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)1724_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 1719, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 1723, + "contract": "contracts/ionic/levered/LeveredPositionFactory.sol:LeveredPositionFactory", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionFactoryFirstExtension.json b/packages/contracts/deployments/superseed/LeveredPositionFactoryFirstExtension.json new file mode 100644 index 0000000000..c36a2c3cbe --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionFactoryFirstExtension.json @@ -0,0 +1,637 @@ +{ + "address": "0xC3cEc17c135d3C5d6BadC284AFF08f396447DaaC", + "abi": [ + { + "inputs": [], + "name": "NoSuchPosition", + "type": "error" + }, + { + "inputs": [], + "name": "PairNotWhitelisted", + "type": "error" + }, + { + "inputs": [], + "name": "PositionNotClosed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "extension", + "type": "address" + } + ], + "name": "_setPositionsExtension", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "position", + "type": "address" + } + ], + "name": "closeAndRemoveUserPosition", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeDistributor", + "outputs": [ + { + "internalType": "contract IFeeDistributor", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAccountsWithOpenPositions", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + } + ], + "name": "getBorrowableMarketsByCollateral", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinBorrowNative", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getPositionsByAccount", + "outputs": [ + { + "internalType": "address[]", + "name": "positions", + "type": "address[]" + }, + { + "internalType": "bool[]", + "name": "closed", + "type": "bool[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "msgSig", + "type": "bytes4" + } + ], + "name": "getPositionsExtension", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "getRedemptionStrategies", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "strategiesData", + "type": "bytes[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelistedCollateralMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidatorsRegistry", + "outputs": [ + { + "internalType": "contract ILiquidatorsRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "closedPosition", + "type": "address" + } + ], + "name": "removeClosedPosition", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x955f4e783a96b3d15439caf3a6a10b4e1ec415fe625f0e8cb14dbcea2a35f7f7", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xC3cEc17c135d3C5d6BadC284AFF08f396447DaaC", + "transactionIndex": 1, + "gasUsed": "1172221", + "logsBloom": "0x000000000000000000000000000000000040000000000000008000000002000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000200000000000000000008000000000000000000000000000000004000000000000000000000000000000000000000000000000000000008004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xec3becf6f6988fc7255c5c6ee5d78fc64c5d460961019421737709077615c427", + "transactionHash": "0x955f4e783a96b3d15439caf3a6a10b4e1ec415fe625f0e8cb14dbcea2a35f7f7", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159541, + "transactionHash": "0x955f4e783a96b3d15439caf3a6a10b4e1ec415fe625f0e8cb14dbcea2a35f7f7", + "address": "0xC3cEc17c135d3C5d6BadC284AFF08f396447DaaC", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xec3becf6f6988fc7255c5c6ee5d78fc64c5d460961019421737709077615c427" + } + ], + "blockNumber": 4159541, + "cumulativeGasUsed": "1216063", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "0e729d9c66e5b1bc1021561041d72a21", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NoSuchPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PairNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PositionNotClosed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"extension\",\"type\":\"address\"}],\"name\":\"_setPositionsExtension\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"closeAndRemoveUserPosition\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeDistributor\",\"outputs\":[{\"internalType\":\"contract IFeeDistributor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAccountsWithOpenPositions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"}],\"name\":\"getBorrowableMarketsByCollateral\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinBorrowNative\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getPositionsByAccount\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"positions\",\"type\":\"address[]\"},{\"internalType\":\"bool[]\",\"name\":\"closed\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"msgSig\",\"type\":\"bytes4\"}],\"name\":\"getPositionsExtension\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getRedemptionStrategies\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"strategiesData\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWhitelistedCollateralMarkets\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidatorsRegistry\",\"outputs\":[{\"internalType\":\"contract ILiquidatorsRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"closedPosition\",\"type\":\"address\"}],\"name\":\"removeClosedPosition\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol\":\"LeveredPositionFactoryFirstExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/external/compound/ICToken.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's CToken Contract\\n * @notice Abstract base for CTokens\\n * @author Compound\\n */\\ninterface ICToken {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function symbol() external view returns (string memory);\\n\\n function comptroller() external view returns (address);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function isCToken() external view returns (bool);\\n\\n function isCEther() external view returns (bool);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external returns (uint256);\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function totalBorrowsCurrent() external returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function borrowBalanceStored(address account) external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external returns (uint256);\\n\\n function exchangeRateCurrent() external returns (uint256);\\n\\n function exchangeRateStored() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xd90b56c414ed688746f99b939cd2550cd1a646996ed7ee020f95877068324c48\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IComptroller.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IPriceOracle.sol\\\";\\nimport \\\"./ICToken.sol\\\";\\nimport \\\"./IUnitroller.sol\\\";\\nimport \\\"./IRewardsDistributor.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n */\\ninterface IComptroller {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function oracle() external view returns (IPriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function getAssetsIn(address account) external view returns (ICToken[] memory);\\n\\n function checkMembership(address account, ICToken cToken) external view returns (bool);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n )\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function getAccountLiquidity(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _become(IUnitroller unitroller) external;\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAllMarkets() external view returns (ICToken[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cTokenAddress) external returns (uint256);\\n\\n function autoImplementation() external view returns (bool);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\\n\\n function _deployMarket(\\n bool isCEther,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICToken cTokenModify,\\n bool isBorrow\\n ) external view returns (uint256);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function isDeprecated(ICToken cToken) external view returns (bool);\\n\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n}\\n\",\"keccak256\":\"0x3ca179bd72163f50f68d15175625f68e4892df753851afdb60fda626c85fa763\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ICToken.sol\\\";\\n\\ninterface IPriceOracle {\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x501ba6588dc3bbcbcd7629eb294b2249dce97cb78e1c78feb1815d220b488368\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IRewardsDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ICToken.sol\\\";\\n\\n/**\\n * @title RewardsDistributor\\n * @author Compound\\n */\\ninterface IRewardsDistributor {\\n /// @dev The token to reward (i.e., COMP)\\n function rewardToken() external view returns (address);\\n\\n /// @notice The portion of compRate that each market currently receives\\n function compSupplySpeeds(address) external view returns (uint256);\\n\\n /// @notice The portion of compRate that each market currently receives\\n function compBorrowSpeeds(address) external view returns (uint256);\\n\\n /// @notice The COMP accrued but not yet transferred to each user\\n function compAccrued(address) external view returns (uint256);\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @dev Called by the Comptroller\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) external;\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @dev Called by the Comptroller\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\\n\\n /**\\n * @notice Returns an array of all markets.\\n */\\n function getAllMarkets() external view returns (ICToken[] memory);\\n}\\n\",\"keccak256\":\"0x175299449a462109cf22ec786c1bcc820f16eba8052dcfa621e65666e657e3f3\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IUnitroller.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ComptrollerCore\\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\\n * CTokens should reference this contract as their comptroller.\\n */\\ninterface IUnitroller {\\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x629111448df95d5f4c6cae88cd8fceb67537af80e82f643e697d2dd4c22e1c49\",\"license\":\"BSD-3-Clause\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/ILeveredPositionFactory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILeveredPositionFactoryStorage {\\n function feeDistributor() external view returns (IFeeDistributor);\\n\\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\\n\\n function blocksPerYear() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n}\\n\\ninterface ILeveredPositionFactoryBase {\\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\\n\\n function _setPairWhitelisted(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n bool _whitelisted\\n ) external;\\n}\\n\\ninterface ILeveredPositionFactoryFirstExtension {\\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n external\\n view\\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getMinBorrowNative() external view returns (uint256);\\n\\n function removeClosedPosition(address closedPosition) external returns (bool removed);\\n\\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\\n\\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\\n\\n function getAccountsWithOpenPositions() external view returns (address[] memory);\\n\\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\\n\\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\\n\\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\\n\\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\\n}\\n\\ninterface ILeveredPositionFactorySecondExtension {\\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\\n\\n function createAndFundPosition(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount\\n ) external returns (LeveredPosition);\\n\\n function createAndFundPositionAtRatio(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount,\\n uint256 _leverageRatio\\n ) external returns (LeveredPosition);\\n}\\n\\ninterface ILeveredPositionFactoryExtension is\\n ILeveredPositionFactoryFirstExtension,\\n ILeveredPositionFactorySecondExtension\\n{}\\n\\ninterface ILeveredPositionFactory is\\n ILeveredPositionFactoryStorage,\\n ILeveredPositionFactoryBase,\\n ILeveredPositionFactoryExtension\\n{}\\n\",\"keccak256\":\"0x1e6fa8f49acc9f2bb029f18e2da60e3df24ef5eb5348767c26bc58d5e6e8a5c7\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/LeveredPosition.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { BasePriceOracle } from \\\"../../oracles/BasePriceOracle.sol\\\";\\nimport { IFundsConversionStrategy } from \\\"../../liquidators/IFundsConversionStrategy.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"../IFlashLoanReceiver.sol\\\";\\nimport { IonicFlywheel } from \\\"../../ionic/strategies/flywheel/IonicFlywheel.sol\\\";\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { LeveredPositionStorage } from \\\"./LeveredPositionStorage.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFlywheelLensRouter_LP {\\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\\n}\\n\\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n error OnlyWhenClosed();\\n error NotPositionOwner();\\n error OnlyFactoryOwner();\\n error AssetNotRescuable();\\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\\n\\n error ConvertFundsFailed();\\n error ExitFailed(uint256 errorCode);\\n error RedeemFailed(uint256 errorCode);\\n error SupplyCollateralFailed(uint256 errorCode);\\n error BorrowStableFailed(uint256 errorCode);\\n error RepayBorrowFailed(uint256 errorCode);\\n error RedeemCollateralFailed(uint256 errorCode);\\n error ExtNotFound(bytes4 _functionSelector);\\n\\n constructor(\\n address _positionOwner,\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket\\n ) LeveredPositionStorage(_positionOwner) {\\n IonicComptroller collateralPool = _collateralMarket.comptroller();\\n IonicComptroller stablePool = _stableMarket.comptroller();\\n require(collateralPool == stablePool, \\\"markets pools differ\\\");\\n pool = collateralPool;\\n\\n collateralMarket = _collateralMarket;\\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\\n stableMarket = _stableMarket;\\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\\n\\n factory = ILeveredPositionFactory(msg.sender);\\n }\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\\n _supplyCollateral(fundingAsset);\\n\\n if (!pool.checkMembership(address(this), collateralMarket)) {\\n address[] memory cTokens = new address[](1);\\n cTokens[0] = address(collateralMarket);\\n pool.enterMarkets(cTokens);\\n }\\n }\\n\\n function closePosition() public returns (uint256) {\\n return closePosition(msg.sender);\\n }\\n\\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n _leverDown(1e18);\\n\\n // calling accrue and exit allows to redeem the full underlying balance\\n collateralMarket.accrueInterest();\\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\\n if (errorCode != 0) revert ExitFailed(errorCode);\\n\\n // redeem all cTokens should leave no dust\\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\\n if (errorCode != 0) revert RedeemFailed(errorCode);\\n\\n if (stableAsset.balanceOf(address(this)) > 0) {\\n // convert all overborrowed leftovers/profits to the collateral asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // withdraw the redeemed collateral\\n withdrawAmount = collateralAsset.balanceOf(address(this));\\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\\n }\\n\\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n // anything under 1x means removing the leverage\\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\\n\\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\\n else _leverDown(targetRatioMantissa);\\n\\n // return the de facto achieved ratio\\n return getCurrentLeverageRatio();\\n }\\n\\n function receiveFlashLoan(\\n address assetAddress,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external override {\\n if (msg.sender == address(collateralMarket)) {\\n // increasing the leverage ratio\\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\\n _leverUpPostFL(stableBorrowAmount);\\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\\n if (positionCollateralBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\\n } else if (msg.sender == address(stableMarket)) {\\n // decreasing the leverage ratio\\n uint256 amountToRedeem = abi.decode(data, (uint256));\\n _leverDownPostFL(borrowedAmount, amountToRedeem);\\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\\n if (positionStableBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\\n } else {\\n revert(\\\"!fl not from either markets\\\");\\n }\\n\\n // repay FL\\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\\n }\\n\\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\\n if (msg.sender != positionOwner) revert NotPositionOwner();\\n if (!isPositionClosed()) revert OnlyWhenClosed();\\n\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\\n return stableLeftovers;\\n }\\n\\n function claimRewards() public {\\n claimRewards(msg.sender);\\n }\\n\\n function claimRewards(address withdrawTo) public {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n fw.claimRewards(address(this));\\n ERC20 rewardToken = fw.rewardToken();\\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\\n if (rewardsAccrued > 0) {\\n rewardToken.transfer(withdrawTo, rewardsAccrued);\\n }\\n }\\n }\\n\\n function rescueTokens(IERC20Upgradeable asset) external {\\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\\n\\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\\n }\\n\\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\\n for (uint256 i = 0; i < rewardTokens.length; i++) {\\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\\n }\\n return (rewardTokens, rewards);\\n }\\n\\n fallback() external {\\n address extension = factory.getPositionsExtension(msg.sig);\\n if (extension == address(0)) revert ExtNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n function getAccruedRewards()\\n external\\n returns (\\n /*view*/\\n ERC20[] memory rewardTokens,\\n uint256[] memory amounts\\n )\\n {\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n rewardTokens = new ERC20[](flywheels.length);\\n amounts = new uint256[](flywheels.length);\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n rewardTokens[i] = fw.rewardToken();\\n amounts[i] = fw.rewardsAccrued(address(this));\\n }\\n }\\n\\n function getCurrentLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtValue = 0;\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n if (debtAmount > 0) {\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n }\\n\\n // TODO check if positionValue > debtValue\\n // s / ( s - b )\\n return (positionValue * 1e18) / (positionValue - debtValue);\\n }\\n\\n function getMinLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\\n }\\n\\n function getMaxLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\\n }\\n\\n function _getLeverageRatioAfterBorrow(\\n uint256 newBorrowsAmount,\\n uint256 positionSupplyAmount,\\n uint256 positionBorrowAmount\\n ) internal view returns (uint256 r) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\\n\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n {\\n // add 10 bps just to not go under the min borrow value\\n assumedSlippage += 10;\\n }\\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\\n\\n int256 s = int256(positionValue);\\n int256 b = int256(currentBorrowsValue);\\n int256 x = int256(topUpCollateralValue);\\n\\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\\n }\\n\\n function isPositionClosed() public view returns (bool) {\\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\\n }\\n\\n function getEquityAmount() external view returns (uint256 equityAmount) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n\\n uint256 equityValue = positionValue - debtValue;\\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\\n }\\n\\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentRatio = getCurrentLeverageRatio();\\n bool up = targetRatio > currentRatio;\\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\\n }\\n\\n function _getSupplyAmountDelta(\\n bool up,\\n uint256 targetRatio,\\n uint256 collateralAssetPrice,\\n uint256 borrowedAssetPrice\\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 assumedSlippage;\\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\\n\\n uint256 supplyValueDeltaAbs;\\n {\\n // s = supply value before\\n // b = borrow value before\\n // r = target ratio after\\n // c = borrow value coefficient to account for the slippage\\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\\n int256 r = int256(targetRatio);\\n int256 r1 = r - 1e18;\\n int256 c = int256(slippageFactor);\\n\\n // some math magic here\\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\\n\\n // x = supplyValueDelta\\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\\n }\\n\\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\\n\\n if (up) {\\n // stables to borrow = c * x\\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\\n } else {\\n // amount to redeem = c * x\\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n Internal Functions\\n ----------------------------------------------------------------*/\\n\\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\\n // in case the funding is with a different asset\\n if (address(collateralAsset) != address(fundingAsset)) {\\n // swap for collateral asset\\n convertAllTo(fundingAsset, collateralAsset);\\n }\\n\\n // supply the collateral\\n amountToSupply = collateralAsset.balanceOf(address(this));\\n collateralAsset.approve(address(collateralMarket), amountToSupply);\\n uint256 errorCode = collateralMarket.mint(amountToSupply);\\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\\n }\\n\\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\\n function _leverUp(uint256 targetRatio) internal {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\\n true,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n\\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n\\n // all stables are swapped for collateral to repay the FL\\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\\n if (collateralLeftovers > 0) {\\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\\n collateralMarket.mint(collateralLeftovers);\\n }\\n }\\n\\n // @dev supply the flash loaned collateral and then borrow stables with it\\n function _leverUpPostFL(uint256 stableToBorrow) internal {\\n // supply the flash loaned collateral\\n _supplyCollateral(collateralAsset);\\n\\n // borrow stables that will be swapped to repay the FL\\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\\n function _leverDown(uint256 targetRatio) internal {\\n uint256 amountToRedeem;\\n uint256 borrowsToRepay;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n if (targetRatio <= 1e18) {\\n // if max levering down, then derive the amount to redeem from the debt to be repaid\\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\\n } else {\\n // else derive the debt to be repaid from the amount to redeem\\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\\n false,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n // the slippage is already accounted for in _getSupplyAmountDelta\\n }\\n\\n if (borrowsToRepay > 0) {\\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n }\\n\\n // all the redeemed collateral is swapped for stables to repay the FL\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n if (stableLeftovers > 0) {\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n if (borrowBalance > 0) {\\n // whatever is smaller\\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\\n stableAsset.approve(address(stableMarket), amountToRepay);\\n stableMarket.repayBorrow(amountToRepay);\\n }\\n }\\n }\\n\\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\\n // repay the borrows\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\\n stableAsset.approve(address(stableMarket), repayAmount);\\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\\n\\n // redeem the corresponding amount needed to repay the FL\\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(collateralAsset, stableAsset);\\n }\\n\\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n private\\n returns (uint256 outputAmount)\\n {\\n uint256 inputAmount = inputToken.balanceOf(address(this));\\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\\n .getRedemptionStrategies(inputToken, outputToken);\\n\\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\\n\\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\\n bytes memory strategyData = strategiesData[i];\\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\\n inputAmount = outputAmount;\\n inputToken = outputToken;\\n }\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.isContract(target), \\\"Address: delegate call to non-contract\\\");\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n if (returndata.length > 0) {\\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\":\"0x544ff68f1ce3eb3a72dbe344a6f208abdfa32a775a52efe6c37f4509956f4342\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\nimport { LeveredPositionFactoryStorage } from \\\"./LeveredPositionFactoryStorage.sol\\\";\\nimport { ILeveredPositionFactoryFirstExtension } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { IComptroller, IPriceOracle } from \\\"../../external/compound/IComptroller.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { AuthoritiesRegistry } from \\\"../AuthoritiesRegistry.sol\\\";\\nimport { PoolRolesAuthority } from \\\"../PoolRolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract LeveredPositionFactoryFirstExtension is\\n LeveredPositionFactoryStorage,\\n DiamondExtension,\\n ILeveredPositionFactoryFirstExtension\\n{\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n error PairNotWhitelisted();\\n error NoSuchPosition();\\n error PositionNotClosed();\\n\\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\\n uint8 fnsCount = 10;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.removeClosedPosition.selector;\\n functionSelectors[--fnsCount] = this.closeAndRemoveUserPosition.selector;\\n functionSelectors[--fnsCount] = this.getMinBorrowNative.selector;\\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.getBorrowableMarketsByCollateral.selector;\\n functionSelectors[--fnsCount] = this.getWhitelistedCollateralMarkets.selector;\\n functionSelectors[--fnsCount] = this.getAccountsWithOpenPositions.selector;\\n functionSelectors[--fnsCount] = this.getPositionsByAccount.selector;\\n functionSelectors[--fnsCount] = this.getPositionsExtension.selector;\\n functionSelectors[--fnsCount] = this._setPositionsExtension.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n // @return true if removed, otherwise false\\n function removeClosedPosition(address closedPosition) external returns (bool) {\\n return _removeClosedPosition(closedPosition, msg.sender);\\n }\\n\\n function closeAndRemoveUserPosition(LeveredPosition position) external onlyOwner returns (bool) {\\n address positionOwner = position.positionOwner();\\n position.closePosition(positionOwner);\\n return _removeClosedPosition(address(position), positionOwner);\\n }\\n\\n function _removeClosedPosition(address closedPosition, address positionOwner) internal returns (bool removed) {\\n EnumerableSet.AddressSet storage userPositions = positionsByAccount[positionOwner];\\n if (!userPositions.contains(closedPosition)) revert NoSuchPosition();\\n if (!LeveredPosition(closedPosition).isPositionClosed()) revert PositionNotClosed();\\n\\n removed = userPositions.remove(closedPosition);\\n if (userPositions.length() == 0) accountsWithOpenPositions.remove(positionOwner);\\n }\\n\\n function _setPositionsExtension(bytes4 msgSig, address extension) external onlyOwner {\\n _positionsExtensions[msgSig] = extension;\\n }\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n\\n function getMinBorrowNative() external view returns (uint256) {\\n return feeDistributor.minBorrowEth();\\n }\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\\n return liquidatorsRegistry.getRedemptionStrategies(inputToken, outputToken);\\n }\\n\\n function getPositionsByAccount(\\n address account\\n ) external view returns (address[] memory positions, bool[] memory closed) {\\n positions = positionsByAccount[account].values();\\n closed = new bool[](positions.length);\\n for (uint256 i = 0; i < positions.length; i++) {\\n closed[i] = LeveredPosition(positions[i]).isPositionClosed();\\n }\\n }\\n\\n function getAccountsWithOpenPositions() external view returns (address[] memory) {\\n return accountsWithOpenPositions.values();\\n }\\n\\n function getWhitelistedCollateralMarkets() external view returns (address[] memory) {\\n return collateralMarkets.values();\\n }\\n\\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory) {\\n return borrowableMarketsByCollateral[_collateralMarket].values();\\n }\\n\\n function getPositionsExtension(bytes4 msgSig) external view returns (address) {\\n return _positionsExtensions[msgSig];\\n }\\n}\\n\",\"keccak256\":\"0x0190dfb659081fc3f263d7cee4b5473d71f8fcd5862a3cd503f5ad95415585f4\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionFactoryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\\n EnumerableSet.AddressSet internal collateralMarkets;\\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\\n\\n IFeeDistributor public feeDistributor;\\n ILiquidatorsRegistry public liquidatorsRegistry;\\n uint256 public blocksPerYear;\\n\\n mapping(bytes4 => address) internal _positionsExtensions;\\n}\\n\",\"keccak256\":\"0x450b84adc8e60b2861c234154e7c137316d216787d5aca83251e77364e1c341f\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ncontract LeveredPositionStorage {\\n address public immutable positionOwner;\\n ILeveredPositionFactory public factory;\\n\\n ICErc20 public collateralMarket;\\n ICErc20 public stableMarket;\\n IonicComptroller public pool;\\n\\n IERC20Upgradeable public collateralAsset;\\n IERC20Upgradeable public stableAsset;\\n\\n constructor(address _positionOwner) {\\n positionOwner = _positionOwner;\\n }\\n}\\n\",\"keccak256\":\"0xe3342347e2315c9a7a8503ef7ba83390f1cd296318a50952a88d984af940e430\",\"license\":\"GPL-3.0\"},\"contracts/ionic/strategies/flywheel/IFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\n\\n/**\\n @title Balance Booster Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \\n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\\n \\n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\\n\\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\\n*/\\ninterface IFlywheelBooster {\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdab1b4b5662148d74acc3491a810d263ec509f9f81a267e9f6c1542ba15eabc\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { IonicFlywheelCore } from \\\"./IonicFlywheelCore.sol\\\";\\nimport \\\"./IIonicFlywheel.sol\\\";\\n\\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\\n bool public constant isRewardsDistributor = true;\\n bool public constant isFlywheel = true;\\n\\n function flywheelPreSupplierAction(address market, address supplier) external {\\n accrue(ERC20(market), supplier);\\n }\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external {}\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external {\\n accrue(ERC20(market), src, dst);\\n }\\n\\n function compAccrued(address user) external view returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n // TODO remove\\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0x60d8d5a8feaa7c0373d24d6fbca523eb86ba251f5374a8821a6aee63cdc90e0d\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/utils/SafeTransferLib.sol\\\";\\nimport { SafeCastLib } from \\\"solmate/utils/SafeCastLib.sol\\\";\\n\\nimport { IFlywheelRewards } from \\\"./rewards/IFlywheelRewards.sol\\\";\\nimport { IFlywheelBooster } from \\\"./IFlywheelBooster.sol\\\";\\n\\nimport { SafeOwnableUpgradeable } from \\\"../../../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\\n using SafeTransferLib for ERC20;\\n using SafeCastLib for uint256;\\n\\n /// @notice How much rewardsToken will be send to treasury\\n uint256 public performanceFee;\\n\\n /// @notice Address that gets rewardsToken accrued by performanceFee\\n address public feeRecipient;\\n\\n /// @notice The token to reward\\n ERC20 public rewardToken;\\n\\n /// @notice append-only list of strategies added\\n ERC20[] public allStrategies;\\n\\n /// @notice the rewards contract for managing streams\\n IFlywheelRewards public flywheelRewards;\\n\\n /// @notice optional booster module for calculating virtual balances on strategies\\n IFlywheelBooster public flywheelBooster;\\n\\n /// @notice The accrued but not yet transferred rewards for each user\\n mapping(address => uint256) internal _rewardsAccrued;\\n\\n /// @notice The strategy index and last updated per strategy\\n mapping(ERC20 => RewardsState) internal _strategyState;\\n\\n /// @notice user index per strategy\\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\\n\\n constructor() {\\n // prevents the misusage of the implementation contract\\n _disableInitializers();\\n }\\n\\n function initialize(\\n ERC20 _rewardToken,\\n IFlywheelRewards _flywheelRewards,\\n IFlywheelBooster _flywheelBooster,\\n address _owner\\n ) public initializer {\\n __SafeOwnable_init(msg.sender);\\n\\n rewardToken = _rewardToken;\\n flywheelRewards = _flywheelRewards;\\n flywheelBooster = _flywheelBooster;\\n\\n _transferOwnership(_owner);\\n\\n performanceFee = 10e16; // 10%\\n feeRecipient = _owner;\\n }\\n\\n /*----------------------------------------------------------------\\n ACCRUE/CLAIM LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a user's rewards accrue to a given strategy.\\n @param strategy the updated rewards strategy\\n @param user the user of the rewards\\n @param rewardsDelta how many new rewards accrued to the user\\n @param rewardsIndex the market index for rewards per token accrued\\n */\\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\\n\\n /** \\n @notice Emitted when a user claims accrued rewards.\\n @param user the user of the rewards\\n @param amount the amount of rewards claimed\\n */\\n event ClaimRewards(address indexed user, uint256 amount);\\n\\n /** \\n @notice accrue rewards for a single user on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the user to be accrued\\n @return the cumulative amount of rewards accrued to user (including prior)\\n */\\n function accrue(ERC20 strategy, address user) public returns (uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return 0;\\n\\n state = accrueStrategy(strategy, state);\\n return accrueUser(strategy, user, state);\\n }\\n\\n /** \\n @notice accrue rewards for a two users on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the first user to be accrued\\n @param user the second user to be accrued\\n @return the cumulative amount of rewards accrued to the first user (including prior)\\n @return the cumulative amount of rewards accrued to the second user (including prior)\\n */\\n function accrue(\\n ERC20 strategy,\\n address user,\\n address secondUser\\n ) public returns (uint256, uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return (0, 0);\\n\\n state = accrueStrategy(strategy, state);\\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\\n }\\n\\n /** \\n @notice claim rewards for a given user\\n @param user the user claiming rewards\\n @dev this function is public, and all rewards transfer to the user\\n */\\n function claimRewards(address user) external {\\n uint256 accrued = rewardsAccrued(user);\\n\\n if (accrued != 0) {\\n _rewardsAccrued[user] = 0;\\n\\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\\n\\n emit ClaimRewards(user, accrued);\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n ADMIN LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a new strategy is added to flywheel by the admin\\n @param newStrategy the new added strategy\\n */\\n event AddStrategy(address indexed newStrategy);\\n\\n /// @notice initialize a new strategy\\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n function _addStrategyForRewards(ERC20 strategy) internal {\\n (uint224 index, ) = strategyState(strategy);\\n require(index == 0, \\\"strategy\\\");\\n _strategyState[strategy] = RewardsState({\\n index: (10**rewardToken.decimals()).safeCastTo224(),\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n\\n allStrategies.push(strategy);\\n emit AddStrategy(address(strategy));\\n }\\n\\n function getAllStrategies() external view returns (ERC20[] memory) {\\n return allStrategies;\\n }\\n\\n /** \\n @notice Emitted when the rewards module changes\\n @param newFlywheelRewards the new rewards module\\n */\\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\\n\\n /// @notice swap out the flywheel rewards contract\\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\\n if (address(flywheelRewards) != address(0)) {\\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\\n if (oldRewardBalance > 0) {\\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\\n }\\n }\\n\\n flywheelRewards = newFlywheelRewards;\\n\\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\\n }\\n\\n /** \\n @notice Emitted when the booster module changes\\n @param newBooster the new booster module\\n */\\n event FlywheelBoosterUpdate(address indexed newBooster);\\n\\n /// @notice swap out the flywheel booster contract\\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\\n flywheelBooster = newBooster;\\n\\n emit FlywheelBoosterUpdate(address(newBooster));\\n }\\n\\n event UpdatedFeeSettings(\\n uint256 oldPerformanceFee,\\n uint256 newPerformanceFee,\\n address oldFeeRecipient,\\n address newFeeRecipient\\n );\\n\\n /**\\n * @notice Update performanceFee and/or feeRecipient\\n * @dev Claim rewards first from the previous feeRecipient before changing it\\n */\\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\\n _updateFeeSettings(_performanceFee, _feeRecipient);\\n }\\n\\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\\n\\n if (feeRecipient != _feeRecipient) {\\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\\n _rewardsAccrued[feeRecipient] = 0;\\n }\\n performanceFee = _performanceFee;\\n feeRecipient = _feeRecipient;\\n }\\n\\n /*----------------------------------------------------------------\\n INTERNAL ACCOUNTING LOGIC\\n ----------------------------------------------------------------*/\\n\\n struct RewardsState {\\n /// @notice The strategy's last updated index\\n uint224 index;\\n /// @notice The timestamp the index was last updated at\\n uint32 lastUpdatedTimestamp;\\n }\\n\\n /// @notice accumulate global rewards on a strategy\\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\\n private\\n returns (RewardsState memory rewardsState)\\n {\\n // calculate accrued rewards through module\\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\\n\\n rewardsState = state;\\n\\n if (strategyRewardsAccrued > 0) {\\n // use the booster or token supply to calculate reward index denominator\\n uint256 supplyTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedTotalSupply(strategy)\\n : strategy.totalSupply();\\n\\n // 100% = 100e16\\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\\n\\n _rewardsAccrued[feeRecipient] += accruedFees;\\n strategyRewardsAccrued -= accruedFees;\\n\\n uint224 deltaIndex;\\n\\n if (supplyTokens != 0)\\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\\n\\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\\n rewardsState = RewardsState({\\n index: state.index + deltaIndex,\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n _strategyState[strategy] = rewardsState;\\n }\\n }\\n\\n /// @notice accumulate rewards on a strategy for a specific user\\n function accrueUser(\\n ERC20 strategy,\\n address user,\\n RewardsState memory state\\n ) private returns (uint256) {\\n // load indices\\n uint224 strategyIndex = state.index;\\n uint224 supplierIndex = userIndex(strategy, user);\\n\\n // sync user index to global\\n _userIndex[strategy][user] = strategyIndex;\\n\\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\\n // zero balances will have no effect other than syncing to global index\\n if (supplierIndex == 0) {\\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\\n }\\n\\n uint224 deltaIndex = strategyIndex - supplierIndex;\\n // use the booster or token balance to calculate reward balance multiplier\\n uint256 supplierTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedBalanceOf(strategy, user)\\n : strategy.balanceOf(user);\\n\\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\\n\\n _rewardsAccrued[user] = supplierAccrued;\\n\\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\\n\\n return supplierAccrued;\\n }\\n\\n function rewardsAccrued(address user) public virtual returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\\n return _userIndex[strategy][user];\\n }\\n\\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0xbd54c90dbc7f93cad52016f14eb5f9b634f98d18da083ef443951deebc5f82aa\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\nimport {IonicFlywheelCore} from \\\"../IonicFlywheelCore.sol\\\";\\n\\n/**\\n @title Rewards Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Rewards module is responsible for:\\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\\n * actually holding rewards that are yet to be claimed\\n\\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\\n\\n Different module strategies include:\\n * a static reward rate per second\\n * a decaying reward rate\\n * a dynamic just-in-time reward stream\\n * liquid governance reward delegation (Curve Gauge style)\\n\\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\\n */\\ninterface IFlywheelRewards {\\n /**\\n @notice calculate the rewards amount accrued to a strategy since the last update.\\n @param strategy the strategy to accrue rewards for.\\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\\n @return rewards the amount of rewards accrued to the market\\n */\\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\\n\\n /// @notice return the flywheel core address\\n function flywheel() external view returns (IonicFlywheelCore);\\n\\n /// @notice return the reward token associated with flywheel core.\\n function rewardToken() external view returns (ERC20);\\n}\\n\",\"keccak256\":\"0x7e966a0e7cc80f799ee7cb3611027381847dafb92b8d8c0f3e96500ecbe217f7\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeCastLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Safe unsigned integer casting library that reverts on overflow.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\\nlibrary SafeCastLib {\\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\\n require(x < 1 << 248);\\n\\n y = uint248(x);\\n }\\n\\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\\n require(x < 1 << 224);\\n\\n y = uint224(x);\\n }\\n\\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\\n require(x < 1 << 192);\\n\\n y = uint192(x);\\n }\\n\\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\\n require(x < 1 << 160);\\n\\n y = uint160(x);\\n }\\n\\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\\n require(x < 1 << 128);\\n\\n y = uint128(x);\\n }\\n\\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\\n require(x < 1 << 96);\\n\\n y = uint96(x);\\n }\\n\\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\\n require(x < 1 << 64);\\n\\n y = uint64(x);\\n }\\n\\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\\n require(x < 1 << 32);\\n\\n y = uint32(x);\\n }\\n\\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\\n require(x < 1 << 24);\\n\\n y = uint24(x);\\n }\\n\\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\\n require(x < 1 << 16);\\n\\n y = uint16(x);\\n }\\n\\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\\n require(x < 1 << 8);\\n\\n y = uint8(x);\\n }\\n}\\n\",\"keccak256\":\"0xb784a14411858036491124e677aecde6d500e695b7a70c74aa8f1001bda2ccab\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), from) // Append the \\\"from\\\" argument.\\n mstore(add(freeMemoryPointer, 36), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 68), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x333b56bef66ff71e3838910781df214acbeb6c2d6ace27a04ebb510f0e669300\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61008b565b600180546001600160a01b03191690556100388161003b565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6113bb8061009a6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c806389f8132e116100ad578063d337a1da11610071578063d337a1da1461026b578063e30c39781461027e578063ed287f3f1461028f578063f2fde38b146102b0578063f4e61066146102c357600080fd5b806389f8132e146102115780638da5cb5b14610226578063a339d75114610237578063a385fb961461023f578063ca2de6bc1461024857600080fd5b806316bb997f116100f457806316bb997f146101a65780632eb0e472146101b9578063715018a6146101ce57806379ba5097146101d657806386ef7482146101de57600080fd5b80630973e916146101265780630d43e8ad146101505780630da2262c1461017b57806312468b7714610191575b600080fd5b610139610134366004610e20565b6102d6565b604051610147929190610e82565b60405180910390f35b600954610163906001600160a01b031681565b6040516001600160a01b039091168152602001610147565b6101836103fb565b604051908152602001610147565b61019961046e565b6040516101479190610edb565b600a54610163906001600160a01b031681565b6101cc6101c7366004610f06565b61047a565b005b6101cc6104bc565b6101cc610511565b6101636101ec366004610f3d565b6001600160e01b0319166000908152600c60205260409020546001600160a01b031690565b61021961058b565b6040516101479190610f58565b6000546001600160a01b0316610163565b610199610896565b610183600b5481565b61025b610256366004610e20565b6108a2565b6040519015158152602001610147565b61025b610279366004610e20565b6108ae565b6001546001600160a01b0316610163565b6102a261029d366004610fa6565b6109a0565b604051610147929190610fe8565b6101cc6102be366004610e20565b610a29565b6101996102d1366004610e20565b610a9a565b6001600160a01b038116600090815260046020526040902060609081906102fc90610aba565b9150815167ffffffffffffffff811115610318576103186110a1565b604051908082528060200260200182016040528015610341578160200160208202803683370190505b50905060005b82518110156103f557828181518110610362576103626110b7565b60200260200101516001600160a01b0316633e2f147f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cb91906110cd565b8282815181106103dd576103dd6110b7565b91151560209283029190910190910152600101610347565b50915091565b6009546040805163fdb25fb160e01b815290516000926001600160a01b03169163fdb25fb19160048083019260209291908290030181865afa158015610445573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046991906110ef565b905090565b60606104696002610aba565b610482610ace565b6001600160e01b0319919091166000908152600c6020526040902080546001600160a01b0319166001600160a01b03909216919091179055565b6104c4610ace565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b0316811461057f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610508565b61058881610b2a565b50565b60408051600a80825261016082019092526060919060009082602082016101408036833701905050905063328b79af60e21b816105c78461111e565b93508360ff16815181106105dd576105dd6110b7565b6001600160e01b03199092166020928302919091019091015263699bd0ed60e11b816106088461111e565b93508360ff168151811061061e5761061e6110b7565b6001600160e01b031990921660209283029190910190910152630368898b60e21b816106498461111e565b93508360ff168151811061065f5761065f6110b7565b6001600160e01b03199092166020928302919091019091015263ed287f3f60e01b8161068a8461111e565b93508360ff16815181106106a0576106a06110b7565b6001600160e01b031990921660209283029190910190910152637a73083360e11b816106cb8461111e565b93508360ff16815181106106e1576106e16110b7565b6001600160e01b03199092166020928302919091019091015263a339d75160e01b8161070c8461111e565b93508360ff1681518110610722576107226110b7565b6001600160e01b0319909216602092830291909101909101526312468b7760e01b8161074d8461111e565b93508360ff1681518110610763576107636110b7565b6001600160e01b0319909216602092830291909101909101526304b9f48b60e11b8161078e8461111e565b93508360ff16815181106107a4576107a46110b7565b6001600160e01b031990921660209283029190910190910152634377ba4160e11b816107cf8461111e565b93508360ff16815181106107e5576107e56110b7565b6001600160e01b031990921660209283029190910190910152631758723960e11b816108108461111e565b93508360ff1681518110610826576108266110b7565b6001600160e01b03199092166020928302919091019091015260ff8216156108905760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610508565b92915050565b60606104696005610aba565b60006108908233610b43565b60006108b8610ace565b6000826001600160a01b031663cb2af14b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c919061113b565b604051632f86e2dd60e01b81526001600160a01b03808316600483015291925090841690632f86e2dd906024016020604051808303816000875af1158015610968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098c91906110ef565b506109978382610b43565b9150505b919050565b600a5460405163ed287f3f60e01b81526001600160a01b0384811660048301528381166024830152606092839291169063ed287f3f90604401600060405180830381865afa1580156109f6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a1e9190810190611297565b915091509250929050565b610a31610ace565b600180546001600160a01b0383166001600160a01b03199091168117909155610a626000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b0381166000908152600760205260409020606090610890905b60606000610ac783610c4d565b9392505050565b6000546001600160a01b03163314610b285760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610508565b565b600180546001600160a01b031916905561058881610ca9565b6001600160a01b0381166000908152600460205260408120610b8181856001600160a01b031660009081526001919091016020526040902054151590565b610b9e57604051632af0900d60e21b815260040160405180910390fd5b836001600160a01b0316633e2f147f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0091906110cd565b610c1d576040516345916a4760e11b815260040160405180910390fd5b610c278185610cf9565b9150610c3281610d0e565b600003610c4657610c44600284610cf9565b505b5092915050565b606081600001805480602002602001604051908101604052809291908181526020018280548015610c9d57602002820191906000526020600020905b815481526020019060010190808311610c89575b50505050509050919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610ac7836001600160a01b038416610d18565b6000610890825490565b60008181526001830160205260408120548015610e01576000610d3c60018361135c565b8554909150600090610d509060019061135c565b9050818114610db5576000866000018281548110610d7057610d706110b7565b9060005260206000200154905080876000018481548110610d9357610d936110b7565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610dc657610dc661136f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610890565b6000915050610890565b6001600160a01b038116811461058857600080fd5b600060208284031215610e3257600080fd5b8135610ac781610e0b565b60008151808452602080850194506020840160005b83811015610e775781516001600160a01b031687529582019590820190600101610e52565b509495945050505050565b604081526000610e956040830185610e3d565b82810360208481019190915284518083528582019282019060005b81811015610ece578451151583529383019391830191600101610eb0565b5090979650505050505050565b602081526000610ac76020830184610e3d565b80356001600160e01b03198116811461099b57600080fd5b60008060408385031215610f1957600080fd5b610f2283610eee565b91506020830135610f3281610e0b565b809150509250929050565b600060208284031215610f4f57600080fd5b610ac782610eee565b6020808252825182820181905260009190848201906040850190845b81811015610f9a5783516001600160e01b03191683529284019291840191600101610f74565b50909695505050505050565b60008060408385031215610fb957600080fd5b8235610f2281610e0b565b60005b83811015610fdf578181015183820152602001610fc7565b50506000910152565b604080825283519082018190526000906020906060840190828701845b8281101561102a5781516001600160a01b031684529284019290840190600101611005565b50505083810382850152845180825282820190600581901b8301840187850160005b8381101561109257601f198087850301865282518051808652611074818b88018c8501610fc4565b96890196601f0190911693909301870192509086019060010161104c565b50909998505050505050505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000602082840312156110df57600080fd5b81518015158114610ac757600080fd5b60006020828403121561110157600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060ff82168061113157611131611108565b6000190192915050565b60006020828403121561114d57600080fd5b8151610ac781610e0b565b604051601f8201601f1916810167ffffffffffffffff81118282101715611181576111816110a1565b604052919050565b600067ffffffffffffffff8211156111a3576111a36110a1565b5060051b60200190565b6000601f83601f8401126111c057600080fd5b825160206111d56111d083611189565b611158565b82815260059290921b850181019181810190878411156111f457600080fd5b8287015b8481101561128b57805167ffffffffffffffff808211156112195760008081fd5b818a0191508a603f83011261122e5760008081fd5b85820151604082821115611244576112446110a1565b611255828b01601f19168901611158565b92508183528c8183860101111561126c5760008081fd5b61127b82898501838701610fc4565b50508452509183019183016111f8565b50979650505050505050565b600080604083850312156112aa57600080fd5b825167ffffffffffffffff808211156112c257600080fd5b818501915085601f8301126112d657600080fd5b815160206112e66111d083611189565b82815260059290921b8401810191818101908984111561130557600080fd5b948201945b8386101561132c57855161131d81610e0b565b8252948201949082019061130a565b9188015191965090935050508082111561134557600080fd5b50611352858286016111ad565b9150509250929050565b8181038181111561089057610890611108565b634e487b7160e01b600052603160045260246000fdfea26469706673582212206c9031cfc0eb63852212bd123c0b6e9b95fbb7cbcd03d2b07bcc4702f24f768564736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101215760003560e01c806389f8132e116100ad578063d337a1da11610071578063d337a1da1461026b578063e30c39781461027e578063ed287f3f1461028f578063f2fde38b146102b0578063f4e61066146102c357600080fd5b806389f8132e146102115780638da5cb5b14610226578063a339d75114610237578063a385fb961461023f578063ca2de6bc1461024857600080fd5b806316bb997f116100f457806316bb997f146101a65780632eb0e472146101b9578063715018a6146101ce57806379ba5097146101d657806386ef7482146101de57600080fd5b80630973e916146101265780630d43e8ad146101505780630da2262c1461017b57806312468b7714610191575b600080fd5b610139610134366004610e20565b6102d6565b604051610147929190610e82565b60405180910390f35b600954610163906001600160a01b031681565b6040516001600160a01b039091168152602001610147565b6101836103fb565b604051908152602001610147565b61019961046e565b6040516101479190610edb565b600a54610163906001600160a01b031681565b6101cc6101c7366004610f06565b61047a565b005b6101cc6104bc565b6101cc610511565b6101636101ec366004610f3d565b6001600160e01b0319166000908152600c60205260409020546001600160a01b031690565b61021961058b565b6040516101479190610f58565b6000546001600160a01b0316610163565b610199610896565b610183600b5481565b61025b610256366004610e20565b6108a2565b6040519015158152602001610147565b61025b610279366004610e20565b6108ae565b6001546001600160a01b0316610163565b6102a261029d366004610fa6565b6109a0565b604051610147929190610fe8565b6101cc6102be366004610e20565b610a29565b6101996102d1366004610e20565b610a9a565b6001600160a01b038116600090815260046020526040902060609081906102fc90610aba565b9150815167ffffffffffffffff811115610318576103186110a1565b604051908082528060200260200182016040528015610341578160200160208202803683370190505b50905060005b82518110156103f557828181518110610362576103626110b7565b60200260200101516001600160a01b0316633e2f147f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cb91906110cd565b8282815181106103dd576103dd6110b7565b91151560209283029190910190910152600101610347565b50915091565b6009546040805163fdb25fb160e01b815290516000926001600160a01b03169163fdb25fb19160048083019260209291908290030181865afa158015610445573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046991906110ef565b905090565b60606104696002610aba565b610482610ace565b6001600160e01b0319919091166000908152600c6020526040902080546001600160a01b0319166001600160a01b03909216919091179055565b6104c4610ace565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b0316811461057f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610508565b61058881610b2a565b50565b60408051600a80825261016082019092526060919060009082602082016101408036833701905050905063328b79af60e21b816105c78461111e565b93508360ff16815181106105dd576105dd6110b7565b6001600160e01b03199092166020928302919091019091015263699bd0ed60e11b816106088461111e565b93508360ff168151811061061e5761061e6110b7565b6001600160e01b031990921660209283029190910190910152630368898b60e21b816106498461111e565b93508360ff168151811061065f5761065f6110b7565b6001600160e01b03199092166020928302919091019091015263ed287f3f60e01b8161068a8461111e565b93508360ff16815181106106a0576106a06110b7565b6001600160e01b031990921660209283029190910190910152637a73083360e11b816106cb8461111e565b93508360ff16815181106106e1576106e16110b7565b6001600160e01b03199092166020928302919091019091015263a339d75160e01b8161070c8461111e565b93508360ff1681518110610722576107226110b7565b6001600160e01b0319909216602092830291909101909101526312468b7760e01b8161074d8461111e565b93508360ff1681518110610763576107636110b7565b6001600160e01b0319909216602092830291909101909101526304b9f48b60e11b8161078e8461111e565b93508360ff16815181106107a4576107a46110b7565b6001600160e01b031990921660209283029190910190910152634377ba4160e11b816107cf8461111e565b93508360ff16815181106107e5576107e56110b7565b6001600160e01b031990921660209283029190910190910152631758723960e11b816108108461111e565b93508360ff1681518110610826576108266110b7565b6001600160e01b03199092166020928302919091019091015260ff8216156108905760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610508565b92915050565b60606104696005610aba565b60006108908233610b43565b60006108b8610ace565b6000826001600160a01b031663cb2af14b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c919061113b565b604051632f86e2dd60e01b81526001600160a01b03808316600483015291925090841690632f86e2dd906024016020604051808303816000875af1158015610968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098c91906110ef565b506109978382610b43565b9150505b919050565b600a5460405163ed287f3f60e01b81526001600160a01b0384811660048301528381166024830152606092839291169063ed287f3f90604401600060405180830381865afa1580156109f6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a1e9190810190611297565b915091509250929050565b610a31610ace565b600180546001600160a01b0383166001600160a01b03199091168117909155610a626000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b0381166000908152600760205260409020606090610890905b60606000610ac783610c4d565b9392505050565b6000546001600160a01b03163314610b285760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610508565b565b600180546001600160a01b031916905561058881610ca9565b6001600160a01b0381166000908152600460205260408120610b8181856001600160a01b031660009081526001919091016020526040902054151590565b610b9e57604051632af0900d60e21b815260040160405180910390fd5b836001600160a01b0316633e2f147f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0091906110cd565b610c1d576040516345916a4760e11b815260040160405180910390fd5b610c278185610cf9565b9150610c3281610d0e565b600003610c4657610c44600284610cf9565b505b5092915050565b606081600001805480602002602001604051908101604052809291908181526020018280548015610c9d57602002820191906000526020600020905b815481526020019060010190808311610c89575b50505050509050919050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610ac7836001600160a01b038416610d18565b6000610890825490565b60008181526001830160205260408120548015610e01576000610d3c60018361135c565b8554909150600090610d509060019061135c565b9050818114610db5576000866000018281548110610d7057610d706110b7565b9060005260206000200154905080876000018481548110610d9357610d936110b7565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610dc657610dc661136f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610890565b6000915050610890565b6001600160a01b038116811461058857600080fd5b600060208284031215610e3257600080fd5b8135610ac781610e0b565b60008151808452602080850194506020840160005b83811015610e775781516001600160a01b031687529582019590820190600101610e52565b509495945050505050565b604081526000610e956040830185610e3d565b82810360208481019190915284518083528582019282019060005b81811015610ece578451151583529383019391830191600101610eb0565b5090979650505050505050565b602081526000610ac76020830184610e3d565b80356001600160e01b03198116811461099b57600080fd5b60008060408385031215610f1957600080fd5b610f2283610eee565b91506020830135610f3281610e0b565b809150509250929050565b600060208284031215610f4f57600080fd5b610ac782610eee565b6020808252825182820181905260009190848201906040850190845b81811015610f9a5783516001600160e01b03191683529284019291840191600101610f74565b50909695505050505050565b60008060408385031215610fb957600080fd5b8235610f2281610e0b565b60005b83811015610fdf578181015183820152602001610fc7565b50506000910152565b604080825283519082018190526000906020906060840190828701845b8281101561102a5781516001600160a01b031684529284019290840190600101611005565b50505083810382850152845180825282820190600581901b8301840187850160005b8381101561109257601f198087850301865282518051808652611074818b88018c8501610fc4565b96890196601f0190911693909301870192509086019060010161104c565b50909998505050505050505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000602082840312156110df57600080fd5b81518015158114610ac757600080fd5b60006020828403121561110157600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060ff82168061113157611131611108565b6000190192915050565b60006020828403121561114d57600080fd5b8151610ac781610e0b565b604051601f8201601f1916810167ffffffffffffffff81118282101715611181576111816110a1565b604052919050565b600067ffffffffffffffff8211156111a3576111a36110a1565b5060051b60200190565b6000601f83601f8401126111c057600080fd5b825160206111d56111d083611189565b611158565b82815260059290921b850181019181810190878411156111f457600080fd5b8287015b8481101561128b57805167ffffffffffffffff808211156112195760008081fd5b818a0191508a603f83011261122e5760008081fd5b85820151604082821115611244576112446110a1565b611255828b01601f19168901611158565b92508183528c8183860101111561126c5760008081fd5b61127b82898501838701610fc4565b50508452509183019183016111f8565b50979650505050505050565b600080604083850312156112aa57600080fd5b825167ffffffffffffffff808211156112c257600080fd5b818501915085601f8301126112d657600080fd5b815160206112e66111d083611189565b82815260059290921b8401810191818101908984111561130557600080fd5b948201945b8386101561132c57855161131d81610e0b565b8252948201949082019061130a565b9188015191965090935050508082111561134557600080fd5b50611352858286016111ad565b9150509250929050565b8181038181111561089057610890611108565b634e487b7160e01b600052603160045260246000fdfea26469706673582212206c9031cfc0eb63852212bd123c0b6e9b95fbb7cbcd03d2b07bcc4702f24f768564736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 120, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 40384, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "accountsWithOpenPositions", + "offset": 0, + "slot": "2", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40389, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "positionsByAccount", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_address,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40392, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "collateralMarkets", + "offset": 0, + "slot": "5", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40398, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "borrowableMarketsByCollateral", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40406, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "__unused", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))" + }, + { + "astId": 40409, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "feeDistributor", + "offset": 0, + "slot": "9", + "type": "t_contract(IFeeDistributor)26285" + }, + { + "astId": 40412, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "liquidatorsRegistry", + "offset": 0, + "slot": "10", + "type": "t_contract(ILiquidatorsRegistry)47786" + }, + { + "astId": 40414, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "blocksPerYear", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 40418, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_positionsExtensions", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_bytes4,t_address)" + } + ], + "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_bytes4": { + "encoding": "inplace", + "label": "bytes4", + "numberOfBytes": "4" + }, + "t_contract(ICErc20)16956": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)93733": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IFeeDistributor)26285": { + "encoding": "inplace", + "label": "contract IFeeDistributor", + "numberOfBytes": "20" + }, + "t_contract(ILiquidatorsRegistry)47786": { + "encoding": "inplace", + "label": "contract ILiquidatorsRegistry", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes4,t_address)": { + "encoding": "mapping", + "key": "t_bytes4", + "label": "mapping(bytes4 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_contract(ICErc20)16956", + "label": "mapping(contract ICErc20 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)2039_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 2038, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)1724_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)1724_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 1719, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 1723, + "contract": "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol:LeveredPositionFactoryFirstExtension", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionFactorySecondExtension.json b/packages/contracts/deployments/superseed/LeveredPositionFactorySecondExtension.json new file mode 100644 index 0000000000..d3eabb8d80 --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionFactorySecondExtension.json @@ -0,0 +1,538 @@ +{ + "address": "0x7DFDd5B55Fe37602B355F7a9Ed0fe00e30C163cb", + "abi": [ + { + "inputs": [], + "name": "PairNotWhitelisted", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "blocksPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "_fundingAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fundingAmount", + "type": "uint256" + } + ], + "name": "createAndFundPosition", + "outputs": [ + { + "internalType": "contract LeveredPosition", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "_fundingAsset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fundingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_leverageRatio", + "type": "uint256" + } + ], + "name": "createAndFundPositionAtRatio", + "outputs": [ + { + "internalType": "contract LeveredPosition", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + } + ], + "name": "createPosition", + "outputs": [ + { + "internalType": "contract LeveredPosition", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeDistributor", + "outputs": [ + { + "internalType": "contract IFeeDistributor", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liquidatorsRegistry", + "outputs": [ + { + "internalType": "contract ILiquidatorsRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xb0e2bd31dd77f42fffdb54b9a0b54577274f6eeafc542a1266de3afdc3009002", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x7DFDd5B55Fe37602B355F7a9Ed0fe00e30C163cb", + "transactionIndex": 1, + "gasUsed": "5097197", + "logsBloom": "0x00000000000010000000000000000000008000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x64c2b048d33ea04fa4ca2d7d3f7af924cfcf3e5069c940c3638f77ccfd8650ce", + "transactionHash": "0xb0e2bd31dd77f42fffdb54b9a0b54577274f6eeafc542a1266de3afdc3009002", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159546, + "transactionHash": "0xb0e2bd31dd77f42fffdb54b9a0b54577274f6eeafc542a1266de3afdc3009002", + "address": "0x7DFDd5B55Fe37602B355F7a9Ed0fe00e30C163cb", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x64c2b048d33ea04fa4ca2d7d3f7af924cfcf3e5069c940c3638f77ccfd8650ce" + } + ], + "blockNumber": 4159546, + "cumulativeGasUsed": "5141039", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "0e729d9c66e5b1bc1021561041d72a21", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"PairNotWhitelisted\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blocksPerYear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"_fundingAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fundingAmount\",\"type\":\"uint256\"}],\"name\":\"createAndFundPosition\",\"outputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"_fundingAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fundingAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_leverageRatio\",\"type\":\"uint256\"}],\"name\":\"createAndFundPositionAtRatio\",\"outputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"}],\"name\":\"createPosition\",\"outputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeDistributor\",\"outputs\":[{\"internalType\":\"contract IFeeDistributor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidatorsRegistry\",\"outputs\":[{\"internalType\":\"contract ILiquidatorsRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol\":\"LeveredPositionFactorySecondExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/external/compound/ICToken.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's CToken Contract\\n * @notice Abstract base for CTokens\\n * @author Compound\\n */\\ninterface ICToken {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function symbol() external view returns (string memory);\\n\\n function comptroller() external view returns (address);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function isCToken() external view returns (bool);\\n\\n function isCEther() external view returns (bool);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external returns (uint256);\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function totalBorrowsCurrent() external returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function borrowBalanceStored(address account) external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external returns (uint256);\\n\\n function exchangeRateCurrent() external returns (uint256);\\n\\n function exchangeRateStored() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xd90b56c414ed688746f99b939cd2550cd1a646996ed7ee020f95877068324c48\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IComptroller.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IPriceOracle.sol\\\";\\nimport \\\"./ICToken.sol\\\";\\nimport \\\"./IUnitroller.sol\\\";\\nimport \\\"./IRewardsDistributor.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n */\\ninterface IComptroller {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function oracle() external view returns (IPriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function getAssetsIn(address account) external view returns (ICToken[] memory);\\n\\n function checkMembership(address account, ICToken cToken) external view returns (bool);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n )\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function getAccountLiquidity(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _become(IUnitroller unitroller) external;\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAllMarkets() external view returns (ICToken[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cTokenAddress) external returns (uint256);\\n\\n function autoImplementation() external view returns (bool);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\\n\\n function _deployMarket(\\n bool isCEther,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICToken cTokenModify,\\n bool isBorrow\\n ) external view returns (uint256);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function isDeprecated(ICToken cToken) external view returns (bool);\\n\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n}\\n\",\"keccak256\":\"0x3ca179bd72163f50f68d15175625f68e4892df753851afdb60fda626c85fa763\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ICToken.sol\\\";\\n\\ninterface IPriceOracle {\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x501ba6588dc3bbcbcd7629eb294b2249dce97cb78e1c78feb1815d220b488368\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IRewardsDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ICToken.sol\\\";\\n\\n/**\\n * @title RewardsDistributor\\n * @author Compound\\n */\\ninterface IRewardsDistributor {\\n /// @dev The token to reward (i.e., COMP)\\n function rewardToken() external view returns (address);\\n\\n /// @notice The portion of compRate that each market currently receives\\n function compSupplySpeeds(address) external view returns (uint256);\\n\\n /// @notice The portion of compRate that each market currently receives\\n function compBorrowSpeeds(address) external view returns (uint256);\\n\\n /// @notice The COMP accrued but not yet transferred to each user\\n function compAccrued(address) external view returns (uint256);\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @dev Called by the Comptroller\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) external;\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @dev Called by the Comptroller\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\\n\\n /**\\n * @notice Returns an array of all markets.\\n */\\n function getAllMarkets() external view returns (ICToken[] memory);\\n}\\n\",\"keccak256\":\"0x175299449a462109cf22ec786c1bcc820f16eba8052dcfa621e65666e657e3f3\",\"license\":\"BSD-3-Clause\"},\"contracts/external/compound/IUnitroller.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title ComptrollerCore\\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\\n * CTokens should reference this contract as their comptroller.\\n */\\ninterface IUnitroller {\\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x629111448df95d5f4c6cae88cd8fceb67537af80e82f643e697d2dd4c22e1c49\",\"license\":\"BSD-3-Clause\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/ILeveredPositionFactory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILeveredPositionFactoryStorage {\\n function feeDistributor() external view returns (IFeeDistributor);\\n\\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\\n\\n function blocksPerYear() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n}\\n\\ninterface ILeveredPositionFactoryBase {\\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\\n\\n function _setPairWhitelisted(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n bool _whitelisted\\n ) external;\\n}\\n\\ninterface ILeveredPositionFactoryFirstExtension {\\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n external\\n view\\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getMinBorrowNative() external view returns (uint256);\\n\\n function removeClosedPosition(address closedPosition) external returns (bool removed);\\n\\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\\n\\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\\n\\n function getAccountsWithOpenPositions() external view returns (address[] memory);\\n\\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\\n\\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\\n\\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\\n\\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\\n}\\n\\ninterface ILeveredPositionFactorySecondExtension {\\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\\n\\n function createAndFundPosition(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount\\n ) external returns (LeveredPosition);\\n\\n function createAndFundPositionAtRatio(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount,\\n uint256 _leverageRatio\\n ) external returns (LeveredPosition);\\n}\\n\\ninterface ILeveredPositionFactoryExtension is\\n ILeveredPositionFactoryFirstExtension,\\n ILeveredPositionFactorySecondExtension\\n{}\\n\\ninterface ILeveredPositionFactory is\\n ILeveredPositionFactoryStorage,\\n ILeveredPositionFactoryBase,\\n ILeveredPositionFactoryExtension\\n{}\\n\",\"keccak256\":\"0x1e6fa8f49acc9f2bb029f18e2da60e3df24ef5eb5348767c26bc58d5e6e8a5c7\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/LeveredPosition.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { BasePriceOracle } from \\\"../../oracles/BasePriceOracle.sol\\\";\\nimport { IFundsConversionStrategy } from \\\"../../liquidators/IFundsConversionStrategy.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"../IFlashLoanReceiver.sol\\\";\\nimport { IonicFlywheel } from \\\"../../ionic/strategies/flywheel/IonicFlywheel.sol\\\";\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { LeveredPositionStorage } from \\\"./LeveredPositionStorage.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFlywheelLensRouter_LP {\\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\\n}\\n\\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n error OnlyWhenClosed();\\n error NotPositionOwner();\\n error OnlyFactoryOwner();\\n error AssetNotRescuable();\\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\\n\\n error ConvertFundsFailed();\\n error ExitFailed(uint256 errorCode);\\n error RedeemFailed(uint256 errorCode);\\n error SupplyCollateralFailed(uint256 errorCode);\\n error BorrowStableFailed(uint256 errorCode);\\n error RepayBorrowFailed(uint256 errorCode);\\n error RedeemCollateralFailed(uint256 errorCode);\\n error ExtNotFound(bytes4 _functionSelector);\\n\\n constructor(\\n address _positionOwner,\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket\\n ) LeveredPositionStorage(_positionOwner) {\\n IonicComptroller collateralPool = _collateralMarket.comptroller();\\n IonicComptroller stablePool = _stableMarket.comptroller();\\n require(collateralPool == stablePool, \\\"markets pools differ\\\");\\n pool = collateralPool;\\n\\n collateralMarket = _collateralMarket;\\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\\n stableMarket = _stableMarket;\\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\\n\\n factory = ILeveredPositionFactory(msg.sender);\\n }\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\\n _supplyCollateral(fundingAsset);\\n\\n if (!pool.checkMembership(address(this), collateralMarket)) {\\n address[] memory cTokens = new address[](1);\\n cTokens[0] = address(collateralMarket);\\n pool.enterMarkets(cTokens);\\n }\\n }\\n\\n function closePosition() public returns (uint256) {\\n return closePosition(msg.sender);\\n }\\n\\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n _leverDown(1e18);\\n\\n // calling accrue and exit allows to redeem the full underlying balance\\n collateralMarket.accrueInterest();\\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\\n if (errorCode != 0) revert ExitFailed(errorCode);\\n\\n // redeem all cTokens should leave no dust\\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\\n if (errorCode != 0) revert RedeemFailed(errorCode);\\n\\n if (stableAsset.balanceOf(address(this)) > 0) {\\n // convert all overborrowed leftovers/profits to the collateral asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // withdraw the redeemed collateral\\n withdrawAmount = collateralAsset.balanceOf(address(this));\\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\\n }\\n\\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n // anything under 1x means removing the leverage\\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\\n\\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\\n else _leverDown(targetRatioMantissa);\\n\\n // return the de facto achieved ratio\\n return getCurrentLeverageRatio();\\n }\\n\\n function receiveFlashLoan(\\n address assetAddress,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external override {\\n if (msg.sender == address(collateralMarket)) {\\n // increasing the leverage ratio\\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\\n _leverUpPostFL(stableBorrowAmount);\\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\\n if (positionCollateralBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\\n } else if (msg.sender == address(stableMarket)) {\\n // decreasing the leverage ratio\\n uint256 amountToRedeem = abi.decode(data, (uint256));\\n _leverDownPostFL(borrowedAmount, amountToRedeem);\\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\\n if (positionStableBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\\n } else {\\n revert(\\\"!fl not from either markets\\\");\\n }\\n\\n // repay FL\\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\\n }\\n\\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\\n if (msg.sender != positionOwner) revert NotPositionOwner();\\n if (!isPositionClosed()) revert OnlyWhenClosed();\\n\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\\n return stableLeftovers;\\n }\\n\\n function claimRewards() public {\\n claimRewards(msg.sender);\\n }\\n\\n function claimRewards(address withdrawTo) public {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n fw.claimRewards(address(this));\\n ERC20 rewardToken = fw.rewardToken();\\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\\n if (rewardsAccrued > 0) {\\n rewardToken.transfer(withdrawTo, rewardsAccrued);\\n }\\n }\\n }\\n\\n function rescueTokens(IERC20Upgradeable asset) external {\\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\\n\\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\\n }\\n\\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\\n for (uint256 i = 0; i < rewardTokens.length; i++) {\\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\\n }\\n return (rewardTokens, rewards);\\n }\\n\\n fallback() external {\\n address extension = factory.getPositionsExtension(msg.sig);\\n if (extension == address(0)) revert ExtNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n function getAccruedRewards()\\n external\\n returns (\\n /*view*/\\n ERC20[] memory rewardTokens,\\n uint256[] memory amounts\\n )\\n {\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n rewardTokens = new ERC20[](flywheels.length);\\n amounts = new uint256[](flywheels.length);\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n rewardTokens[i] = fw.rewardToken();\\n amounts[i] = fw.rewardsAccrued(address(this));\\n }\\n }\\n\\n function getCurrentLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtValue = 0;\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n if (debtAmount > 0) {\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n }\\n\\n // TODO check if positionValue > debtValue\\n // s / ( s - b )\\n return (positionValue * 1e18) / (positionValue - debtValue);\\n }\\n\\n function getMinLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\\n }\\n\\n function getMaxLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\\n }\\n\\n function _getLeverageRatioAfterBorrow(\\n uint256 newBorrowsAmount,\\n uint256 positionSupplyAmount,\\n uint256 positionBorrowAmount\\n ) internal view returns (uint256 r) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\\n\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n {\\n // add 10 bps just to not go under the min borrow value\\n assumedSlippage += 10;\\n }\\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\\n\\n int256 s = int256(positionValue);\\n int256 b = int256(currentBorrowsValue);\\n int256 x = int256(topUpCollateralValue);\\n\\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\\n }\\n\\n function isPositionClosed() public view returns (bool) {\\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\\n }\\n\\n function getEquityAmount() external view returns (uint256 equityAmount) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n\\n uint256 equityValue = positionValue - debtValue;\\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\\n }\\n\\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentRatio = getCurrentLeverageRatio();\\n bool up = targetRatio > currentRatio;\\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\\n }\\n\\n function _getSupplyAmountDelta(\\n bool up,\\n uint256 targetRatio,\\n uint256 collateralAssetPrice,\\n uint256 borrowedAssetPrice\\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 assumedSlippage;\\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\\n\\n uint256 supplyValueDeltaAbs;\\n {\\n // s = supply value before\\n // b = borrow value before\\n // r = target ratio after\\n // c = borrow value coefficient to account for the slippage\\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\\n int256 r = int256(targetRatio);\\n int256 r1 = r - 1e18;\\n int256 c = int256(slippageFactor);\\n\\n // some math magic here\\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\\n\\n // x = supplyValueDelta\\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\\n }\\n\\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\\n\\n if (up) {\\n // stables to borrow = c * x\\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\\n } else {\\n // amount to redeem = c * x\\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n Internal Functions\\n ----------------------------------------------------------------*/\\n\\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\\n // in case the funding is with a different asset\\n if (address(collateralAsset) != address(fundingAsset)) {\\n // swap for collateral asset\\n convertAllTo(fundingAsset, collateralAsset);\\n }\\n\\n // supply the collateral\\n amountToSupply = collateralAsset.balanceOf(address(this));\\n collateralAsset.approve(address(collateralMarket), amountToSupply);\\n uint256 errorCode = collateralMarket.mint(amountToSupply);\\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\\n }\\n\\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\\n function _leverUp(uint256 targetRatio) internal {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\\n true,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n\\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n\\n // all stables are swapped for collateral to repay the FL\\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\\n if (collateralLeftovers > 0) {\\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\\n collateralMarket.mint(collateralLeftovers);\\n }\\n }\\n\\n // @dev supply the flash loaned collateral and then borrow stables with it\\n function _leverUpPostFL(uint256 stableToBorrow) internal {\\n // supply the flash loaned collateral\\n _supplyCollateral(collateralAsset);\\n\\n // borrow stables that will be swapped to repay the FL\\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\\n function _leverDown(uint256 targetRatio) internal {\\n uint256 amountToRedeem;\\n uint256 borrowsToRepay;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n if (targetRatio <= 1e18) {\\n // if max levering down, then derive the amount to redeem from the debt to be repaid\\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\\n } else {\\n // else derive the debt to be repaid from the amount to redeem\\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\\n false,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n // the slippage is already accounted for in _getSupplyAmountDelta\\n }\\n\\n if (borrowsToRepay > 0) {\\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n }\\n\\n // all the redeemed collateral is swapped for stables to repay the FL\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n if (stableLeftovers > 0) {\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n if (borrowBalance > 0) {\\n // whatever is smaller\\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\\n stableAsset.approve(address(stableMarket), amountToRepay);\\n stableMarket.repayBorrow(amountToRepay);\\n }\\n }\\n }\\n\\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\\n // repay the borrows\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\\n stableAsset.approve(address(stableMarket), repayAmount);\\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\\n\\n // redeem the corresponding amount needed to repay the FL\\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(collateralAsset, stableAsset);\\n }\\n\\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n private\\n returns (uint256 outputAmount)\\n {\\n uint256 inputAmount = inputToken.balanceOf(address(this));\\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\\n .getRedemptionStrategies(inputToken, outputToken);\\n\\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\\n\\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\\n bytes memory strategyData = strategiesData[i];\\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\\n inputAmount = outputAmount;\\n inputToken = outputToken;\\n }\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.isContract(target), \\\"Address: delegate call to non-contract\\\");\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n if (returndata.length > 0) {\\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\":\"0x544ff68f1ce3eb3a72dbe344a6f208abdfa32a775a52efe6c37f4509956f4342\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\nimport { LeveredPositionFactoryStorage } from \\\"./LeveredPositionFactoryStorage.sol\\\";\\nimport { ILeveredPositionFactorySecondExtension } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { IComptroller, IPriceOracle } from \\\"../../external/compound/IComptroller.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { AuthoritiesRegistry } from \\\"../AuthoritiesRegistry.sol\\\";\\nimport { PoolRolesAuthority } from \\\"../PoolRolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract LeveredPositionFactorySecondExtension is\\n LeveredPositionFactoryStorage,\\n DiamondExtension,\\n ILeveredPositionFactorySecondExtension\\n{\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n error PairNotWhitelisted();\\n\\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\\n uint8 fnsCount = 3;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.createPosition.selector;\\n functionSelectors[--fnsCount] = this.createAndFundPosition.selector;\\n functionSelectors[--fnsCount] = this.createAndFundPositionAtRatio.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) public returns (LeveredPosition) {\\n if (!borrowableMarketsByCollateral[_collateralMarket].contains(address(_stableMarket))) revert PairNotWhitelisted();\\n\\n LeveredPosition position = new LeveredPosition(msg.sender, _collateralMarket, _stableMarket);\\n\\n accountsWithOpenPositions.add(msg.sender);\\n positionsByAccount[msg.sender].add(address(position));\\n\\n AuthoritiesRegistry authoritiesRegistry = feeDistributor.authoritiesRegistry();\\n address poolAddress = address(_collateralMarket.comptroller());\\n PoolRolesAuthority poolAuth = authoritiesRegistry.poolsAuthorities(poolAddress);\\n if (address(poolAuth) != address(0)) {\\n authoritiesRegistry.setUserRole(poolAddress, address(position), poolAuth.LEVERED_POSITION_ROLE(), true);\\n }\\n\\n return position;\\n }\\n\\n function createAndFundPosition(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount\\n ) public returns (LeveredPosition) {\\n LeveredPosition position = createPosition(_collateralMarket, _stableMarket);\\n _fundingAsset.safeTransferFrom(msg.sender, address(this), _fundingAmount);\\n _fundingAsset.approve(address(position), _fundingAmount);\\n position.fundPosition(_fundingAsset, _fundingAmount);\\n return position;\\n }\\n\\n function createAndFundPositionAtRatio(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount,\\n uint256 _leverageRatio\\n ) external returns (LeveredPosition) {\\n LeveredPosition position = createAndFundPosition(_collateralMarket, _stableMarket, _fundingAsset, _fundingAmount);\\n if (_leverageRatio > 1e18) {\\n position.adjustLeverageRatio(_leverageRatio);\\n }\\n return position;\\n }\\n}\\n\",\"keccak256\":\"0x382500af7d15f66826c6a9ac369af80c00ff8f0ca424ef8c9f85e298de02d7d2\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionFactoryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\\n EnumerableSet.AddressSet internal collateralMarkets;\\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\\n\\n IFeeDistributor public feeDistributor;\\n ILiquidatorsRegistry public liquidatorsRegistry;\\n uint256 public blocksPerYear;\\n\\n mapping(bytes4 => address) internal _positionsExtensions;\\n}\\n\",\"keccak256\":\"0x450b84adc8e60b2861c234154e7c137316d216787d5aca83251e77364e1c341f\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ncontract LeveredPositionStorage {\\n address public immutable positionOwner;\\n ILeveredPositionFactory public factory;\\n\\n ICErc20 public collateralMarket;\\n ICErc20 public stableMarket;\\n IonicComptroller public pool;\\n\\n IERC20Upgradeable public collateralAsset;\\n IERC20Upgradeable public stableAsset;\\n\\n constructor(address _positionOwner) {\\n positionOwner = _positionOwner;\\n }\\n}\\n\",\"keccak256\":\"0xe3342347e2315c9a7a8503ef7ba83390f1cd296318a50952a88d984af940e430\",\"license\":\"GPL-3.0\"},\"contracts/ionic/strategies/flywheel/IFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\n\\n/**\\n @title Balance Booster Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \\n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\\n \\n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\\n\\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\\n*/\\ninterface IFlywheelBooster {\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdab1b4b5662148d74acc3491a810d263ec509f9f81a267e9f6c1542ba15eabc\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { IonicFlywheelCore } from \\\"./IonicFlywheelCore.sol\\\";\\nimport \\\"./IIonicFlywheel.sol\\\";\\n\\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\\n bool public constant isRewardsDistributor = true;\\n bool public constant isFlywheel = true;\\n\\n function flywheelPreSupplierAction(address market, address supplier) external {\\n accrue(ERC20(market), supplier);\\n }\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external {}\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external {\\n accrue(ERC20(market), src, dst);\\n }\\n\\n function compAccrued(address user) external view returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n // TODO remove\\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0x60d8d5a8feaa7c0373d24d6fbca523eb86ba251f5374a8821a6aee63cdc90e0d\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/utils/SafeTransferLib.sol\\\";\\nimport { SafeCastLib } from \\\"solmate/utils/SafeCastLib.sol\\\";\\n\\nimport { IFlywheelRewards } from \\\"./rewards/IFlywheelRewards.sol\\\";\\nimport { IFlywheelBooster } from \\\"./IFlywheelBooster.sol\\\";\\n\\nimport { SafeOwnableUpgradeable } from \\\"../../../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\\n using SafeTransferLib for ERC20;\\n using SafeCastLib for uint256;\\n\\n /// @notice How much rewardsToken will be send to treasury\\n uint256 public performanceFee;\\n\\n /// @notice Address that gets rewardsToken accrued by performanceFee\\n address public feeRecipient;\\n\\n /// @notice The token to reward\\n ERC20 public rewardToken;\\n\\n /// @notice append-only list of strategies added\\n ERC20[] public allStrategies;\\n\\n /// @notice the rewards contract for managing streams\\n IFlywheelRewards public flywheelRewards;\\n\\n /// @notice optional booster module for calculating virtual balances on strategies\\n IFlywheelBooster public flywheelBooster;\\n\\n /// @notice The accrued but not yet transferred rewards for each user\\n mapping(address => uint256) internal _rewardsAccrued;\\n\\n /// @notice The strategy index and last updated per strategy\\n mapping(ERC20 => RewardsState) internal _strategyState;\\n\\n /// @notice user index per strategy\\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\\n\\n constructor() {\\n // prevents the misusage of the implementation contract\\n _disableInitializers();\\n }\\n\\n function initialize(\\n ERC20 _rewardToken,\\n IFlywheelRewards _flywheelRewards,\\n IFlywheelBooster _flywheelBooster,\\n address _owner\\n ) public initializer {\\n __SafeOwnable_init(msg.sender);\\n\\n rewardToken = _rewardToken;\\n flywheelRewards = _flywheelRewards;\\n flywheelBooster = _flywheelBooster;\\n\\n _transferOwnership(_owner);\\n\\n performanceFee = 10e16; // 10%\\n feeRecipient = _owner;\\n }\\n\\n /*----------------------------------------------------------------\\n ACCRUE/CLAIM LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a user's rewards accrue to a given strategy.\\n @param strategy the updated rewards strategy\\n @param user the user of the rewards\\n @param rewardsDelta how many new rewards accrued to the user\\n @param rewardsIndex the market index for rewards per token accrued\\n */\\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\\n\\n /** \\n @notice Emitted when a user claims accrued rewards.\\n @param user the user of the rewards\\n @param amount the amount of rewards claimed\\n */\\n event ClaimRewards(address indexed user, uint256 amount);\\n\\n /** \\n @notice accrue rewards for a single user on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the user to be accrued\\n @return the cumulative amount of rewards accrued to user (including prior)\\n */\\n function accrue(ERC20 strategy, address user) public returns (uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return 0;\\n\\n state = accrueStrategy(strategy, state);\\n return accrueUser(strategy, user, state);\\n }\\n\\n /** \\n @notice accrue rewards for a two users on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the first user to be accrued\\n @param user the second user to be accrued\\n @return the cumulative amount of rewards accrued to the first user (including prior)\\n @return the cumulative amount of rewards accrued to the second user (including prior)\\n */\\n function accrue(\\n ERC20 strategy,\\n address user,\\n address secondUser\\n ) public returns (uint256, uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return (0, 0);\\n\\n state = accrueStrategy(strategy, state);\\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\\n }\\n\\n /** \\n @notice claim rewards for a given user\\n @param user the user claiming rewards\\n @dev this function is public, and all rewards transfer to the user\\n */\\n function claimRewards(address user) external {\\n uint256 accrued = rewardsAccrued(user);\\n\\n if (accrued != 0) {\\n _rewardsAccrued[user] = 0;\\n\\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\\n\\n emit ClaimRewards(user, accrued);\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n ADMIN LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a new strategy is added to flywheel by the admin\\n @param newStrategy the new added strategy\\n */\\n event AddStrategy(address indexed newStrategy);\\n\\n /// @notice initialize a new strategy\\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n function _addStrategyForRewards(ERC20 strategy) internal {\\n (uint224 index, ) = strategyState(strategy);\\n require(index == 0, \\\"strategy\\\");\\n _strategyState[strategy] = RewardsState({\\n index: (10**rewardToken.decimals()).safeCastTo224(),\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n\\n allStrategies.push(strategy);\\n emit AddStrategy(address(strategy));\\n }\\n\\n function getAllStrategies() external view returns (ERC20[] memory) {\\n return allStrategies;\\n }\\n\\n /** \\n @notice Emitted when the rewards module changes\\n @param newFlywheelRewards the new rewards module\\n */\\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\\n\\n /// @notice swap out the flywheel rewards contract\\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\\n if (address(flywheelRewards) != address(0)) {\\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\\n if (oldRewardBalance > 0) {\\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\\n }\\n }\\n\\n flywheelRewards = newFlywheelRewards;\\n\\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\\n }\\n\\n /** \\n @notice Emitted when the booster module changes\\n @param newBooster the new booster module\\n */\\n event FlywheelBoosterUpdate(address indexed newBooster);\\n\\n /// @notice swap out the flywheel booster contract\\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\\n flywheelBooster = newBooster;\\n\\n emit FlywheelBoosterUpdate(address(newBooster));\\n }\\n\\n event UpdatedFeeSettings(\\n uint256 oldPerformanceFee,\\n uint256 newPerformanceFee,\\n address oldFeeRecipient,\\n address newFeeRecipient\\n );\\n\\n /**\\n * @notice Update performanceFee and/or feeRecipient\\n * @dev Claim rewards first from the previous feeRecipient before changing it\\n */\\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\\n _updateFeeSettings(_performanceFee, _feeRecipient);\\n }\\n\\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\\n\\n if (feeRecipient != _feeRecipient) {\\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\\n _rewardsAccrued[feeRecipient] = 0;\\n }\\n performanceFee = _performanceFee;\\n feeRecipient = _feeRecipient;\\n }\\n\\n /*----------------------------------------------------------------\\n INTERNAL ACCOUNTING LOGIC\\n ----------------------------------------------------------------*/\\n\\n struct RewardsState {\\n /// @notice The strategy's last updated index\\n uint224 index;\\n /// @notice The timestamp the index was last updated at\\n uint32 lastUpdatedTimestamp;\\n }\\n\\n /// @notice accumulate global rewards on a strategy\\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\\n private\\n returns (RewardsState memory rewardsState)\\n {\\n // calculate accrued rewards through module\\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\\n\\n rewardsState = state;\\n\\n if (strategyRewardsAccrued > 0) {\\n // use the booster or token supply to calculate reward index denominator\\n uint256 supplyTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedTotalSupply(strategy)\\n : strategy.totalSupply();\\n\\n // 100% = 100e16\\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\\n\\n _rewardsAccrued[feeRecipient] += accruedFees;\\n strategyRewardsAccrued -= accruedFees;\\n\\n uint224 deltaIndex;\\n\\n if (supplyTokens != 0)\\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\\n\\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\\n rewardsState = RewardsState({\\n index: state.index + deltaIndex,\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n _strategyState[strategy] = rewardsState;\\n }\\n }\\n\\n /// @notice accumulate rewards on a strategy for a specific user\\n function accrueUser(\\n ERC20 strategy,\\n address user,\\n RewardsState memory state\\n ) private returns (uint256) {\\n // load indices\\n uint224 strategyIndex = state.index;\\n uint224 supplierIndex = userIndex(strategy, user);\\n\\n // sync user index to global\\n _userIndex[strategy][user] = strategyIndex;\\n\\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\\n // zero balances will have no effect other than syncing to global index\\n if (supplierIndex == 0) {\\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\\n }\\n\\n uint224 deltaIndex = strategyIndex - supplierIndex;\\n // use the booster or token balance to calculate reward balance multiplier\\n uint256 supplierTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedBalanceOf(strategy, user)\\n : strategy.balanceOf(user);\\n\\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\\n\\n _rewardsAccrued[user] = supplierAccrued;\\n\\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\\n\\n return supplierAccrued;\\n }\\n\\n function rewardsAccrued(address user) public virtual returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\\n return _userIndex[strategy][user];\\n }\\n\\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0xbd54c90dbc7f93cad52016f14eb5f9b634f98d18da083ef443951deebc5f82aa\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\nimport {IonicFlywheelCore} from \\\"../IonicFlywheelCore.sol\\\";\\n\\n/**\\n @title Rewards Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Rewards module is responsible for:\\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\\n * actually holding rewards that are yet to be claimed\\n\\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\\n\\n Different module strategies include:\\n * a static reward rate per second\\n * a decaying reward rate\\n * a dynamic just-in-time reward stream\\n * liquid governance reward delegation (Curve Gauge style)\\n\\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\\n */\\ninterface IFlywheelRewards {\\n /**\\n @notice calculate the rewards amount accrued to a strategy since the last update.\\n @param strategy the strategy to accrue rewards for.\\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\\n @return rewards the amount of rewards accrued to the market\\n */\\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\\n\\n /// @notice return the flywheel core address\\n function flywheel() external view returns (IonicFlywheelCore);\\n\\n /// @notice return the reward token associated with flywheel core.\\n function rewardToken() external view returns (ERC20);\\n}\\n\",\"keccak256\":\"0x7e966a0e7cc80f799ee7cb3611027381847dafb92b8d8c0f3e96500ecbe217f7\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeCastLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Safe unsigned integer casting library that reverts on overflow.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\\nlibrary SafeCastLib {\\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\\n require(x < 1 << 248);\\n\\n y = uint248(x);\\n }\\n\\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\\n require(x < 1 << 224);\\n\\n y = uint224(x);\\n }\\n\\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\\n require(x < 1 << 192);\\n\\n y = uint192(x);\\n }\\n\\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\\n require(x < 1 << 160);\\n\\n y = uint160(x);\\n }\\n\\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\\n require(x < 1 << 128);\\n\\n y = uint128(x);\\n }\\n\\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\\n require(x < 1 << 96);\\n\\n y = uint96(x);\\n }\\n\\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\\n require(x < 1 << 64);\\n\\n y = uint64(x);\\n }\\n\\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\\n require(x < 1 << 32);\\n\\n y = uint32(x);\\n }\\n\\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\\n require(x < 1 << 24);\\n\\n y = uint24(x);\\n }\\n\\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\\n require(x < 1 << 16);\\n\\n y = uint16(x);\\n }\\n\\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\\n require(x < 1 << 8);\\n\\n y = uint8(x);\\n }\\n}\\n\",\"keccak256\":\"0xb784a14411858036491124e677aecde6d500e695b7a70c74aa8f1001bda2ccab\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), from) // Append the \\\"from\\\" argument.\\n mstore(add(freeMemoryPointer, 36), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 68), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x333b56bef66ff71e3838910781df214acbeb6c2d6ace27a04ebb510f0e669300\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61008b565b600180546001600160a01b03191690556100388161003b565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b615ad48061009a6000396000f3fe60806040523480156200001157600080fd5b5060043610620000c35760003560e01c80637bf8f349116200007a5780637bf8f349146200015157806389f8132e14620001685780638da5cb5b1462000181578063a385fb961462000193578063e30c397814620001ac578063f2fde38b14620001be57600080fd5b80630d43e8ad14620000c857806316bb997f14620000f9578063534da460146200010d5780636969e58b1462000124578063715018a6146200013b57806379ba50971462000147575b600080fd5b600954620000dc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600a54620000dc906001600160a01b031681565b620000dc6200011e36600462000d1a565b620001d5565b620000dc6200013536600462000d7c565b62000273565b6200014562000588565b005b62000145620005df565b620000dc6200016236600462000dba565b6200065d565b620001726200076c565b604051620000f0919062000e12565b6000546001600160a01b0316620000dc565b6200019d600b5481565b604051908152602001620000f0565b6001546001600160a01b0316620000dc565b62000145620001cf36600462000e62565b620008b8565b600080620001e6878787876200065d565b9050670de0b6b3a76400008311156200026957604051639028493360e01b8152600481018490526001600160a01b038216906390284933906024016020604051808303816000875af115801562000241573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000267919062000e82565b505b9695505050505050565b6001600160a01b03821660009081526007602052604081206200029790836200092c565b620002b557604051633f94e3f760e01b815260040160405180910390fd5b6000338484604051620002c89062000cf6565b6001600160a01b03938416815291831660208301529091166040820152606001604051809103906000f08015801562000305573d6000803e3d6000fd5b5090506200031560023362000951565b5033600090815260046020526040902062000331908262000951565b50600954604080516322ab0bc360e21b815290516000926001600160a01b031691638aac2f0c9160048083019260209291908290030181865afa1580156200037d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003a3919062000e9c565b90506000856001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200040c919062000e9c565b60405163ec2ffdd160e01b81526001600160a01b03808316600483015291925060009184169063ec2ffdd190602401602060405180830381865afa15801562000459573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200047f919062000e9c565b90506001600160a01b038116156200057b57826001600160a01b031663ca224d988386846001600160a01b0316633300183c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620004e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000507919062000ebc565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260ff16604482015260016064820152608401600060405180830381600087803b1580156200056157600080fd5b505af115801562000576573d6000803e3d6000fd5b505050505b5091925050505b92915050565b6200059262000968565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b031681146200064f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401620005d6565b6200065a81620009c6565b50565b6000806200066c868662000273565b9050620006856001600160a01b038516333086620009e1565b60405163095ea7b360e01b81526001600160a01b0382811660048301526024820185905285169063095ea7b3906044016020604051808303816000875af1158015620006d5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006fb919062000ee1565b50604051633a8a230760e01b81526001600160a01b03858116600483015260248201859052821690633a8a230790604401600060405180830381600087803b1580156200074757600080fd5b505af11580156200075c573d6000803e3d6000fd5b509293505050505b949350505050565b604080516003808252608082019092526060919060009082602082018580368337019050509050636969e58b60e01b81620007a78462000f05565b93508360ff1681518110620007c057620007c062000f31565b6001600160e01b031990921660209283029190910190910152637bf8f34960e01b81620007ed8462000f05565b93508360ff168151811062000806576200080662000f31565b6001600160e01b03199092166020928302919091019091015263029a6d2360e51b81620008338462000f05565b93508360ff16815181106200084c576200084c62000f31565b6001600160e01b03199092166020928302919091019091015260ff821615620005825760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401620005d6565b620008c262000968565b600180546001600160a01b0383166001600160a01b03199091168117909155620008f46000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b60006200094a836001600160a01b03841662000a43565b6000546001600160a01b03163314620009c45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620005d6565b565b600180546001600160a01b03191690556200065a8162000a95565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905262000a3d90859062000ae5565b50505050565b600081815260018301602052604081205462000a8c5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000582565b50600062000582565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600062000b3c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000bc39092919063ffffffff16565b80519091501562000bbe578080602001905181019062000b5d919062000ee1565b62000bbe5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620005d6565b505050565b606062000764848460008585600080866001600160a01b0316858760405162000bed919062000f6d565b60006040518083038185875af1925050503d806000811462000c2c576040519150601f19603f3d011682016040523d82523d6000602084013e62000c31565b606091505b509150915062000c448783838762000c4f565b979650505050505050565b6060831562000cc357825160000362000cbb576001600160a01b0385163b62000cbb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620005d6565b508162000764565b62000764838381511562000cda5781518083602001fd5b8060405162461bcd60e51b8152600401620005d6919062000f8b565b614ade8062000fc183390190565b6001600160a01b03811681146200065a57600080fd5b600080600080600060a0868803121562000d3357600080fd5b853562000d408162000d04565b9450602086013562000d528162000d04565b9350604086013562000d648162000d04565b94979396509394606081013594506080013592915050565b6000806040838503121562000d9057600080fd5b823562000d9d8162000d04565b9150602083013562000daf8162000d04565b809150509250929050565b6000806000806080858703121562000dd157600080fd5b843562000dde8162000d04565b9350602085013562000df08162000d04565b9250604085013562000e028162000d04565b9396929550929360600135925050565b6020808252825182820181905260009190848201906040850190845b8181101562000e565783516001600160e01b0319168352928401929184019160010162000e2e565b50909695505050505050565b60006020828403121562000e7557600080fd5b81356200094a8162000d04565b60006020828403121562000e9557600080fd5b5051919050565b60006020828403121562000eaf57600080fd5b81516200094a8162000d04565b60006020828403121562000ecf57600080fd5b815160ff811681146200094a57600080fd5b60006020828403121562000ef457600080fd5b815180151581146200094a57600080fd5b600060ff82168062000f2757634e487b7160e01b600052601160045260246000fd5b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b60005b8381101562000f6457818101518382015260200162000f4a565b50506000910152565b6000825162000f8181846020870162000f47565b9190910192915050565b602081526000825180602084015262000fac81604085016020870162000f47565b601f01601f1916919091016040019291505056fe60a06040523480156200001157600080fd5b5060405162004ade38038062004ade8339810160408190526200003491620002e5565b6001600160a01b0380841660805260408051635fe3b56760e01b81529051600092851691635fe3b5679160048083019260209291908290030181865afa15801562000083573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000a9919062000339565b90506000826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000112919062000339565b9050806001600160a01b0316826001600160a01b0316146200017a5760405162461bcd60e51b815260206004820152601460248201527f6d61726b65747320706f6f6c7320646966666572000000000000000000000000604482015260640160405180910390fd5b600380546001600160a01b038085166001600160a01b03199283161790925560018054928716929091168217905560408051636f307dc360e01b81529051636f307dc3916004808201926020929091908290030181865afa158015620001e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020a919062000339565b600480546001600160a01b039283166001600160a01b031991821617825560028054938716939091168317905560408051636f307dc360e01b81529051636f307dc3928281019260209291908290030181865afa15801562000270573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000296919062000339565b600580546001600160a01b03929092166001600160a01b0319928316179055600080549091163317905550620003609350505050565b6001600160a01b0381168114620002e257600080fd5b50565b600080600060608486031215620002fb57600080fd5b83516200030881620002cc565b60208501519093506200031b81620002cc565b60408501519092506200032e81620002cc565b809150509250925092565b6000602082840312156200034c57600080fd5b81516200035981620002cc565b9392505050565b608051614738620003a6600039600081816103ec01528181610534015281816107af015281816114160152818161155001528181611b1e0152611ee701526147386000f3fe608060405234801561001057600080fd5b50600436106101575760003560e01c806393ff897b116100c3578063b21fd0291161007c578063b21fd029146103b1578063c31443bb146103c4578063c393d0e3146103cc578063c45a0155146103d4578063cb2af14b146103e7578063ef5cfb8c1461040e57610157565b806393ff897b1461033c578063958fa2801461035d578063a415deda14610370578063a7e269a614610383578063a833cb7f14610396578063aabaecd61461039e57610157565b80633a8a2307116101155780633a8a2307146102cd5780633e2f147f146102e0578063459b9ef1146102f8578063555b334a146103005780636813f99914610316578063902849331461032957610157565b8062ae3bf81461023157806316f0115b146102445780631d7d45b3146102745780632f86e2dd1461029c578063372500ab146102bd57806337460704146102c5575b60008054604051634377ba4160e11b815282356001600160e01b03191660048201526001600160a01b03909116906386ef748290602401602060405180830381865afa1580156101ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cf9190613e62565b90506001600160a01b03811661020b57604051637d60257960e01b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e80801561022a573d6000f35b3d6000fd5b005b61022f61023f366004613e7f565b610421565b600354610257906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610287610282366004613e9c565b610613565b6040805192835260208301919091520161026b565b6102af6102aa366004613e7f565b6107a2565b60405190815260200161026b565b61022f610b43565b6102af610b4e565b61022f6102db366004613eb5565b610cda565b6102e8610e41565b604051901515815260200161026b565b6102af610eb4565b6103086110c6565b60405161026b929190613f1d565b600554610257906001600160a01b031681565b6102af610337366004613e9c565b611409565b61034f61034a366004613e7f565b6114c1565b60405161026b929190613fb8565b61022f61036b366004613fdd565b6115cf565b600154610257906001600160a01b031681565b600254610257906001600160a01b031681565b6102af61184f565b600454610257906001600160a01b031681565b6102af6103bf366004613e7f565b611b11565b6102af611c08565b6102af611ecc565b600054610257906001600160a01b031681565b6102577f000000000000000000000000000000000000000000000000000000000000000081565b61022f61041c366004613e7f565b611edc565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104969190613e62565b6001600160a01b0316336001600160a01b0316146104c7576040516325f8474360e11b815260040160405180910390fd5b6005546001600160a01b03828116911614806104f057506004546001600160a01b038281169116145b1561050e57604051631c5c3c5b60e21b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b0382169063a9059cbb907f00000000000000000000000000000000000000000000000000000000000000009083906370a0823190602401602060405180830381865afa15801561057c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a09190614066565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156105eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060f919061407f565b5050565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561066b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068f9190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa1580156106df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107039190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa158015610753573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107779190614066565b90506000610783611c08565b905080871161079481898587612285565b965096505050505050915091565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015906107e857506000546001600160a01b03163314155b15610806576040516370d645e360e01b815260040160405180910390fd5b610817670de0b6b3a76400006126fa565b600160009054906101000a90046001600160a01b03166001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561086c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108909190614066565b50600354600154604051630ede4edd60e41b81526001600160a01b039182166004820152600092919091169063ede4edd0906024016020604051808303816000875af11580156108e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109089190614066565b9050801561092c5760405163059548ef60e51b815260048101829052602401610202565b6001546040516370a0823160e01b81523060048201526001600160a01b039091169063db006a759082906370a0823190602401602060405180830381865afa15801561097c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a09190614066565b6040518263ffffffff1660e01b81526004016109be91815260200190565b6020604051808303816000875af11580156109dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a019190614066565b90508015610a255760405163eeddaac560e01b815260048101829052602401610202565b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a929190614066565b1115610ab657600554600454610ab4916001600160a01b039081169116612cc2565b505b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190614066565b600454909250610b3d906001600160a01b03168484612e45565b50919050565b610b4c33611edc565b565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190614066565b905080600003610bd157600091505090565b600354600254604051630cbb414760e11b81523060048201526001600160a01b039182166024820152600160448201526000929190911690631976828e90606401602060405180830381865afa158015610c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c539190614066565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015610ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc59190614066565b9050610cd2828483612ea8565b935050505090565b610cef6001600160a01b0383163330846131f1565b610cf882613229565b5060035460015460405163929fe9a160e01b81526001600160a01b039283169263929fe9a192610d30923092909116906004016140a1565b602060405180830381865afa158015610d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d71919061407f565b61060f5760408051600180825281830190925260009160208083019080368337505060015482519293506001600160a01b031691839150600090610db757610db76140d1565b6001600160a01b039283166020918202929092010152600354604051631853304760e31b815291169063c299823890610df49084906004016140e7565b6000604051808303816000875af1158015610e13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e3b91908101906141be565b50505050565b600154604051633af9e66960e01b81523060048201526000916001600160a01b031690633af9e66990602401602060405180830381865afa158015610e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eae9190614066565b15919050565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015610f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f259190614066565b905080600003610f3757600091505090565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015610f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa59190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110199190614066565b905060008160008054906101000a90046001600160a01b03166001600160a01b0316630da2262c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561106f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110939190614066565b6110a590670de0b6b3a7640000614209565b6110af9190614236565b90506110bd81856000612ea8565b94505050505090565b6060806000600360009054906101000a90046001600160a01b03166001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561111e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261114691908101906142b2565b9050805167ffffffffffffffff811115611162576111626140bb565b60405190808252806020026020018201604052801561118b578160200160208202803683370190505b509250805167ffffffffffffffff8111156111a8576111a86140bb565b6040519080825280602002602001820160405280156111d1578160200160208202803683370190505b50915060005b81518110156114035760008282815181106111f4576111f46140d1565b6020908102919091010151600154604051632e6f912b60e21b81529192506001600160a01b038084169263b9be44ac9261123492169030906004016140a1565b6020604051808303816000875af1158015611253573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112779190614066565b50600254604051632e6f912b60e21b81526001600160a01b038381169263b9be44ac926112ac929091169030906004016140a1565b6020604051808303816000875af11580156112cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ef9190614066565b50806001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa15801561132e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113529190613e62565b858381518110611364576113646140d1565b6001600160a01b039283166020918202929092010152604051630ff6b5a760e31b815230600482015290821690637fb5ad38906024016020604051808303816000875af11580156113b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113dd9190614066565b8483815181106113ef576113ef6140d1565b6020908102919091010152506001016111d7565b50509091565b6000336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480159061144f57506000546001600160a01b03163314155b1561146d576040516370d645e360e01b815260040160405180910390fd5b670de0b6b3a7640000821161148d5761148d670de0b6b3a76400006126fa565b81611496611c08565b10156114aa576114a5826133dd565b6114b3565b6114b3826126fa565b6114bb611c08565b92915050565b604051639cf1fd5360e01b81523060048201526060908190839060009081906001600160a01b03841690639cf1fd53906024016000604051808303816000875af1158015611513573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261153b91908101906142e7565b9150915060005b82518110156115c3576115bb7f0000000000000000000000000000000000000000000000000000000000000000838381518110611581576115816140d1565b602002602001015185848151811061159b5761159b6140d1565b60200260200101516001600160a01b0316612e459092919063ffffffff16565b600101611542565b50909590945092505050565b6001546001600160a01b031633036116b65760006115ef82840184613e9c565b90506115fa8161372a565b600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166c9190614066565b9050848110156116af57600480546040516319ad25f160e11b81526001600160a01b03909116918101919091526024810182905260448101869052606401610202565b50506117d7565b6002546001600160a01b0316330361178f5760006116d682840184613e9c565b90506116e284826137f0565b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f9190614066565b9050848110156116af576005546040516319ad25f160e11b81526001600160a01b0390911660048201526024810182905260448101869052606401610202565b60405162461bcd60e51b815260206004820152601b60248201527f21666c206e6f742066726f6d20656974686572206d61726b65747300000000006044820152606401610202565b60405163095ea7b360e01b8152336004820152602481018490526001600160a01b0385169063095ea7b3906044016020604051808303816000875af1158015611824573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611848919061407f565b5050505050565b600080600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c99190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015611919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193d9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561198d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b19190614066565b600154604051633af9e66960e01b81523060048201529192506000916001600160a01b0390911690633af9e66990602401602060405180830381865afa1580156119ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a239190614066565b90506000670de0b6b3a7640000611a3a8385614209565b611a449190614236565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015611a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab69190614066565b90506000670de0b6b3a7640000611acd8388614209565b611ad79190614236565b90506000611ae5828561434b565b905085611afa82670de0b6b3a7640000614209565b611b049190614236565b9850505050505050505090565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611b5c576040516370d645e360e01b815260040160405180910390fd5b611b64610e41565b611b815760405163716041e560e01b815260040160405180910390fd5b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611bca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bee9190614066565b6005549091506114bb906001600160a01b03168483612e45565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015611c55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c799190614066565b905080600003611c8b57600091505090565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015611cd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf99190613e62565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015611d49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6d9190614066565b90506000670de0b6b3a7640000611d848584614209565b611d8e9190614236565b6002546040516305eff7ef60e21b815230600482015291925060009182916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015611ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e009190614066565b90508015611e9b5760025460405163fc57d4df60e01b81526001600160a01b03918216600482015260009187169063fc57d4df90602401602060405180830381865afa158015611e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e789190614066565b9050670de0b6b3a7640000611e8d8383614209565b611e979190614236565b9250505b611ea5828461434b565b611eb784670de0b6b3a7640000614209565b611ec19190614236565b965050505050505090565b6000611ed7336107a2565b905090565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801590611f2057506000546001600160a01b03163314155b15611f3e576040516370d645e360e01b815260040160405180910390fd5b60035460408051633605b51b60e01b815290516000926001600160a01b031691633605b51b91600480830192869291908290030181865afa158015611f87573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611faf91908101906142b2565b905060005b8151811015612280576000828281518110611fd157611fd16140d1565b6020908102919091010151600154604051632e6f912b60e21b81529192506001600160a01b038084169263b9be44ac9261201192169030906004016140a1565b6020604051808303816000875af1158015612030573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120549190614066565b50600254604051632e6f912b60e21b81526001600160a01b038381169263b9be44ac92612089929091169030906004016140a1565b6020604051808303816000875af11580156120a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cc9190614066565b50604051633bd73ee360e21b81523060048201526001600160a01b0382169063ef5cfb8c90602401600060405180830381600087803b15801561210e57600080fd5b505af1158015612122573d6000803e3d6000fd5b505050506000816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218a9190613e62565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156121d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f89190614066565b905080156122755760405163a9059cbb60e01b81526001600160a01b0387811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af115801561224f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612273919061407f565b505b505050600101611fb4565b505050565b600154604051633af9e66960e01b8152306004820152600091829182916001600160a01b031690633af9e66990602401602060405180830381865afa1580156122d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f69190614066565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123689190614066565b9050600088156124675760008054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e79190613e62565b60055460048054604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461241f949082169390911691016140a1565b602060405180830381865afa15801561243c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124609190614066565b9050612557565b60008054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124dc9190613e62565b60048054600554604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b946125139482169390911691016140a1565b602060405180830381865afa158015612530573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125549190614066565b90505b6000612710612566838261435e565b61257890670de0b6b3a7640000614209565b6125829190614236565b9050600080670de0b6b3a764000061259a878c614209565b6125a49190614236565b90506000670de0b6b3a76400006125bb878c614209565b6125c59190614236565b90508b60006125dc670de0b6b3a764000083614371565b90508560006125f383670de0b6b3a7640000614398565b6125fd8584614398565b6126079190614371565b6126118587614398565b61261b8886614398565b6126259190614371565b61263790670de0b6b3a7640000614398565b61264191906143c8565b905060008112612651578061265a565b61265a816143f6565b96505050505050508881670de0b6b3a76400006126779190614209565b6126819190614236565b96508761269682670de0b6b3a7640000614209565b6126a09190614236565b95508a156126cc57670de0b6b3a76400006126bb8388614209565b6126c59190614236565b95506126ec565b670de0b6b3a76400006126df8389614209565b6126e99190614236565b96505b505050505094509492505050565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127769190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa1580156127c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ea9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561283a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285e9190614066565b9050670de0b6b3a76400008611612a36576002546040516305eff7ef60e21b81523060048201526001600160a01b03909116906317bfdfbc90602401602060405180830381865afa1580156128b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128db9190614066565b935060006128e98386614209565b905060008060009054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129639190613e62565b60048054600554604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461299a9482169390911691016140a1565b602060405180830381865afa1580156129b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129db9190614066565b905060006127106129ec838261435e565b6129f69085614209565b612a009190614236565b9050612a0c8482614236565b97506000612a1a8583614412565b1115612a2e57612a2b60018961435e565b97505b505050612a49565b612a436000878385612285565b90955093505b8315612ace576002546040805160208082018990528251808303909101815281830192839052633c3b4b8960e01b9092526001600160a01b0390921691633c3b4b8991612a9b91889190604401614476565b600060405180830381600087803b158015612ab557600080fd5b505af1158015612ac9573d6000803e3d6000fd5b505050505b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612b17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3b9190614066565b90508015612cb9576002546040516305eff7ef60e21b81523060048201526000916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015612b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bb09190614066565b90508015612cb7576000828211612bc75781612bc9565b825b60055460025460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b3906044016020604051808303816000875af1158015612c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c44919061407f565b5060025460405163073a938160e11b8152600481018390526001600160a01b0390911690630e752702906024016020604051808303816000875af1158015612c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb49190614066565b50505b505b50505050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015612d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2f9190614066565b6000805460405163ed287f3f60e01b8152929350909182916001600160a01b03169063ed287f3f90612d6790899089906004016140a1565b600060405180830381865afa158015612d84573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612dac9190810190614574565b915091508151600003612dd257604051634fd1fa8360e11b815260040160405180910390fd5b60005b8251811015612e3b576000838281518110612df257612df26140d1565b602002602001015190506000838381518110612e1057612e106140d1565b60200260200101519050612e2689878484613a36565b90995089985096508695505050600101612dd5565b5050505092915050565b6040516001600160a01b03831660248201526044810182905261228090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ab7565b600080600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612efe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f229190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015612f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f969190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa158015612fe6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061300a9190614066565b90506000670de0b6b3a76400006130218488614209565b61302b9190614236565b90506000670de0b6b3a7640000613042858b614209565b61304c9190614236565b90506000670de0b6b3a7640000613063858b614209565b61306d9190614236565b905060008060009054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e79190613e62565b60055460048054604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461311f949082169390911691016140a1565b602060405180830381865afa15801561313c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131609190614066565b905061316d600a8261435e565b9050600061317d8261271061435e565b61318985612710614209565b6131939190614236565b905082858286826131a4838661462f565b6131ae9190614371565b6131b89190614371565b6131c2828561462f565b6131d490670de0b6b3a7640000614398565b6131de91906143c8565b9f9e505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e3b9085906323b872dd60e01b90608401612e71565b6004546000906001600160a01b0383811691161461325a576004546132589083906001600160a01b0316612cc2565b505b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa1580156132a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c79190614066565b6004805460015460405163095ea7b360e01b81526001600160a01b039182169381019390935260248301849052929350919091169063095ea7b3906044016020604051808303816000875af1158015613324573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613348919061407f565b5060015460405163140e25ad60e31b8152600481018390526000916001600160a01b03169063a0712d68906024016020604051808303816000875af1158015613395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b99190614066565b90508015610b3d57604051631a25a97b60e31b815260048101829052602401610202565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015613427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344b9190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa15801561349b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134bf9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561350f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135339190614066565b90506000806135456001878587612285565b6001546040805160208082018590528251808303909101815281830192839052633c3b4b8960e01b9092529395509193506001600160a01b031691633c3b4b899161359591869190604401614476565b600060405180830381600087803b1580156135af57600080fd5b505af11580156135c3573d6000803e3d6000fd5b5050600480546040516370a0823160e01b81523092810192909252600093506001600160a01b031691506370a0823190602401602060405180830381865afa158015613613573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136379190614066565b90508015612cb9576004805460015460405163095ea7b360e01b81526001600160a01b039182169381019390935260248301849052169063095ea7b3906044016020604051808303816000875af1158015613696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ba919061407f565b5060015460405163140e25ad60e31b8152600481018390526001600160a01b039091169063a0712d68906024016020604051808303816000875af1158015613706573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb79190614066565b60045461373f906001600160a01b0316613229565b5060025460405163317afabb60e21b8152600481018390526000916001600160a01b03169063c5ebeaec906024016020604051808303816000875af115801561378c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b09190614066565b905080156137d457604051636f86fa6b60e11b815260048101829052602401610202565b600554600454612280916001600160a01b039081169116612cc2565b6002546040516305eff7ef60e21b81523060048201526000916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015613839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385d9190614066565b9050600081841061386e5781613870565b835b60055460025460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b3906044016020604051808303816000875af11580156138c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138eb919061407f565b5060025460405163073a938160e11b8152600481018390526000916001600160a01b031690630e752702906024016020604051808303816000875af1158015613938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061395c9190614066565b9050801561397f5760405162f0f70d60e41b815260048101829052602401610202565b60015460405163852a12e360e01b8152600481018690526001600160a01b039091169063852a12e3906024016020604051808303816000875af11580156139ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ee9190614066565b90508015613a125760405163213e72eb60e11b815260048101829052602401610202565b600454600554613a2e916001600160a01b039081169116612cc2565b505050505050565b6000806000613a93856310badf4e60e01b898988604051602401613a5c93929190614657565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613b89565b905080806020019051810190613aa9919061467e565b925092505094509492505050565b6000613b0c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c7d9092919063ffffffff16565b8051909150156122805780806020019051810190613b2a919061407f565b6122805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610202565b60606001600160a01b0383163b613bf15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610202565b600080846001600160a01b031684604051613c0c91906146ac565b600060405180830381855af49150503d8060008114613c47576040519150601f19603f3d011682016040523d82523d6000602084013e613c4c565b606091505b5091509150613c7482826040518060600160405280602781526020016146dc60279139613c96565b95945050505050565b6060613c8c8484600085613ccf565b90505b9392505050565b60608315613ca5575081613c8f565b825115613cb55782518084602001fd5b8160405162461bcd60e51b815260040161020291906146c8565b606082471015613d305760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610202565b600080866001600160a01b03168587604051613d4c91906146ac565b60006040518083038185875af1925050503d8060008114613d89576040519150601f19603f3d011682016040523d82523d6000602084013e613d8e565b606091505b5091509150613d9f87838387613dac565b925050505b949350505050565b60608315613e1b578251600003613e14576001600160a01b0385163b613e145760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610202565b5081613da4565b613da48383815115613e305781518083602001fd5b8060405162461bcd60e51b815260040161020291906146c8565b6001600160a01b0381168114613e5f57600080fd5b50565b600060208284031215613e7457600080fd5b8151613c8f81613e4a565b600060208284031215613e9157600080fd5b8135613c8f81613e4a565b600060208284031215613eae57600080fd5b5035919050565b60008060408385031215613ec857600080fd5b8235613ed381613e4a565b946020939093013593505050565b60008151808452602080850194506020840160005b83811015613f1257815187529582019590820190600101613ef6565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015613f5f5781516001600160a01b031684529284019290840190600101613f3a565b5050508381036020850152613f748186613ee1565b9695505050505050565b60008151808452602080850194506020840160005b83811015613f125781516001600160a01b031687529582019590820190600101613f93565b604081526000613fcb6040830185613f7e565b8281036020840152613c748185613ee1565b60008060008060608587031215613ff357600080fd5b8435613ffe81613e4a565b935060208501359250604085013567ffffffffffffffff8082111561402257600080fd5b818701915087601f83011261403657600080fd5b81358181111561404557600080fd5b88602082850101111561405757600080fd5b95989497505060200194505050565b60006020828403121561407857600080fd5b5051919050565b60006020828403121561409157600080fd5b81518015158114613c8f57600080fd5b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b602081526000613c8f6020830184613f7e565b604051601f8201601f1916810167ffffffffffffffff81118282101715614123576141236140bb565b604052919050565b600067ffffffffffffffff821115614145576141456140bb565b5060051b60200190565b600082601f83011261416057600080fd5b815160206141756141708361412b565b6140fa565b8083825260208201915060208460051b87010193508684111561419757600080fd5b602086015b848110156141b3578051835291830191830161419c565b509695505050505050565b6000602082840312156141d057600080fd5b815167ffffffffffffffff8111156141e757600080fd5b613da48482850161414f565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176114bb576114bb6141f3565b634e487b7160e01b600052601260045260246000fd5b60008261424557614245614220565b500490565b600082601f83011261425b57600080fd5b8151602061426b6141708361412b565b8083825260208201915060208460051b87010193508684111561428d57600080fd5b602086015b848110156141b35780516142a581613e4a565b8352918301918301614292565b6000602082840312156142c457600080fd5b815167ffffffffffffffff8111156142db57600080fd5b613da48482850161424a565b600080604083850312156142fa57600080fd5b825167ffffffffffffffff8082111561431257600080fd5b61431e8683870161424a565b9350602085015191508082111561433457600080fd5b506143418582860161414f565b9150509250929050565b818103818111156114bb576114bb6141f3565b808201808211156114bb576114bb6141f3565b8181036000831280158383131683831282161715614391576143916141f3565b5092915050565b80820260008212600160ff1b841416156143b4576143b46141f3565b81810583148215176114bb576114bb6141f3565b6000826143d7576143d7614220565b600160ff1b8214600019841416156143f1576143f16141f3565b500590565b6000600160ff1b820161440b5761440b6141f3565b5060000390565b60008261442157614421614220565b500690565b60005b83811015614441578181015183820152602001614429565b50506000910152565b60008151808452614462816020860160208601614426565b601f01601f19169290920160200192915050565b828152604060208201526000613c8c604083018461444a565b6000601f83601f8401126144a257600080fd5b825160206144b26141708361412b565b82815260059290921b850181019181810190878411156144d157600080fd5b8287015b8481101561456857805167ffffffffffffffff808211156144f65760008081fd5b818a0191508a603f83011261450b5760008081fd5b85820151604082821115614521576145216140bb565b614532828b01601f191689016140fa565b92508183528c818386010111156145495760008081fd5b61455882898501838701614426565b50508452509183019183016144d5565b50979650505050505050565b6000806040838503121561458757600080fd5b825167ffffffffffffffff8082111561459f57600080fd5b818501915085601f8301126145b357600080fd5b815160206145c36141708361412b565b82815260059290921b840181019181810190898411156145e257600080fd5b948201945b838610156146095785516145fa81613e4a565b825294820194908201906145e7565b9188015191965090935050508082111561462257600080fd5b506143418582860161448f565b808201828112600083128015821682158216171561464f5761464f6141f3565b505092915050565b60018060a01b0384168152826020820152606060408201526000613c74606083018461444a565b6000806040838503121561469157600080fd5b825161469c81613e4a565b6020939093015192949293505050565b600082516146be818460208701614426565b9190910192915050565b602081526000613c8f602083018461444a56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220bb947124d5177e7907e7c523985f4cbd8f35b3017c860b0dc112e792211cf00464736f6c63430008160033a2646970667358221220f99d272d310f040b1e014f4ec228cc0f3b901ca3c92cbd1f0ff83ea29d29f1be64736f6c63430008160033", + "deployedBytecode": "0x60806040523480156200001157600080fd5b5060043610620000c35760003560e01c80637bf8f349116200007a5780637bf8f349146200015157806389f8132e14620001685780638da5cb5b1462000181578063a385fb961462000193578063e30c397814620001ac578063f2fde38b14620001be57600080fd5b80630d43e8ad14620000c857806316bb997f14620000f9578063534da460146200010d5780636969e58b1462000124578063715018a6146200013b57806379ba50971462000147575b600080fd5b600954620000dc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600a54620000dc906001600160a01b031681565b620000dc6200011e36600462000d1a565b620001d5565b620000dc6200013536600462000d7c565b62000273565b6200014562000588565b005b62000145620005df565b620000dc6200016236600462000dba565b6200065d565b620001726200076c565b604051620000f0919062000e12565b6000546001600160a01b0316620000dc565b6200019d600b5481565b604051908152602001620000f0565b6001546001600160a01b0316620000dc565b62000145620001cf36600462000e62565b620008b8565b600080620001e6878787876200065d565b9050670de0b6b3a76400008311156200026957604051639028493360e01b8152600481018490526001600160a01b038216906390284933906024016020604051808303816000875af115801562000241573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000267919062000e82565b505b9695505050505050565b6001600160a01b03821660009081526007602052604081206200029790836200092c565b620002b557604051633f94e3f760e01b815260040160405180910390fd5b6000338484604051620002c89062000cf6565b6001600160a01b03938416815291831660208301529091166040820152606001604051809103906000f08015801562000305573d6000803e3d6000fd5b5090506200031560023362000951565b5033600090815260046020526040902062000331908262000951565b50600954604080516322ab0bc360e21b815290516000926001600160a01b031691638aac2f0c9160048083019260209291908290030181865afa1580156200037d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003a3919062000e9c565b90506000856001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200040c919062000e9c565b60405163ec2ffdd160e01b81526001600160a01b03808316600483015291925060009184169063ec2ffdd190602401602060405180830381865afa15801562000459573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200047f919062000e9c565b90506001600160a01b038116156200057b57826001600160a01b031663ca224d988386846001600160a01b0316633300183c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620004e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000507919062000ebc565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260ff16604482015260016064820152608401600060405180830381600087803b1580156200056157600080fd5b505af115801562000576573d6000803e3d6000fd5b505050505b5091925050505b92915050565b6200059262000968565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b031681146200064f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401620005d6565b6200065a81620009c6565b50565b6000806200066c868662000273565b9050620006856001600160a01b038516333086620009e1565b60405163095ea7b360e01b81526001600160a01b0382811660048301526024820185905285169063095ea7b3906044016020604051808303816000875af1158015620006d5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006fb919062000ee1565b50604051633a8a230760e01b81526001600160a01b03858116600483015260248201859052821690633a8a230790604401600060405180830381600087803b1580156200074757600080fd5b505af11580156200075c573d6000803e3d6000fd5b509293505050505b949350505050565b604080516003808252608082019092526060919060009082602082018580368337019050509050636969e58b60e01b81620007a78462000f05565b93508360ff1681518110620007c057620007c062000f31565b6001600160e01b031990921660209283029190910190910152637bf8f34960e01b81620007ed8462000f05565b93508360ff168151811062000806576200080662000f31565b6001600160e01b03199092166020928302919091019091015263029a6d2360e51b81620008338462000f05565b93508360ff16815181106200084c576200084c62000f31565b6001600160e01b03199092166020928302919091019091015260ff821615620005825760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401620005d6565b620008c262000968565b600180546001600160a01b0383166001600160a01b03199091168117909155620008f46000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b60006200094a836001600160a01b03841662000a43565b6000546001600160a01b03163314620009c45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620005d6565b565b600180546001600160a01b03191690556200065a8162000a95565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905262000a3d90859062000ae5565b50505050565b600081815260018301602052604081205462000a8c5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000582565b50600062000582565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600062000b3c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000bc39092919063ffffffff16565b80519091501562000bbe578080602001905181019062000b5d919062000ee1565b62000bbe5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620005d6565b505050565b606062000764848460008585600080866001600160a01b0316858760405162000bed919062000f6d565b60006040518083038185875af1925050503d806000811462000c2c576040519150601f19603f3d011682016040523d82523d6000602084013e62000c31565b606091505b509150915062000c448783838762000c4f565b979650505050505050565b6060831562000cc357825160000362000cbb576001600160a01b0385163b62000cbb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620005d6565b508162000764565b62000764838381511562000cda5781518083602001fd5b8060405162461bcd60e51b8152600401620005d6919062000f8b565b614ade8062000fc183390190565b6001600160a01b03811681146200065a57600080fd5b600080600080600060a0868803121562000d3357600080fd5b853562000d408162000d04565b9450602086013562000d528162000d04565b9350604086013562000d648162000d04565b94979396509394606081013594506080013592915050565b6000806040838503121562000d9057600080fd5b823562000d9d8162000d04565b9150602083013562000daf8162000d04565b809150509250929050565b6000806000806080858703121562000dd157600080fd5b843562000dde8162000d04565b9350602085013562000df08162000d04565b9250604085013562000e028162000d04565b9396929550929360600135925050565b6020808252825182820181905260009190848201906040850190845b8181101562000e565783516001600160e01b0319168352928401929184019160010162000e2e565b50909695505050505050565b60006020828403121562000e7557600080fd5b81356200094a8162000d04565b60006020828403121562000e9557600080fd5b5051919050565b60006020828403121562000eaf57600080fd5b81516200094a8162000d04565b60006020828403121562000ecf57600080fd5b815160ff811681146200094a57600080fd5b60006020828403121562000ef457600080fd5b815180151581146200094a57600080fd5b600060ff82168062000f2757634e487b7160e01b600052601160045260246000fd5b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b60005b8381101562000f6457818101518382015260200162000f4a565b50506000910152565b6000825162000f8181846020870162000f47565b9190910192915050565b602081526000825180602084015262000fac81604085016020870162000f47565b601f01601f1916919091016040019291505056fe60a06040523480156200001157600080fd5b5060405162004ade38038062004ade8339810160408190526200003491620002e5565b6001600160a01b0380841660805260408051635fe3b56760e01b81529051600092851691635fe3b5679160048083019260209291908290030181865afa15801562000083573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000a9919062000339565b90506000826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000112919062000339565b9050806001600160a01b0316826001600160a01b0316146200017a5760405162461bcd60e51b815260206004820152601460248201527f6d61726b65747320706f6f6c7320646966666572000000000000000000000000604482015260640160405180910390fd5b600380546001600160a01b038085166001600160a01b03199283161790925560018054928716929091168217905560408051636f307dc360e01b81529051636f307dc3916004808201926020929091908290030181865afa158015620001e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020a919062000339565b600480546001600160a01b039283166001600160a01b031991821617825560028054938716939091168317905560408051636f307dc360e01b81529051636f307dc3928281019260209291908290030181865afa15801562000270573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000296919062000339565b600580546001600160a01b03929092166001600160a01b0319928316179055600080549091163317905550620003609350505050565b6001600160a01b0381168114620002e257600080fd5b50565b600080600060608486031215620002fb57600080fd5b83516200030881620002cc565b60208501519093506200031b81620002cc565b60408501519092506200032e81620002cc565b809150509250925092565b6000602082840312156200034c57600080fd5b81516200035981620002cc565b9392505050565b608051614738620003a6600039600081816103ec01528181610534015281816107af015281816114160152818161155001528181611b1e0152611ee701526147386000f3fe608060405234801561001057600080fd5b50600436106101575760003560e01c806393ff897b116100c3578063b21fd0291161007c578063b21fd029146103b1578063c31443bb146103c4578063c393d0e3146103cc578063c45a0155146103d4578063cb2af14b146103e7578063ef5cfb8c1461040e57610157565b806393ff897b1461033c578063958fa2801461035d578063a415deda14610370578063a7e269a614610383578063a833cb7f14610396578063aabaecd61461039e57610157565b80633a8a2307116101155780633a8a2307146102cd5780633e2f147f146102e0578063459b9ef1146102f8578063555b334a146103005780636813f99914610316578063902849331461032957610157565b8062ae3bf81461023157806316f0115b146102445780631d7d45b3146102745780632f86e2dd1461029c578063372500ab146102bd57806337460704146102c5575b60008054604051634377ba4160e11b815282356001600160e01b03191660048201526001600160a01b03909116906386ef748290602401602060405180830381865afa1580156101ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cf9190613e62565b90506001600160a01b03811661020b57604051637d60257960e01b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e80801561022a573d6000f35b3d6000fd5b005b61022f61023f366004613e7f565b610421565b600354610257906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610287610282366004613e9c565b610613565b6040805192835260208301919091520161026b565b6102af6102aa366004613e7f565b6107a2565b60405190815260200161026b565b61022f610b43565b6102af610b4e565b61022f6102db366004613eb5565b610cda565b6102e8610e41565b604051901515815260200161026b565b6102af610eb4565b6103086110c6565b60405161026b929190613f1d565b600554610257906001600160a01b031681565b6102af610337366004613e9c565b611409565b61034f61034a366004613e7f565b6114c1565b60405161026b929190613fb8565b61022f61036b366004613fdd565b6115cf565b600154610257906001600160a01b031681565b600254610257906001600160a01b031681565b6102af61184f565b600454610257906001600160a01b031681565b6102af6103bf366004613e7f565b611b11565b6102af611c08565b6102af611ecc565b600054610257906001600160a01b031681565b6102577f000000000000000000000000000000000000000000000000000000000000000081565b61022f61041c366004613e7f565b611edc565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104969190613e62565b6001600160a01b0316336001600160a01b0316146104c7576040516325f8474360e11b815260040160405180910390fd5b6005546001600160a01b03828116911614806104f057506004546001600160a01b038281169116145b1561050e57604051631c5c3c5b60e21b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b0382169063a9059cbb907f00000000000000000000000000000000000000000000000000000000000000009083906370a0823190602401602060405180830381865afa15801561057c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a09190614066565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156105eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060f919061407f565b5050565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561066b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068f9190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa1580156106df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107039190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa158015610753573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107779190614066565b90506000610783611c08565b905080871161079481898587612285565b965096505050505050915091565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015906107e857506000546001600160a01b03163314155b15610806576040516370d645e360e01b815260040160405180910390fd5b610817670de0b6b3a76400006126fa565b600160009054906101000a90046001600160a01b03166001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af115801561086c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108909190614066565b50600354600154604051630ede4edd60e41b81526001600160a01b039182166004820152600092919091169063ede4edd0906024016020604051808303816000875af11580156108e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109089190614066565b9050801561092c5760405163059548ef60e51b815260048101829052602401610202565b6001546040516370a0823160e01b81523060048201526001600160a01b039091169063db006a759082906370a0823190602401602060405180830381865afa15801561097c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a09190614066565b6040518263ffffffff1660e01b81526004016109be91815260200190565b6020604051808303816000875af11580156109dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a019190614066565b90508015610a255760405163eeddaac560e01b815260048101829052602401610202565b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a929190614066565b1115610ab657600554600454610ab4916001600160a01b039081169116612cc2565b505b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190614066565b600454909250610b3d906001600160a01b03168484612e45565b50919050565b610b4c33611edc565b565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190614066565b905080600003610bd157600091505090565b600354600254604051630cbb414760e11b81523060048201526001600160a01b039182166024820152600160448201526000929190911690631976828e90606401602060405180830381865afa158015610c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c539190614066565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015610ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc59190614066565b9050610cd2828483612ea8565b935050505090565b610cef6001600160a01b0383163330846131f1565b610cf882613229565b5060035460015460405163929fe9a160e01b81526001600160a01b039283169263929fe9a192610d30923092909116906004016140a1565b602060405180830381865afa158015610d4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d71919061407f565b61060f5760408051600180825281830190925260009160208083019080368337505060015482519293506001600160a01b031691839150600090610db757610db76140d1565b6001600160a01b039283166020918202929092010152600354604051631853304760e31b815291169063c299823890610df49084906004016140e7565b6000604051808303816000875af1158015610e13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e3b91908101906141be565b50505050565b600154604051633af9e66960e01b81523060048201526000916001600160a01b031690633af9e66990602401602060405180830381865afa158015610e8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eae9190614066565b15919050565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015610f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f259190614066565b905080600003610f3757600091505090565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015610f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa59190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015610ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110199190614066565b905060008160008054906101000a90046001600160a01b03166001600160a01b0316630da2262c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561106f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110939190614066565b6110a590670de0b6b3a7640000614209565b6110af9190614236565b90506110bd81856000612ea8565b94505050505090565b6060806000600360009054906101000a90046001600160a01b03166001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561111e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261114691908101906142b2565b9050805167ffffffffffffffff811115611162576111626140bb565b60405190808252806020026020018201604052801561118b578160200160208202803683370190505b509250805167ffffffffffffffff8111156111a8576111a86140bb565b6040519080825280602002602001820160405280156111d1578160200160208202803683370190505b50915060005b81518110156114035760008282815181106111f4576111f46140d1565b6020908102919091010151600154604051632e6f912b60e21b81529192506001600160a01b038084169263b9be44ac9261123492169030906004016140a1565b6020604051808303816000875af1158015611253573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112779190614066565b50600254604051632e6f912b60e21b81526001600160a01b038381169263b9be44ac926112ac929091169030906004016140a1565b6020604051808303816000875af11580156112cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ef9190614066565b50806001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa15801561132e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113529190613e62565b858381518110611364576113646140d1565b6001600160a01b039283166020918202929092010152604051630ff6b5a760e31b815230600482015290821690637fb5ad38906024016020604051808303816000875af11580156113b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113dd9190614066565b8483815181106113ef576113ef6140d1565b6020908102919091010152506001016111d7565b50509091565b6000336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480159061144f57506000546001600160a01b03163314155b1561146d576040516370d645e360e01b815260040160405180910390fd5b670de0b6b3a7640000821161148d5761148d670de0b6b3a76400006126fa565b81611496611c08565b10156114aa576114a5826133dd565b6114b3565b6114b3826126fa565b6114bb611c08565b92915050565b604051639cf1fd5360e01b81523060048201526060908190839060009081906001600160a01b03841690639cf1fd53906024016000604051808303816000875af1158015611513573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261153b91908101906142e7565b9150915060005b82518110156115c3576115bb7f0000000000000000000000000000000000000000000000000000000000000000838381518110611581576115816140d1565b602002602001015185848151811061159b5761159b6140d1565b60200260200101516001600160a01b0316612e459092919063ffffffff16565b600101611542565b50909590945092505050565b6001546001600160a01b031633036116b65760006115ef82840184613e9c565b90506115fa8161372a565b600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166c9190614066565b9050848110156116af57600480546040516319ad25f160e11b81526001600160a01b03909116918101919091526024810182905260448101869052606401610202565b50506117d7565b6002546001600160a01b0316330361178f5760006116d682840184613e9c565b90506116e284826137f0565b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f9190614066565b9050848110156116af576005546040516319ad25f160e11b81526001600160a01b0390911660048201526024810182905260448101869052606401610202565b60405162461bcd60e51b815260206004820152601b60248201527f21666c206e6f742066726f6d20656974686572206d61726b65747300000000006044820152606401610202565b60405163095ea7b360e01b8152336004820152602481018490526001600160a01b0385169063095ea7b3906044016020604051808303816000875af1158015611824573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611848919061407f565b5050505050565b600080600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c99190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015611919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193d9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561198d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b19190614066565b600154604051633af9e66960e01b81523060048201529192506000916001600160a01b0390911690633af9e66990602401602060405180830381865afa1580156119ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a239190614066565b90506000670de0b6b3a7640000611a3a8385614209565b611a449190614236565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015611a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab69190614066565b90506000670de0b6b3a7640000611acd8388614209565b611ad79190614236565b90506000611ae5828561434b565b905085611afa82670de0b6b3a7640000614209565b611b049190614236565b9850505050505050505090565b6000336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611b5c576040516370d645e360e01b815260040160405180910390fd5b611b64610e41565b611b815760405163716041e560e01b815260040160405180910390fd5b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611bca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bee9190614066565b6005549091506114bb906001600160a01b03168483612e45565b600154604051633af9e66960e01b815230600482015260009182916001600160a01b0390911690633af9e66990602401602060405180830381865afa158015611c55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c799190614066565b905080600003611c8b57600091505090565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015611cd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf99190613e62565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015611d49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6d9190614066565b90506000670de0b6b3a7640000611d848584614209565b611d8e9190614236565b6002546040516305eff7ef60e21b815230600482015291925060009182916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015611ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e009190614066565b90508015611e9b5760025460405163fc57d4df60e01b81526001600160a01b03918216600482015260009187169063fc57d4df90602401602060405180830381865afa158015611e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e789190614066565b9050670de0b6b3a7640000611e8d8383614209565b611e979190614236565b9250505b611ea5828461434b565b611eb784670de0b6b3a7640000614209565b611ec19190614236565b965050505050505090565b6000611ed7336107a2565b905090565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801590611f2057506000546001600160a01b03163314155b15611f3e576040516370d645e360e01b815260040160405180910390fd5b60035460408051633605b51b60e01b815290516000926001600160a01b031691633605b51b91600480830192869291908290030181865afa158015611f87573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611faf91908101906142b2565b905060005b8151811015612280576000828281518110611fd157611fd16140d1565b6020908102919091010151600154604051632e6f912b60e21b81529192506001600160a01b038084169263b9be44ac9261201192169030906004016140a1565b6020604051808303816000875af1158015612030573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120549190614066565b50600254604051632e6f912b60e21b81526001600160a01b038381169263b9be44ac92612089929091169030906004016140a1565b6020604051808303816000875af11580156120a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cc9190614066565b50604051633bd73ee360e21b81523060048201526001600160a01b0382169063ef5cfb8c90602401600060405180830381600087803b15801561210e57600080fd5b505af1158015612122573d6000803e3d6000fd5b505050506000816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218a9190613e62565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156121d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f89190614066565b905080156122755760405163a9059cbb60e01b81526001600160a01b0387811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af115801561224f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612273919061407f565b505b505050600101611fb4565b505050565b600154604051633af9e66960e01b8152306004820152600091829182916001600160a01b031690633af9e66990602401602060405180830381865afa1580156122d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f69190614066565b6002546040516305eff7ef60e21b81523060048201529192506000916001600160a01b03909116906317bfdfbc90602401602060405180830381865afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123689190614066565b9050600088156124675760008054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e79190613e62565b60055460048054604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461241f949082169390911691016140a1565b602060405180830381865afa15801561243c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124609190614066565b9050612557565b60008054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124dc9190613e62565b60048054600554604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b946125139482169390911691016140a1565b602060405180830381865afa158015612530573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125549190614066565b90505b6000612710612566838261435e565b61257890670de0b6b3a7640000614209565b6125829190614236565b9050600080670de0b6b3a764000061259a878c614209565b6125a49190614236565b90506000670de0b6b3a76400006125bb878c614209565b6125c59190614236565b90508b60006125dc670de0b6b3a764000083614371565b90508560006125f383670de0b6b3a7640000614398565b6125fd8584614398565b6126079190614371565b6126118587614398565b61261b8886614398565b6126259190614371565b61263790670de0b6b3a7640000614398565b61264191906143c8565b905060008112612651578061265a565b61265a816143f6565b96505050505050508881670de0b6b3a76400006126779190614209565b6126819190614236565b96508761269682670de0b6b3a7640000614209565b6126a09190614236565b95508a156126cc57670de0b6b3a76400006126bb8388614209565b6126c59190614236565b95506126ec565b670de0b6b3a76400006126df8389614209565b6126e99190614236565b96505b505050505094509492505050565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127769190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa1580156127c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ea9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561283a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285e9190614066565b9050670de0b6b3a76400008611612a36576002546040516305eff7ef60e21b81523060048201526001600160a01b03909116906317bfdfbc90602401602060405180830381865afa1580156128b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128db9190614066565b935060006128e98386614209565b905060008060009054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129639190613e62565b60048054600554604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461299a9482169390911691016140a1565b602060405180830381865afa1580156129b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129db9190614066565b905060006127106129ec838261435e565b6129f69085614209565b612a009190614236565b9050612a0c8482614236565b97506000612a1a8583614412565b1115612a2e57612a2b60018961435e565b97505b505050612a49565b612a436000878385612285565b90955093505b8315612ace576002546040805160208082018990528251808303909101815281830192839052633c3b4b8960e01b9092526001600160a01b0390921691633c3b4b8991612a9b91889190604401614476565b600060405180830381600087803b158015612ab557600080fd5b505af1158015612ac9573d6000803e3d6000fd5b505050505b6005546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015612b17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3b9190614066565b90508015612cb9576002546040516305eff7ef60e21b81523060048201526000916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015612b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bb09190614066565b90508015612cb7576000828211612bc75781612bc9565b825b60055460025460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b3906044016020604051808303816000875af1158015612c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c44919061407f565b5060025460405163073a938160e11b8152600481018390526001600160a01b0390911690630e752702906024016020604051808303816000875af1158015612c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb49190614066565b50505b505b50505050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015612d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2f9190614066565b6000805460405163ed287f3f60e01b8152929350909182916001600160a01b03169063ed287f3f90612d6790899089906004016140a1565b600060405180830381865afa158015612d84573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612dac9190810190614574565b915091508151600003612dd257604051634fd1fa8360e11b815260040160405180910390fd5b60005b8251811015612e3b576000838281518110612df257612df26140d1565b602002602001015190506000838381518110612e1057612e106140d1565b60200260200101519050612e2689878484613a36565b90995089985096508695505050600101612dd5565b5050505092915050565b6040516001600160a01b03831660248201526044810182905261228090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ab7565b600080600360009054906101000a90046001600160a01b03166001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612efe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f229190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa158015612f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f969190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa158015612fe6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061300a9190614066565b90506000670de0b6b3a76400006130218488614209565b61302b9190614236565b90506000670de0b6b3a7640000613042858b614209565b61304c9190614236565b90506000670de0b6b3a7640000613063858b614209565b61306d9190614236565b905060008060009054906101000a90046001600160a01b03166001600160a01b03166316bb997f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e79190613e62565b60055460048054604051632f53ef2b60e01b81526001600160a01b0394851694632f53ef2b9461311f949082169390911691016140a1565b602060405180830381865afa15801561313c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131609190614066565b905061316d600a8261435e565b9050600061317d8261271061435e565b61318985612710614209565b6131939190614236565b905082858286826131a4838661462f565b6131ae9190614371565b6131b89190614371565b6131c2828561462f565b6131d490670de0b6b3a7640000614398565b6131de91906143c8565b9f9e505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e3b9085906323b872dd60e01b90608401612e71565b6004546000906001600160a01b0383811691161461325a576004546132589083906001600160a01b0316612cc2565b505b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa1580156132a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c79190614066565b6004805460015460405163095ea7b360e01b81526001600160a01b039182169381019390935260248301849052929350919091169063095ea7b3906044016020604051808303816000875af1158015613324573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613348919061407f565b5060015460405163140e25ad60e31b8152600481018390526000916001600160a01b03169063a0712d68906024016020604051808303816000875af1158015613395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b99190614066565b90508015610b3d57604051631a25a97b60e31b815260048101829052602401610202565b600354604080516307dc0d1d60e41b815290516000926001600160a01b031691637dc0d1d09160048083019260209291908290030181865afa158015613427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344b9190613e62565b60025460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919083169063fc57d4df90602401602060405180830381865afa15801561349b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134bf9190614066565b60015460405163fc57d4df60e01b81526001600160a01b0391821660048201529192506000919084169063fc57d4df90602401602060405180830381865afa15801561350f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135339190614066565b90506000806135456001878587612285565b6001546040805160208082018590528251808303909101815281830192839052633c3b4b8960e01b9092529395509193506001600160a01b031691633c3b4b899161359591869190604401614476565b600060405180830381600087803b1580156135af57600080fd5b505af11580156135c3573d6000803e3d6000fd5b5050600480546040516370a0823160e01b81523092810192909252600093506001600160a01b031691506370a0823190602401602060405180830381865afa158015613613573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136379190614066565b90508015612cb9576004805460015460405163095ea7b360e01b81526001600160a01b039182169381019390935260248301849052169063095ea7b3906044016020604051808303816000875af1158015613696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136ba919061407f565b5060015460405163140e25ad60e31b8152600481018390526001600160a01b039091169063a0712d68906024016020604051808303816000875af1158015613706573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb79190614066565b60045461373f906001600160a01b0316613229565b5060025460405163317afabb60e21b8152600481018390526000916001600160a01b03169063c5ebeaec906024016020604051808303816000875af115801561378c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b09190614066565b905080156137d457604051636f86fa6b60e11b815260048101829052602401610202565b600554600454612280916001600160a01b039081169116612cc2565b6002546040516305eff7ef60e21b81523060048201526000916001600160a01b0316906317bfdfbc90602401602060405180830381865afa158015613839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385d9190614066565b9050600081841061386e5781613870565b835b60055460025460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b3906044016020604051808303816000875af11580156138c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138eb919061407f565b5060025460405163073a938160e11b8152600481018390526000916001600160a01b031690630e752702906024016020604051808303816000875af1158015613938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061395c9190614066565b9050801561397f5760405162f0f70d60e41b815260048101829052602401610202565b60015460405163852a12e360e01b8152600481018690526001600160a01b039091169063852a12e3906024016020604051808303816000875af11580156139ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ee9190614066565b90508015613a125760405163213e72eb60e11b815260048101829052602401610202565b600454600554613a2e916001600160a01b039081169116612cc2565b505050505050565b6000806000613a93856310badf4e60e01b898988604051602401613a5c93929190614657565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613b89565b905080806020019051810190613aa9919061467e565b925092505094509492505050565b6000613b0c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c7d9092919063ffffffff16565b8051909150156122805780806020019051810190613b2a919061407f565b6122805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610202565b60606001600160a01b0383163b613bf15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610202565b600080846001600160a01b031684604051613c0c91906146ac565b600060405180830381855af49150503d8060008114613c47576040519150601f19603f3d011682016040523d82523d6000602084013e613c4c565b606091505b5091509150613c7482826040518060600160405280602781526020016146dc60279139613c96565b95945050505050565b6060613c8c8484600085613ccf565b90505b9392505050565b60608315613ca5575081613c8f565b825115613cb55782518084602001fd5b8160405162461bcd60e51b815260040161020291906146c8565b606082471015613d305760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610202565b600080866001600160a01b03168587604051613d4c91906146ac565b60006040518083038185875af1925050503d8060008114613d89576040519150601f19603f3d011682016040523d82523d6000602084013e613d8e565b606091505b5091509150613d9f87838387613dac565b925050505b949350505050565b60608315613e1b578251600003613e14576001600160a01b0385163b613e145760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610202565b5081613da4565b613da48383815115613e305781518083602001fd5b8060405162461bcd60e51b815260040161020291906146c8565b6001600160a01b0381168114613e5f57600080fd5b50565b600060208284031215613e7457600080fd5b8151613c8f81613e4a565b600060208284031215613e9157600080fd5b8135613c8f81613e4a565b600060208284031215613eae57600080fd5b5035919050565b60008060408385031215613ec857600080fd5b8235613ed381613e4a565b946020939093013593505050565b60008151808452602080850194506020840160005b83811015613f1257815187529582019590820190600101613ef6565b509495945050505050565b604080825283519082018190526000906020906060840190828701845b82811015613f5f5781516001600160a01b031684529284019290840190600101613f3a565b5050508381036020850152613f748186613ee1565b9695505050505050565b60008151808452602080850194506020840160005b83811015613f125781516001600160a01b031687529582019590820190600101613f93565b604081526000613fcb6040830185613f7e565b8281036020840152613c748185613ee1565b60008060008060608587031215613ff357600080fd5b8435613ffe81613e4a565b935060208501359250604085013567ffffffffffffffff8082111561402257600080fd5b818701915087601f83011261403657600080fd5b81358181111561404557600080fd5b88602082850101111561405757600080fd5b95989497505060200194505050565b60006020828403121561407857600080fd5b5051919050565b60006020828403121561409157600080fd5b81518015158114613c8f57600080fd5b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b602081526000613c8f6020830184613f7e565b604051601f8201601f1916810167ffffffffffffffff81118282101715614123576141236140bb565b604052919050565b600067ffffffffffffffff821115614145576141456140bb565b5060051b60200190565b600082601f83011261416057600080fd5b815160206141756141708361412b565b6140fa565b8083825260208201915060208460051b87010193508684111561419757600080fd5b602086015b848110156141b3578051835291830191830161419c565b509695505050505050565b6000602082840312156141d057600080fd5b815167ffffffffffffffff8111156141e757600080fd5b613da48482850161414f565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176114bb576114bb6141f3565b634e487b7160e01b600052601260045260246000fd5b60008261424557614245614220565b500490565b600082601f83011261425b57600080fd5b8151602061426b6141708361412b565b8083825260208201915060208460051b87010193508684111561428d57600080fd5b602086015b848110156141b35780516142a581613e4a565b8352918301918301614292565b6000602082840312156142c457600080fd5b815167ffffffffffffffff8111156142db57600080fd5b613da48482850161424a565b600080604083850312156142fa57600080fd5b825167ffffffffffffffff8082111561431257600080fd5b61431e8683870161424a565b9350602085015191508082111561433457600080fd5b506143418582860161414f565b9150509250929050565b818103818111156114bb576114bb6141f3565b808201808211156114bb576114bb6141f3565b8181036000831280158383131683831282161715614391576143916141f3565b5092915050565b80820260008212600160ff1b841416156143b4576143b46141f3565b81810583148215176114bb576114bb6141f3565b6000826143d7576143d7614220565b600160ff1b8214600019841416156143f1576143f16141f3565b500590565b6000600160ff1b820161440b5761440b6141f3565b5060000390565b60008261442157614421614220565b500690565b60005b83811015614441578181015183820152602001614429565b50506000910152565b60008151808452614462816020860160208601614426565b601f01601f19169290920160200192915050565b828152604060208201526000613c8c604083018461444a565b6000601f83601f8401126144a257600080fd5b825160206144b26141708361412b565b82815260059290921b850181019181810190878411156144d157600080fd5b8287015b8481101561456857805167ffffffffffffffff808211156144f65760008081fd5b818a0191508a603f83011261450b5760008081fd5b85820151604082821115614521576145216140bb565b614532828b01601f191689016140fa565b92508183528c818386010111156145495760008081fd5b61455882898501838701614426565b50508452509183019183016144d5565b50979650505050505050565b6000806040838503121561458757600080fd5b825167ffffffffffffffff8082111561459f57600080fd5b818501915085601f8301126145b357600080fd5b815160206145c36141708361412b565b82815260059290921b840181019181810190898411156145e257600080fd5b948201945b838610156146095785516145fa81613e4a565b825294820194908201906145e7565b9188015191965090935050508082111561462257600080fd5b506143418582860161448f565b808201828112600083128015821682158216171561464f5761464f6141f3565b505092915050565b60018060a01b0384168152826020820152606060408201526000613c74606083018461444a565b6000806040838503121561469157600080fd5b825161469c81613e4a565b6020939093015192949293505050565b600082516146be818460208701614426565b9190910192915050565b602081526000613c8f602083018461444a56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220bb947124d5177e7907e7c523985f4cbd8f35b3017c860b0dc112e792211cf00464736f6c63430008160033a2646970667358221220f99d272d310f040b1e014f4ec228cc0f3b901ca3c92cbd1f0ff83ea29d29f1be64736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 120, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 40384, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "accountsWithOpenPositions", + "offset": 0, + "slot": "2", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40389, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "positionsByAccount", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_address,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40392, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "collateralMarkets", + "offset": 0, + "slot": "5", + "type": "t_struct(AddressSet)2039_storage" + }, + { + "astId": 40398, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "borrowableMarketsByCollateral", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)" + }, + { + "astId": 40406, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "__unused", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))" + }, + { + "astId": 40409, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "feeDistributor", + "offset": 0, + "slot": "9", + "type": "t_contract(IFeeDistributor)26285" + }, + { + "astId": 40412, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "liquidatorsRegistry", + "offset": 0, + "slot": "10", + "type": "t_contract(ILiquidatorsRegistry)47786" + }, + { + "astId": 40414, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "blocksPerYear", + "offset": 0, + "slot": "11", + "type": "t_uint256" + }, + { + "astId": 40418, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_positionsExtensions", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_bytes4,t_address)" + } + ], + "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_bytes4": { + "encoding": "inplace", + "label": "bytes4", + "numberOfBytes": "4" + }, + "t_contract(ICErc20)16956": { + "encoding": "inplace", + "label": "contract ICErc20", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)93733": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IFeeDistributor)26285": { + "encoding": "inplace", + "label": "contract IFeeDistributor", + "numberOfBytes": "20" + }, + "t_contract(ILiquidatorsRegistry)47786": { + "encoding": "inplace", + "label": "contract ILiquidatorsRegistry", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes4,t_address)": { + "encoding": "mapping", + "key": "t_bytes4", + "label": "mapping(bytes4 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(ICErc20)16956,t_struct(AddressSet)2039_storage)": { + "encoding": "mapping", + "key": "t_contract(ICErc20)16956", + "label": "mapping(contract ICErc20 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2039_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)93733,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)93733", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)2039_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 2038, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)1724_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)1724_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 1719, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 1723, + "contract": "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol:LeveredPositionFactorySecondExtension", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionsLens.json b/packages/contracts/deployments/superseed/LeveredPositionsLens.json new file mode 100644 index 0000000000..7803639a08 --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionsLens.json @@ -0,0 +1,730 @@ +{ + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_targetLeverageRatio", + "type": "uint256" + } + ], + "name": "getBorrowRateAtRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + } + ], + "name": "getBorrowableMarketsAndRates", + "outputs": [ + { + "internalType": "address[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "underlyingsPrices", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "names", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "symbols", + "type": "string[]" + }, + { + "internalType": "uint256[]", + "name": "rates", + "type": "uint256[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCollateralMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "contract IonicComptroller[]", + "name": "poolOfMarket", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "underlyingPrices", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "names", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "symbols", + "type": "string[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "uint256[]", + "name": "totalUnderlyingSupplied", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "ratesPerBlock", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newFunding", + "type": "uint256" + } + ], + "name": "getLeverageRatioAfterFunding", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_supplyAPY", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_supplyAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_targetLeverageRatio", + "type": "uint256" + } + ], + "name": "getNetAPY", + "outputs": [ + { + "internalType": "int256", + "name": "netAPY", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyAPY", + "type": "uint256" + } + ], + "name": "getNetApyForPosition", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyAPY", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newFunding", + "type": "uint256" + } + ], + "name": "getNetApyForPositionAfterFunding", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyApy", + "type": "uint256" + } + ], + "name": "getPositionInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "collateralAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowedAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionSupplyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityValue", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "currentApy", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "debtRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "safetyBuffer", + "type": "uint256" + } + ], + "internalType": "struct LeveredPositionsLens.PositionInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition[]", + "name": "positions", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "supplyApys", + "type": "uint256[]" + } + ], + "name": "getPositionsInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "collateralAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowedAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionSupplyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityValue", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "currentApy", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "debtRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "safetyBuffer", + "type": "uint256" + } + ], + "internalType": "struct LeveredPositionsLens.PositionInfo[]", + "name": "infos", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "_factory", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "_factory", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "transactionIndex": 1, + "gasUsed": "746933", + "logsBloom": "0x00000000000000000000000000020000400000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000480000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040080000000000400000010000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91", + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000948bb10123b349f0c9f358fe36735c260df0b4cc" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + }, + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 1, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + }, + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 2, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + } + ], + "blockNumber": 4159560, + "cumulativeGasUsed": "790775", + "status": 1, + "byzantium": true + }, + "args": [ + "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000005d74800e977bfc8e14eca28c9405bacbd091738e" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + "0x5d74800e977bFc8E14Eca28C9405BacbD091738E" + ] + }, + "implementation": "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionsLens_Implementation.json b/packages/contracts/deployments/superseed/LeveredPositionsLens_Implementation.json new file mode 100644 index 0000000000..d725d52f82 --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionsLens_Implementation.json @@ -0,0 +1,586 @@ +{ + "address": "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_targetLeverageRatio", + "type": "uint256" + } + ], + "name": "getBorrowRateAtRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + } + ], + "name": "getBorrowableMarketsAndRates", + "outputs": [ + { + "internalType": "address[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "underlyingsPrices", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "names", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "symbols", + "type": "string[]" + }, + { + "internalType": "uint256[]", + "name": "rates", + "type": "uint256[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCollateralMarkets", + "outputs": [ + { + "internalType": "address[]", + "name": "markets", + "type": "address[]" + }, + { + "internalType": "contract IonicComptroller[]", + "name": "poolOfMarket", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "underlyingPrices", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "names", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "symbols", + "type": "string[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "uint256[]", + "name": "totalUnderlyingSupplied", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "ratesPerBlock", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newFunding", + "type": "uint256" + } + ], + "name": "getLeverageRatioAfterFunding", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_supplyAPY", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_supplyAmount", + "type": "uint256" + }, + { + "internalType": "contract ICErc20", + "name": "_collateralMarket", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "_stableMarket", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_targetLeverageRatio", + "type": "uint256" + } + ], + "name": "getNetAPY", + "outputs": [ + { + "internalType": "int256", + "name": "netAPY", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyAPY", + "type": "uint256" + } + ], + "name": "getNetApyForPosition", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyAPY", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newFunding", + "type": "uint256" + } + ], + "name": "getNetApyForPositionAfterFunding", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition", + "name": "pos", + "type": "address" + }, + { + "internalType": "uint256", + "name": "supplyApy", + "type": "uint256" + } + ], + "name": "getPositionInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "collateralAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowedAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionSupplyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityValue", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "currentApy", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "debtRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "safetyBuffer", + "type": "uint256" + } + ], + "internalType": "struct LeveredPositionsLens.PositionInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract LeveredPosition[]", + "name": "positions", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "supplyApys", + "type": "uint256[]" + } + ], + "name": "getPositionsInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "collateralAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowedAssetPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionSupplyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "positionValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "debtValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "equityValue", + "type": "uint256" + }, + { + "internalType": "int256", + "name": "currentApy", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "debtRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationThreshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "safetyBuffer", + "type": "uint256" + } + ], + "internalType": "struct LeveredPositionsLens.PositionInfo[]", + "name": "infos", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "_factory", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ILeveredPositionFactory", + "name": "_factory", + "type": "address" + } + ], + "name": "reinitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x50d932609df66b350f642717bc0a1e611df5fb6b1f0f9fb7e8ef981b6b0c78c3", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC", + "transactionIndex": 1, + "gasUsed": "2400854", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x7649ef7c6182db53c953a6e3887fd27493da6f662a78b3610d9390ac0aa6b535", + "transactionHash": "0x50d932609df66b350f642717bc0a1e611df5fb6b1f0f9fb7e8ef981b6b0c78c3", + "logs": [], + "blockNumber": 4159558, + "cumulativeGasUsed": "2444696", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "0e729d9c66e5b1bc1021561041d72a21", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"factory\",\"outputs\":[{\"internalType\":\"contract ILeveredPositionFactory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_equityAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_targetLeverageRatio\",\"type\":\"uint256\"}],\"name\":\"getBorrowRateAtRatio\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"}],\"name\":\"getBorrowableMarketsAndRates\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"markets\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"underlyings\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"underlyingsPrices\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"names\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"symbols\",\"type\":\"string[]\"},{\"internalType\":\"uint256[]\",\"name\":\"rates\",\"type\":\"uint256[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCollateralMarkets\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"markets\",\"type\":\"address[]\"},{\"internalType\":\"contract IonicComptroller[]\",\"name\":\"poolOfMarket\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"underlyings\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"underlyingPrices\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"names\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"symbols\",\"type\":\"string[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"uint256[]\",\"name\":\"totalUnderlyingSupplied\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ratesPerBlock\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"pos\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newFunding\",\"type\":\"uint256\"}],\"name\":\"getLeverageRatioAfterFunding\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_supplyAPY\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_supplyAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_collateralMarket\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"_stableMarket\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_targetLeverageRatio\",\"type\":\"uint256\"}],\"name\":\"getNetAPY\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"netAPY\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"pos\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyAPY\",\"type\":\"uint256\"}],\"name\":\"getNetApyForPosition\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"pos\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyAPY\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"newFunding\",\"type\":\"uint256\"}],\"name\":\"getNetApyForPositionAfterFunding\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition\",\"name\":\"pos\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"supplyApy\",\"type\":\"uint256\"}],\"name\":\"getPositionInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"collateralAssetPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowedAssetPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionSupplyAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"debtValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"equityAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"equityValue\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"currentApy\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"debtRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidationThreshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"safetyBuffer\",\"type\":\"uint256\"}],\"internalType\":\"struct LeveredPositionsLens.PositionInfo\",\"name\":\"info\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract LeveredPosition[]\",\"name\":\"positions\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"supplyApys\",\"type\":\"uint256[]\"}],\"name\":\"getPositionsInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"collateralAssetPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowedAssetPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionSupplyAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"debtValue\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"equityAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"equityValue\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"currentApy\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"debtRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidationThreshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"safetyBuffer\",\"type\":\"uint256\"}],\"internalType\":\"struct LeveredPositionsLens.PositionInfo[]\",\"name\":\"infos\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ILeveredPositionFactory\",\"name\":\"_factory\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ILeveredPositionFactory\",\"name\":\"_factory\",\"type\":\"address\"}],\"name\":\"reinitialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"getBorrowRateAtRatio(address,address,uint256,uint256)\":{\"details\":\"returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\"},\"getBorrowableMarketsAndRates(address)\":{\"details\":\"returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\"},\"getCollateralMarkets()\":{\"details\":\"returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getBorrowRateAtRatio(address,address,uint256,uint256)\":{\"notice\":\"this is a lens fn, it is not intended to be used on-chain\"},\"getBorrowableMarketsAndRates(address)\":{\"notice\":\"this is a lens fn, it is not intended to be used on-chain\"},\"getCollateralMarkets()\":{\"notice\":\"this is a lens fn, it is not intended to be used on-chain\"},\"getNetAPY(uint256,uint256,address,address,uint256)\":{\"notice\":\"this is a lens fn, it is not intended to be used on-chain\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/levered/LeveredPositionsLens.sol\":\"LeveredPositionsLens\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/IFlashLoanReceiver.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ninterface IFlashLoanReceiver {\\n function receiveFlashLoan(\\n address borrowedAsset,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3db1dbf3e47975f60cccc859740aa84665d9fd683079c7329285008502c454da\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/ILeveredPositionFactory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { IFeeDistributor } from \\\"../../compound/IFeeDistributor.sol\\\";\\nimport { ILiquidatorsRegistry } from \\\"../../liquidators/registry/ILiquidatorsRegistry.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILeveredPositionFactoryStorage {\\n function feeDistributor() external view returns (IFeeDistributor);\\n\\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\\n\\n function blocksPerYear() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n}\\n\\ninterface ILeveredPositionFactoryBase {\\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\\n\\n function _setPairWhitelisted(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n bool _whitelisted\\n ) external;\\n}\\n\\ninterface ILeveredPositionFactoryFirstExtension {\\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n external\\n view\\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getMinBorrowNative() external view returns (uint256);\\n\\n function removeClosedPosition(address closedPosition) external returns (bool removed);\\n\\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\\n\\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\\n\\n function getAccountsWithOpenPositions() external view returns (address[] memory);\\n\\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\\n\\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\\n\\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\\n\\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\\n}\\n\\ninterface ILeveredPositionFactorySecondExtension {\\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\\n\\n function createAndFundPosition(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount\\n ) external returns (LeveredPosition);\\n\\n function createAndFundPositionAtRatio(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n IERC20Upgradeable _fundingAsset,\\n uint256 _fundingAmount,\\n uint256 _leverageRatio\\n ) external returns (LeveredPosition);\\n}\\n\\ninterface ILeveredPositionFactoryExtension is\\n ILeveredPositionFactoryFirstExtension,\\n ILeveredPositionFactorySecondExtension\\n{}\\n\\ninterface ILeveredPositionFactory is\\n ILeveredPositionFactoryStorage,\\n ILeveredPositionFactoryBase,\\n ILeveredPositionFactoryExtension\\n{}\\n\",\"keccak256\":\"0x1e6fa8f49acc9f2bb029f18e2da60e3df24ef5eb5348767c26bc58d5e6e8a5c7\",\"license\":\"UNLICENSED\"},\"contracts/ionic/levered/LeveredPosition.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { BasePriceOracle } from \\\"../../oracles/BasePriceOracle.sol\\\";\\nimport { IFundsConversionStrategy } from \\\"../../liquidators/IFundsConversionStrategy.sol\\\";\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IFlashLoanReceiver } from \\\"../IFlashLoanReceiver.sol\\\";\\nimport { IonicFlywheel } from \\\"../../ionic/strategies/flywheel/IonicFlywheel.sol\\\";\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { LeveredPositionStorage } from \\\"./LeveredPositionStorage.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFlywheelLensRouter_LP {\\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\\n}\\n\\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n error OnlyWhenClosed();\\n error NotPositionOwner();\\n error OnlyFactoryOwner();\\n error AssetNotRescuable();\\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\\n\\n error ConvertFundsFailed();\\n error ExitFailed(uint256 errorCode);\\n error RedeemFailed(uint256 errorCode);\\n error SupplyCollateralFailed(uint256 errorCode);\\n error BorrowStableFailed(uint256 errorCode);\\n error RepayBorrowFailed(uint256 errorCode);\\n error RedeemCollateralFailed(uint256 errorCode);\\n error ExtNotFound(bytes4 _functionSelector);\\n\\n constructor(\\n address _positionOwner,\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket\\n ) LeveredPositionStorage(_positionOwner) {\\n IonicComptroller collateralPool = _collateralMarket.comptroller();\\n IonicComptroller stablePool = _stableMarket.comptroller();\\n require(collateralPool == stablePool, \\\"markets pools differ\\\");\\n pool = collateralPool;\\n\\n collateralMarket = _collateralMarket;\\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\\n stableMarket = _stableMarket;\\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\\n\\n factory = ILeveredPositionFactory(msg.sender);\\n }\\n\\n /*----------------------------------------------------------------\\n Mutable Functions\\n ----------------------------------------------------------------*/\\n\\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\\n _supplyCollateral(fundingAsset);\\n\\n if (!pool.checkMembership(address(this), collateralMarket)) {\\n address[] memory cTokens = new address[](1);\\n cTokens[0] = address(collateralMarket);\\n pool.enterMarkets(cTokens);\\n }\\n }\\n\\n function closePosition() public returns (uint256) {\\n return closePosition(msg.sender);\\n }\\n\\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n _leverDown(1e18);\\n\\n // calling accrue and exit allows to redeem the full underlying balance\\n collateralMarket.accrueInterest();\\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\\n if (errorCode != 0) revert ExitFailed(errorCode);\\n\\n // redeem all cTokens should leave no dust\\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\\n if (errorCode != 0) revert RedeemFailed(errorCode);\\n\\n if (stableAsset.balanceOf(address(this)) > 0) {\\n // convert all overborrowed leftovers/profits to the collateral asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // withdraw the redeemed collateral\\n withdrawAmount = collateralAsset.balanceOf(address(this));\\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\\n }\\n\\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n // anything under 1x means removing the leverage\\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\\n\\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\\n else _leverDown(targetRatioMantissa);\\n\\n // return the de facto achieved ratio\\n return getCurrentLeverageRatio();\\n }\\n\\n function receiveFlashLoan(\\n address assetAddress,\\n uint256 borrowedAmount,\\n bytes calldata data\\n ) external override {\\n if (msg.sender == address(collateralMarket)) {\\n // increasing the leverage ratio\\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\\n _leverUpPostFL(stableBorrowAmount);\\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\\n if (positionCollateralBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\\n } else if (msg.sender == address(stableMarket)) {\\n // decreasing the leverage ratio\\n uint256 amountToRedeem = abi.decode(data, (uint256));\\n _leverDownPostFL(borrowedAmount, amountToRedeem);\\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\\n if (positionStableBalance < borrowedAmount)\\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\\n } else {\\n revert(\\\"!fl not from either markets\\\");\\n }\\n\\n // repay FL\\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\\n }\\n\\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\\n if (msg.sender != positionOwner) revert NotPositionOwner();\\n if (!isPositionClosed()) revert OnlyWhenClosed();\\n\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\\n return stableLeftovers;\\n }\\n\\n function claimRewards() public {\\n claimRewards(msg.sender);\\n }\\n\\n function claimRewards(address withdrawTo) public {\\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\\n\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n fw.claimRewards(address(this));\\n ERC20 rewardToken = fw.rewardToken();\\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\\n if (rewardsAccrued > 0) {\\n rewardToken.transfer(withdrawTo, rewardsAccrued);\\n }\\n }\\n }\\n\\n function rescueTokens(IERC20Upgradeable asset) external {\\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\\n\\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\\n }\\n\\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\\n for (uint256 i = 0; i < rewardTokens.length; i++) {\\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\\n }\\n return (rewardTokens, rewards);\\n }\\n\\n fallback() external {\\n address extension = factory.getPositionsExtension(msg.sig);\\n if (extension == address(0)) revert ExtNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n View Functions\\n ----------------------------------------------------------------*/\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n function getAccruedRewards()\\n external\\n returns (\\n /*view*/\\n ERC20[] memory rewardTokens,\\n uint256[] memory amounts\\n )\\n {\\n address[] memory flywheels = pool.getRewardsDistributors();\\n\\n rewardTokens = new ERC20[](flywheels.length);\\n amounts = new uint256[](flywheels.length);\\n\\n for (uint256 i = 0; i < flywheels.length; i++) {\\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\\n fw.accrue(ERC20(address(collateralMarket)), address(this));\\n fw.accrue(ERC20(address(stableMarket)), address(this));\\n rewardTokens[i] = fw.rewardToken();\\n amounts[i] = fw.rewardsAccrued(address(this));\\n }\\n }\\n\\n function getCurrentLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtValue = 0;\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n if (debtAmount > 0) {\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n }\\n\\n // TODO check if positionValue > debtValue\\n // s / ( s - b )\\n return (positionValue * 1e18) / (positionValue - debtValue);\\n }\\n\\n function getMinLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\\n }\\n\\n function getMaxLeverageRatio() public view returns (uint256) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n if (positionSupplyAmount == 0) return 0;\\n\\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\\n }\\n\\n function _getLeverageRatioAfterBorrow(\\n uint256 newBorrowsAmount,\\n uint256 positionSupplyAmount,\\n uint256 positionBorrowAmount\\n ) internal view returns (uint256 r) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\\n\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n {\\n // add 10 bps just to not go under the min borrow value\\n assumedSlippage += 10;\\n }\\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\\n\\n int256 s = int256(positionValue);\\n int256 b = int256(currentBorrowsValue);\\n int256 x = int256(topUpCollateralValue);\\n\\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\\n }\\n\\n function isPositionClosed() public view returns (bool) {\\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\\n }\\n\\n function getEquityAmount() external view returns (uint256 equityAmount) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\\n\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\\n\\n uint256 equityValue = positionValue - debtValue;\\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\\n }\\n\\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n uint256 currentRatio = getCurrentLeverageRatio();\\n bool up = targetRatio > currentRatio;\\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\\n }\\n\\n function _getSupplyAmountDelta(\\n bool up,\\n uint256 targetRatio,\\n uint256 collateralAssetPrice,\\n uint256 borrowedAssetPrice\\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 assumedSlippage;\\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\\n\\n uint256 supplyValueDeltaAbs;\\n {\\n // s = supply value before\\n // b = borrow value before\\n // r = target ratio after\\n // c = borrow value coefficient to account for the slippage\\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\\n int256 r = int256(targetRatio);\\n int256 r1 = r - 1e18;\\n int256 c = int256(slippageFactor);\\n\\n // some math magic here\\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\\n\\n // x = supplyValueDelta\\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\\n }\\n\\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\\n\\n if (up) {\\n // stables to borrow = c * x\\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\\n } else {\\n // amount to redeem = c * x\\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n Internal Functions\\n ----------------------------------------------------------------*/\\n\\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\\n // in case the funding is with a different asset\\n if (address(collateralAsset) != address(fundingAsset)) {\\n // swap for collateral asset\\n convertAllTo(fundingAsset, collateralAsset);\\n }\\n\\n // supply the collateral\\n amountToSupply = collateralAsset.balanceOf(address(this));\\n collateralAsset.approve(address(collateralMarket), amountToSupply);\\n uint256 errorCode = collateralMarket.mint(amountToSupply);\\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\\n }\\n\\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\\n function _leverUp(uint256 targetRatio) internal {\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\\n true,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n\\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n\\n // all stables are swapped for collateral to repay the FL\\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\\n if (collateralLeftovers > 0) {\\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\\n collateralMarket.mint(collateralLeftovers);\\n }\\n }\\n\\n // @dev supply the flash loaned collateral and then borrow stables with it\\n function _leverUpPostFL(uint256 stableToBorrow) internal {\\n // supply the flash loaned collateral\\n _supplyCollateral(collateralAsset);\\n\\n // borrow stables that will be swapped to repay the FL\\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(stableAsset, collateralAsset);\\n }\\n\\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\\n function _leverDown(uint256 targetRatio) internal {\\n uint256 amountToRedeem;\\n uint256 borrowsToRepay;\\n\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\\n\\n if (targetRatio <= 1e18) {\\n // if max levering down, then derive the amount to redeem from the debt to be repaid\\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\\n // accounting for swaps slippage\\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\\n } else {\\n // else derive the debt to be repaid from the amount to redeem\\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\\n false,\\n targetRatio,\\n collateralAssetPrice,\\n stableAssetPrice\\n );\\n // the slippage is already accounted for in _getSupplyAmountDelta\\n }\\n\\n if (borrowsToRepay > 0) {\\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\\n // the execution will first receive a callback to receiveFlashLoan()\\n // then it continues from here\\n }\\n\\n // all the redeemed collateral is swapped for stables to repay the FL\\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\\n if (stableLeftovers > 0) {\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n if (borrowBalance > 0) {\\n // whatever is smaller\\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\\n stableAsset.approve(address(stableMarket), amountToRepay);\\n stableMarket.repayBorrow(amountToRepay);\\n }\\n }\\n }\\n\\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\\n // repay the borrows\\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\\n stableAsset.approve(address(stableMarket), repayAmount);\\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\\n\\n // redeem the corresponding amount needed to repay the FL\\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\\n\\n // swap for the FL asset\\n convertAllTo(collateralAsset, stableAsset);\\n }\\n\\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n private\\n returns (uint256 outputAmount)\\n {\\n uint256 inputAmount = inputToken.balanceOf(address(this));\\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\\n .getRedemptionStrategies(inputToken, outputToken);\\n\\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\\n\\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\\n bytes memory strategyData = strategiesData[i];\\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\\n inputAmount = outputAmount;\\n inputToken = outputToken;\\n }\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.isContract(target), \\\"Address: delegate call to non-contract\\\");\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n if (returndata.length > 0) {\\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\":\"0x544ff68f1ce3eb3a72dbe344a6f208abdfa32a775a52efe6c37f4509956f4342\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ncontract LeveredPositionStorage {\\n address public immutable positionOwner;\\n ILeveredPositionFactory public factory;\\n\\n ICErc20 public collateralMarket;\\n ICErc20 public stableMarket;\\n IonicComptroller public pool;\\n\\n IERC20Upgradeable public collateralAsset;\\n IERC20Upgradeable public stableAsset;\\n\\n constructor(address _positionOwner) {\\n positionOwner = _positionOwner;\\n }\\n}\\n\",\"keccak256\":\"0xe3342347e2315c9a7a8503ef7ba83390f1cd296318a50952a88d984af940e430\",\"license\":\"GPL-3.0\"},\"contracts/ionic/levered/LeveredPositionsLens.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport { ILeveredPositionFactory } from \\\"./ILeveredPositionFactory.sol\\\";\\nimport { LeveredPosition } from \\\"./LeveredPosition.sol\\\";\\nimport { ICErc20 } from \\\"../../compound/CTokenInterfaces.sol\\\";\\nimport { IonicComptroller } from \\\"../../compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"../../oracles/BasePriceOracle.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\ncontract LeveredPositionsLens is Initializable {\\n ILeveredPositionFactory public factory;\\n\\n function initialize(ILeveredPositionFactory _factory) external initializer {\\n factory = _factory;\\n }\\n\\n function reinitialize(ILeveredPositionFactory _factory) external reinitializer(2) {\\n factory = _factory;\\n }\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n /// @dev returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\\n function getCollateralMarkets()\\n external\\n view\\n returns (\\n address[] memory markets,\\n IonicComptroller[] memory poolOfMarket,\\n address[] memory underlyings,\\n uint256[] memory underlyingPrices,\\n string[] memory names,\\n string[] memory symbols,\\n uint8[] memory decimals,\\n uint256[] memory totalUnderlyingSupplied,\\n uint256[] memory ratesPerBlock\\n )\\n {\\n markets = factory.getWhitelistedCollateralMarkets();\\n poolOfMarket = new IonicComptroller[](markets.length);\\n underlyings = new address[](markets.length);\\n underlyingPrices = new uint256[](markets.length);\\n names = new string[](markets.length);\\n symbols = new string[](markets.length);\\n totalUnderlyingSupplied = new uint256[](markets.length);\\n decimals = new uint8[](markets.length);\\n ratesPerBlock = new uint256[](markets.length);\\n for (uint256 i = 0; i < markets.length; i++) {\\n ICErc20 market = ICErc20(markets[i]);\\n poolOfMarket[i] = market.comptroller();\\n underlyingPrices[i] = BasePriceOracle(poolOfMarket[i].oracle()).getUnderlyingPrice(market);\\n underlyings[i] = market.underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyings[i]);\\n names[i] = underlying.name();\\n symbols[i] = underlying.symbol();\\n decimals[i] = underlying.decimals();\\n totalUnderlyingSupplied[i] = market.getTotalUnderlyingSupplied();\\n ratesPerBlock[i] = market.supplyRatePerBlock();\\n }\\n }\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n /// @dev returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\\n function getBorrowRateAtRatio(\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n uint256 _equityAmount,\\n uint256 _targetLeverageRatio\\n ) external view returns (uint256) {\\n IonicComptroller pool = IonicComptroller(_stableMarket.comptroller());\\n BasePriceOracle oracle = pool.oracle();\\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(_stableMarket);\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\\n\\n uint256 borrowAmount = ((_targetLeverageRatio - 1e18) * _equityAmount * collateralAssetPrice) /\\n (stableAssetPrice * 1e18);\\n return _stableMarket.borrowRatePerBlockAfterBorrow(borrowAmount) * factory.blocksPerYear();\\n }\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n /// @dev returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\\n function getBorrowableMarketsAndRates(ICErc20 _collateralMarket)\\n external\\n view\\n returns (\\n address[] memory markets,\\n address[] memory underlyings,\\n uint256[] memory underlyingsPrices,\\n string[] memory names,\\n string[] memory symbols,\\n uint256[] memory rates,\\n uint8[] memory decimals\\n )\\n {\\n markets = factory.getBorrowableMarketsByCollateral(_collateralMarket);\\n underlyings = new address[](markets.length);\\n names = new string[](markets.length);\\n symbols = new string[](markets.length);\\n rates = new uint256[](markets.length);\\n decimals = new uint8[](markets.length);\\n underlyingsPrices = new uint256[](markets.length);\\n for (uint256 i = 0; i < markets.length; i++) {\\n ICErc20 market = ICErc20(markets[i]);\\n address underlyingAddress = market.underlying();\\n underlyings[i] = underlyingAddress;\\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyingAddress);\\n names[i] = underlying.name();\\n symbols[i] = underlying.symbol();\\n rates[i] = market.borrowRatePerBlock();\\n decimals[i] = underlying.decimals();\\n underlyingsPrices[i] = market.comptroller().oracle().getUnderlyingPrice(market);\\n }\\n }\\n\\n /// @notice this is a lens fn, it is not intended to be used on-chain\\n function getNetAPY(\\n uint256 _supplyAPY,\\n uint256 _supplyAmount,\\n ICErc20 _collateralMarket,\\n ICErc20 _stableMarket,\\n uint256 _targetLeverageRatio\\n ) public view returns (int256 netAPY) {\\n if (_supplyAmount == 0 || _targetLeverageRatio <= 1e18) return 0;\\n\\n IonicComptroller pool = IonicComptroller(_collateralMarket.comptroller());\\n BasePriceOracle oracle = pool.oracle();\\n // TODO the calcs can be implemented without using collateralAssetPrice\\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\\n\\n // total collateral = base collateral + levered collateral\\n uint256 totalCollateral = (_supplyAmount * _targetLeverageRatio) / 1e18;\\n uint256 yieldFromTotalSupplyScaled = _supplyAPY * totalCollateral;\\n int256 yieldValueScaled = int256((yieldFromTotalSupplyScaled * collateralAssetPrice) / 1e18);\\n\\n uint256 borrowedValueScaled = (totalCollateral - _supplyAmount) * collateralAssetPrice;\\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\\n int256 borrowInterestValueScaled = int256((_borrowRate * borrowedValueScaled) / 1e18);\\n\\n int256 netValueDiffScaled = yieldValueScaled - borrowInterestValueScaled;\\n\\n netAPY = ((netValueDiffScaled / int256(collateralAssetPrice)) * 1e18) / int256(_supplyAmount);\\n }\\n\\n function getPositionsInfo(LeveredPosition[] calldata positions, uint256[] calldata supplyApys)\\n external\\n view\\n returns (PositionInfo[] memory infos)\\n {\\n infos = new PositionInfo[](positions.length);\\n for (uint256 i = 0; i < positions.length; i++) {\\n infos[i] = getPositionInfo(positions[i], supplyApys[i]);\\n }\\n }\\n\\n function getLeverageRatioAfterFunding(LeveredPosition pos, uint256 newFunding) public view returns (uint256) {\\n uint256 equityAmount = pos.getEquityAmount();\\n if (equityAmount == 0 && newFunding == 0) return 0;\\n\\n uint256 suppliedCollateralCurrent = pos.collateralMarket().balanceOfUnderlying(address(pos));\\n return ((suppliedCollateralCurrent + newFunding) * 1e18) / (equityAmount + newFunding);\\n }\\n\\n function getNetApyForPositionAfterFunding(\\n LeveredPosition pos,\\n uint256 supplyAPY,\\n uint256 newFunding\\n ) public view returns (int256) {\\n return\\n getNetAPY(\\n supplyAPY,\\n pos.getEquityAmount() + newFunding,\\n pos.collateralMarket(),\\n pos.stableMarket(),\\n getLeverageRatioAfterFunding(pos, newFunding)\\n );\\n }\\n\\n function getNetApyForPosition(LeveredPosition pos, uint256 supplyAPY) public view returns (int256) {\\n return getNetApyForPositionAfterFunding(pos, supplyAPY, 0);\\n }\\n\\n struct PositionInfo {\\n uint256 collateralAssetPrice;\\n uint256 borrowedAssetPrice;\\n uint256 positionSupplyAmount;\\n uint256 positionValue;\\n uint256 debtAmount;\\n uint256 debtValue;\\n uint256 equityAmount;\\n uint256 equityValue;\\n int256 currentApy;\\n uint256 debtRatio;\\n uint256 liquidationThreshold;\\n uint256 safetyBuffer;\\n }\\n\\n function getPositionInfo(LeveredPosition pos, uint256 supplyApy) public view returns (PositionInfo memory info) {\\n ICErc20 collateralMarket = pos.collateralMarket();\\n IonicComptroller pool = pos.pool();\\n info.collateralAssetPrice = pool.oracle().getUnderlyingPrice(collateralMarket);\\n {\\n info.positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(pos));\\n info.positionValue = (info.collateralAssetPrice * info.positionSupplyAmount) / 1e18;\\n info.currentApy = getNetApyForPosition(pos, supplyApy);\\n }\\n\\n {\\n ICErc20 stableMarket = pos.stableMarket();\\n info.borrowedAssetPrice = pool.oracle().getUnderlyingPrice(stableMarket);\\n info.debtAmount = stableMarket.borrowBalanceCurrent(address(pos));\\n info.debtValue = (info.borrowedAssetPrice * info.debtAmount) / 1e18;\\n info.equityValue = info.positionValue - info.debtValue;\\n info.debtRatio = info.positionValue == 0 ? 0 : (info.debtValue * 1e18) / info.positionValue;\\n info.equityAmount = (info.equityValue * 1e18) / info.collateralAssetPrice;\\n }\\n\\n {\\n (, uint256 collateralFactor) = pool.markets(address(collateralMarket));\\n info.liquidationThreshold = collateralFactor;\\n info.safetyBuffer = collateralFactor - info.debtRatio;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x00f592d293fa179b1737b66421e4b74b7d2f59558154265c5dfb1344b0a00c98\",\"license\":\"GPL-3.0\"},\"contracts/ionic/strategies/flywheel/IFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\n\\n/**\\n @title Balance Booster Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \\n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\\n \\n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\\n\\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\\n*/\\ninterface IFlywheelBooster {\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdab1b4b5662148d74acc3491a810d263ec509f9f81a267e9f6c1542ba15eabc\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { IonicFlywheelCore } from \\\"./IonicFlywheelCore.sol\\\";\\nimport \\\"./IIonicFlywheel.sol\\\";\\n\\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\\n bool public constant isRewardsDistributor = true;\\n bool public constant isFlywheel = true;\\n\\n function flywheelPreSupplierAction(address market, address supplier) external {\\n accrue(ERC20(market), supplier);\\n }\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external {}\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external {\\n accrue(ERC20(market), src, dst);\\n }\\n\\n function compAccrued(address user) external view returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n // TODO remove\\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0x60d8d5a8feaa7c0373d24d6fbca523eb86ba251f5374a8821a6aee63cdc90e0d\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/utils/SafeTransferLib.sol\\\";\\nimport { SafeCastLib } from \\\"solmate/utils/SafeCastLib.sol\\\";\\n\\nimport { IFlywheelRewards } from \\\"./rewards/IFlywheelRewards.sol\\\";\\nimport { IFlywheelBooster } from \\\"./IFlywheelBooster.sol\\\";\\n\\nimport { SafeOwnableUpgradeable } from \\\"../../../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\\n using SafeTransferLib for ERC20;\\n using SafeCastLib for uint256;\\n\\n /// @notice How much rewardsToken will be send to treasury\\n uint256 public performanceFee;\\n\\n /// @notice Address that gets rewardsToken accrued by performanceFee\\n address public feeRecipient;\\n\\n /// @notice The token to reward\\n ERC20 public rewardToken;\\n\\n /// @notice append-only list of strategies added\\n ERC20[] public allStrategies;\\n\\n /// @notice the rewards contract for managing streams\\n IFlywheelRewards public flywheelRewards;\\n\\n /// @notice optional booster module for calculating virtual balances on strategies\\n IFlywheelBooster public flywheelBooster;\\n\\n /// @notice The accrued but not yet transferred rewards for each user\\n mapping(address => uint256) internal _rewardsAccrued;\\n\\n /// @notice The strategy index and last updated per strategy\\n mapping(ERC20 => RewardsState) internal _strategyState;\\n\\n /// @notice user index per strategy\\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\\n\\n constructor() {\\n // prevents the misusage of the implementation contract\\n _disableInitializers();\\n }\\n\\n function initialize(\\n ERC20 _rewardToken,\\n IFlywheelRewards _flywheelRewards,\\n IFlywheelBooster _flywheelBooster,\\n address _owner\\n ) public initializer {\\n __SafeOwnable_init(msg.sender);\\n\\n rewardToken = _rewardToken;\\n flywheelRewards = _flywheelRewards;\\n flywheelBooster = _flywheelBooster;\\n\\n _transferOwnership(_owner);\\n\\n performanceFee = 10e16; // 10%\\n feeRecipient = _owner;\\n }\\n\\n /*----------------------------------------------------------------\\n ACCRUE/CLAIM LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a user's rewards accrue to a given strategy.\\n @param strategy the updated rewards strategy\\n @param user the user of the rewards\\n @param rewardsDelta how many new rewards accrued to the user\\n @param rewardsIndex the market index for rewards per token accrued\\n */\\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\\n\\n /** \\n @notice Emitted when a user claims accrued rewards.\\n @param user the user of the rewards\\n @param amount the amount of rewards claimed\\n */\\n event ClaimRewards(address indexed user, uint256 amount);\\n\\n /** \\n @notice accrue rewards for a single user on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the user to be accrued\\n @return the cumulative amount of rewards accrued to user (including prior)\\n */\\n function accrue(ERC20 strategy, address user) public returns (uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return 0;\\n\\n state = accrueStrategy(strategy, state);\\n return accrueUser(strategy, user, state);\\n }\\n\\n /** \\n @notice accrue rewards for a two users on a strategy\\n @param strategy the strategy to accrue a user's rewards on\\n @param user the first user to be accrued\\n @param user the second user to be accrued\\n @return the cumulative amount of rewards accrued to the first user (including prior)\\n @return the cumulative amount of rewards accrued to the second user (including prior)\\n */\\n function accrue(\\n ERC20 strategy,\\n address user,\\n address secondUser\\n ) public returns (uint256, uint256) {\\n (uint224 index, uint32 ts) = strategyState(strategy);\\n RewardsState memory state = RewardsState(index, ts);\\n\\n if (state.index == 0) return (0, 0);\\n\\n state = accrueStrategy(strategy, state);\\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\\n }\\n\\n /** \\n @notice claim rewards for a given user\\n @param user the user claiming rewards\\n @dev this function is public, and all rewards transfer to the user\\n */\\n function claimRewards(address user) external {\\n uint256 accrued = rewardsAccrued(user);\\n\\n if (accrued != 0) {\\n _rewardsAccrued[user] = 0;\\n\\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\\n\\n emit ClaimRewards(user, accrued);\\n }\\n }\\n\\n /*----------------------------------------------------------------\\n ADMIN LOGIC\\n ----------------------------------------------------------------*/\\n\\n /** \\n @notice Emitted when a new strategy is added to flywheel by the admin\\n @param newStrategy the new added strategy\\n */\\n event AddStrategy(address indexed newStrategy);\\n\\n /// @notice initialize a new strategy\\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\\n _addStrategyForRewards(strategy);\\n }\\n\\n function _addStrategyForRewards(ERC20 strategy) internal {\\n (uint224 index, ) = strategyState(strategy);\\n require(index == 0, \\\"strategy\\\");\\n _strategyState[strategy] = RewardsState({\\n index: (10**rewardToken.decimals()).safeCastTo224(),\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n\\n allStrategies.push(strategy);\\n emit AddStrategy(address(strategy));\\n }\\n\\n function getAllStrategies() external view returns (ERC20[] memory) {\\n return allStrategies;\\n }\\n\\n /** \\n @notice Emitted when the rewards module changes\\n @param newFlywheelRewards the new rewards module\\n */\\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\\n\\n /// @notice swap out the flywheel rewards contract\\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\\n if (address(flywheelRewards) != address(0)) {\\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\\n if (oldRewardBalance > 0) {\\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\\n }\\n }\\n\\n flywheelRewards = newFlywheelRewards;\\n\\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\\n }\\n\\n /** \\n @notice Emitted when the booster module changes\\n @param newBooster the new booster module\\n */\\n event FlywheelBoosterUpdate(address indexed newBooster);\\n\\n /// @notice swap out the flywheel booster contract\\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\\n flywheelBooster = newBooster;\\n\\n emit FlywheelBoosterUpdate(address(newBooster));\\n }\\n\\n event UpdatedFeeSettings(\\n uint256 oldPerformanceFee,\\n uint256 newPerformanceFee,\\n address oldFeeRecipient,\\n address newFeeRecipient\\n );\\n\\n /**\\n * @notice Update performanceFee and/or feeRecipient\\n * @dev Claim rewards first from the previous feeRecipient before changing it\\n */\\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\\n _updateFeeSettings(_performanceFee, _feeRecipient);\\n }\\n\\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\\n\\n if (feeRecipient != _feeRecipient) {\\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\\n _rewardsAccrued[feeRecipient] = 0;\\n }\\n performanceFee = _performanceFee;\\n feeRecipient = _feeRecipient;\\n }\\n\\n /*----------------------------------------------------------------\\n INTERNAL ACCOUNTING LOGIC\\n ----------------------------------------------------------------*/\\n\\n struct RewardsState {\\n /// @notice The strategy's last updated index\\n uint224 index;\\n /// @notice The timestamp the index was last updated at\\n uint32 lastUpdatedTimestamp;\\n }\\n\\n /// @notice accumulate global rewards on a strategy\\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\\n private\\n returns (RewardsState memory rewardsState)\\n {\\n // calculate accrued rewards through module\\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\\n\\n rewardsState = state;\\n\\n if (strategyRewardsAccrued > 0) {\\n // use the booster or token supply to calculate reward index denominator\\n uint256 supplyTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedTotalSupply(strategy)\\n : strategy.totalSupply();\\n\\n // 100% = 100e16\\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\\n\\n _rewardsAccrued[feeRecipient] += accruedFees;\\n strategyRewardsAccrued -= accruedFees;\\n\\n uint224 deltaIndex;\\n\\n if (supplyTokens != 0)\\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\\n\\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\\n rewardsState = RewardsState({\\n index: state.index + deltaIndex,\\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\\n });\\n _strategyState[strategy] = rewardsState;\\n }\\n }\\n\\n /// @notice accumulate rewards on a strategy for a specific user\\n function accrueUser(\\n ERC20 strategy,\\n address user,\\n RewardsState memory state\\n ) private returns (uint256) {\\n // load indices\\n uint224 strategyIndex = state.index;\\n uint224 supplierIndex = userIndex(strategy, user);\\n\\n // sync user index to global\\n _userIndex[strategy][user] = strategyIndex;\\n\\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\\n // zero balances will have no effect other than syncing to global index\\n if (supplierIndex == 0) {\\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\\n }\\n\\n uint224 deltaIndex = strategyIndex - supplierIndex;\\n // use the booster or token balance to calculate reward balance multiplier\\n uint256 supplierTokens = address(flywheelBooster) != address(0)\\n ? flywheelBooster.boostedBalanceOf(strategy, user)\\n : strategy.balanceOf(user);\\n\\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\\n\\n _rewardsAccrued[user] = supplierAccrued;\\n\\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\\n\\n return supplierAccrued;\\n }\\n\\n function rewardsAccrued(address user) public virtual returns (uint256) {\\n return _rewardsAccrued[user];\\n }\\n\\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\\n return _userIndex[strategy][user];\\n }\\n\\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0xbd54c90dbc7f93cad52016f14eb5f9b634f98d18da083ef443951deebc5f82aa\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\nimport {IonicFlywheelCore} from \\\"../IonicFlywheelCore.sol\\\";\\n\\n/**\\n @title Rewards Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Rewards module is responsible for:\\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\\n * actually holding rewards that are yet to be claimed\\n\\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\\n\\n Different module strategies include:\\n * a static reward rate per second\\n * a decaying reward rate\\n * a dynamic just-in-time reward stream\\n * liquid governance reward delegation (Curve Gauge style)\\n\\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\\n */\\ninterface IFlywheelRewards {\\n /**\\n @notice calculate the rewards amount accrued to a strategy since the last update.\\n @param strategy the strategy to accrue rewards for.\\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\\n @return rewards the amount of rewards accrued to the market\\n */\\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\\n\\n /// @notice return the flywheel core address\\n function flywheel() external view returns (IonicFlywheelCore);\\n\\n /// @notice return the reward token associated with flywheel core.\\n function rewardToken() external view returns (ERC20);\\n}\\n\",\"keccak256\":\"0x7e966a0e7cc80f799ee7cb3611027381847dafb92b8d8c0f3e96500ecbe217f7\",\"license\":\"AGPL-3.0-only\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeCastLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Safe unsigned integer casting library that reverts on overflow.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\\nlibrary SafeCastLib {\\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\\n require(x < 1 << 248);\\n\\n y = uint248(x);\\n }\\n\\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\\n require(x < 1 << 224);\\n\\n y = uint224(x);\\n }\\n\\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\\n require(x < 1 << 192);\\n\\n y = uint192(x);\\n }\\n\\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\\n require(x < 1 << 160);\\n\\n y = uint160(x);\\n }\\n\\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\\n require(x < 1 << 128);\\n\\n y = uint128(x);\\n }\\n\\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\\n require(x < 1 << 96);\\n\\n y = uint96(x);\\n }\\n\\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\\n require(x < 1 << 64);\\n\\n y = uint64(x);\\n }\\n\\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\\n require(x < 1 << 32);\\n\\n y = uint32(x);\\n }\\n\\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\\n require(x < 1 << 24);\\n\\n y = uint24(x);\\n }\\n\\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\\n require(x < 1 << 16);\\n\\n y = uint16(x);\\n }\\n\\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\\n require(x < 1 << 8);\\n\\n y = uint8(x);\\n }\\n}\\n\",\"keccak256\":\"0xb784a14411858036491124e677aecde6d500e695b7a70c74aa8f1001bda2ccab\",\"license\":\"AGPL-3.0-only\"},\"solmate/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), from) // Append the \\\"from\\\" argument.\\n mstore(add(freeMemoryPointer, 36), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 68), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // Get a pointer to some free memory.\\n let freeMemoryPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(add(freeMemoryPointer, 4), to) // Append the \\\"to\\\" argument.\\n mstore(add(freeMemoryPointer, 36), amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\\n // Counterintuitively, this call must be positioned second to the or() call in the\\n // surrounding and() call or else returndatasize() will be zero during the computation.\\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\\n )\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x333b56bef66ff71e3838910781df214acbeb6c2d6ace27a04ebb510f0e669300\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50612a77806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638f4b1166116100715780638f4b11661461015e578063c03497c01461017e578063c45a01551461019b578063c4d66de8146101cc578063cc3e7804146101e1578063f7e7d1fd146101f457600080fd5b8063012db95c146100b95780631327d7fb146100df5780631a610317146100ff57806360ff773e146101125780636bbdc780146101385780638de1624d1461014b575b600080fd5b6100cc6100c7366004612166565b610207565b6040519081526020015b60405180910390f35b6100f26100ed366004612166565b610396565b6040516100d69190612210565b6100cc61010d366004612166565b6108ca565b61012561012036600461221f565b6108df565b6040516100d6979695949392919061237a565b6100cc610146366004612403565b610f51565b6100cc610159366004612449565b61123e565b61017161016c3660046124e6565b611559565b6040516100d69190612551565b610186611630565b6040516100d6999897969594939291906125a0565b6000546101b4906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100d6565b6101df6101da36600461221f565b611e0f565b005b6100cc6101ef366004612699565b611efe565b6101df61020236600461221f565b612047565b600080836001600160a01b031663a833cb7f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610248573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026c91906126ce565b90508015801561027a575082155b15610289576000915050610390565b6000846001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906126e7565b604051633af9e66960e01b81526001600160a01b0387811660048301529190911690633af9e66990602401602060405180830381865afa158015610335573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035991906126ce565b9050610365848361271a565b61036f858361271a565b61038190670de0b6b3a764000061272d565b61038b919061275a565b925050505b92915050565b61039e6120ed565b6000836001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040291906126e7565b90506000846001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610444573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046891906126e7565b9050806001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cc91906126e7565b60405163fc57d4df60e01b81526001600160a01b038481166004830152919091169063fc57d4df90602401602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906126ce565b8352604051633af9e66960e01b81526001600160a01b038681166004830152831690633af9e66990602401602060405180830381865afa158015610580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a491906126ce565b604084018190528351670de0b6b3a7640000916105c09161272d565b6105ca919061275a565b60608401526105d985856108ca565b836101000181815250506000856001600160a01b031663a7e269a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610623573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064791906126e7565b9050816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ab91906126e7565b60405163fc57d4df60e01b81526001600160a01b038381166004830152919091169063fc57d4df90602401602060405180830381865afa1580156106f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071791906126ce565b60208501526040516305eff7ef60e21b81526001600160a01b0387811660048301528216906317bfdfbc90602401602060405180830381865afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078691906126ce565b608085018190526020850151670de0b6b3a7640000916107a59161272d565b6107af919061275a565b60a0850181905260608501516107c5919061276e565b60e08501526060840151156107ff57606084015160a08501516107f090670de0b6b3a764000061272d565b6107fa919061275a565b610802565b60005b610120850152835160e085015161082190670de0b6b3a764000061272d565b61082b919061275a565b60c085015250604051638e8f294b60e01b81526001600160a01b03838116600483015260009190831690638e8f294b906024016040805180830381865afa15801561087a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089e9190612781565b61014086018190526101208601519092506108ba91508261276e565b6101608501525091949350505050565b60006108d883836000611efe565b9392505050565b600054604051637a73083360e11b81526001600160a01b038381166004830152606092839283928392839283928392620100009004169063f4e6106690602401600060405180830381865afa15801561093c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261096491908101906127fa565b965086516001600160401b0381111561097f5761097f6127b4565b6040519080825280602002602001820160405280156109a8578160200160208202803683370190505b50955086516001600160401b038111156109c4576109c46127b4565b6040519080825280602002602001820160405280156109f757816020015b60608152602001906001900390816109e25790505b50935086516001600160401b03811115610a1357610a136127b4565b604051908082528060200260200182016040528015610a4657816020015b6060815260200190600190039081610a315790505b50925086516001600160401b03811115610a6257610a626127b4565b604051908082528060200260200182016040528015610a8b578160200160208202803683370190505b50915086516001600160401b03811115610aa757610aa76127b4565b604051908082528060200260200182016040528015610ad0578160200160208202803683370190505b50905086516001600160401b03811115610aec57610aec6127b4565b604051908082528060200260200182016040528015610b15578160200160208202803683370190505b50945060005b8751811015610f45576000888281518110610b3857610b386128ab565b602002602001015190506000816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba691906126e7565b905080898481518110610bbb57610bbb6128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250506000819050806001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c1e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c4691908101906128c1565b888581518110610c5857610c586128ab565b6020026020010181905250806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ca1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cc991908101906128c1565b878581518110610cdb57610cdb6128ab565b6020026020010181905250826001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4891906126ce565b868581518110610d5a57610d5a6128ab565b602002602001018181525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc8919061294b565b858581518110610dda57610dda6128ab565b602002602001019060ff16908160ff1681525050826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5091906126e7565b6001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb191906126e7565b60405163fc57d4df60e01b81526001600160a01b038581166004830152919091169063fc57d4df90602401602060405180830381865afa158015610ef9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1d91906126ce565b898581518110610f2f57610f2f6128ab565b6020908102919091010152505050600101610b1b565b50919395979092949650565b600080846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb691906126e7565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101c91906126e7565b60405163fc57d4df60e01b81526001600160a01b03888116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015611068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108c91906126ce565b60405163fc57d4df60e01b81526001600160a01b038a8116600483015291925060009184169063fc57d4df90602401602060405180830381865afa1580156110d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fc91906126ce565b9050600061111283670de0b6b3a764000061272d565b8289611126670de0b6b3a76400008b61276e565b611130919061272d565b61113a919061272d565b611144919061275a565b9050600060029054906101000a90046001600160a01b03166001600160a01b031663a385fb966040518163ffffffff1660e01b8152600401602060405180830381865afa158015611199573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bd91906126ce565b60405163cfcd4c0760e01b8152600481018390526001600160a01b038b169063cfcd4c0790602401602060405180830381865afa158015611202573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122691906126ce565b611230919061272d565b9a9950505050505050505050565b60008415806112555750670de0b6b3a76400008211155b1561126257506000611550565b6000846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c691906126e7565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132c91906126e7565b60405163fc57d4df60e01b81526001600160a01b03888116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015611378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139c91906126ce565b90506000670de0b6b3a76400006113b3878b61272d565b6113bd919061275a565b905060006113cb828c61272d565b90506000670de0b6b3a76400006113e2858461272d565b6113ec919061275a565b90506000846113fb8d8661276e565b611405919061272d565b905060008060029054906101000a90046001600160a01b03166001600160a01b031663a385fb966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561145b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147f91906126ce565b8b6001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e191906126ce565b6114eb919061272d565b90506000670de0b6b3a7640000611502848461272d565b61150c919061275a565b9050600061151a828661296e565b90508e6115278983612995565b61153990670de0b6b3a76400006129c3565b6115439190612995565b9a50505050505050505050505b95945050505050565b6060836001600160401b03811115611573576115736127b4565b6040519080825280602002602001820160405280156115ac57816020015b6115996120ed565b8152602001906001900390816115915790505b50905060005b84811015611627576116028686838181106115cf576115cf6128ab565b90506020020160208101906115e4919061221f565b8585848181106115f6576115f66128ab565b90506020020135610396565b828281518110611614576116146128ab565b60209081029190910101526001016115b2565b50949350505050565b6060806060806060806060806060600060029054906101000a90046001600160a01b03166001600160a01b031663a339d7516040518163ffffffff1660e01b8152600401600060405180830381865afa158015611691573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116b991908101906127fa565b985088516001600160401b038111156116d4576116d46127b4565b6040519080825280602002602001820160405280156116fd578160200160208202803683370190505b50975088516001600160401b03811115611719576117196127b4565b604051908082528060200260200182016040528015611742578160200160208202803683370190505b50965088516001600160401b0381111561175e5761175e6127b4565b604051908082528060200260200182016040528015611787578160200160208202803683370190505b50955088516001600160401b038111156117a3576117a36127b4565b6040519080825280602002602001820160405280156117d657816020015b60608152602001906001900390816117c15790505b50945088516001600160401b038111156117f2576117f26127b4565b60405190808252806020026020018201604052801561182557816020015b60608152602001906001900390816118105790505b50935088516001600160401b03811115611841576118416127b4565b60405190808252806020026020018201604052801561186a578160200160208202803683370190505b50915088516001600160401b03811115611886576118866127b4565b6040519080825280602002602001820160405280156118af578160200160208202803683370190505b50925088516001600160401b038111156118cb576118cb6127b4565b6040519080825280602002602001820160405280156118f4578160200160208202803683370190505b50905060005b8951811015611e035760008a8281518110611917576119176128ab565b60200260200101519050806001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198391906126e7565b8a8381518110611995576119956128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250508982815181106119c7576119c76128ab565b60200260200101516001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3091906126e7565b60405163fc57d4df60e01b81526001600160a01b038381166004830152919091169063fc57d4df90602401602060405180830381865afa158015611a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9c91906126ce565b888381518110611aae57611aae6128ab565b602002602001018181525050806001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1c91906126e7565b898381518110611b2e57611b2e6128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250506000898381518110611b6257611b626128ab565b60200260200101519050806001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611baa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bd291908101906128c1565b888481518110611be457611be46128ab565b6020026020010181905250806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611c2d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c5591908101906128c1565b878481518110611c6757611c676128ab565b6020026020010181905250806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd4919061294b565b868481518110611ce657611ce66128ab565b602002602001019060ff16908160ff1681525050816001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5c91906126ce565b858481518110611d6e57611d6e6128ab565b602002602001018181525050816001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611db8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ddc91906126ce565b848481518110611dee57611dee6128ab565b602090810291909101015250506001016118fa565b50909192939495969798565b600054610100900460ff1615808015611e2f5750600054600160ff909116105b80611e495750303b158015611e49575060005460ff166001145b611e6e5760405162461bcd60e51b8152600401611e65906129f3565b60405180910390fd5b6000805460ff191660011790558015611e91576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015611efa576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b600061203f8383866001600160a01b031663a833cb7f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6791906126ce565b611f71919061271a565b866001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd391906126e7565b876001600160a01b031663a7e269a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612011573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203591906126e7565b6101598988610207565b949350505050565b600054600290610100900460ff16158015612069575060005460ff8083169116105b6120855760405162461bcd60e51b8152600401611e65906129f3565b6000805461010060ff841661ffff19909216821717610100600160b01b03191661ff0019620100006001600160a01b0387160216179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001611ef1565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038116811461216357600080fd5b50565b6000806040838503121561217957600080fd5b82356121848161214e565b946020939093013593505050565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301526101008082015181840152506101208082015181840152506101408082015181840152506101608082015181840152505050565b61018081016103908284612192565b60006020828403121561223157600080fd5b81356108d88161214e565b60008151808452602080850194506020840160005b838110156122765781516001600160a01b031687529582019590820190600101612251565b509495945050505050565b60008151808452602080850194506020840160005b8381101561227657815187529582019590820190600101612296565b60005b838110156122cd5781810151838201526020016122b5565b50506000910152565b600082825180855260208086019550808260051b84010181860160005b8481101561233957601f1980878503018a528251805180865261231b818888018985016122b2565b9a86019a601f019091169390930184019250908301906001016122f3565b5090979650505050505050565b60008151808452602080850194506020840160005b8381101561227657815160ff168752958201959082019060010161235b565b60e08152600061238d60e083018a61223c565b828103602084015261239f818a61223c565b905082810360408401526123b38189612281565b905082810360608401526123c781886122d6565b905082810360808401526123db81876122d6565b905082810360a08401526123ef8186612281565b905082810360c08401526112308185612346565b6000806000806080858703121561241957600080fd5b84356124248161214e565b935060208501356124348161214e565b93969395505050506040820135916060013590565b600080600080600060a0868803121561246157600080fd5b8535945060208601359350604086013561247a8161214e565b9250606086013561248a8161214e565b949793965091946080013592915050565b60008083601f8401126124ad57600080fd5b5081356001600160401b038111156124c457600080fd5b6020830191508360208260051b85010111156124df57600080fd5b9250929050565b600080600080604085870312156124fc57600080fd5b84356001600160401b038082111561251357600080fd5b61251f8883890161249b565b9096509450602087013591508082111561253857600080fd5b506125458782880161249b565b95989497509550505050565b6020808252825182820181905260009190848201906040850190845b8181101561259457612580838551612192565b92840192610180929092019160010161256d565b50909695505050505050565b60006101208083526125b48184018d61223c565b905060208382036020850152818c5180845260208401915060208e01935060005b818110156125fa5784516001600160a01b0316835293830193918301916001016125d5565b5050848103604086015261260e818d61223c565b925050508281036060840152612624818a612281565b9050828103608084015261263881896122d6565b905082810360a084015261264c81886122d6565b905082810360c08401526126608187612346565b905082810360e08401526126748186612281565b90508281036101008401526126898185612281565b9c9b505050505050505050505050565b6000806000606084860312156126ae57600080fd5b83356126b98161214e565b95602085013595506040909401359392505050565b6000602082840312156126e057600080fd5b5051919050565b6000602082840312156126f957600080fd5b81516108d88161214e565b634e487b7160e01b600052601160045260246000fd5b8082018082111561039057610390612704565b808202811582820484141761039057610390612704565b634e487b7160e01b600052601260045260246000fd5b60008261276957612769612744565b500490565b8181038181111561039057610390612704565b6000806040838503121561279457600080fd5b825180151581146127a457600080fd5b6020939093015192949293505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156127f2576127f26127b4565b604052919050565b6000602080838503121561280d57600080fd5b82516001600160401b038082111561282457600080fd5b818501915085601f83011261283857600080fd5b81518181111561284a5761284a6127b4565b8060051b915061285b8483016127ca565b818152918301840191848101908884111561287557600080fd5b938501935b8385101561289f578451925061288f8361214e565b828252938501939085019061287a565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156128d357600080fd5b81516001600160401b03808211156128ea57600080fd5b818401915084601f8301126128fe57600080fd5b815181811115612910576129106127b4565b612923601f8201601f19166020016127ca565b915080825285602082850101111561293a57600080fd5b6116278160208401602086016122b2565b60006020828403121561295d57600080fd5b815160ff811681146108d857600080fd5b818103600083128015838313168383128216171561298e5761298e612704565b5092915050565b6000826129a4576129a4612744565b600160ff1b8214600019841416156129be576129be612704565b500590565b80820260008212600160ff1b841416156129df576129df612704565b818105831482151761039057610390612704565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b60608201526080019056fea2646970667358221220e8234b7fbc8d2d025f4e27e5955e77e0d4f88afdb4d3eb63fbfc6a10bcd64b8164736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638f4b1166116100715780638f4b11661461015e578063c03497c01461017e578063c45a01551461019b578063c4d66de8146101cc578063cc3e7804146101e1578063f7e7d1fd146101f457600080fd5b8063012db95c146100b95780631327d7fb146100df5780631a610317146100ff57806360ff773e146101125780636bbdc780146101385780638de1624d1461014b575b600080fd5b6100cc6100c7366004612166565b610207565b6040519081526020015b60405180910390f35b6100f26100ed366004612166565b610396565b6040516100d69190612210565b6100cc61010d366004612166565b6108ca565b61012561012036600461221f565b6108df565b6040516100d6979695949392919061237a565b6100cc610146366004612403565b610f51565b6100cc610159366004612449565b61123e565b61017161016c3660046124e6565b611559565b6040516100d69190612551565b610186611630565b6040516100d6999897969594939291906125a0565b6000546101b4906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100d6565b6101df6101da36600461221f565b611e0f565b005b6100cc6101ef366004612699565b611efe565b6101df61020236600461221f565b612047565b600080836001600160a01b031663a833cb7f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610248573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026c91906126ce565b90508015801561027a575082155b15610289576000915050610390565b6000846001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906126e7565b604051633af9e66960e01b81526001600160a01b0387811660048301529190911690633af9e66990602401602060405180830381865afa158015610335573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035991906126ce565b9050610365848361271a565b61036f858361271a565b61038190670de0b6b3a764000061272d565b61038b919061275a565b925050505b92915050565b61039e6120ed565b6000836001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040291906126e7565b90506000846001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610444573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046891906126e7565b9050806001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cc91906126e7565b60405163fc57d4df60e01b81526001600160a01b038481166004830152919091169063fc57d4df90602401602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906126ce565b8352604051633af9e66960e01b81526001600160a01b038681166004830152831690633af9e66990602401602060405180830381865afa158015610580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a491906126ce565b604084018190528351670de0b6b3a7640000916105c09161272d565b6105ca919061275a565b60608401526105d985856108ca565b836101000181815250506000856001600160a01b031663a7e269a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610623573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064791906126e7565b9050816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ab91906126e7565b60405163fc57d4df60e01b81526001600160a01b038381166004830152919091169063fc57d4df90602401602060405180830381865afa1580156106f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071791906126ce565b60208501526040516305eff7ef60e21b81526001600160a01b0387811660048301528216906317bfdfbc90602401602060405180830381865afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078691906126ce565b608085018190526020850151670de0b6b3a7640000916107a59161272d565b6107af919061275a565b60a0850181905260608501516107c5919061276e565b60e08501526060840151156107ff57606084015160a08501516107f090670de0b6b3a764000061272d565b6107fa919061275a565b610802565b60005b610120850152835160e085015161082190670de0b6b3a764000061272d565b61082b919061275a565b60c085015250604051638e8f294b60e01b81526001600160a01b03838116600483015260009190831690638e8f294b906024016040805180830381865afa15801561087a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089e9190612781565b61014086018190526101208601519092506108ba91508261276e565b6101608501525091949350505050565b60006108d883836000611efe565b9392505050565b600054604051637a73083360e11b81526001600160a01b038381166004830152606092839283928392839283928392620100009004169063f4e6106690602401600060405180830381865afa15801561093c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261096491908101906127fa565b965086516001600160401b0381111561097f5761097f6127b4565b6040519080825280602002602001820160405280156109a8578160200160208202803683370190505b50955086516001600160401b038111156109c4576109c46127b4565b6040519080825280602002602001820160405280156109f757816020015b60608152602001906001900390816109e25790505b50935086516001600160401b03811115610a1357610a136127b4565b604051908082528060200260200182016040528015610a4657816020015b6060815260200190600190039081610a315790505b50925086516001600160401b03811115610a6257610a626127b4565b604051908082528060200260200182016040528015610a8b578160200160208202803683370190505b50915086516001600160401b03811115610aa757610aa76127b4565b604051908082528060200260200182016040528015610ad0578160200160208202803683370190505b50905086516001600160401b03811115610aec57610aec6127b4565b604051908082528060200260200182016040528015610b15578160200160208202803683370190505b50945060005b8751811015610f45576000888281518110610b3857610b386128ab565b602002602001015190506000816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba691906126e7565b905080898481518110610bbb57610bbb6128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250506000819050806001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c1e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c4691908101906128c1565b888581518110610c5857610c586128ab565b6020026020010181905250806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ca1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cc991908101906128c1565b878581518110610cdb57610cdb6128ab565b6020026020010181905250826001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4891906126ce565b868581518110610d5a57610d5a6128ab565b602002602001018181525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc8919061294b565b858581518110610dda57610dda6128ab565b602002602001019060ff16908160ff1681525050826001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5091906126e7565b6001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb191906126e7565b60405163fc57d4df60e01b81526001600160a01b038581166004830152919091169063fc57d4df90602401602060405180830381865afa158015610ef9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1d91906126ce565b898581518110610f2f57610f2f6128ab565b6020908102919091010152505050600101610b1b565b50919395979092949650565b600080846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb691906126e7565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101c91906126e7565b60405163fc57d4df60e01b81526001600160a01b03888116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015611068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108c91906126ce565b60405163fc57d4df60e01b81526001600160a01b038a8116600483015291925060009184169063fc57d4df90602401602060405180830381865afa1580156110d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fc91906126ce565b9050600061111283670de0b6b3a764000061272d565b8289611126670de0b6b3a76400008b61276e565b611130919061272d565b61113a919061272d565b611144919061275a565b9050600060029054906101000a90046001600160a01b03166001600160a01b031663a385fb966040518163ffffffff1660e01b8152600401602060405180830381865afa158015611199573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bd91906126ce565b60405163cfcd4c0760e01b8152600481018390526001600160a01b038b169063cfcd4c0790602401602060405180830381865afa158015611202573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122691906126ce565b611230919061272d565b9a9950505050505050505050565b60008415806112555750670de0b6b3a76400008211155b1561126257506000611550565b6000846001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c691906126e7565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132c91906126e7565b60405163fc57d4df60e01b81526001600160a01b03888116600483015291925060009183169063fc57d4df90602401602060405180830381865afa158015611378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139c91906126ce565b90506000670de0b6b3a76400006113b3878b61272d565b6113bd919061275a565b905060006113cb828c61272d565b90506000670de0b6b3a76400006113e2858461272d565b6113ec919061275a565b90506000846113fb8d8661276e565b611405919061272d565b905060008060029054906101000a90046001600160a01b03166001600160a01b031663a385fb966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561145b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147f91906126ce565b8b6001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e191906126ce565b6114eb919061272d565b90506000670de0b6b3a7640000611502848461272d565b61150c919061275a565b9050600061151a828661296e565b90508e6115278983612995565b61153990670de0b6b3a76400006129c3565b6115439190612995565b9a50505050505050505050505b95945050505050565b6060836001600160401b03811115611573576115736127b4565b6040519080825280602002602001820160405280156115ac57816020015b6115996120ed565b8152602001906001900390816115915790505b50905060005b84811015611627576116028686838181106115cf576115cf6128ab565b90506020020160208101906115e4919061221f565b8585848181106115f6576115f66128ab565b90506020020135610396565b828281518110611614576116146128ab565b60209081029190910101526001016115b2565b50949350505050565b6060806060806060806060806060600060029054906101000a90046001600160a01b03166001600160a01b031663a339d7516040518163ffffffff1660e01b8152600401600060405180830381865afa158015611691573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116b991908101906127fa565b985088516001600160401b038111156116d4576116d46127b4565b6040519080825280602002602001820160405280156116fd578160200160208202803683370190505b50975088516001600160401b03811115611719576117196127b4565b604051908082528060200260200182016040528015611742578160200160208202803683370190505b50965088516001600160401b0381111561175e5761175e6127b4565b604051908082528060200260200182016040528015611787578160200160208202803683370190505b50955088516001600160401b038111156117a3576117a36127b4565b6040519080825280602002602001820160405280156117d657816020015b60608152602001906001900390816117c15790505b50945088516001600160401b038111156117f2576117f26127b4565b60405190808252806020026020018201604052801561182557816020015b60608152602001906001900390816118105790505b50935088516001600160401b03811115611841576118416127b4565b60405190808252806020026020018201604052801561186a578160200160208202803683370190505b50915088516001600160401b03811115611886576118866127b4565b6040519080825280602002602001820160405280156118af578160200160208202803683370190505b50925088516001600160401b038111156118cb576118cb6127b4565b6040519080825280602002602001820160405280156118f4578160200160208202803683370190505b50905060005b8951811015611e035760008a8281518110611917576119176128ab565b60200260200101519050806001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198391906126e7565b8a8381518110611995576119956128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250508982815181106119c7576119c76128ab565b60200260200101516001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3091906126e7565b60405163fc57d4df60e01b81526001600160a01b038381166004830152919091169063fc57d4df90602401602060405180830381865afa158015611a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9c91906126ce565b888381518110611aae57611aae6128ab565b602002602001018181525050806001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1c91906126e7565b898381518110611b2e57611b2e6128ab565b60200260200101906001600160a01b031690816001600160a01b0316815250506000898381518110611b6257611b626128ab565b60200260200101519050806001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611baa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bd291908101906128c1565b888481518110611be457611be46128ab565b6020026020010181905250806001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611c2d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c5591908101906128c1565b878481518110611c6757611c676128ab565b6020026020010181905250806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd4919061294b565b868481518110611ce657611ce66128ab565b602002602001019060ff16908160ff1681525050816001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5c91906126ce565b858481518110611d6e57611d6e6128ab565b602002602001018181525050816001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611db8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ddc91906126ce565b848481518110611dee57611dee6128ab565b602090810291909101015250506001016118fa565b50909192939495969798565b600054610100900460ff1615808015611e2f5750600054600160ff909116105b80611e495750303b158015611e49575060005460ff166001145b611e6e5760405162461bcd60e51b8152600401611e65906129f3565b60405180910390fd5b6000805460ff191660011790558015611e91576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015611efa576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b600061203f8383866001600160a01b031663a833cb7f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6791906126ce565b611f71919061271a565b866001600160a01b031663a415deda6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd391906126e7565b876001600160a01b031663a7e269a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612011573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203591906126e7565b6101598988610207565b949350505050565b600054600290610100900460ff16158015612069575060005460ff8083169116105b6120855760405162461bcd60e51b8152600401611e65906129f3565b6000805461010060ff841661ffff19909216821717610100600160b01b03191661ff0019620100006001600160a01b0387160216179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001611ef1565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038116811461216357600080fd5b50565b6000806040838503121561217957600080fd5b82356121848161214e565b946020939093013593505050565b805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301526101008082015181840152506101208082015181840152506101408082015181840152506101608082015181840152505050565b61018081016103908284612192565b60006020828403121561223157600080fd5b81356108d88161214e565b60008151808452602080850194506020840160005b838110156122765781516001600160a01b031687529582019590820190600101612251565b509495945050505050565b60008151808452602080850194506020840160005b8381101561227657815187529582019590820190600101612296565b60005b838110156122cd5781810151838201526020016122b5565b50506000910152565b600082825180855260208086019550808260051b84010181860160005b8481101561233957601f1980878503018a528251805180865261231b818888018985016122b2565b9a86019a601f019091169390930184019250908301906001016122f3565b5090979650505050505050565b60008151808452602080850194506020840160005b8381101561227657815160ff168752958201959082019060010161235b565b60e08152600061238d60e083018a61223c565b828103602084015261239f818a61223c565b905082810360408401526123b38189612281565b905082810360608401526123c781886122d6565b905082810360808401526123db81876122d6565b905082810360a08401526123ef8186612281565b905082810360c08401526112308185612346565b6000806000806080858703121561241957600080fd5b84356124248161214e565b935060208501356124348161214e565b93969395505050506040820135916060013590565b600080600080600060a0868803121561246157600080fd5b8535945060208601359350604086013561247a8161214e565b9250606086013561248a8161214e565b949793965091946080013592915050565b60008083601f8401126124ad57600080fd5b5081356001600160401b038111156124c457600080fd5b6020830191508360208260051b85010111156124df57600080fd5b9250929050565b600080600080604085870312156124fc57600080fd5b84356001600160401b038082111561251357600080fd5b61251f8883890161249b565b9096509450602087013591508082111561253857600080fd5b506125458782880161249b565b95989497509550505050565b6020808252825182820181905260009190848201906040850190845b8181101561259457612580838551612192565b92840192610180929092019160010161256d565b50909695505050505050565b60006101208083526125b48184018d61223c565b905060208382036020850152818c5180845260208401915060208e01935060005b818110156125fa5784516001600160a01b0316835293830193918301916001016125d5565b5050848103604086015261260e818d61223c565b925050508281036060840152612624818a612281565b9050828103608084015261263881896122d6565b905082810360a084015261264c81886122d6565b905082810360c08401526126608187612346565b905082810360e08401526126748186612281565b90508281036101008401526126898185612281565b9c9b505050505050505050505050565b6000806000606084860312156126ae57600080fd5b83356126b98161214e565b95602085013595506040909401359392505050565b6000602082840312156126e057600080fd5b5051919050565b6000602082840312156126f957600080fd5b81516108d88161214e565b634e487b7160e01b600052601160045260246000fd5b8082018082111561039057610390612704565b808202811582820484141761039057610390612704565b634e487b7160e01b600052601260045260246000fd5b60008261276957612769612744565b500490565b8181038181111561039057610390612704565b6000806040838503121561279457600080fd5b825180151581146127a457600080fd5b6020939093015192949293505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156127f2576127f26127b4565b604052919050565b6000602080838503121561280d57600080fd5b82516001600160401b038082111561282457600080fd5b818501915085601f83011261283857600080fd5b81518181111561284a5761284a6127b4565b8060051b915061285b8483016127ca565b818152918301840191848101908884111561287557600080fd5b938501935b8385101561289f578451925061288f8361214e565b828252938501939085019061287a565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156128d357600080fd5b81516001600160401b03808211156128ea57600080fd5b818401915084601f8301126128fe57600080fd5b815181811115612910576129106127b4565b612923601f8201601f19166020016127ca565b915080825285602082850101111561293a57600080fd5b6116278160208401602086016122b2565b60006020828403121561295d57600080fd5b815160ff811681146108d857600080fd5b818103600083128015838313168383128216171561298e5761298e612704565b5092915050565b6000826129a4576129a4612744565b600160ff1b8214600019841416156129be576129be612704565b500590565b80820260008212600160ff1b841416156129df576129df612704565b818105831482151761039057610390612704565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b60608201526080019056fea2646970667358221220e8234b7fbc8d2d025f4e27e5955e77e0d4f88afdb4d3eb63fbfc6a10bcd64b8164736f6c63430008160033", + "devdoc": { + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "getBorrowRateAtRatio(address,address,uint256,uint256)": { + "details": "returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount" + }, + "getBorrowableMarketsAndRates(address)": { + "details": "returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset" + }, + "getCollateralMarkets()": { + "details": "returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted" + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getBorrowRateAtRatio(address,address,uint256,uint256)": { + "notice": "this is a lens fn, it is not intended to be used on-chain" + }, + "getBorrowableMarketsAndRates(address)": { + "notice": "this is a lens fn, it is not intended to be used on-chain" + }, + "getCollateralMarkets()": { + "notice": "this is a lens fn, it is not intended to be used on-chain" + }, + "getNetAPY(uint256,uint256,address,address,uint256)": { + "notice": "this is a lens fn, it is not intended to be used on-chain" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 92881, + "contract": "contracts/ionic/levered/LeveredPositionsLens.sol:LeveredPositionsLens", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 92884, + "contract": "contracts/ionic/levered/LeveredPositionsLens.sol:LeveredPositionsLens", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 40477, + "contract": "contracts/ionic/levered/LeveredPositionsLens.sol:LeveredPositionsLens", + "label": "factory", + "offset": 2, + "slot": "0", + "type": "t_contract(ILeveredPositionFactory)37260" + } + ], + "types": { + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(ILeveredPositionFactory)37260": { + "encoding": "inplace", + "label": "contract ILeveredPositionFactory", + "numberOfBytes": "20" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LeveredPositionsLens_Proxy.json b/packages/contracts/deployments/superseed/LeveredPositionsLens_Proxy.json new file mode 100644 index 0000000000..8f940674bc --- /dev/null +++ b/packages/contracts/deployments/superseed/LeveredPositionsLens_Proxy.json @@ -0,0 +1,247 @@ +{ + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "transactionIndex": 1, + "gasUsed": "746933", + "logsBloom": "0x00000000000000000000000000020000400000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000480000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040080000000000400000010000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91", + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000948bb10123b349f0c9f358fe36735c260df0b4cc" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + }, + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 1, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + }, + { + "transactionIndex": 1, + "blockNumber": 4159560, + "transactionHash": "0x597dea2977330cd08c9b6fc63492ea0f2da69410f5a813ba25470f52c571d2d3", + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 2, + "blockHash": "0xb737ad4a4a4a1cf03f4da8c153c56793f351912f8a931dd86b8b608850585e91" + } + ], + "blockNumber": 4159560, + "cumulativeGasUsed": "790775", + "status": 1, + "byzantium": true + }, + "args": [ + "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xc4d66de80000000000000000000000005d74800e977bfc8e14eca28c9405bacbd091738e" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LiquidatorsRegistry.json b/packages/contracts/deployments/superseed/LiquidatorsRegistry.json new file mode 100644 index 0000000000..4b6ce0c38e --- /dev/null +++ b/packages/contracts/deployments/superseed/LiquidatorsRegistry.json @@ -0,0 +1,752 @@ +{ + "address": "0x2DDF3DdFE856D1A4E5DBcb324194E2a622AeD83C", + "abi": [ + { + "inputs": [ + { + "internalType": "contract AddressesProvider", + "name": "_ap", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "_currentImpl", + "type": "address" + } + ], + "name": "FunctionAlreadyAdded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "FunctionNotFound", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "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" + }, + { + "stateMutability": "nonpayable", + "type": "fallback" + }, + { + "inputs": [], + "name": "_listExtensions", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract DiamondExtension", + "name": "extensionToAdd", + "type": "address" + }, + { + "internalType": "contract DiamondExtension", + "name": "extensionToReplace", + "type": "address" + } + ], + "name": "_registerExtension", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "asExtension", + "outputs": [ + { + "internalType": "contract LiquidatorsRegistryExtension", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "customUniV3Router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "defaultOutputToken", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "redemptionStrategiesByName", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesByTokens", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "uniswapV3Fees", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x50a1f366e14c80035615635be45a21e9b032eda82fff8c63a09bcd1470f34893", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x2DDF3DdFE856D1A4E5DBcb324194E2a622AeD83C", + "transactionIndex": 1, + "gasUsed": "978617", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000001000000100000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000020200000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xea3c91a88fc5b2853e763e175fc3a5fe3ea83bb2bdbd40b3baedc7fb3ec561ae", + "transactionHash": "0x50a1f366e14c80035615635be45a21e9b032eda82fff8c63a09bcd1470f34893", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159497, + "transactionHash": "0x50a1f366e14c80035615635be45a21e9b032eda82fff8c63a09bcd1470f34893", + "address": "0x2DDF3DdFE856D1A4E5DBcb324194E2a622AeD83C", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xea3c91a88fc5b2853e763e175fc3a5fe3ea83bb2bdbd40b3baedc7fb3ec561ae" + } + ], + "blockNumber": 4159497, + "cumulativeGasUsed": "1030847", + "status": 1, + "byzantium": true + }, + "args": [ + "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea" + ], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"_ap\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"_currentImpl\",\"type\":\"address\"}],\"name\":\"FunctionAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"}],\"name\":\"FunctionNotFound\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"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\"},{\"stateMutability\":\"nonpayable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"_listExtensions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToAdd\",\"type\":\"address\"},{\"internalType\":\"contract DiamondExtension\",\"name\":\"extensionToReplace\",\"type\":\"address\"}],\"name\":\"_registerExtension\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"asExtension\",\"outputs\":[{\"internalType\":\"contract LiquidatorsRegistryExtension\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"customUniV3Router\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"defaultOutputToken\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"redemptionStrategiesByName\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesByTokens\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"uniswapV3Fees\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_registerExtension(address,address)\":{\"details\":\"register a logic extension\",\"params\":{\"extensionToAdd\":\"the extension whose functions are to be added\",\"extensionToReplace\":\"the extension whose functions are to be removed/replaced\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/liquidators/registry/LiquidatorsRegistry.sol\":\"LiquidatorsRegistry\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/external/aerodrome/IAerodromeRouter.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.10;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20_Router {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\\ninterface IWETH is IERC20_Router {\\n function deposit() external payable;\\n\\n function withdraw(uint256) external;\\n}\\n\\ninterface IRouter_Aerodrome {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n address factory;\\n }\\n\\n error ETHTransferFailed();\\n error Expired();\\n error InsufficientAmount();\\n error InsufficientAmountA();\\n error InsufficientAmountB();\\n error InsufficientAmountADesired();\\n error InsufficientAmountBDesired();\\n error InsufficientAmountAOptimal();\\n error InsufficientLiquidity();\\n error InsufficientOutputAmount();\\n error InvalidAmountInForETHDeposit();\\n error InvalidTokenInForETHDeposit();\\n error InvalidPath();\\n error InvalidRouteA();\\n error InvalidRouteB();\\n error OnlyWETH();\\n error PoolDoesNotExist();\\n error PoolFactoryDoesNotExist();\\n error SameAddresses();\\n error ZeroAddress();\\n\\n /// @notice Address of FactoryRegistry.sol\\n function factoryRegistry() external view returns (address);\\n\\n /// @notice Address of Protocol PoolFactory.sol\\n function defaultFactory() external view returns (address);\\n\\n /// @notice Address of Voter.sol\\n function voter() external view returns (address);\\n\\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\\n function weth() external view returns (IWETH);\\n\\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\\n function ETHER() external view returns (address);\\n\\n /// @dev Struct containing information necessary to zap in and out of pools\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable Stable or volatile pool\\n /// @param factory factory of pool\\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\\n struct Zap {\\n address tokenA;\\n address tokenB;\\n bool stable;\\n address factory;\\n uint256 amountOutMinA;\\n uint256 amountOutMinB;\\n uint256 amountAMin;\\n uint256 amountBMin;\\n }\\n\\n /// @notice Sort two tokens by which address value is less than the other\\n /// @param tokenA Address of token to sort\\n /// @param tokenB Address of token to sort\\n /// @return token0 Lower address value between tokenA and tokenB\\n /// @return token1 Higher address value between tokenA and tokenB\\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\\n\\n /// @notice Calculate the address of a pool by its' factory.\\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\\n /// Reverts if _factory is not approved by the FactoryRegistry\\n /// @dev Returns a randomly generated address for a nonexistent pool\\n /// @param tokenA Address of token to query\\n /// @param tokenB Address of token to query\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of factory which created the pool\\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\\n\\n /// @notice Fetch and sort the reserves for a pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @return reserveA Amount of reserves of the sorted token A\\n /// @return reserveB Amount of reserves of the sorted token B\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n /// @notice Perform chained getAmountOut calculations on any number of pools\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n // **** ADD LIQUIDITY ****\\n\\n /// @notice Quote the amount deposited into a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Quote the amount of liquidity removed from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @param liquidity Amount of liquidity to remove\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function quoteRemoveLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 liquidity\\n ) external view returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Add liquidity of two tokens to a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @param amountAMin Minimum amount of tokenA to deposit\\n /// @param amountBMin Minimum amount of tokenB to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountTokenDesired Amount of token desired to deposit\\n /// @param amountTokenMin Minimum amount of token to deposit\\n /// @param amountETHMin Minimum amount of ETH to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to add liquidity\\n /// @return amountToken Amount of token to actually deposit\\n /// @return amountETH Amount of tokenETH to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidityETH(\\n address token,\\n bool stable,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\\n\\n // **** REMOVE LIQUIDITY ****\\n\\n /// @notice Remove liquidity of two tokens from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountAMin Minimum amount of tokenA to receive\\n /// @param amountBMin Minimum amount of tokenB to receive\\n /// @param to Recipient of tokens received\\n /// @param deadline Deadline to remove liquidity\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountToken Amount of token received\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETH(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountETH);\\n\\n // **** SWAP ****\\n\\n /// @notice Swap one token for another\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap ETH for a token\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n /// @notice Swap a token for WETH (returned as ETH)\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap one token for another without slippage protection\\n /// @return amounts Array of amounts to swap per route\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function UNSAFE_swapExactTokensForTokens(\\n uint256[] memory amounts,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n // **** SWAP (supporting fee-on-transfer tokens) ****\\n\\n /// @notice Swap one token for another supporting fee-on-transfer tokens\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external;\\n\\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable;\\n\\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external;\\n\\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\\n /// Slippage is required for the initial swap.\\n /// Additional slippage may be required when adding liquidity as the\\n /// price of the token may have changed.\\n /// @param tokenIn Token you are zapping in from (i.e. input token).\\n /// @param amountInA Amount of input token you wish to send down routesA\\n /// @param amountInB Amount of input token you wish to send down routesB\\n /// @param zapInPool Contains zap struct information. See Zap struct.\\n /// @param routesA Route used to convert input token to tokenA\\n /// @param routesB Route used to convert input token to tokenB\\n /// @param to Address you wish to mint liquidity to.\\n /// @param stake Auto-stake liquidity in corresponding gauge.\\n /// @return liquidity Amount of LP tokens created from zapping in.\\n function zapIn(\\n address tokenIn,\\n uint256 amountInA,\\n uint256 amountInB,\\n Zap calldata zapInPool,\\n Route[] calldata routesA,\\n Route[] calldata routesB,\\n address to,\\n bool stake\\n ) external payable returns (uint256 liquidity);\\n\\n /// @notice Zap out a pool (B, C) into A.\\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\\n /// Slippage is required for the removal of liquidity.\\n /// Additional slippage may be required on the swap as the\\n /// price of the token may have changed.\\n /// @param tokenOut Token you are zapping out to (i.e. output token).\\n /// @param liquidity Amount of liquidity you wish to remove.\\n /// @param zapOutPool Contains zap struct information. See Zap struct.\\n /// @param routesA Route used to convert tokenA into output token.\\n /// @param routesB Route used to convert tokenB into output token.\\n function zapOut(\\n address tokenOut,\\n uint256 liquidity,\\n Zap calldata zapOutPool,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external;\\n\\n /// @notice Used to generate params required for zapping in.\\n /// Zap in => remove liquidity then swap.\\n /// Apply slippage to expected swap values to account for changes in reserves in between.\\n /// @dev Output token refers to the token you want to zap in from.\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable .\\n /// @param _factory .\\n /// @param amountInA Amount of input token you wish to send down routesA\\n /// @param amountInB Amount of input token you wish to send down routesB\\n /// @param routesA Route used to convert input token to tokenA\\n /// @param routesB Route used to convert input token to tokenB\\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\\n function generateZapInParams(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 amountInA,\\n uint256 amountInB,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\\n\\n /// @notice Used to generate params required for zapping out.\\n /// Zap out => swap then add liquidity.\\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\\n /// @dev Output token refers to the token you want to zap out of.\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable .\\n /// @param _factory .\\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\\n /// @param routesA Route used to convert tokenA into output token.\\n /// @param routesB Route used to convert tokenB into output token.\\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\\n function generateZapOutParams(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 liquidity,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\\n\\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\\n /// @dev Returns stable liquidity ratio of B to (A + B).\\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\\n /// Therefore you should deposit more of token A than B.\\n /// @param tokenA tokenA of stable pool you are zapping into.\\n /// @param tokenB tokenB of stable pool you are zapping into.\\n /// @param factory Factory that created stable pool.\\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\\n function quoteStableLiquidityRatio(\\n address tokenA,\\n address tokenB,\\n address factory\\n ) external view returns (uint256 ratio);\\n}\\n\",\"keccak256\":\"0x1cbdfc308cad7ca41351b75713136e52f0036b8dab53cc771ebce8aebe09a69e\",\"license\":\"Unlicense\"},\"contracts/external/solidly/IPair.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nstruct Observation {\\n uint256 timestamp;\\n uint256 reserve0Cumulative;\\n uint256 reserve1Cumulative;\\n}\\n\\ninterface IPair {\\n function observations(uint256 index) external pure returns (Observation memory);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function metadata()\\n external\\n view\\n returns (\\n uint256 dec0,\\n uint256 dec1,\\n uint256 r0,\\n uint256 r1,\\n bool st,\\n address t0,\\n address t1\\n );\\n\\n function claimFees() external returns (uint256, uint256);\\n\\n function tokens() external returns (address, address);\\n\\n function stable() external view returns (bool);\\n\\n function observationLength() external view returns (uint256);\\n\\n function lastObservation() external view returns (Observation memory);\\n\\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\\n\\n function currentCumulativePrices()\\n external\\n view\\n returns (\\n uint256 reserve0Cumulative,\\n uint256 reserve1Cumulative,\\n uint256 blockTimestamp\\n );\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\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 function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function sync() external;\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint256 _reserve0,\\n uint256 _reserve1,\\n uint256 _blockTimestampLast\\n );\\n\\n function getAmountOut(uint256, address) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xd13d4e85d4d16d46d2df3f1a8f5f1bcc6762f9d8ae0aa807847ea644ce0d0f72\",\"license\":\"MIT\"},\"contracts/external/solidly/IRouter.sol\":{\"content\":\"pragma solidity >=0.8.0;\\n\\ninterface IRouter {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n }\\n\\n function isPair(address pair) external view returns (bool);\\n\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n function pairFor(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (address pair);\\n\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n )\\n external\\n returns (\\n uint256 amountA,\\n uint256 amountB,\\n uint256 liquidity\\n );\\n\\n function swapExactTokensForTokensSimple(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address tokenFrom,\\n address tokenTo,\\n bool stable,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n )\\n external\\n view\\n returns (\\n uint256 amountA,\\n uint256 amountB,\\n uint256 liquidity\\n );\\n}\\n\",\"keccak256\":\"0x1b0243564ad8f92731f75038da17d97be2c2d8bebd5c6fa3a565d5d367909260\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/external/velodrome/IVelodromeRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IRouter_Velodrome {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n }\\n\\n error ETHTransferFailed();\\n error Expired();\\n error InsufficientAmount();\\n error InsufficientAmountA();\\n error InsufficientAmountB();\\n error InsufficientAmountADesired();\\n error InsufficientAmountBDesired();\\n error InsufficientLiquidity();\\n error InsufficientOutputAmount();\\n error InvalidPath();\\n error OnlyWETH();\\n error SameAddresses();\\n error ZeroAddress();\\n\\n /// @notice Address of Velodrome v2 pool factory\\n function factory() external view returns (address);\\n\\n /// @notice Address of Velodrome v2 pool implementation\\n function poolImplementation() external view returns (address);\\n\\n /// @notice Sort two tokens by which address value is less than the other\\n /// @param tokenA Address of token to sort\\n /// @param tokenB Address of token to sort\\n /// @return token0 Lower address value between tokenA and tokenB\\n /// @return token1 Higher address value between tokenA and tokenB\\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\\n\\n /// @notice Calculate the address of a pool by its' factory.\\n /// @dev Returns a randomly generated address for a nonexistent pool\\n /// @param tokenA Address of token to query\\n /// @param tokenB Address of token to query\\n /// @param stable True if pool is stable, false if volatile\\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\\n\\n /// @notice Fetch and sort the reserves for a pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @return reserveA Amount of reserves of the sorted token A\\n /// @return reserveB Amount of reserves of the sorted token B\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n /// @notice Perform chained getAmountOut calculations on any number of pools\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n // **** ADD LIQUIDITY ****\\n\\n /// @notice Quote the amount deposited into a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Quote the amount of liquidity removed from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function quoteRemoveLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity\\n ) external view returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Add liquidity of two tokens to a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @param amountAMin Minimum amount of tokenA to deposit\\n /// @param amountBMin Minimum amount of tokenB to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountTokenDesired Amount of token desired to deposit\\n /// @param amountTokenMin Minimum amount of token to deposit\\n /// @param amountETHMin Minimum amount of ETH to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to add liquidity\\n /// @return amountToken Amount of token to actually deposit\\n /// @return amountETH Amount of tokenETH to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidityETH(\\n address token,\\n bool stable,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\\n\\n // **** REMOVE LIQUIDITY ****\\n\\n /// @notice Remove liquidity of two tokens from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountAMin Minimum amount of tokenA to receive\\n /// @param amountBMin Minimum amount of tokenB to receive\\n /// @param to Recipient of tokens received\\n /// @param deadline Deadline to remove liquidity\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountToken Amount of token received\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETH(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountETH);\\n\\n /// @notice Swap one token for another\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap ETH for a token\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n /// @notice Swap a token for WETH (returned as ETH)\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0x29168afaf1e3c6ed7ec938f37305a4687e42befebc54e27b43c980bef93d5361\",\"license\":\"MIT\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/LiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\nimport \\\"./LiquidatorsRegistryStorage.sol\\\";\\nimport \\\"./LiquidatorsRegistryExtension.sol\\\";\\n\\ncontract LiquidatorsRegistry is LiquidatorsRegistryStorage, DiamondBase {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n constructor(AddressesProvider _ap) SafeOwnable() {\\n ap = _ap;\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\\n public\\n override\\n onlyOwner\\n {\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n\\n function asExtension() public view returns (LiquidatorsRegistryExtension) {\\n return LiquidatorsRegistryExtension(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x64c7d8af207804ab1a36867c88c3a5298ea69ce28ccba1dc6b92b254dd29bfe7\",\"license\":\"GPL-3.0\"},\"contracts/liquidators/registry/LiquidatorsRegistryExtension.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"./ILiquidatorsRegistry.sol\\\";\\nimport \\\"./LiquidatorsRegistryStorage.sol\\\";\\n\\nimport \\\"../IRedemptionStrategy.sol\\\";\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\nimport { MasterPriceOracle } from \\\"../../oracles/MasterPriceOracle.sol\\\";\\n\\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \\\"../../external/aerodrome/IAerodromeRouter.sol\\\";\\nimport { IRouter_Velodrome as IVelodromeV2Router } from \\\"../../external/velodrome/IVelodromeRouter.sol\\\";\\nimport { IRouter } from \\\"../../external/solidly/IRouter.sol\\\";\\nimport { IPair } from \\\"../../external/solidly/IPair.sol\\\";\\nimport { IUniswapV2Pair } from \\\"../../external/uniswap/IUniswapV2Pair.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n error NoRedemptionPath();\\n error OutputTokenMismatch();\\n\\n event SlippageUpdated(\\n IERC20Upgradeable indexed from,\\n IERC20Upgradeable indexed to,\\n uint256 prevValue,\\n uint256 newValue\\n );\\n\\n // @notice maximum slippage in swaps, in bps\\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\\n\\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\\n uint8 fnsCount = 7;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\\n functionSelectors[--fnsCount] = this.swap.selector;\\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\\n functionSelectors[--fnsCount] = this.getSlippage.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage) {\\n slippage = conversionSlippage[inputToken][outputToken];\\n // TODO slippage == 0 should be allowed\\n if (slippage == 0) return MAX_SLIPPAGE;\\n }\\n\\n function getAllRedemptionStrategies() public view returns (address[] memory) {\\n return redemptionStrategies.values();\\n }\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage) {\\n if (inputAmount == 0) return (0, 0);\\n\\n outputAmount = swap(inputToken, inputAmount, outputToken);\\n if (outputAmount == 0) return (0, 0);\\n\\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\\\"MasterPriceOracle\\\"));\\n uint256 inputTokenPrice = mpo.price(address(inputToken));\\n uint256 outputTokenPrice = mpo.price(address(outputToken));\\n\\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\\n\\n if (outputTokensValue < inputTokensValue) {\\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\\n }\\n // min slippage should be non-zero\\n // just in case of rounding errors\\n slippage += 1;\\n\\n // cache the slippage\\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\\n\\n conversionSlippage[inputToken][outputToken] = slippage;\\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\\n }\\n }\\n\\n /// @dev returns price scaled to 1e36 - decimals\\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\\n return\\n tokenDecimals <= 18\\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\\n }\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) public returns (uint256 outputAmount) {\\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\\n outputAmount = convertAllTo(inputToken, outputToken);\\n outputToken.safeTransfer(msg.sender, outputAmount);\\n }\\n\\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\\n uint256 inputAmount = inputToken.balanceOf(address(this));\\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\\n inputToken,\\n outputToken\\n );\\n\\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\\n\\n IERC20Upgradeable swapInputToken = inputToken;\\n uint256 swapInputAmount = inputAmount;\\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\\n bytes memory strategyData = strategiesData[i];\\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\\n swapInputToken,\\n swapInputAmount,\\n redemptionStrategy,\\n strategyData\\n );\\n swapInputAmount = swapOutputAmount;\\n swapInputToken = swapOutputToken;\\n }\\n\\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\\n return outputToken.balanceOf(address(this));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.isContract(target), \\\"Address: delegate call to non-contract\\\");\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n if (returndata.length > 0) {\\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\\n return inputTokensByOutputToken[outputToken].values();\\n }\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\\n IERC20Upgradeable tokenToRedeem = inputToken;\\n IERC20Upgradeable targetOutputToken = outputToken;\\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\\n bytes[] memory strategiesDataTemp = new bytes[](10);\\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\\n uint256 optimalPathIterator = 0;\\n\\n uint256 k = 0;\\n while (tokenToRedeem != targetOutputToken) {\\n IERC20Upgradeable nextRedeemedToken;\\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\\n if (address(directStrategy) != address(0)) {\\n nextRedeemedToken = targetOutputToken;\\n } else {\\n // check if an optimal path is preconfigured\\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\\n }\\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\\n nextRedeemedToken = optimalPath[optimalPathIterator++];\\n } else {\\n // else if no optimal path is available, use the default\\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\\n }\\n }\\n\\n // check if going in an endless loop\\n for (uint256 i = 0; i < tokenPath.length; i++) {\\n if (nextRedeemedToken == tokenPath[i]) break;\\n }\\n\\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\\n tokenToRedeem,\\n nextRedeemedToken\\n );\\n if (address(strategy) == address(0)) break;\\n\\n strategiesTemp[k] = strategy;\\n strategiesDataTemp[k] = strategyData;\\n tokenPath[k] = nextRedeemedToken;\\n tokenToRedeem = nextRedeemedToken;\\n\\n k++;\\n if (k == 10) break;\\n }\\n\\n strategies = new IRedemptionStrategy[](k);\\n strategiesData = new bytes[](k);\\n\\n for (uint8 i = 0; i < k; i++) {\\n strategies[i] = strategiesTemp[i];\\n strategiesData[i] = strategiesDataTemp[i];\\n }\\n }\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\\n\\n if (isStrategy(strategy, \\\"UniswapV2LiquidatorFunder\\\") || isStrategy(strategy, \\\"KimUniV2Liquidator\\\")) {\\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"UniswapV3LiquidatorFunder\\\")) {\\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AlgebraSwapLiquidator\\\")) {\\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AerodromeV2Liquidator\\\")) {\\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AerodromeCLLiquidator\\\")) {\\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"CurveSwapLiquidator\\\")) {\\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"VelodromeV2Liquidator\\\")) {\\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\\n } else {\\n revert(\\\"no strategy data\\\");\\n }\\n }\\n\\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\\n }\\n\\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\\n }\\n address wnative = ap.getAddress(\\\"wtoken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == wnative) return wnative;\\n }\\n address stableToken = ap.getAddress(\\\"stableToken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == stableToken) return stableToken;\\n }\\n address wbtc = ap.getAddress(\\\"wBTCToken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == wbtc) return wbtc;\\n }\\n return tokens[0];\\n }\\n\\n function getUniswapV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (address) {\\n address customRouter = customUniV3Router[inputToken][outputToken];\\n if (customRouter == address(0)) {\\n customRouter = customUniV3Router[outputToken][inputToken];\\n }\\n\\n if (customRouter != address(0)) {\\n return customRouter;\\n } else {\\n // get asset specific router or default\\n return ap.getAddress(\\\"UNISWAP_V3_ROUTER\\\");\\n }\\n }\\n\\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"IUniswapV2Router02\\\");\\n }\\n\\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"AERODROME_V2_ROUTER\\\");\\n }\\n\\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"AERODROME_CL_ROUTER\\\");\\n }\\n\\n function uniswapV3LiquidatorFunderData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\\n if (fee == 0) fee = 500;\\n\\n address router = getUniswapV3Router(inputToken, outputToken);\\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\\\"Quoter\\\"));\\n }\\n\\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\\n return _wrappedToUnwrapped4626[address(inputToken)];\\n }\\n\\n function getAeroCLTickSpacing(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (int24) {\\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\\n if (tickSpacing == 0) {\\n tickSpacing = 1;\\n }\\n return tickSpacing;\\n }\\n\\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\\n }\\n\\n function uniswapV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\\n swapPath[0] = inputToken;\\n swapPath[1] = outputToken;\\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\\n }\\n\\n function aerodromeV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\\n swapPath[0] = IAerodromeV2Router.Route({\\n from: address(inputToken),\\n to: address(outputToken),\\n stable: aeroV2IsStable(inputToken, outputToken),\\n factory: ap.getAddress(\\\"AERODROME_V2_FACTORY\\\")\\n });\\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\\n }\\n\\n function aerodromeCLLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(\\n inputToken,\\n outputToken,\\n getAerodromeCLRouter(inputToken),\\n getWrappedToUnwrapped4626(inputToken),\\n getWrappedToUnwrapped4626(outputToken),\\n getAeroCLTickSpacing(inputToken, outputToken)\\n );\\n }\\n\\n function algebraSwapLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(outputToken, ap.getAddress(\\\"ALGEBRA_SWAP_ROUTER\\\"));\\n }\\n\\n function curveSwapLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(\\n ap.getAddress(\\\"CURVE_V2_ORACLE_NO_REGISTRY\\\"),\\n outputToken,\\n getWrappedToUnwrapped4626(inputToken),\\n getWrappedToUnwrapped4626(outputToken)\\n );\\n }\\n\\n function velodromeV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\\n swapPath[0] = IVelodromeV2Router.Route({\\n from: address(inputToken),\\n to: address(outputToken),\\n stable: aeroV2IsStable(inputToken, outputToken)\\n });\\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\\n }\\n}\\n\",\"keccak256\":\"0x992e6ecf073a14d40de42133e192d1fc21fb0b5c79436c9d748d79eb3eae2437\",\"license\":\"GPL-3.0\"},\"contracts/liquidators/registry/LiquidatorsRegistryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../IRedemptionStrategy.sol\\\";\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { AddressesProvider } from \\\"../../ionic/AddressesProvider.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\\n AddressesProvider public ap;\\n\\n EnumerableSet.AddressSet internal redemptionStrategies;\\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\\n EnumerableSet.AddressSet internal outputTokensSet;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\\n mapping(address => address) internal _wrappedToUnwrapped4626;\\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\\n}\\n\",\"keccak256\":\"0xf16140deeab4ab4f1191fe87b6158f704c8da7c71dbc4aa3d9999bc572112cb3\",\"license\":\"GPL-3.0\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506040516110d33803806110d383398101604081905261002f916100c9565b6100383361005d565b600280546001600160a01b0319166001600160a01b03929092169190911790556100f9565b600180546001600160a01b031916905561007681610079565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100db57600080fd5b81516001600160a01b03811681146100f257600080fd5b9392505050565b610fcb806101086000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638db87c271161008c578063dc54bc8111610066578063dc54bc81146102b1578063dee7fe48146102b7578063e30c3978146102eb578063f2fde38b146102fc576100ea565b80638db87c2714610220578063a700f9e414610249578063c8ff6fee1461027d576100ea565b8063715018a6116100c8578063715018a6146101ec57806379ba5097146101f457806389cd9855146101fc5780638da5cb5b1461020f576100ea565b8063398cd955146101635780633c4f743c146101ac5780636333d001146101d7575b60006101016000356001600160e01b03191661030f565b90506001600160a01b03811661013d57604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e80801561015c573d6000f35b3d6000fd5b005b610193610171366004610c84565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020015b60405180910390f35b6002546101bf906001600160a01b031681565b6040516001600160a01b0390911681526020016101a3565b6101df61032f565b6040516101a39190610cbd565b61016161033e565b61016161038e565b61016161020a366004610c84565b610408565b6000546001600160a01b03166101bf565b6101bf61022e366004610d0a565b6007602052600090815260409020546001600160a01b031681565b6101bf610257366004610c84565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6101bf61028b366004610c84565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b306101bf565b6101bf6102c5366004610d75565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6001546001600160a01b03166101bf565b61016161030a366004610d0a565b61041e565b600061032982600080516020610f7683398151915261048f565b92915050565b606061033961052a565b905090565b61034661059c565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f77656400006044820152606401610134565b60015433906001600160a01b031681146103fc5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610134565b610405816105f8565b50565b61041061059c565b61041a8282610611565b5050565b61042661059c565b600180546001600160a01b0383166001600160a01b031990911681179091556104576000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8054600090815b8181101561051f57846001600160e01b0319168460000182815481106104be576104be610e0a565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610517578360000181815481106104f8576104f8610e0a565b6000918252602090912001546001600160a01b03169250610329915050565b600101610496565b506000949350505050565b6060600080516020610f7683398151915260010180548060200260200160405190810160405280929190818152602001828054801561059257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610574575b5050505050905090565b6000546001600160a01b031633146105f65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610134565b565b600180546001600160a01b031916905561040581610632565b6001600160a01b038116156106295761062981610682565b61041a826107b6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080516020610f7683398151915261069a826108ad565b60005b600182015460ff821610156107b157826001600160a01b0316826001018260ff16815481106106ce576106ce610e0a565b6000918252602090912001546001600160a01b03160361079f576001808301805490916106fa91610e36565b8154811061070a5761070a610e0a565b6000918252602090912001546001830180546001600160a01b039092169160ff841690811061073b5761073b610e0a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508160010180548061077c5761077c610e49565b600082815260209020810160001990810180546001600160a01b03191690550190555b806107a981610e5f565b91505061069d565b505050565b600080516020610f7683398151915260005b600182015460ff8216101561086d57826001600160a01b0316826001018260ff16815481106107f9576107f9610e0a565b6000918252602090912001546001600160a01b03160361085b5760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c72656164792061646465640000000000000000006044820152606401610134565b8061086581610e5f565b9150506107c8565b5061087782610a72565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156108ed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109159190810190610e7e565b9050600080516020610f7683398151915260005b82518161ffff161015610a6c576000838261ffff168151811061094e5761094e610e0a565b60200260200101519050610962818461048f565b6001600160a01b0316856001600160a01b03161461098257610982610f3e565b600061098e8285610bf2565b845490915084906109a190600190610e36565b815481106109b1576109b1610e0a565b90600052602060002001846000018261ffff16815481106109d4576109d4610e0a565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080610a3557610a35610e49565b600082815260209020810160001990810180546001600160c01b031916905501905550819050610a6481610f54565b915050610929565b50505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ab2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ada9190810190610e7e565b600080516020610f7683398151915280549192509060005b8351811015610beb576000848281518110610b0f57610b0f610e0a565b602002602001015190506000610b25828661048f565b90506001600160a01b03811615610b6a57604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b0382166024820152604401610134565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b0319909216939092169290921791909117905583610bda81610f54565b94505060019092019150610af29050565b5050505050565b8054600090815b8161ffff168161ffff161015610c6357846001600160e01b031916846000018261ffff1681548110610c2d57610c2d610e0a565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610c5b5791506103299050565b600101610bf9565b5061ffff949350505050565b6001600160a01b038116811461040557600080fd5b60008060408385031215610c9757600080fd5b8235610ca281610c6f565b91506020830135610cb281610c6f565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015610cfe5783516001600160a01b031683529284019291840191600101610cd9565b50909695505050505050565b600060208284031215610d1c57600080fd5b8135610d2781610c6f565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610d6d57610d6d610d2e565b604052919050565b60006020808385031215610d8857600080fd5b823567ffffffffffffffff80821115610da057600080fd5b818501915085601f830112610db457600080fd5b813581811115610dc657610dc6610d2e565b610dd8601f8201601f19168501610d44565b91508082528684828501011115610dee57600080fd5b8084840185840137600090820190930192909252509392505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561032957610329610e20565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff8103610e7557610e75610e20565b60010192915050565b60006020808385031215610e9157600080fd5b825167ffffffffffffffff80821115610ea957600080fd5b818501915085601f830112610ebd57600080fd5b815181811115610ecf57610ecf610d2e565b8060051b9150610ee0848301610d44565b8181529183018401918481019088841115610efa57600080fd5b938501935b83851015610f3257845192506001600160e01b031983168314610f225760008081fd5b8282529385019390850190610eff565b98975050505050505050565b634e487b7160e01b600052600160045260246000fd5b600061ffff808316818103610f6b57610f6b610e20565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a264697066735822122071f0c45696d10bd772aaaa132af8c2a1c9d4537eff6a0f3f64d5f5558d2869df64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638db87c271161008c578063dc54bc8111610066578063dc54bc81146102b1578063dee7fe48146102b7578063e30c3978146102eb578063f2fde38b146102fc576100ea565b80638db87c2714610220578063a700f9e414610249578063c8ff6fee1461027d576100ea565b8063715018a6116100c8578063715018a6146101ec57806379ba5097146101f457806389cd9855146101fc5780638da5cb5b1461020f576100ea565b8063398cd955146101635780633c4f743c146101ac5780636333d001146101d7575b60006101016000356001600160e01b03191661030f565b90506001600160a01b03811661013d57604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e80801561015c573d6000f35b3d6000fd5b005b610193610171366004610c84565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020015b60405180910390f35b6002546101bf906001600160a01b031681565b6040516001600160a01b0390911681526020016101a3565b6101df61032f565b6040516101a39190610cbd565b61016161033e565b61016161038e565b61016161020a366004610c84565b610408565b6000546001600160a01b03166101bf565b6101bf61022e366004610d0a565b6007602052600090815260409020546001600160a01b031681565b6101bf610257366004610c84565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6101bf61028b366004610c84565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b306101bf565b6101bf6102c5366004610d75565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6001546001600160a01b03166101bf565b61016161030a366004610d0a565b61041e565b600061032982600080516020610f7683398151915261048f565b92915050565b606061033961052a565b905090565b61034661059c565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f77656400006044820152606401610134565b60015433906001600160a01b031681146103fc5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610134565b610405816105f8565b50565b61041061059c565b61041a8282610611565b5050565b61042661059c565b600180546001600160a01b0383166001600160a01b031990911681179091556104576000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8054600090815b8181101561051f57846001600160e01b0319168460000182815481106104be576104be610e0a565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610517578360000181815481106104f8576104f8610e0a565b6000918252602090912001546001600160a01b03169250610329915050565b600101610496565b506000949350505050565b6060600080516020610f7683398151915260010180548060200260200160405190810160405280929190818152602001828054801561059257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610574575b5050505050905090565b6000546001600160a01b031633146105f65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610134565b565b600180546001600160a01b031916905561040581610632565b6001600160a01b038116156106295761062981610682565b61041a826107b6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080516020610f7683398151915261069a826108ad565b60005b600182015460ff821610156107b157826001600160a01b0316826001018260ff16815481106106ce576106ce610e0a565b6000918252602090912001546001600160a01b03160361079f576001808301805490916106fa91610e36565b8154811061070a5761070a610e0a565b6000918252602090912001546001830180546001600160a01b039092169160ff841690811061073b5761073b610e0a565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508160010180548061077c5761077c610e49565b600082815260209020810160001990810180546001600160a01b03191690550190555b806107a981610e5f565b91505061069d565b505050565b600080516020610f7683398151915260005b600182015460ff8216101561086d57826001600160a01b0316826001018260ff16815481106107f9576107f9610e0a565b6000918252602090912001546001600160a01b03160361085b5760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c72656164792061646465640000000000000000006044820152606401610134565b8061086581610e5f565b9150506107c8565b5061087782610a72565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156108ed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109159190810190610e7e565b9050600080516020610f7683398151915260005b82518161ffff161015610a6c576000838261ffff168151811061094e5761094e610e0a565b60200260200101519050610962818461048f565b6001600160a01b0316856001600160a01b03161461098257610982610f3e565b600061098e8285610bf2565b845490915084906109a190600190610e36565b815481106109b1576109b1610e0a565b90600052602060002001846000018261ffff16815481106109d4576109d4610e0a565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080610a3557610a35610e49565b600082815260209020810160001990810180546001600160c01b031916905501905550819050610a6481610f54565b915050610929565b50505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ab2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ada9190810190610e7e565b600080516020610f7683398151915280549192509060005b8351811015610beb576000848281518110610b0f57610b0f610e0a565b602002602001015190506000610b25828661048f565b90506001600160a01b03811615610b6a57604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b0382166024820152604401610134565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b0319909216939092169290921791909117905583610bda81610f54565b94505060019092019150610af29050565b5050505050565b8054600090815b8161ffff168161ffff161015610c6357846001600160e01b031916846000018261ffff1681548110610c2d57610c2d610e0a565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610c5b5791506103299050565b600101610bf9565b5061ffff949350505050565b6001600160a01b038116811461040557600080fd5b60008060408385031215610c9757600080fd5b8235610ca281610c6f565b91506020830135610cb281610c6f565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015610cfe5783516001600160a01b031683529284019291840191600101610cd9565b50909695505050505050565b600060208284031215610d1c57600080fd5b8135610d2781610c6f565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610d6d57610d6d610d2e565b604052919050565b60006020808385031215610d8857600080fd5b823567ffffffffffffffff80821115610da057600080fd5b818501915085601f830112610db457600080fd5b813581811115610dc657610dc6610d2e565b610dd8601f8201601f19168501610d44565b91508082528684828501011115610dee57600080fd5b8084840185840137600090820190930192909252509392505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561032957610329610e20565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff8103610e7557610e75610e20565b60010192915050565b60006020808385031215610e9157600080fd5b825167ffffffffffffffff80821115610ea957600080fd5b818501915085601f830112610ebd57600080fd5b815181811115610ecf57610ecf610d2e565b8060051b9150610ee0848301610d44565b8181529183018401918481019088841115610efa57600080fd5b938501935b83851015610f3257845192506001600160e01b031983168314610f225760008081fd5b8282529385019390850190610eff565b98975050505050505050565b634e487b7160e01b600052600160045260246000fd5b600061ffff808316818103610f6b57610f6b610e20565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a264697066735822122071f0c45696d10bd772aaaa132af8c2a1c9d4537eff6a0f3f64d5f5558d2869df64736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_registerExtension(address,address)": { + "details": "register a logic extension", + "params": { + "extensionToAdd": "the extension whose functions are to be added", + "extensionToReplace": "the extension whose functions are to be removed/replaced" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2741, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2854, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 78123, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "ap", + "offset": 0, + "slot": "2", + "type": "t_contract(AddressesProvider)51667" + }, + { + "astId": 78126, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "redemptionStrategies", + "offset": 0, + "slot": "3", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78131, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "redemptionStrategiesByName", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)" + }, + { + "astId": 78140, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "redemptionStrategiesByTokens", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))" + }, + { + "astId": 78146, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "defaultOutputToken", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)" + }, + { + "astId": 78152, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "inputTokensByOutputToken", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 78155, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "outputTokensSet", + "offset": 0, + "slot": "9", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78163, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "conversionSlippage", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78171, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "conversionSlippageUpdated", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78179, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "uniswapV3Fees", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))" + }, + { + "astId": 78187, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "customUniV3Router", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))" + }, + { + "astId": 78197, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_optimalSwapPath", + "offset": 0, + "slot": "15", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))" + }, + { + "astId": 78201, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_wrappedToUnwrapped4626", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 78207, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_aeroCLTickSpacings", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_int24))" + }, + { + "astId": 78213, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_aeroV2IsStable", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_mapping(t_address,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_array(t_contract(IERC20Upgradeable)185186)dyn_storage": { + "base": "t_contract(IERC20Upgradeable)185186", + "encoding": "dynamic_array", + "label": "contract IERC20Upgradeable[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(AddressesProvider)51667": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)185186": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IRedemptionStrategy)69921": { + "encoding": "inplace", + "label": "contract IRedemptionStrategy", + "numberOfBytes": "20" + }, + "t_int24": { + "encoding": "inplace", + "label": "int24", + "numberOfBytes": "3" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_int24)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => int24)", + "numberOfBytes": "32", + "value": "t_int24" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_int24))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => int24))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_int24)" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(IERC20Upgradeable)185186)dyn_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable)", + "numberOfBytes": "32", + "value": "t_contract(IERC20Upgradeable)185186" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[]))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IRedemptionStrategy))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint24))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint24)", + "numberOfBytes": "32", + "value": "t_uint24" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/liquidators/registry/LiquidatorsRegistry.sol:LiquidatorsRegistry", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint24": { + "encoding": "inplace", + "label": "uint24", + "numberOfBytes": "3" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LiquidatorsRegistryExtension.json b/packages/contracts/deployments/superseed/LiquidatorsRegistryExtension.json new file mode 100644 index 0000000000..9605b7f7fc --- /dev/null +++ b/packages/contracts/deployments/superseed/LiquidatorsRegistryExtension.json @@ -0,0 +1,906 @@ +{ + "address": "0xA90f1c28F8Bc9C92113e54d0b7d007647Ee216a4", + "abi": [ + { + "inputs": [], + "name": "NoRedemptionPath", + "type": "error" + }, + { + "inputs": [], + "name": "OutputTokenMismatch", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "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": "contract IERC20Upgradeable", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20Upgradeable", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "prevValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newValue", + "type": "uint256" + } + ], + "name": "SlippageUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "MAX_SLIPPAGE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "amountOutAndSlippageOfSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "slippage", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "customUniV3Router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "defaultOutputToken", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllRedemptionStrategies", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "getInputTokensByOutputToken", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "getRedemptionStrategies", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "bytes[]", + "name": "strategiesData", + "type": "bytes[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "getRedemptionStrategy", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategy", + "type": "address" + }, + { + "internalType": "bytes", + "name": "strategyData", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "getSlippage", + "outputs": [ + { + "internalType": "uint256", + "name": "slippage", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "redemptionStrategiesByName", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesByTokens", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "uniswapV3Fees", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x8593c37bff604773ca3f81008bb416fdea4d0128ce537b9e95867cfdc86927fc", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xA90f1c28F8Bc9C92113e54d0b7d007647Ee216a4", + "transactionIndex": 1, + "gasUsed": "2470358", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800800000200000000000000000000000000000000000000000000100000000000000000000000200000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2b6b4c6943431437ceae02a300c50b4f9152af2c6e9eb654f58696449e00f032", + "transactionHash": "0x8593c37bff604773ca3f81008bb416fdea4d0128ce537b9e95867cfdc86927fc", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159500, + "transactionHash": "0x8593c37bff604773ca3f81008bb416fdea4d0128ce537b9e95867cfdc86927fc", + "address": "0xA90f1c28F8Bc9C92113e54d0b7d007647Ee216a4", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x2b6b4c6943431437ceae02a300c50b4f9152af2c6e9eb654f58696449e00f032" + } + ], + "blockNumber": 4159500, + "cumulativeGasUsed": "2514200", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NoRedemptionPath\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OutputTokenMismatch\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"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\":\"contract IERC20Upgradeable\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"prevValue\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newValue\",\"type\":\"uint256\"}],\"name\":\"SlippageUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_SLIPPAGE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"amountOutAndSlippageOfSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"outputAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"slippage\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"customUniV3Router\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"defaultOutputToken\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllRedemptionStrategies\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getInputTokensByOutputToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getRedemptionStrategies\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"bytes[]\",\"name\":\"strategiesData\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getRedemptionStrategy\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"strategyData\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"getSlippage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"slippage\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"redemptionStrategiesByName\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesByTokens\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputAmount\",\"type\":\"uint256\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"swap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"outputAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"uniswapV3Fees\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/liquidators/registry/LiquidatorsRegistryExtension.sol\":\"LiquidatorsRegistryExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/external/aerodrome/IAerodromeRouter.sol\":{\"content\":\"// SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.10;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20_Router {\\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(address from, address to, uint256 amount) external returns (bool);\\n}\\n\\ninterface IWETH is IERC20_Router {\\n function deposit() external payable;\\n\\n function withdraw(uint256) external;\\n}\\n\\ninterface IRouter_Aerodrome {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n address factory;\\n }\\n\\n error ETHTransferFailed();\\n error Expired();\\n error InsufficientAmount();\\n error InsufficientAmountA();\\n error InsufficientAmountB();\\n error InsufficientAmountADesired();\\n error InsufficientAmountBDesired();\\n error InsufficientAmountAOptimal();\\n error InsufficientLiquidity();\\n error InsufficientOutputAmount();\\n error InvalidAmountInForETHDeposit();\\n error InvalidTokenInForETHDeposit();\\n error InvalidPath();\\n error InvalidRouteA();\\n error InvalidRouteB();\\n error OnlyWETH();\\n error PoolDoesNotExist();\\n error PoolFactoryDoesNotExist();\\n error SameAddresses();\\n error ZeroAddress();\\n\\n /// @notice Address of FactoryRegistry.sol\\n function factoryRegistry() external view returns (address);\\n\\n /// @notice Address of Protocol PoolFactory.sol\\n function defaultFactory() external view returns (address);\\n\\n /// @notice Address of Voter.sol\\n function voter() external view returns (address);\\n\\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\\n function weth() external view returns (IWETH);\\n\\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\\n function ETHER() external view returns (address);\\n\\n /// @dev Struct containing information necessary to zap in and out of pools\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable Stable or volatile pool\\n /// @param factory factory of pool\\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\\n struct Zap {\\n address tokenA;\\n address tokenB;\\n bool stable;\\n address factory;\\n uint256 amountOutMinA;\\n uint256 amountOutMinB;\\n uint256 amountAMin;\\n uint256 amountBMin;\\n }\\n\\n /// @notice Sort two tokens by which address value is less than the other\\n /// @param tokenA Address of token to sort\\n /// @param tokenB Address of token to sort\\n /// @return token0 Lower address value between tokenA and tokenB\\n /// @return token1 Higher address value between tokenA and tokenB\\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\\n\\n /// @notice Calculate the address of a pool by its' factory.\\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\\n /// Reverts if _factory is not approved by the FactoryRegistry\\n /// @dev Returns a randomly generated address for a nonexistent pool\\n /// @param tokenA Address of token to query\\n /// @param tokenB Address of token to query\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of factory which created the pool\\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\\n\\n /// @notice Fetch and sort the reserves for a pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @return reserveA Amount of reserves of the sorted token A\\n /// @return reserveB Amount of reserves of the sorted token B\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n /// @notice Perform chained getAmountOut calculations on any number of pools\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n // **** ADD LIQUIDITY ****\\n\\n /// @notice Quote the amount deposited into a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Quote the amount of liquidity removed from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param _factory Address of PoolFactory for tokenA and tokenB\\n /// @param liquidity Amount of liquidity to remove\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function quoteRemoveLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 liquidity\\n ) external view returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Add liquidity of two tokens to a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @param amountAMin Minimum amount of tokenA to deposit\\n /// @param amountBMin Minimum amount of tokenB to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountTokenDesired Amount of token desired to deposit\\n /// @param amountTokenMin Minimum amount of token to deposit\\n /// @param amountETHMin Minimum amount of ETH to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to add liquidity\\n /// @return amountToken Amount of token to actually deposit\\n /// @return amountETH Amount of tokenETH to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidityETH(\\n address token,\\n bool stable,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\\n\\n // **** REMOVE LIQUIDITY ****\\n\\n /// @notice Remove liquidity of two tokens from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountAMin Minimum amount of tokenA to receive\\n /// @param amountBMin Minimum amount of tokenB to receive\\n /// @param to Recipient of tokens received\\n /// @param deadline Deadline to remove liquidity\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountToken Amount of token received\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETH(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountETH);\\n\\n // **** SWAP ****\\n\\n /// @notice Swap one token for another\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap ETH for a token\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n /// @notice Swap a token for WETH (returned as ETH)\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap one token for another without slippage protection\\n /// @return amounts Array of amounts to swap per route\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function UNSAFE_swapExactTokensForTokens(\\n uint256[] memory amounts,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n // **** SWAP (supporting fee-on-transfer tokens) ****\\n\\n /// @notice Swap one token for another supporting fee-on-transfer tokens\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external;\\n\\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable;\\n\\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external;\\n\\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\\n /// Slippage is required for the initial swap.\\n /// Additional slippage may be required when adding liquidity as the\\n /// price of the token may have changed.\\n /// @param tokenIn Token you are zapping in from (i.e. input token).\\n /// @param amountInA Amount of input token you wish to send down routesA\\n /// @param amountInB Amount of input token you wish to send down routesB\\n /// @param zapInPool Contains zap struct information. See Zap struct.\\n /// @param routesA Route used to convert input token to tokenA\\n /// @param routesB Route used to convert input token to tokenB\\n /// @param to Address you wish to mint liquidity to.\\n /// @param stake Auto-stake liquidity in corresponding gauge.\\n /// @return liquidity Amount of LP tokens created from zapping in.\\n function zapIn(\\n address tokenIn,\\n uint256 amountInA,\\n uint256 amountInB,\\n Zap calldata zapInPool,\\n Route[] calldata routesA,\\n Route[] calldata routesB,\\n address to,\\n bool stake\\n ) external payable returns (uint256 liquidity);\\n\\n /// @notice Zap out a pool (B, C) into A.\\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\\n /// Slippage is required for the removal of liquidity.\\n /// Additional slippage may be required on the swap as the\\n /// price of the token may have changed.\\n /// @param tokenOut Token you are zapping out to (i.e. output token).\\n /// @param liquidity Amount of liquidity you wish to remove.\\n /// @param zapOutPool Contains zap struct information. See Zap struct.\\n /// @param routesA Route used to convert tokenA into output token.\\n /// @param routesB Route used to convert tokenB into output token.\\n function zapOut(\\n address tokenOut,\\n uint256 liquidity,\\n Zap calldata zapOutPool,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external;\\n\\n /// @notice Used to generate params required for zapping in.\\n /// Zap in => remove liquidity then swap.\\n /// Apply slippage to expected swap values to account for changes in reserves in between.\\n /// @dev Output token refers to the token you want to zap in from.\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable .\\n /// @param _factory .\\n /// @param amountInA Amount of input token you wish to send down routesA\\n /// @param amountInB Amount of input token you wish to send down routesB\\n /// @param routesA Route used to convert input token to tokenA\\n /// @param routesB Route used to convert input token to tokenB\\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\\n function generateZapInParams(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 amountInA,\\n uint256 amountInB,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\\n\\n /// @notice Used to generate params required for zapping out.\\n /// Zap out => swap then add liquidity.\\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\\n /// @dev Output token refers to the token you want to zap out of.\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable .\\n /// @param _factory .\\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\\n /// @param routesA Route used to convert tokenA into output token.\\n /// @param routesB Route used to convert tokenB into output token.\\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\\n function generateZapOutParams(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n address _factory,\\n uint256 liquidity,\\n Route[] calldata routesA,\\n Route[] calldata routesB\\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\\n\\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\\n /// @dev Returns stable liquidity ratio of B to (A + B).\\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\\n /// Therefore you should deposit more of token A than B.\\n /// @param tokenA tokenA of stable pool you are zapping into.\\n /// @param tokenB tokenB of stable pool you are zapping into.\\n /// @param factory Factory that created stable pool.\\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\\n function quoteStableLiquidityRatio(\\n address tokenA,\\n address tokenB,\\n address factory\\n ) external view returns (uint256 ratio);\\n}\\n\",\"keccak256\":\"0x1cbdfc308cad7ca41351b75713136e52f0036b8dab53cc771ebce8aebe09a69e\",\"license\":\"Unlicense\"},\"contracts/external/solidly/IPair.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nstruct Observation {\\n uint256 timestamp;\\n uint256 reserve0Cumulative;\\n uint256 reserve1Cumulative;\\n}\\n\\ninterface IPair {\\n function observations(uint256 index) external pure returns (Observation memory);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function metadata()\\n external\\n view\\n returns (\\n uint256 dec0,\\n uint256 dec1,\\n uint256 r0,\\n uint256 r1,\\n bool st,\\n address t0,\\n address t1\\n );\\n\\n function claimFees() external returns (uint256, uint256);\\n\\n function tokens() external returns (address, address);\\n\\n function stable() external view returns (bool);\\n\\n function observationLength() external view returns (uint256);\\n\\n function lastObservation() external view returns (Observation memory);\\n\\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\\n\\n function currentCumulativePrices()\\n external\\n view\\n returns (\\n uint256 reserve0Cumulative,\\n uint256 reserve1Cumulative,\\n uint256 blockTimestamp\\n );\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\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 function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function sync() external;\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint256 _reserve0,\\n uint256 _reserve1,\\n uint256 _blockTimestampLast\\n );\\n\\n function getAmountOut(uint256, address) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xd13d4e85d4d16d46d2df3f1a8f5f1bcc6762f9d8ae0aa807847ea644ce0d0f72\",\"license\":\"MIT\"},\"contracts/external/solidly/IRouter.sol\":{\"content\":\"pragma solidity >=0.8.0;\\n\\ninterface IRouter {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n }\\n\\n function isPair(address pair) external view returns (bool);\\n\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n function pairFor(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (address pair);\\n\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n )\\n external\\n returns (\\n uint256 amountA,\\n uint256 amountB,\\n uint256 liquidity\\n );\\n\\n function swapExactTokensForTokensSimple(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address tokenFrom,\\n address tokenTo,\\n bool stable,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n )\\n external\\n view\\n returns (\\n uint256 amountA,\\n uint256 amountB,\\n uint256 liquidity\\n );\\n}\\n\",\"keccak256\":\"0x1b0243564ad8f92731f75038da17d97be2c2d8bebd5c6fa3a565d5d367909260\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/external/velodrome/IVelodromeRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IRouter_Velodrome {\\n struct Route {\\n address from;\\n address to;\\n bool stable;\\n }\\n\\n error ETHTransferFailed();\\n error Expired();\\n error InsufficientAmount();\\n error InsufficientAmountA();\\n error InsufficientAmountB();\\n error InsufficientAmountADesired();\\n error InsufficientAmountBDesired();\\n error InsufficientLiquidity();\\n error InsufficientOutputAmount();\\n error InvalidPath();\\n error OnlyWETH();\\n error SameAddresses();\\n error ZeroAddress();\\n\\n /// @notice Address of Velodrome v2 pool factory\\n function factory() external view returns (address);\\n\\n /// @notice Address of Velodrome v2 pool implementation\\n function poolImplementation() external view returns (address);\\n\\n /// @notice Sort two tokens by which address value is less than the other\\n /// @param tokenA Address of token to sort\\n /// @param tokenB Address of token to sort\\n /// @return token0 Lower address value between tokenA and tokenB\\n /// @return token1 Higher address value between tokenA and tokenB\\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\\n\\n /// @notice Calculate the address of a pool by its' factory.\\n /// @dev Returns a randomly generated address for a nonexistent pool\\n /// @param tokenA Address of token to query\\n /// @param tokenB Address of token to query\\n /// @param stable True if pool is stable, false if volatile\\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\\n\\n /// @notice Fetch and sort the reserves for a pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @return reserveA Amount of reserves of the sorted token A\\n /// @return reserveB Amount of reserves of the sorted token B\\n function getReserves(\\n address tokenA,\\n address tokenB,\\n bool stable\\n ) external view returns (uint256 reserveA, uint256 reserveB);\\n\\n /// @notice Perform chained getAmountOut calculations on any number of pools\\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\\n\\n // **** ADD LIQUIDITY ****\\n\\n /// @notice Quote the amount deposited into a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function quoteAddLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired\\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Quote the amount of liquidity removed from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function quoteRemoveLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity\\n ) external view returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Add liquidity of two tokens to a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountADesired Amount of tokenA desired to deposit\\n /// @param amountBDesired Amount of tokenB desired to deposit\\n /// @param amountAMin Minimum amount of tokenA to deposit\\n /// @param amountBMin Minimum amount of tokenB to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountA Amount of tokenA to actually deposit\\n /// @return amountB Amount of tokenB to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 amountADesired,\\n uint256 amountBDesired,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\\n\\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param amountTokenDesired Amount of token desired to deposit\\n /// @param amountTokenMin Minimum amount of token to deposit\\n /// @param amountETHMin Minimum amount of ETH to deposit\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to add liquidity\\n /// @return amountToken Amount of token to actually deposit\\n /// @return amountETH Amount of tokenETH to actually deposit\\n /// @return liquidity Amount of liquidity token returned from deposit\\n function addLiquidityETH(\\n address token,\\n bool stable,\\n uint256 amountTokenDesired,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\\n\\n // **** REMOVE LIQUIDITY ****\\n\\n /// @notice Remove liquidity of two tokens from a Pool\\n /// @param tokenA .\\n /// @param tokenB .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountAMin Minimum amount of tokenA to receive\\n /// @param amountBMin Minimum amount of tokenB to receive\\n /// @param to Recipient of tokens received\\n /// @param deadline Deadline to remove liquidity\\n /// @return amountA Amount of tokenA received\\n /// @return amountB Amount of tokenB received\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountAMin,\\n uint256 amountBMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountA, uint256 amountB);\\n\\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountToken Amount of token received\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETH(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountToken, uint256 amountETH);\\n\\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\\n /// @param token .\\n /// @param stable True if pool is stable, false if volatile\\n /// @param liquidity Amount of liquidity to remove\\n /// @param amountTokenMin Minimum amount of token to receive\\n /// @param amountETHMin Minimum amount of ETH to receive\\n /// @param to Recipient of liquidity token\\n /// @param deadline Deadline to receive liquidity\\n /// @return amountETH Amount of ETH received\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n bool stable,\\n uint256 liquidity,\\n uint256 amountTokenMin,\\n uint256 amountETHMin,\\n address to,\\n uint256 deadline\\n ) external returns (uint256 amountETH);\\n\\n /// @notice Swap one token for another\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n /// @notice Swap ETH for a token\\n /// @param amountOutMin Minimum amount of desired token received\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n /// @notice Swap a token for WETH (returned as ETH)\\n /// @param amountIn Amount of token in\\n /// @param amountOutMin Minimum amount of desired ETH\\n /// @param routes Array of trade routes used in the swap\\n /// @param to Recipient of the tokens received\\n /// @param deadline Deadline to receive tokens\\n /// @return amounts Array of amounts returned per route\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n Route[] calldata routes,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0x29168afaf1e3c6ed7ec938f37305a4687e42befebc54e27b43c980bef93d5361\",\"license\":\"MIT\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/LiquidatorsRegistryExtension.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"./ILiquidatorsRegistry.sol\\\";\\nimport \\\"./LiquidatorsRegistryStorage.sol\\\";\\n\\nimport \\\"../IRedemptionStrategy.sol\\\";\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\nimport { MasterPriceOracle } from \\\"../../oracles/MasterPriceOracle.sol\\\";\\n\\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \\\"../../external/aerodrome/IAerodromeRouter.sol\\\";\\nimport { IRouter_Velodrome as IVelodromeV2Router } from \\\"../../external/velodrome/IVelodromeRouter.sol\\\";\\nimport { IRouter } from \\\"../../external/solidly/IRouter.sol\\\";\\nimport { IPair } from \\\"../../external/solidly/IPair.sol\\\";\\nimport { IUniswapV2Pair } from \\\"../../external/uniswap/IUniswapV2Pair.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using SafeERC20Upgradeable for IERC20Upgradeable;\\n\\n error NoRedemptionPath();\\n error OutputTokenMismatch();\\n\\n event SlippageUpdated(\\n IERC20Upgradeable indexed from,\\n IERC20Upgradeable indexed to,\\n uint256 prevValue,\\n uint256 newValue\\n );\\n\\n // @notice maximum slippage in swaps, in bps\\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\\n\\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\\n uint8 fnsCount = 7;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\\n functionSelectors[--fnsCount] = this.swap.selector;\\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\\n functionSelectors[--fnsCount] = this.getSlippage.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage) {\\n slippage = conversionSlippage[inputToken][outputToken];\\n // TODO slippage == 0 should be allowed\\n if (slippage == 0) return MAX_SLIPPAGE;\\n }\\n\\n function getAllRedemptionStrategies() public view returns (address[] memory) {\\n return redemptionStrategies.values();\\n }\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage) {\\n if (inputAmount == 0) return (0, 0);\\n\\n outputAmount = swap(inputToken, inputAmount, outputToken);\\n if (outputAmount == 0) return (0, 0);\\n\\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\\\"MasterPriceOracle\\\"));\\n uint256 inputTokenPrice = mpo.price(address(inputToken));\\n uint256 outputTokenPrice = mpo.price(address(outputToken));\\n\\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\\n\\n if (outputTokensValue < inputTokensValue) {\\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\\n }\\n // min slippage should be non-zero\\n // just in case of rounding errors\\n slippage += 1;\\n\\n // cache the slippage\\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\\n\\n conversionSlippage[inputToken][outputToken] = slippage;\\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\\n }\\n }\\n\\n /// @dev returns price scaled to 1e36 - decimals\\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\\n return\\n tokenDecimals <= 18\\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\\n }\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) public returns (uint256 outputAmount) {\\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\\n outputAmount = convertAllTo(inputToken, outputToken);\\n outputToken.safeTransfer(msg.sender, outputAmount);\\n }\\n\\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\\n uint256 inputAmount = inputToken.balanceOf(address(this));\\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\\n inputToken,\\n outputToken\\n );\\n\\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\\n\\n IERC20Upgradeable swapInputToken = inputToken;\\n uint256 swapInputAmount = inputAmount;\\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\\n bytes memory strategyData = strategiesData[i];\\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\\n swapInputToken,\\n swapInputAmount,\\n redemptionStrategy,\\n strategyData\\n );\\n swapInputAmount = swapOutputAmount;\\n swapInputToken = swapOutputToken;\\n }\\n\\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\\n return outputToken.balanceOf(address(this));\\n }\\n\\n function convertCustomFunds(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IRedemptionStrategy strategy,\\n bytes memory strategyData\\n ) private returns (IERC20Upgradeable, uint256) {\\n bytes memory returndata = _functionDelegateCall(\\n address(strategy),\\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\\n );\\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\\n }\\n\\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\\n require(AddressUpgradeable.isContract(target), \\\"Address: delegate call to non-contract\\\");\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n if (returndata.length > 0) {\\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\\n return inputTokensByOutputToken[outputToken].values();\\n }\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\\n IERC20Upgradeable tokenToRedeem = inputToken;\\n IERC20Upgradeable targetOutputToken = outputToken;\\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\\n bytes[] memory strategiesDataTemp = new bytes[](10);\\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\\n uint256 optimalPathIterator = 0;\\n\\n uint256 k = 0;\\n while (tokenToRedeem != targetOutputToken) {\\n IERC20Upgradeable nextRedeemedToken;\\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\\n if (address(directStrategy) != address(0)) {\\n nextRedeemedToken = targetOutputToken;\\n } else {\\n // check if an optimal path is preconfigured\\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\\n }\\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\\n nextRedeemedToken = optimalPath[optimalPathIterator++];\\n } else {\\n // else if no optimal path is available, use the default\\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\\n }\\n }\\n\\n // check if going in an endless loop\\n for (uint256 i = 0; i < tokenPath.length; i++) {\\n if (nextRedeemedToken == tokenPath[i]) break;\\n }\\n\\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\\n tokenToRedeem,\\n nextRedeemedToken\\n );\\n if (address(strategy) == address(0)) break;\\n\\n strategiesTemp[k] = strategy;\\n strategiesDataTemp[k] = strategyData;\\n tokenPath[k] = nextRedeemedToken;\\n tokenToRedeem = nextRedeemedToken;\\n\\n k++;\\n if (k == 10) break;\\n }\\n\\n strategies = new IRedemptionStrategy[](k);\\n strategiesData = new bytes[](k);\\n\\n for (uint8 i = 0; i < k; i++) {\\n strategies[i] = strategiesTemp[i];\\n strategiesData[i] = strategiesDataTemp[i];\\n }\\n }\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\\n\\n if (isStrategy(strategy, \\\"UniswapV2LiquidatorFunder\\\") || isStrategy(strategy, \\\"KimUniV2Liquidator\\\")) {\\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"UniswapV3LiquidatorFunder\\\")) {\\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AlgebraSwapLiquidator\\\")) {\\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AerodromeV2Liquidator\\\")) {\\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"AerodromeCLLiquidator\\\")) {\\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"CurveSwapLiquidator\\\")) {\\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\\n } else if (isStrategy(strategy, \\\"VelodromeV2Liquidator\\\")) {\\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\\n } else {\\n revert(\\\"no strategy data\\\");\\n }\\n }\\n\\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\\n }\\n\\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\\n }\\n address wnative = ap.getAddress(\\\"wtoken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == wnative) return wnative;\\n }\\n address stableToken = ap.getAddress(\\\"stableToken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == stableToken) return stableToken;\\n }\\n address wbtc = ap.getAddress(\\\"wBTCToken\\\");\\n for (uint256 i = 0; i < tokens.length; i++) {\\n if (tokens[i] == wbtc) return wbtc;\\n }\\n return tokens[0];\\n }\\n\\n function getUniswapV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (address) {\\n address customRouter = customUniV3Router[inputToken][outputToken];\\n if (customRouter == address(0)) {\\n customRouter = customUniV3Router[outputToken][inputToken];\\n }\\n\\n if (customRouter != address(0)) {\\n return customRouter;\\n } else {\\n // get asset specific router or default\\n return ap.getAddress(\\\"UNISWAP_V3_ROUTER\\\");\\n }\\n }\\n\\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"IUniswapV2Router02\\\");\\n }\\n\\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"AERODROME_V2_ROUTER\\\");\\n }\\n\\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\\n // get asset specific router or default\\n return ap.getAddress(\\\"AERODROME_CL_ROUTER\\\");\\n }\\n\\n function uniswapV3LiquidatorFunderData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\\n if (fee == 0) fee = 500;\\n\\n address router = getUniswapV3Router(inputToken, outputToken);\\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\\\"Quoter\\\"));\\n }\\n\\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\\n return _wrappedToUnwrapped4626[address(inputToken)];\\n }\\n\\n function getAeroCLTickSpacing(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (int24) {\\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\\n if (tickSpacing == 0) {\\n tickSpacing = 1;\\n }\\n return tickSpacing;\\n }\\n\\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\\n }\\n\\n function uniswapV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\\n swapPath[0] = inputToken;\\n swapPath[1] = outputToken;\\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\\n }\\n\\n function aerodromeV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\\n swapPath[0] = IAerodromeV2Router.Route({\\n from: address(inputToken),\\n to: address(outputToken),\\n stable: aeroV2IsStable(inputToken, outputToken),\\n factory: ap.getAddress(\\\"AERODROME_V2_FACTORY\\\")\\n });\\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\\n }\\n\\n function aerodromeCLLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(\\n inputToken,\\n outputToken,\\n getAerodromeCLRouter(inputToken),\\n getWrappedToUnwrapped4626(inputToken),\\n getWrappedToUnwrapped4626(outputToken),\\n getAeroCLTickSpacing(inputToken, outputToken)\\n );\\n }\\n\\n function algebraSwapLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(outputToken, ap.getAddress(\\\"ALGEBRA_SWAP_ROUTER\\\"));\\n }\\n\\n function curveSwapLiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n strategyData = abi.encode(\\n ap.getAddress(\\\"CURVE_V2_ORACLE_NO_REGISTRY\\\"),\\n outputToken,\\n getWrappedToUnwrapped4626(inputToken),\\n getWrappedToUnwrapped4626(outputToken)\\n );\\n }\\n\\n function velodromeV2LiquidatorData(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) internal view returns (bytes memory strategyData) {\\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\\n swapPath[0] = IVelodromeV2Router.Route({\\n from: address(inputToken),\\n to: address(outputToken),\\n stable: aeroV2IsStable(inputToken, outputToken)\\n });\\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\\n }\\n}\\n\",\"keccak256\":\"0x992e6ecf073a14d40de42133e192d1fc21fb0b5c79436c9d748d79eb3eae2437\",\"license\":\"GPL-3.0\"},\"contracts/liquidators/registry/LiquidatorsRegistryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../IRedemptionStrategy.sol\\\";\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { AddressesProvider } from \\\"../../ionic/AddressesProvider.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\\n AddressesProvider public ap;\\n\\n EnumerableSet.AddressSet internal redemptionStrategies;\\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\\n EnumerableSet.AddressSet internal outputTokensSet;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\\n mapping(address => address) internal _wrappedToUnwrapped4626;\\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\\n}\\n\",\"keccak256\":\"0xf16140deeab4ab4f1191fe87b6158f704c8da7c71dbc4aa3d9999bc572112cb3\",\"license\":\"GPL-3.0\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4586689c55edb37fc3cac296d75d3851b3aee3f378aaa54d8a9258a384fbf541\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506200001d3362000023565b62000091565b600180546001600160a01b03191690556200003e8162000041565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612b3280620000a16000396000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c8063a6fdd2bb116100ad578063e30c397811610071578063e30c39781461031f578063ed287f3f14610330578063f2fde38b14610351578063f560cebd14610364578063f97595181461038c57600080fd5b8063a6fdd2bb1461025a578063a700f9e414610262578063b6b928fd14610296578063c8ff6fee146102b7578063dee7fe48146102eb57600080fd5b8063715018a6116100f4578063715018a6146101f957806379ba50971461020357806389f8132e1461020b5780638da5cb5b146102205780638db87c271461023157600080fd5b80632f53ef2b14610131578063398cd955146101575780633c4f743c1461019b578063403de57f146101c65780636d069a67146101e6575b600080fd5b61014461013f3660046123c5565b610395565b6040519081526020015b60405180910390f35b6101876101653660046123c5565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff909116815260200161014e565b6002546101ae906001600160a01b031681565b6040516001600160a01b03909116815260200161014e565b6101d96101d43660046123fe565b6103d0565b60405161014e919061241b565b6101446101f4366004612468565b6103f4565b610201610432565b005b610201610487565b610213610501565b60405161014e91906124aa565b6000546001600160a01b03166101ae565b6101ae61023f3660046123fe565b6007602052600090815260409020546001600160a01b031681565b6101d9610742565b6101ae6102703660046123c5565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6102a96102a43660046123c5565b610753565b60405161014e92919061253c565b6101ae6102c53660046123c5565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b6101ae6102f9366004612576565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6001546001600160a01b03166101ae565b61034361033e3660046123c5565b6109fd565b60405161014e929190612627565b61020161035f3660046123fe565b610e6d565b610377610372366004612468565b610ede565b6040805192835260208301919091520161014e565b61014461038481565b6001600160a01b038083166000908152600b60209081526040808320938516835292905290812054908190036103ca57506103845b92915050565b6001600160a01b03811660009081526008602052604090206060906103ca906111ff565b600061040b6001600160a01b03851633308661120c565b610415848361127d565b905061042b6001600160a01b0383163383611434565b9392505050565b61043a611469565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b031681146104f55760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b606482015260840161047e565b6104fe816114c5565b50565b604080516007808252610100820190925260609190600090826020820160e08036833701905050905063ed287f3f60e01b8161053c846126de565b93508360ff1681518110610552576105526126fb565b6001600160e01b03199092166020928302919091019091015263b6b928fd60e01b8161057d846126de565b93508360ff1681518110610593576105936126fb565b6001600160e01b03199092166020928302919091019091015263403de57f60e01b816105be846126de565b93508360ff16815181106105d4576105d46126fb565b6001600160e01b031990921660209283029190910190910152636d069a6760e01b816105ff846126de565b93508360ff1681518110610615576106156126fb565b6001600160e01b03199092166020928302919091019091015263a6fdd2bb60e01b81610640846126de565b93508360ff1681518110610656576106566126fb565b6001600160e01b03199092166020928302919091019091015263f560cebd60e01b81610681846126de565b93508360ff1681518110610697576106976126fb565b6001600160e01b031990921660209283029190910190910152632f53ef2b60e01b816106c2846126de565b93508360ff16815181106106d8576106d86126fb565b6001600160e01b03199092166020928302919091019091015260ff8216156103ca5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161047e565b606061074e60036111ff565b905090565b6001600160a01b0380831660009081526006602090815260408083208585168452825291829020548251808401909352601983527f556e697377617056324c697175696461746f7246756e6465720000000000000091830191909152909116906060906107c19083906114de565b806107fb57506107fb826040518060400160405280601281526020017125b4b6aab734ab192634b8bab4b230ba37b960711b8152506114de565b156108115761080a8484611528565b90506109f6565b610850826040518060400160405280601981526020017f556e697377617056334c697175696461746f7246756e646572000000000000008152506114de565b1561085f5761080a84846115e8565b610896826040518060400160405280601581526020017420b633b2b13930a9bbb0b82634b8bab4b230ba37b960591b8152506114de565b156108a55761080a848461174c565b6108dc826040518060400160405280601581526020017420b2b937b23937b6b2ab192634b8bab4b230ba37b960591b8152506114de565b156108eb5761080a8484611818565b610922826040518060400160405280601581526020017420b2b937b23937b6b2a1a62634b8bab4b230ba37b960591b8152506114de565b156109315761080a8484611988565b610966826040518060400160405280601381526020017221bab93b32a9bbb0b82634b8bab4b230ba37b960691b8152506114de565b156109755761080a8484611a0d565b6109ac82604051806040016040528060158152602001742b32b637b23937b6b2ab192634b8bab4b230ba37b960591b8152506114de565b156109bb5761080a8484611af9565b60405162461bcd60e51b815260206004820152601060248201526f6e6f207374726174656779206461746160801b604482015260640161047e565b9250929050565b60408051600a80825261016082019092526060918291859185916000916020820161014080368337505060408051600a80825261016082019092529293506000929150602082015b6060815260200190600190039081610a4557505060408051600a80825261016082019092529192506000919060208201610140803683375050604080516000808252602082019092529293509050805b866001600160a01b0316886001600160a01b031614610d19576001600160a01b0380891660009081526006602090815260408083208b851684529091528120549091168015610ae657889150610bf9565b8451158015610b1957506001600160a01b03808b166000908152600f60209081526040808320938d168352929052205415155b15610b9a576001600160a01b03808b166000908152600f60209081526040808320938d1683529281529082902080548351818402810184019094528084529091830182828015610b9257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610b74575b505050505094505b845115801590610baa5750845184105b15610bdb578484610bba81612711565b955081518110610bcc57610bcc6126fb565b60200260200101519150610bf9565b6001600160a01b03808b166000908152600760205260409020541691505b60005b8651811015610c4057868181518110610c1757610c176126fb565b60200260200101516001600160a01b0316836001600160a01b03160315610c4057600101610bfc565b50600080610c4e8c85610753565b90925090506001600160a01b038216610c6a5750505050610d19565b818a8681518110610c7d57610c7d6126fb565b60200260200101906001600160a01b031690816001600160a01b03168152505080898681518110610cb057610cb06126fb565b602002602001018190525083888681518110610cce57610cce6126fb565b60200260200101906001600160a01b031690816001600160a01b031681525050839b508480610cfc90612711565b95505084600a03610d105750505050610d19565b50505050610a95565b8067ffffffffffffffff811115610d3257610d32612560565b604051908082528060200260200182016040528015610d5b578160200160208202803683370190505b5099508067ffffffffffffffff811115610d7757610d77612560565b604051908082528060200260200182016040528015610daa57816020015b6060815260200190600190039081610d955790505b50985060005b818160ff161015610e5d57868160ff1681518110610dd057610dd06126fb565b60200260200101518b8260ff1681518110610ded57610ded6126fb565b60200260200101906001600160a01b031690816001600160a01b031681525050858160ff1681518110610e2257610e226126fb565b60200260200101518a8260ff1681518110610e3f57610e3f6126fb565b60200260200101819052508080610e559061272a565b915050610db0565b5050505050505050509250929050565b610e75611469565b600180546001600160a01b0383166001600160a01b03199091168117909155610ea66000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60008083600003610ef4575060009050806111f7565b610eff8585856103f4565b915081600003610f14575060009050806111f7565b60025460405163bf40fac160e01b81526020600482015260116024820152704d617374657250726963654f7261636c6560781b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015610f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa39190612749565b6040516315d5220f60e31b81526001600160a01b03888116600483015291925060009183169063aea9107890602401602060405180830381865afa158015610fef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110139190612766565b6040516315d5220f60e31b81526001600160a01b03878116600483015291925060009184169063aea9107890602401602060405180830381865afa15801561105f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110839190612766565b90506000611091838a611bc0565b61109b908961277f565b905060006110a98389611bc0565b6110b3908861277f565b9050818110156110e157816110c88282612796565b6110d49061271061277f565b6110de91906127a9565b95505b6110ec6001876127cb565b6001600160a01b03808c166000908152600b60209081526040808320938d168352929052205490965080158061115357506001600160a01b03808c166000908152600c60209081526040808320938d1683529290522054611388906111519042612796565b115b156111f057886001600160a01b03168b6001600160a01b03167f5d4661f2f390321d7ed6695cf1f19cd360bafab39b6dc6e06e5b48f1653486a1838a6040516111a6929190918252602082015260400190565b60405180910390a36001600160a01b03808c166000818152600b60209081526040808320948e168084529482528083208c9055928252600c81528282209382529290925290204290555b5050505050505b935093915050565b6060600061042b83611c80565b6040516001600160a01b03808516602483015283166044820152606481018290526112779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611cdc565b50505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa1580156112c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ea9190612766565b90506000806112f986866109fd565b91509150815160000361131f57604051631aa27a4d60e21b815260040160405180910390fd5b858360005b845181101561138d576000858281518110611341576113416126fb565b60200260200101519050600085838151811061135f5761135f6126fb565b6020026020010151905060008061137887878686611dae565b90975095505060019093019250611324915050565b50866001600160a01b0316826001600160a01b0316146113c05760405163fdbb00c560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b038816906370a0823190602401602060405180830381865afa158015611404573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114289190612766565b98975050505050505050565b6040516001600160a01b03831660248201526044810182905261146490849063a9059cbb60e01b90606401611240565b505050565b6000546001600160a01b031633146114c35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161047e565b565b600180546001600160a01b03191690556104fe81611e2f565b60006001600160a01b0383161580159061042b575060058260405161150391906127de565b908152604051908190036020019020546001600160a01b038481169116149392505050565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110611561576115616126fb565b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611595576115956126fb565b60200260200101906001600160a01b031690816001600160a01b0316815250506115be84611e7f565b816040516020016115d09291906127fa565b60405160208183030381529060405291505092915050565b6001600160a01b038083166000908152600d6020908152604080832093851683529290529081205460609162ffffff9091169081900361164f57506001600160a01b038083166000908152600d602090815260408083209387168352929052205462ffffff165b8062ffffff1660000361166157506101f45b600061166d8585611f10565b60025460405163bf40fac160e01b815260206004820152600660248201526528bab7ba32b960d11b604482015291925086918691859185916001600160a01b03169063bf40fac190606401602060405180830381865afa1580156116d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f99190612749565b604080516001600160a01b0396871660208201529486169085015262ffffff9092166060840152831660808301529190911660a082015260c0016040516020818303038152906040529250505092915050565b60025460405163bf40fac160e01b815260206004820152601360248201527220a623a2a12920afa9aba0a82fa927aaaa22a960691b604482015260609183916001600160a01b039091169063bf40fac190606401602060405180830381865afa1580156117bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e19190612749565b604080516001600160a01b03938416602082015292909116908201526060015b604051602081830303815290604052905092915050565b60408051600180825281830190925260609160009190816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181611833575050604080516080810182526001600160a01b0387811680835290871660208084018290526000928352601281528483209183525282902054929350919082019060ff161515815260025460405163bf40fac160e01b815260206004820181905260146024830152734145524f44524f4d455f56325f464143544f525960601b6044830152909201916001600160a01b039091169063bf40fac190606401602060405180830381865afa15801561191f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119439190612749565b6001600160a01b031681525081600081518110611962576119626126fb565b602002602001018190525061197684612015565b816040516020016115d0929190612856565b606082826119958561206a565b6001600160a01b0386811660009081526010602052604080822054888416835291205490821691166119c788886120bf565b604080516001600160a01b039788166020820152958716908601529285166060850152908416608084015290921660a082015260029190910b60c082015260e001611801565b60025460405163bf40fac160e01b815260206004820152601b60248201527f43555256455f56325f4f5241434c455f4e4f5f5245474953545259000000000060448201526060916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa89190612749565b6001600160a01b03848116600090815260106020908152604080832054878516808552938290205482519686169387019390935290850192909252908216606084015216608082015260a001611801565b60408051600180825281830190925260609160009190816020015b6040805160608101825260008082526020808301829052928201528252600019909201910181611b14575050604080516060810182526001600160a01b0387811680835290871660208084018290526000928352601281528483209183525282902054929350919082019060ff16151581525081600081518110611b9a57611b9a6126fb565b6020026020010181905250611bae84612015565b816040516020016115d09291906128d5565b600080826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c259190612938565b60ff1690506012811115611c5857611c3e601282612796565b611c4990600a612a3f565b611c5390856127a9565b611c78565b611c63816012612796565b611c6e90600a612a3f565b611c78908561277f565b949350505050565b606081600001805480602002602001604051908101604052809291908181526020018280548015611cd057602002820191906000526020600020905b815481526020019060010190808311611cbc575b50505050509050919050565b6000611d31826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120fb9092919063ffffffff16565b8051909150156114645780806020019051810190611d4f9190612a4b565b6114645760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161047e565b6000806000611e0b856310badf4e60e01b898988604051602401611dd493929190612a6d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261210a565b905080806020019051810190611e219190612a94565b925092505094509492505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460405163bf40fac160e01b815260206004820152601260248201527124aab734b9bbb0b82b192937baba32b9181960711b60448201526000916001600160a01b03169063bf40fac1906064015b602060405180830381865afa158015611eec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190612749565b6001600160a01b038083166000908152600e60209081526040808320858516845290915281205490911680611f6957506001600160a01b038083166000908152600e602090815260408083208785168452909152902054165b6001600160a01b03811615611f7f5790506103ca565b60025460405163bf40fac160e01b81526020600482015260116024820152702aa724a9aba0a82fab19afa927aaaa22a960791b60448201526001600160a01b039091169063bf40fac190606401602060405180830381865afa158015611fe9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200d9190612749565b9150506103ca565b60025460405163bf40fac160e01b815260206004820152601360248201527220a2a927a22927a6a2afab192fa927aaaa22a960691b60448201526000916001600160a01b03169063bf40fac190606401611ecf565b60025460405163bf40fac160e01b815260206004820152601360248201527220a2a927a22927a6a2afa1a62fa927aaaa22a960691b60448201526000916001600160a01b03169063bf40fac190606401611ecf565b6001600160a01b03808316600090815260116020908152604080832093851683529290529081205460020b80820361042b575060019392505050565b6060611c7884846000856121fe565b60606001600160a01b0383163b6121725760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161047e565b600080846001600160a01b03168460405161218d91906127de565b600060405180830381855af49150503d80600081146121c8576040519150601f19603f3d011682016040523d82523d6000602084013e6121cd565b606091505b50915091506121f58282604051806060016040528060278152602001612ad6602791396122d9565b95945050505050565b60608247101561225f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161047e565b600080866001600160a01b0316858760405161227b91906127de565b60006040518083038185875af1925050503d80600081146122b8576040519150601f19603f3d011682016040523d82523d6000602084013e6122bd565b606091505b50915091506122ce87838387612312565b979650505050505050565b606083156122e857508161042b565b8251156122f85782518084602001fd5b8160405162461bcd60e51b815260040161047e9190612ac2565b6060831561238157825160000361237a576001600160a01b0385163b61237a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161047e565b5081611c78565b611c7883838151156123965781518083602001fd5b8060405162461bcd60e51b815260040161047e9190612ac2565b6001600160a01b03811681146104fe57600080fd5b600080604083850312156123d857600080fd5b82356123e3816123b0565b915060208301356123f3816123b0565b809150509250929050565b60006020828403121561241057600080fd5b813561042b816123b0565b6020808252825182820181905260009190848201906040850190845b8181101561245c5783516001600160a01b031683529284019291840191600101612437565b50909695505050505050565b60008060006060848603121561247d57600080fd5b8335612488816123b0565b925060208401359150604084013561249f816123b0565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b8181101561245c5783516001600160e01b031916835292840192918401916001016124c6565b60005b838110156125075781810151838201526020016124ef565b50506000910152565b600081518084526125288160208601602086016124ec565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090611c7890830184612510565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561258857600080fd5b813567ffffffffffffffff808211156125a057600080fd5b818401915084601f8301126125b457600080fd5b8135818111156125c6576125c6612560565b604051601f8201601f19908116603f011681019083821181831017156125ee576125ee612560565b8160405282815287602084870101111561260757600080fd5b826020860160208301376000928101602001929092525095945050505050565b604080825283519082018190526000906020906060840190828701845b828110156126695781516001600160a01b031684529284019290840190600101612644565b50505083810382850152845180825282820190600581901b8301840187850160005b838110156126b957601f198684030185526126a7838351612510565b9487019492509086019060010161268b565b50909998505050505050505050565b634e487b7160e01b600052601160045260246000fd5b600060ff8216806126f1576126f16126c8565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b600060018201612723576127236126c8565b5060010190565b600060ff821660ff8103612740576127406126c8565b60010192915050565b60006020828403121561275b57600080fd5b815161042b816123b0565b60006020828403121561277857600080fd5b5051919050565b80820281158282048414176103ca576103ca6126c8565b818103818111156103ca576103ca6126c8565b6000826127c657634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103ca576103ca6126c8565b600082516127f08184602087016124ec565b9190910192915050565b6001600160a01b038381168252604060208084018290528451918401829052600092858201929091906060860190855b8181101561284857855185168352948301949183019160010161282a565b509098975050505050505050565b6001600160a01b038381168252604060208084018290528451848301819052600093606092909183870190888301875b828110156128c5578151805187168552858101518716868601528881015115158986015287015186168785015260809093019290840190600101612886565b50919a9950505050505050505050565b6001600160a01b038381168252604060208084018290528451848301819052600093606092909183870190888301875b828110156128c5578151805187168552858101518716868601528801511515888501529286019290840190600101612905565b60006020828403121561294a57600080fd5b815160ff8116811461042b57600080fd5b600181815b8085111561299657816000190482111561297c5761297c6126c8565b8085161561298957918102915b93841c9390800290612960565b509250929050565b6000826129ad575060016103ca565b816129ba575060006103ca565b81600181146129d057600281146129da576129f6565b60019150506103ca565b60ff8411156129eb576129eb6126c8565b50506001821b6103ca565b5060208310610133831016604e8410600b8410161715612a19575081810a6103ca565b612a23838361295b565b8060001904821115612a3757612a376126c8565b029392505050565b600061042b838361299e565b600060208284031215612a5d57600080fd5b8151801515811461042b57600080fd5b60018060a01b03841681528260208201526060604082015260006121f56060830184612510565b60008060408385031215612aa757600080fd5b8251612ab2816123b0565b6020939093015192949293505050565b60208152600061042b602083018461251056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051a489ca91c5567580b03f8ca1c720d649c9a4cecf7acf1bcd2caa760e9ce0a464736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061012c5760003560e01c8063a6fdd2bb116100ad578063e30c397811610071578063e30c39781461031f578063ed287f3f14610330578063f2fde38b14610351578063f560cebd14610364578063f97595181461038c57600080fd5b8063a6fdd2bb1461025a578063a700f9e414610262578063b6b928fd14610296578063c8ff6fee146102b7578063dee7fe48146102eb57600080fd5b8063715018a6116100f4578063715018a6146101f957806379ba50971461020357806389f8132e1461020b5780638da5cb5b146102205780638db87c271461023157600080fd5b80632f53ef2b14610131578063398cd955146101575780633c4f743c1461019b578063403de57f146101c65780636d069a67146101e6575b600080fd5b61014461013f3660046123c5565b610395565b6040519081526020015b60405180910390f35b6101876101653660046123c5565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff909116815260200161014e565b6002546101ae906001600160a01b031681565b6040516001600160a01b03909116815260200161014e565b6101d96101d43660046123fe565b6103d0565b60405161014e919061241b565b6101446101f4366004612468565b6103f4565b610201610432565b005b610201610487565b610213610501565b60405161014e91906124aa565b6000546001600160a01b03166101ae565b6101ae61023f3660046123fe565b6007602052600090815260409020546001600160a01b031681565b6101d9610742565b6101ae6102703660046123c5565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6102a96102a43660046123c5565b610753565b60405161014e92919061253c565b6101ae6102c53660046123c5565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b6101ae6102f9366004612576565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6001546001600160a01b03166101ae565b61034361033e3660046123c5565b6109fd565b60405161014e929190612627565b61020161035f3660046123fe565b610e6d565b610377610372366004612468565b610ede565b6040805192835260208301919091520161014e565b61014461038481565b6001600160a01b038083166000908152600b60209081526040808320938516835292905290812054908190036103ca57506103845b92915050565b6001600160a01b03811660009081526008602052604090206060906103ca906111ff565b600061040b6001600160a01b03851633308661120c565b610415848361127d565b905061042b6001600160a01b0383163383611434565b9392505050565b61043a611469565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f776564000060448201526064015b60405180910390fd5b60015433906001600160a01b031681146104f55760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b606482015260840161047e565b6104fe816114c5565b50565b604080516007808252610100820190925260609190600090826020820160e08036833701905050905063ed287f3f60e01b8161053c846126de565b93508360ff1681518110610552576105526126fb565b6001600160e01b03199092166020928302919091019091015263b6b928fd60e01b8161057d846126de565b93508360ff1681518110610593576105936126fb565b6001600160e01b03199092166020928302919091019091015263403de57f60e01b816105be846126de565b93508360ff16815181106105d4576105d46126fb565b6001600160e01b031990921660209283029190910190910152636d069a6760e01b816105ff846126de565b93508360ff1681518110610615576106156126fb565b6001600160e01b03199092166020928302919091019091015263a6fdd2bb60e01b81610640846126de565b93508360ff1681518110610656576106566126fb565b6001600160e01b03199092166020928302919091019091015263f560cebd60e01b81610681846126de565b93508360ff1681518110610697576106976126fb565b6001600160e01b031990921660209283029190910190910152632f53ef2b60e01b816106c2846126de565b93508360ff16815181106106d8576106d86126fb565b6001600160e01b03199092166020928302919091019091015260ff8216156103ca5760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e67746800000000604482015260640161047e565b606061074e60036111ff565b905090565b6001600160a01b0380831660009081526006602090815260408083208585168452825291829020548251808401909352601983527f556e697377617056324c697175696461746f7246756e6465720000000000000091830191909152909116906060906107c19083906114de565b806107fb57506107fb826040518060400160405280601281526020017125b4b6aab734ab192634b8bab4b230ba37b960711b8152506114de565b156108115761080a8484611528565b90506109f6565b610850826040518060400160405280601981526020017f556e697377617056334c697175696461746f7246756e646572000000000000008152506114de565b1561085f5761080a84846115e8565b610896826040518060400160405280601581526020017420b633b2b13930a9bbb0b82634b8bab4b230ba37b960591b8152506114de565b156108a55761080a848461174c565b6108dc826040518060400160405280601581526020017420b2b937b23937b6b2ab192634b8bab4b230ba37b960591b8152506114de565b156108eb5761080a8484611818565b610922826040518060400160405280601581526020017420b2b937b23937b6b2a1a62634b8bab4b230ba37b960591b8152506114de565b156109315761080a8484611988565b610966826040518060400160405280601381526020017221bab93b32a9bbb0b82634b8bab4b230ba37b960691b8152506114de565b156109755761080a8484611a0d565b6109ac82604051806040016040528060158152602001742b32b637b23937b6b2ab192634b8bab4b230ba37b960591b8152506114de565b156109bb5761080a8484611af9565b60405162461bcd60e51b815260206004820152601060248201526f6e6f207374726174656779206461746160801b604482015260640161047e565b9250929050565b60408051600a80825261016082019092526060918291859185916000916020820161014080368337505060408051600a80825261016082019092529293506000929150602082015b6060815260200190600190039081610a4557505060408051600a80825261016082019092529192506000919060208201610140803683375050604080516000808252602082019092529293509050805b866001600160a01b0316886001600160a01b031614610d19576001600160a01b0380891660009081526006602090815260408083208b851684529091528120549091168015610ae657889150610bf9565b8451158015610b1957506001600160a01b03808b166000908152600f60209081526040808320938d168352929052205415155b15610b9a576001600160a01b03808b166000908152600f60209081526040808320938d1683529281529082902080548351818402810184019094528084529091830182828015610b9257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610b74575b505050505094505b845115801590610baa5750845184105b15610bdb578484610bba81612711565b955081518110610bcc57610bcc6126fb565b60200260200101519150610bf9565b6001600160a01b03808b166000908152600760205260409020541691505b60005b8651811015610c4057868181518110610c1757610c176126fb565b60200260200101516001600160a01b0316836001600160a01b03160315610c4057600101610bfc565b50600080610c4e8c85610753565b90925090506001600160a01b038216610c6a5750505050610d19565b818a8681518110610c7d57610c7d6126fb565b60200260200101906001600160a01b031690816001600160a01b03168152505080898681518110610cb057610cb06126fb565b602002602001018190525083888681518110610cce57610cce6126fb565b60200260200101906001600160a01b031690816001600160a01b031681525050839b508480610cfc90612711565b95505084600a03610d105750505050610d19565b50505050610a95565b8067ffffffffffffffff811115610d3257610d32612560565b604051908082528060200260200182016040528015610d5b578160200160208202803683370190505b5099508067ffffffffffffffff811115610d7757610d77612560565b604051908082528060200260200182016040528015610daa57816020015b6060815260200190600190039081610d955790505b50985060005b818160ff161015610e5d57868160ff1681518110610dd057610dd06126fb565b60200260200101518b8260ff1681518110610ded57610ded6126fb565b60200260200101906001600160a01b031690816001600160a01b031681525050858160ff1681518110610e2257610e226126fb565b60200260200101518a8260ff1681518110610e3f57610e3f6126fb565b60200260200101819052508080610e559061272a565b915050610db0565b5050505050505050509250929050565b610e75611469565b600180546001600160a01b0383166001600160a01b03199091168117909155610ea66000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60008083600003610ef4575060009050806111f7565b610eff8585856103f4565b915081600003610f14575060009050806111f7565b60025460405163bf40fac160e01b81526020600482015260116024820152704d617374657250726963654f7261636c6560781b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015610f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa39190612749565b6040516315d5220f60e31b81526001600160a01b03888116600483015291925060009183169063aea9107890602401602060405180830381865afa158015610fef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110139190612766565b6040516315d5220f60e31b81526001600160a01b03878116600483015291925060009184169063aea9107890602401602060405180830381865afa15801561105f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110839190612766565b90506000611091838a611bc0565b61109b908961277f565b905060006110a98389611bc0565b6110b3908861277f565b9050818110156110e157816110c88282612796565b6110d49061271061277f565b6110de91906127a9565b95505b6110ec6001876127cb565b6001600160a01b03808c166000908152600b60209081526040808320938d168352929052205490965080158061115357506001600160a01b03808c166000908152600c60209081526040808320938d1683529290522054611388906111519042612796565b115b156111f057886001600160a01b03168b6001600160a01b03167f5d4661f2f390321d7ed6695cf1f19cd360bafab39b6dc6e06e5b48f1653486a1838a6040516111a6929190918252602082015260400190565b60405180910390a36001600160a01b03808c166000818152600b60209081526040808320948e168084529482528083208c9055928252600c81528282209382529290925290204290555b5050505050505b935093915050565b6060600061042b83611c80565b6040516001600160a01b03808516602483015283166044820152606481018290526112779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611cdc565b50505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa1580156112c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ea9190612766565b90506000806112f986866109fd565b91509150815160000361131f57604051631aa27a4d60e21b815260040160405180910390fd5b858360005b845181101561138d576000858281518110611341576113416126fb565b60200260200101519050600085838151811061135f5761135f6126fb565b6020026020010151905060008061137887878686611dae565b90975095505060019093019250611324915050565b50866001600160a01b0316826001600160a01b0316146113c05760405163fdbb00c560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b038816906370a0823190602401602060405180830381865afa158015611404573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114289190612766565b98975050505050505050565b6040516001600160a01b03831660248201526044810182905261146490849063a9059cbb60e01b90606401611240565b505050565b6000546001600160a01b031633146114c35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161047e565b565b600180546001600160a01b03191690556104fe81611e2f565b60006001600160a01b0383161580159061042b575060058260405161150391906127de565b908152604051908190036020019020546001600160a01b038481169116149392505050565b604080516002808252606080830184529260009291906020830190803683370190505090508381600081518110611561576115616126fb565b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611595576115956126fb565b60200260200101906001600160a01b031690816001600160a01b0316815250506115be84611e7f565b816040516020016115d09291906127fa565b60405160208183030381529060405291505092915050565b6001600160a01b038083166000908152600d6020908152604080832093851683529290529081205460609162ffffff9091169081900361164f57506001600160a01b038083166000908152600d602090815260408083209387168352929052205462ffffff165b8062ffffff1660000361166157506101f45b600061166d8585611f10565b60025460405163bf40fac160e01b815260206004820152600660248201526528bab7ba32b960d11b604482015291925086918691859185916001600160a01b03169063bf40fac190606401602060405180830381865afa1580156116d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f99190612749565b604080516001600160a01b0396871660208201529486169085015262ffffff9092166060840152831660808301529190911660a082015260c0016040516020818303038152906040529250505092915050565b60025460405163bf40fac160e01b815260206004820152601360248201527220a623a2a12920afa9aba0a82fa927aaaa22a960691b604482015260609183916001600160a01b039091169063bf40fac190606401602060405180830381865afa1580156117bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e19190612749565b604080516001600160a01b03938416602082015292909116908201526060015b604051602081830303815290604052905092915050565b60408051600180825281830190925260609160009190816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181611833575050604080516080810182526001600160a01b0387811680835290871660208084018290526000928352601281528483209183525282902054929350919082019060ff161515815260025460405163bf40fac160e01b815260206004820181905260146024830152734145524f44524f4d455f56325f464143544f525960601b6044830152909201916001600160a01b039091169063bf40fac190606401602060405180830381865afa15801561191f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119439190612749565b6001600160a01b031681525081600081518110611962576119626126fb565b602002602001018190525061197684612015565b816040516020016115d0929190612856565b606082826119958561206a565b6001600160a01b0386811660009081526010602052604080822054888416835291205490821691166119c788886120bf565b604080516001600160a01b039788166020820152958716908601529285166060850152908416608084015290921660a082015260029190910b60c082015260e001611801565b60025460405163bf40fac160e01b815260206004820152601b60248201527f43555256455f56325f4f5241434c455f4e4f5f5245474953545259000000000060448201526060916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa89190612749565b6001600160a01b03848116600090815260106020908152604080832054878516808552938290205482519686169387019390935290850192909252908216606084015216608082015260a001611801565b60408051600180825281830190925260609160009190816020015b6040805160608101825260008082526020808301829052928201528252600019909201910181611b14575050604080516060810182526001600160a01b0387811680835290871660208084018290526000928352601281528483209183525282902054929350919082019060ff16151581525081600081518110611b9a57611b9a6126fb565b6020026020010181905250611bae84612015565b816040516020016115d09291906128d5565b600080826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c259190612938565b60ff1690506012811115611c5857611c3e601282612796565b611c4990600a612a3f565b611c5390856127a9565b611c78565b611c63816012612796565b611c6e90600a612a3f565b611c78908561277f565b949350505050565b606081600001805480602002602001604051908101604052809291908181526020018280548015611cd057602002820191906000526020600020905b815481526020019060010190808311611cbc575b50505050509050919050565b6000611d31826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120fb9092919063ffffffff16565b8051909150156114645780806020019051810190611d4f9190612a4b565b6114645760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161047e565b6000806000611e0b856310badf4e60e01b898988604051602401611dd493929190612a6d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261210a565b905080806020019051810190611e219190612a94565b925092505094509492505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460405163bf40fac160e01b815260206004820152601260248201527124aab734b9bbb0b82b192937baba32b9181960711b60448201526000916001600160a01b03169063bf40fac1906064015b602060405180830381865afa158015611eec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190612749565b6001600160a01b038083166000908152600e60209081526040808320858516845290915281205490911680611f6957506001600160a01b038083166000908152600e602090815260408083208785168452909152902054165b6001600160a01b03811615611f7f5790506103ca565b60025460405163bf40fac160e01b81526020600482015260116024820152702aa724a9aba0a82fab19afa927aaaa22a960791b60448201526001600160a01b039091169063bf40fac190606401602060405180830381865afa158015611fe9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200d9190612749565b9150506103ca565b60025460405163bf40fac160e01b815260206004820152601360248201527220a2a927a22927a6a2afab192fa927aaaa22a960691b60448201526000916001600160a01b03169063bf40fac190606401611ecf565b60025460405163bf40fac160e01b815260206004820152601360248201527220a2a927a22927a6a2afa1a62fa927aaaa22a960691b60448201526000916001600160a01b03169063bf40fac190606401611ecf565b6001600160a01b03808316600090815260116020908152604080832093851683529290529081205460020b80820361042b575060019392505050565b6060611c7884846000856121fe565b60606001600160a01b0383163b6121725760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161047e565b600080846001600160a01b03168460405161218d91906127de565b600060405180830381855af49150503d80600081146121c8576040519150601f19603f3d011682016040523d82523d6000602084013e6121cd565b606091505b50915091506121f58282604051806060016040528060278152602001612ad6602791396122d9565b95945050505050565b60608247101561225f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161047e565b600080866001600160a01b0316858760405161227b91906127de565b60006040518083038185875af1925050503d80600081146122b8576040519150601f19603f3d011682016040523d82523d6000602084013e6122bd565b606091505b50915091506122ce87838387612312565b979650505050505050565b606083156122e857508161042b565b8251156122f85782518084602001fd5b8160405162461bcd60e51b815260040161047e9190612ac2565b6060831561238157825160000361237a576001600160a01b0385163b61237a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161047e565b5081611c78565b611c7883838151156123965781518083602001fd5b8060405162461bcd60e51b815260040161047e9190612ac2565b6001600160a01b03811681146104fe57600080fd5b600080604083850312156123d857600080fd5b82356123e3816123b0565b915060208301356123f3816123b0565b809150509250929050565b60006020828403121561241057600080fd5b813561042b816123b0565b6020808252825182820181905260009190848201906040850190845b8181101561245c5783516001600160a01b031683529284019291840191600101612437565b50909695505050505050565b60008060006060848603121561247d57600080fd5b8335612488816123b0565b925060208401359150604084013561249f816123b0565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b8181101561245c5783516001600160e01b031916835292840192918401916001016124c6565b60005b838110156125075781810151838201526020016124ef565b50506000910152565b600081518084526125288160208601602086016124ec565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090611c7890830184612510565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561258857600080fd5b813567ffffffffffffffff808211156125a057600080fd5b818401915084601f8301126125b457600080fd5b8135818111156125c6576125c6612560565b604051601f8201601f19908116603f011681019083821181831017156125ee576125ee612560565b8160405282815287602084870101111561260757600080fd5b826020860160208301376000928101602001929092525095945050505050565b604080825283519082018190526000906020906060840190828701845b828110156126695781516001600160a01b031684529284019290840190600101612644565b50505083810382850152845180825282820190600581901b8301840187850160005b838110156126b957601f198684030185526126a7838351612510565b9487019492509086019060010161268b565b50909998505050505050505050565b634e487b7160e01b600052601160045260246000fd5b600060ff8216806126f1576126f16126c8565b6000190192915050565b634e487b7160e01b600052603260045260246000fd5b600060018201612723576127236126c8565b5060010190565b600060ff821660ff8103612740576127406126c8565b60010192915050565b60006020828403121561275b57600080fd5b815161042b816123b0565b60006020828403121561277857600080fd5b5051919050565b80820281158282048414176103ca576103ca6126c8565b818103818111156103ca576103ca6126c8565b6000826127c657634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103ca576103ca6126c8565b600082516127f08184602087016124ec565b9190910192915050565b6001600160a01b038381168252604060208084018290528451918401829052600092858201929091906060860190855b8181101561284857855185168352948301949183019160010161282a565b509098975050505050505050565b6001600160a01b038381168252604060208084018290528451848301819052600093606092909183870190888301875b828110156128c5578151805187168552858101518716868601528881015115158986015287015186168785015260809093019290840190600101612886565b50919a9950505050505050505050565b6001600160a01b038381168252604060208084018290528451848301819052600093606092909183870190888301875b828110156128c5578151805187168552858101518716868601528801511515888501529286019290840190600101612905565b60006020828403121561294a57600080fd5b815160ff8116811461042b57600080fd5b600181815b8085111561299657816000190482111561297c5761297c6126c8565b8085161561298957918102915b93841c9390800290612960565b509250929050565b6000826129ad575060016103ca565b816129ba575060006103ca565b81600181146129d057600281146129da576129f6565b60019150506103ca565b60ff8411156129eb576129eb6126c8565b50506001821b6103ca565b5060208310610133831016604e8410600b8410161715612a19575081810a6103ca565b612a23838361295b565b8060001904821115612a3757612a376126c8565b029392505050565b600061042b838361299e565b600060208284031215612a5d57600080fd5b8151801515811461042b57600080fd5b60018060a01b03841681528260208201526060604082015260006121f56060830184612510565b60008060408385031215612aa757600080fd5b8251612ab2816123b0565b6020939093015192949293505050565b60208152600061042b602083018461251056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051a489ca91c5567580b03f8ca1c720d649c9a4cecf7acf1bcd2caa760e9ce0a464736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2741, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2854, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 78123, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "ap", + "offset": 0, + "slot": "2", + "type": "t_contract(AddressesProvider)51667" + }, + { + "astId": 78126, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "redemptionStrategies", + "offset": 0, + "slot": "3", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78131, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "redemptionStrategiesByName", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)" + }, + { + "astId": 78140, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "redemptionStrategiesByTokens", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))" + }, + { + "astId": 78146, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "defaultOutputToken", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)" + }, + { + "astId": 78152, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "inputTokensByOutputToken", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 78155, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "outputTokensSet", + "offset": 0, + "slot": "9", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78163, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "conversionSlippage", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78171, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "conversionSlippageUpdated", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78179, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "uniswapV3Fees", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))" + }, + { + "astId": 78187, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "customUniV3Router", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))" + }, + { + "astId": 78197, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_optimalSwapPath", + "offset": 0, + "slot": "15", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))" + }, + { + "astId": 78201, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_wrappedToUnwrapped4626", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 78207, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_aeroCLTickSpacings", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_int24))" + }, + { + "astId": 78213, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_aeroV2IsStable", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_mapping(t_address,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_array(t_contract(IERC20Upgradeable)185186)dyn_storage": { + "base": "t_contract(IERC20Upgradeable)185186", + "encoding": "dynamic_array", + "label": "contract IERC20Upgradeable[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(AddressesProvider)51667": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)185186": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IRedemptionStrategy)69921": { + "encoding": "inplace", + "label": "contract IRedemptionStrategy", + "numberOfBytes": "20" + }, + "t_int24": { + "encoding": "inplace", + "label": "int24", + "numberOfBytes": "3" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_int24)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => int24)", + "numberOfBytes": "32", + "value": "t_int24" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_int24))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => int24))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_int24)" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(IERC20Upgradeable)185186)dyn_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable)", + "numberOfBytes": "32", + "value": "t_contract(IERC20Upgradeable)185186" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[]))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IRedemptionStrategy))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint24))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint24)", + "numberOfBytes": "32", + "value": "t_uint24" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol:LiquidatorsRegistryExtension", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint24": { + "encoding": "inplace", + "label": "uint24", + "numberOfBytes": "3" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LiquidatorsRegistrySecondExtension.json b/packages/contracts/deployments/superseed/LiquidatorsRegistrySecondExtension.json new file mode 100644 index 0000000000..f21618262c --- /dev/null +++ b/packages/contracts/deployments/superseed/LiquidatorsRegistrySecondExtension.json @@ -0,0 +1,1132 @@ +{ + "address": "0xc71B968C6C23e2723Bae32957D815C9bE3ca1b34", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "_getExtensionFunctions", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategyToRemove", + "type": "address" + } + ], + "name": "_removeRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + } + ], + "name": "_resetRedemptionStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickSpacing", + "type": "int24" + } + ], + "name": "_setAeroCLTickSpacings", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "bool", + "name": "isStable", + "type": "bool" + } + ], + "name": "_setAeroV2IsStable", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "_setDefaultOutputToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "optimalPath", + "type": "address[]" + } + ], + "name": "_setOptimalSwapPath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + } + ], + "name": "_setRedemptionStrategies", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "strategy", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "_setRedemptionStrategy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "slippages", + "type": "uint256[]" + } + ], + "name": "_setSlippages", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + }, + { + "internalType": "uint24[]", + "name": "fees", + "type": "uint24[]" + } + ], + "name": "_setUniswapV3Fees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "routers", + "type": "address[]" + } + ], + "name": "_setUniswapV3Routers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrapped", + "type": "address" + }, + { + "internalType": "address", + "name": "unwrapped", + "type": "address" + } + ], + "name": "_setWrappedToUnwrapped4626", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "aeroCLTickSpacings", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "address", + "name": "outputToken", + "type": "address" + } + ], + "name": "aeroV2IsStable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ap", + "outputs": [ + { + "internalType": "contract AddressesProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "customUniV3Router", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "defaultOutputToken", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllPairsStrategies", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "strategies", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "inputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "outputTokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + } + ], + "name": "optimalSwapPath", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRedemptionStrategy[]", + "name": "configStrategies", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configInputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configOutputTokens", + "type": "address[]" + } + ], + "name": "pairsStrategiesMatch", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "redemptionStrategiesByName", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "redemptionStrategiesByTokens", + "outputs": [ + { + "internalType": "contract IRedemptionStrategy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configInputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configOutputTokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "configFees", + "type": "uint256[]" + } + ], + "name": "uniswapPairsFeesMatch", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configInputTokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20Upgradeable[]", + "name": "configOutputTokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "configRouters", + "type": "address[]" + } + ], + "name": "uniswapPairsRoutersMatch", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "name": "uniswapV3Fees", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wrapped", + "type": "address" + } + ], + "name": "wrappedToUnwrapped4626", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x7c643e56438c2c906357b2c0e48f63939d8e644d62b42f89d0effa2ef40daf9e", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xc71B968C6C23e2723Bae32957D815C9bE3ca1b34", + "transactionIndex": 1, + "gasUsed": "2437336", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000008000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000002000000000000000000000000000000000000000000000", + "blockHash": "0x1fd4280471a83b8aad5109e3d47140bde453baaf95d235401d6f113b576c4a37", + "transactionHash": "0x7c643e56438c2c906357b2c0e48f63939d8e644d62b42f89d0effa2ef40daf9e", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159503, + "transactionHash": "0x7c643e56438c2c906357b2c0e48f63939d8e644d62b42f89d0effa2ef40daf9e", + "address": "0xc71B968C6C23e2723Bae32957D815C9bE3ca1b34", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x1fd4280471a83b8aad5109e3d47140bde453baaf95d235401d6f113b576c4a37" + } + ], + "blockNumber": 4159503, + "cumulativeGasUsed": "2489566", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_getExtensionFunctions\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"strategyToRemove\",\"type\":\"address\"}],\"name\":\"_removeRedemptionStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"}],\"name\":\"_resetRedemptionStrategies\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"int24\",\"name\":\"tickSpacing\",\"type\":\"int24\"}],\"name\":\"_setAeroCLTickSpacings\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isStable\",\"type\":\"bool\"}],\"name\":\"_setAeroV2IsStable\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"_setDefaultOutputToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"optimalPath\",\"type\":\"address[]\"}],\"name\":\"_setOptimalSwapPath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"}],\"name\":\"_setRedemptionStrategies\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"_setRedemptionStrategy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"slippages\",\"type\":\"uint256[]\"}],\"name\":\"_setSlippages\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint24[]\",\"name\":\"fees\",\"type\":\"uint24[]\"}],\"name\":\"_setUniswapV3Fees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"routers\",\"type\":\"address[]\"}],\"name\":\"_setUniswapV3Routers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wrapped\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"unwrapped\",\"type\":\"address\"}],\"name\":\"_setWrappedToUnwrapped4626\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"aeroCLTickSpacings\",\"outputs\":[{\"internalType\":\"int24\",\"name\":\"\",\"type\":\"int24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"aeroV2IsStable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ap\",\"outputs\":[{\"internalType\":\"contract AddressesProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"customUniV3Router\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"defaultOutputToken\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllPairsStrategies\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"strategies\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"inputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"outputTokens\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"}],\"name\":\"optimalSwapPath\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IRedemptionStrategy[]\",\"name\":\"configStrategies\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configInputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configOutputTokens\",\"type\":\"address[]\"}],\"name\":\"pairsStrategiesMatch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"redemptionStrategiesByName\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"redemptionStrategiesByTokens\",\"outputs\":[{\"internalType\":\"contract IRedemptionStrategy\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configInputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configOutputTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"configFees\",\"type\":\"uint256[]\"}],\"name\":\"uniswapPairsFeesMatch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configInputTokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20Upgradeable[]\",\"name\":\"configOutputTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"configRouters\",\"type\":\"address[]\"}],\"name\":\"uniswapPairsRoutersMatch\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"uniswapV3Fees\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wrapped\",\"type\":\"address\"}],\"name\":\"wrappedToUnwrapped4626\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"_getExtensionFunctions()\":{\"returns\":{\"_0\":\"a list of all the function selectors that this logic extension exposes\"}},\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol\":\"LiquidatorsRegistrySecondExtension\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\nabstract contract SafeOwnable is Ownable2Step {\\n function renounceOwnership() public override onlyOwner {\\n revert(\\\"renounce ownership not allowed\\\");\\n }\\n}\\n\",\"keccak256\":\"0x197d918d773af5d2d6b0235539ede726a9dd5f5153e4c0356a5700f2d85c836f\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/ILiquidatorsRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"../../liquidators/IRedemptionStrategy.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface ILiquidatorsRegistryStorage {\\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\\n\\n function redemptionStrategiesByTokens(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy);\\n\\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\\n\\n function owner() external view returns (address);\\n\\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\\n\\n function customUniV3Router(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (address);\\n}\\n\\ninterface ILiquidatorsRegistryExtension {\\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\\n\\n function getRedemptionStrategies(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\\n\\n function getRedemptionStrategy(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\\n\\n function getAllRedemptionStrategies() external view returns (address[] memory);\\n\\n function getSlippage(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (uint256 slippage);\\n\\n function swap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256);\\n\\n function amountOutAndSlippageOfSwap(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n IERC20Upgradeable outputToken\\n ) external returns (uint256 outputAmount, uint256 slippage);\\n}\\n\\ninterface ILiquidatorsRegistrySecondExtension {\\n function getAllPairsStrategies()\\n external\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n );\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool);\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool);\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool);\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external;\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external;\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external;\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external;\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external;\\n\\n function optimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) external view returns (IERC20Upgradeable[] memory);\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external;\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\\n}\\n\\ninterface ILiquidatorsRegistry is\\n ILiquidatorsRegistryExtension,\\n ILiquidatorsRegistrySecondExtension,\\n ILiquidatorsRegistryStorage\\n{}\\n\",\"keccak256\":\"0x53b61246b353c91a1d3c646c458210abbeeeeb2f3536c6f57cf6d97983eeb74e\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"./ILiquidatorsRegistry.sol\\\";\\nimport \\\"./LiquidatorsRegistryStorage.sol\\\";\\n\\nimport \\\"../../ionic/DiamondExtension.sol\\\";\\n\\ncontract LiquidatorsRegistrySecondExtension is\\n LiquidatorsRegistryStorage,\\n DiamondExtension,\\n ILiquidatorsRegistrySecondExtension\\n{\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\\n uint8 fnsCount = 20;\\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\\n functionSelectors[--fnsCount] = this.getAllPairsStrategies.selector;\\n functionSelectors[--fnsCount] = this.pairsStrategiesMatch.selector;\\n functionSelectors[--fnsCount] = this.uniswapPairsFeesMatch.selector;\\n functionSelectors[--fnsCount] = this.uniswapPairsRoutersMatch.selector;\\n functionSelectors[--fnsCount] = this._setSlippages.selector;\\n functionSelectors[--fnsCount] = this._setUniswapV3Fees.selector;\\n functionSelectors[--fnsCount] = this._setUniswapV3Routers.selector;\\n functionSelectors[--fnsCount] = this._setDefaultOutputToken.selector;\\n functionSelectors[--fnsCount] = this._setRedemptionStrategy.selector;\\n functionSelectors[--fnsCount] = this._setRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this._removeRedemptionStrategy.selector;\\n functionSelectors[--fnsCount] = this._resetRedemptionStrategies.selector;\\n functionSelectors[--fnsCount] = this.optimalSwapPath.selector;\\n functionSelectors[--fnsCount] = this._setOptimalSwapPath.selector;\\n functionSelectors[--fnsCount] = this.wrappedToUnwrapped4626.selector;\\n functionSelectors[--fnsCount] = this.aeroCLTickSpacings.selector;\\n functionSelectors[--fnsCount] = this.aeroV2IsStable.selector;\\n functionSelectors[--fnsCount] = this._setWrappedToUnwrapped4626.selector;\\n functionSelectors[--fnsCount] = this._setAeroCLTickSpacings.selector;\\n functionSelectors[--fnsCount] = this._setAeroV2IsStable.selector;\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return functionSelectors;\\n }\\n\\n function _setSlippages(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint256[] calldata slippages\\n ) external onlyOwner {\\n require(slippages.length == inputTokens.length && inputTokens.length == outputTokens.length, \\\"!arrays len\\\");\\n\\n for (uint256 i = 0; i < slippages.length; i++) {\\n conversionSlippage[inputTokens[i]][outputTokens[i]] = slippages[i];\\n }\\n }\\n\\n function _setUniswapV3Fees(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n uint24[] calldata fees\\n ) external onlyOwner {\\n require(fees.length == inputTokens.length && inputTokens.length == outputTokens.length, \\\"!arrays len\\\");\\n\\n for (uint256 i = 0; i < fees.length; i++) {\\n uniswapV3Fees[inputTokens[i]][outputTokens[i]] = fees[i];\\n }\\n }\\n\\n function _setUniswapV3Routers(\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens,\\n address[] calldata routers\\n ) external onlyOwner {\\n require(routers.length == inputTokens.length && inputTokens.length == outputTokens.length, \\\"!arrays len\\\");\\n\\n for (uint256 i = 0; i < routers.length; i++) {\\n customUniV3Router[inputTokens[i]][outputTokens[i]] = routers[i];\\n }\\n }\\n\\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external onlyOwner {\\n defaultOutputToken[inputToken] = outputToken;\\n }\\n\\n function _setRedemptionStrategy(\\n IRedemptionStrategy strategy,\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken\\n ) public onlyOwner {\\n string memory name = strategy.name();\\n IRedemptionStrategy oldStrategy = redemptionStrategiesByName[name];\\n\\n redemptionStrategiesByTokens[inputToken][outputToken] = strategy;\\n redemptionStrategiesByName[name] = strategy;\\n\\n redemptionStrategies.remove(address(oldStrategy));\\n redemptionStrategies.add(address(strategy));\\n\\n if (defaultOutputToken[inputToken] == IERC20Upgradeable(address(0))) {\\n defaultOutputToken[inputToken] = outputToken;\\n }\\n inputTokensByOutputToken[outputToken].add(address(inputToken));\\n outputTokensSet.add(address(outputToken));\\n }\\n\\n function _setRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external onlyOwner {\\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \\\"!arrays len\\\");\\n for (uint256 i = 0; i < strategies.length; i++) {\\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\\n }\\n }\\n\\n function _resetRedemptionStrategies(\\n IRedemptionStrategy[] calldata strategies,\\n IERC20Upgradeable[] calldata inputTokens,\\n IERC20Upgradeable[] calldata outputTokens\\n ) external onlyOwner {\\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \\\"!arrays len\\\");\\n\\n // empty the input/output token mappings/sets\\n address[] memory _outputTokens = outputTokensSet.values();\\n for (uint256 i = 0; i < _outputTokens.length; i++) {\\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\\n for (uint256 j = 0; j < _inputTokens.length; j++) {\\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\\n }\\n outputTokensSet.remove(_outputTokens[i]);\\n }\\n\\n // empty the strategies mappings/sets\\n address[] memory _currentStrategies = redemptionStrategies.values();\\n for (uint256 i = 0; i < _currentStrategies.length; i++) {\\n IRedemptionStrategy _currentStrategy = IRedemptionStrategy(_currentStrategies[i]);\\n string memory _name = _currentStrategy.name();\\n redemptionStrategiesByName[_name] = IRedemptionStrategy(address(0));\\n redemptionStrategies.remove(_currentStrategies[i]);\\n }\\n\\n // write the new strategies and their tokens configs\\n for (uint256 i = 0; i < strategies.length; i++) {\\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\\n }\\n }\\n\\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external onlyOwner {\\n // check all the input/output tokens if they match the strategy to remove\\n address[] memory _outputTokens = outputTokensSet.values();\\n for (uint256 i = 0; i < _outputTokens.length; i++) {\\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\\n for (uint256 j = 0; j < _inputTokens.length; j++) {\\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\\n IRedemptionStrategy _currentStrategy = redemptionStrategiesByTokens[_inputToken][_outputToken];\\n\\n // only nullify the input/output tokens config if the strategy matches\\n if (_currentStrategy == strategyToRemove) {\\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\\n if (defaultOutputToken[_inputToken] == _outputToken) {\\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\\n }\\n }\\n }\\n if (inputTokensByOutputToken[_outputToken].length() == 0) {\\n outputTokensSet.remove(address(_outputToken));\\n }\\n }\\n\\n redemptionStrategiesByName[strategyToRemove.name()] = IRedemptionStrategy(address(0));\\n redemptionStrategies.remove(address(strategyToRemove));\\n }\\n\\n function uniswapPairsFeesMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n uint256[] calldata configFees\\n ) external view returns (bool) {\\n // find a match for each config fee\\n for (uint256 i = 0; i < configFees.length; i++) {\\n if (uniswapV3Fees[configInputTokens[i]][configOutputTokens[i]] != configFees[i]) return false;\\n }\\n\\n return true;\\n }\\n\\n function uniswapPairsRoutersMatch(\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens,\\n address[] calldata configRouters\\n ) external view returns (bool) {\\n // find a match for each config router\\n for (uint256 i = 0; i < configRouters.length; i++) {\\n if (customUniV3Router[configInputTokens[i]][configOutputTokens[i]] != configRouters[i]) return false;\\n }\\n\\n return true;\\n }\\n\\n function pairsStrategiesMatch(\\n IRedemptionStrategy[] calldata configStrategies,\\n IERC20Upgradeable[] calldata configInputTokens,\\n IERC20Upgradeable[] calldata configOutputTokens\\n ) external view returns (bool) {\\n (\\n IRedemptionStrategy[] memory onChainStrategies,\\n IERC20Upgradeable[] memory onChainInputTokens,\\n IERC20Upgradeable[] memory onChainOutputTokens\\n ) = getAllPairsStrategies();\\n // find a match for each config strategy\\n for (uint256 i = 0; i < configStrategies.length; i++) {\\n bool foundMatch = false;\\n for (uint256 j = 0; j < onChainStrategies.length; j++) {\\n if (\\n onChainStrategies[j] == configStrategies[i] &&\\n onChainInputTokens[j] == configInputTokens[i] &&\\n onChainOutputTokens[j] == configOutputTokens[i]\\n ) {\\n foundMatch = true;\\n break;\\n }\\n }\\n if (!foundMatch) return false;\\n }\\n\\n // find a match for each on-chain strategy\\n for (uint256 i = 0; i < onChainStrategies.length; i++) {\\n bool foundMatch = false;\\n for (uint256 j = 0; j < configStrategies.length; j++) {\\n if (\\n onChainStrategies[i] == configStrategies[j] &&\\n onChainInputTokens[i] == configInputTokens[j] &&\\n onChainOutputTokens[i] == configOutputTokens[j]\\n ) {\\n foundMatch = true;\\n break;\\n }\\n }\\n if (!foundMatch) return false;\\n }\\n\\n return true;\\n }\\n\\n function getAllPairsStrategies()\\n public\\n view\\n returns (\\n IRedemptionStrategy[] memory strategies,\\n IERC20Upgradeable[] memory inputTokens,\\n IERC20Upgradeable[] memory outputTokens\\n )\\n {\\n address[] memory _outputTokens = outputTokensSet.values();\\n uint256 pairsCounter = 0;\\n\\n {\\n for (uint256 i = 0; i < _outputTokens.length; i++) {\\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\\n pairsCounter += _inputTokens.length;\\n }\\n\\n strategies = new IRedemptionStrategy[](pairsCounter);\\n inputTokens = new IERC20Upgradeable[](pairsCounter);\\n outputTokens = new IERC20Upgradeable[](pairsCounter);\\n }\\n\\n pairsCounter = 0;\\n for (uint256 i = 0; i < _outputTokens.length; i++) {\\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\\n for (uint256 j = 0; j < _inputTokens.length; j++) {\\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\\n strategies[pairsCounter] = redemptionStrategiesByTokens[_inputToken][_outputToken];\\n inputTokens[pairsCounter] = _inputToken;\\n outputTokens[pairsCounter] = _outputToken;\\n pairsCounter++;\\n }\\n }\\n }\\n\\n function optimalSwapPath(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\\n external\\n view\\n returns (IERC20Upgradeable[] memory)\\n {\\n return _optimalSwapPath[inputToken][outputToken];\\n }\\n\\n function _setOptimalSwapPath(\\n IERC20Upgradeable inputToken,\\n IERC20Upgradeable outputToken,\\n IERC20Upgradeable[] calldata optimalPath\\n ) external onlyOwner {\\n _optimalSwapPath[inputToken][outputToken] = optimalPath;\\n }\\n\\n function wrappedToUnwrapped4626(address wrapped) external view returns (address) {\\n return _wrappedToUnwrapped4626[wrapped];\\n }\\n\\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24) {\\n return _aeroCLTickSpacings[inputToken][outputToken];\\n }\\n\\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool) {\\n return _aeroV2IsStable[inputToken][outputToken];\\n }\\n\\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external onlyOwner {\\n _wrappedToUnwrapped4626[wrapped] = unwrapped;\\n }\\n\\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external onlyOwner {\\n _aeroCLTickSpacings[inputToken][outputToken] = tickSpacing;\\n }\\n\\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external onlyOwner {\\n _aeroV2IsStable[inputToken][outputToken] = isStable;\\n }\\n}\\n\",\"keccak256\":\"0x9f58968aad035ddec608d9815aa01400ec73fe3aea19f60bafdcf6be3adac74c\",\"license\":\"GPL-3.0\"},\"contracts/liquidators/registry/LiquidatorsRegistryStorage.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.10;\\n\\nimport \\\"../IRedemptionStrategy.sol\\\";\\nimport { SafeOwnable } from \\\"../../ionic/SafeOwnable.sol\\\";\\nimport { AddressesProvider } from \\\"../../ionic/AddressesProvider.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\\n AddressesProvider public ap;\\n\\n EnumerableSet.AddressSet internal redemptionStrategies;\\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\\n EnumerableSet.AddressSet internal outputTokensSet;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\\n\\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\\n mapping(address => address) internal _wrappedToUnwrapped4626;\\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\\n}\\n\",\"keccak256\":\"0xf16140deeab4ab4f1191fe87b6158f704c8da7c71dbc4aa3d9999bc572112cb3\",\"license\":\"GPL-3.0\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506200001d3362000023565b62000091565b600180546001600160a01b03191690556200003e8162000041565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612a9b80620000a16000396000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c806379ba50971161010f578063aeabb621116100a2578063e187a7dd11610071578063e187a7dd14610536578063e30c397814610549578063eb29d9f81461055a578063f2fde38b1461056d57600080fd5b8063aeabb621146104a8578063c8ff6fee146104bb578063d7341acf146104ef578063dee7fe481461050257600080fd5b80638db87c27116100de5780638db87c27146104185780639268343c14610441578063a1bb91e314610461578063a700f9e41461047457600080fd5b806379ba5097146103ae578063800bc373146103b657806389f8132e146103f25780638da5cb5b1461040757600080fd5b80633cb0d04f116101875780635495a6d7116101565780635495a6d71461036d578063715018a61461038057806372c9889c146103885780637949fe7a1461039b57600080fd5b80633cb0d04f146102f557806348963a3914610321578063514b49d914610347578063531de1ca1461035a57600080fd5b8063366eda2e116101c3578063366eda2e14610260578063398cd955146102735780633a063848146102b75780633c4f743c146102ca57600080fd5b80630d856eef146101f55780632434cb7f146102155780632e4e1a941461022a5780633322d8771461023d575b600080fd5b6101fd610580565b60405161020c9392919061247d565b60405180910390f35b6102286102233660046124fe565b61084b565b005b610228610238366004612583565b610881565b61025061024b3660046125e8565b6108c0565b604051901515815260200161020c565b61022861026e3660046125e8565b610b96565b6102a36102813660046124fe565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff909116815260200161020c565b6102286102c5366004612682565b610c65565b6002546102dd906001600160a01b031681565b6040516001600160a01b03909116815260200161020c565b6102dd6103033660046126d2565b6001600160a01b039081166000908152601060205260409020541690565b61033461032f3660046124fe565b610ca7565b60405160029190910b815260200161020c565b6102286103553660046126d2565b610cd7565b6102286103683660046126ef565b610f7b565b61022861037b3660046125e8565b610fc3565b6102286110af565b6102286103963660046125e8565b6110ff565b6102286103a93660046124fe565b611210565b610228611246565b6102506103c43660046124fe565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205460ff1690565b6103fa6112c0565b60405161020c9190612736565b6000546001600160a01b03166102dd565b6102dd6104263660046126d2565b6007602052600090815260409020546001600160a01b031681565b61045461044f3660046124fe565b61184f565b60405161020c9190612784565b61022861046f3660046125e8565b6118d2565b6102dd6104823660046124fe565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6102506104b63660046125e8565b611c2a565b6102dd6104c93660046124fe565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b6102286104fd366004612797565b611d1c565b6102dd610510366004612846565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6102286105443660046125e8565b611ec6565b6001546001600160a01b03166102dd565b6102506105683660046125e8565b611fd5565b61022861057b3660046126d2565b6120a4565b606080606060006105916009612115565b90506000805b82518110156106085760008382815181106105b4576105b46128c6565b6020026020010151905060006105ed60086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b90508051846105fc91906128f2565b93505050600101610597565b508067ffffffffffffffff811115610622576106226127d7565b60405190808252806020026020018201604052801561064b578160200160208202803683370190505b5094508067ffffffffffffffff811115610667576106676127d7565b604051908082528060200260200182016040528015610690578160200160208202803683370190505b5093508067ffffffffffffffff8111156106ac576106ac6127d7565b6040519080825280602002602001820160405280156106d5578160200160208202803683370190505b5092506000905060005b82518110156108435760008382815181106106fc576106fc6128c6565b60200260200101519050600061073560086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015610838576000828281518110610757576107576128c6565b6020908102919091018101516001600160a01b038082166000908152600684526040808220898416835290945292909220548c51919350909116908b90889081106107a4576107a46128c6565b60200260200101906001600160a01b031690816001600160a01b031681525050808987815181106107d7576107d76128c6565b60200260200101906001600160a01b031690816001600160a01b0316815250508388878151811061080a5761080a6128c6565b6001600160a01b03909216602092830291909101909101528561082c81612905565b9650505060010161073a565b5050506001016106df565b505050909192565b610853612129565b6001600160a01b03918216600090815260076020526040902080546001600160a01b03191691909216179055565b610889612129565b6001600160a01b038085166000908152600f602090815260408083209387168352929052206108b99083836123c0565b5050505050565b6000806000806108ce610580565b92509250925060005b89811015610a2b576000805b8551811015610a0e578c8c848181106108fe576108fe6128c6565b905060200201602081019061091391906126d2565b6001600160a01b031686828151811061092e5761092e6128c6565b60200260200101516001600160a01b031614801561099c57508a8a84818110610959576109596128c6565b905060200201602081019061096e91906126d2565b6001600160a01b0316858281518110610989576109896128c6565b60200260200101516001600160a01b0316145b80156109f857508888848181106109b5576109b56128c6565b90506020020160208101906109ca91906126d2565b6001600160a01b03168482815181106109e5576109e56128c6565b60200260200101516001600160a01b0316145b15610a065760019150610a0e565b6001016108e3565b5080610a2257600095505050505050610b8c565b506001016108d7565b5060005b8351811015610b83576000805b8b811015610b66578c8c82818110610a5657610a566128c6565b9050602002016020810190610a6b91906126d2565b6001600160a01b0316868481518110610a8657610a866128c6565b60200260200101516001600160a01b0316148015610af457508a8a82818110610ab157610ab16128c6565b9050602002016020810190610ac691906126d2565b6001600160a01b0316858481518110610ae157610ae16128c6565b60200260200101516001600160a01b0316145b8015610b505750888882818110610b0d57610b0d6128c6565b9050602002016020810190610b2291906126d2565b6001600160a01b0316848481518110610b3d57610b3d6128c6565b60200260200101516001600160a01b0316145b15610b5e5760019150610b66565b600101610a3c565b5080610b7a57600095505050505050610b8c565b50600101610a2f565b50600193505050505b9695505050505050565b610b9e612129565b8483148015610bac57508281145b610bd15760405162461bcd60e51b8152600401610bc89061291e565b60405180910390fd5b60005b85811015610c5c57610c54878783818110610bf157610bf16128c6565b9050602002016020810190610c0691906126d2565b868684818110610c1857610c186128c6565b9050602002016020810190610c2d91906126d2565b858585818110610c3f57610c3f6128c6565b90506020020160208101906104fd91906126d2565b600101610bd4565b50505050505050565b610c6d612129565b6001600160a01b03928316600090815260126020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6001600160a01b0380831660009081526011602090815260408083209385168352929052205460020b5b92915050565b610cdf612129565b6000610ceb6009612115565b905060005b8151811015610ec4576000828281518110610d0d57610d0d6128c6565b602002602001015190506000610d4660086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015610e84576000828281518110610d6857610d686128c6565b6020908102919091018101516001600160a01b0380821660009081526006845260408082208984168352909452929092205490925081169088168103610e7a576001600160a01b03808316600090815260066020908152604080832093891683529290522080546001600160a01b03191690558351610e2e90859085908110610df357610df36128c6565b602002602001015160086000886001600160a01b03166001600160a01b0316815260200190815260200160002061218590919063ffffffff16565b506001600160a01b03828116600090815260076020526040902054818716911603610e7a576001600160a01b038216600090815260076020526040902080546001600160a01b03191690555b5050600101610d4b565b506001600160a01b0382166000908152600860205260409020610ea69061219a565b600003610eba57610eb8600983612185565b505b5050600101610cf0565b5060006005836001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610f07573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f2f9190810190612967565b604051610f3c91906129de565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055610f76600383612185565b505050565b610f83612129565b6001600160a01b03928316600090815260116020908152604080832094909516825292909252919020805462ffffff191662ffffff909216919091179055565b610fcb612129565b8085148015610fd957508483145b610ff55760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c57828282818110611012576110126128c6565b90506020020135600b600089898581811061102f5761102f6128c6565b905060200201602081019061104491906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611078576110786128c6565b905060200201602081019061108d91906126d2565b6001600160a01b03168152602081019190915260400160002055600101610ff8565b6110b7612129565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f77656400006044820152606401610bc8565b611107612129565b808514801561111557508483145b6111315760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c5782828281811061114e5761114e6128c6565b905060200201602081019061116391906126d2565b600e6000898985818110611179576111796128c6565b905060200201602081019061118e91906126d2565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008787858181106111c2576111c26128c6565b90506020020160208101906111d791906126d2565b6001600160a01b039081168252602082019290925260400160002080546001600160a01b03191692909116919091179055600101611134565b611218612129565b6001600160a01b03918216600090815260106020526040902080546001600160a01b03191691909216179055565b60015433906001600160a01b031681146112b45760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610bc8565b6112bd816121a4565b50565b6040805160148082526102a0820190925260609190600090826020820161028080368337019050509050630d856eef60e01b816112fc846129fa565b93508360ff1681518110611312576113126128c6565b6001600160e01b031990921660209283029190910190910152633322d87760e01b8161133d846129fa565b93508360ff1681518110611353576113536128c6565b6001600160e01b031990921660209283029190910190910152631d653b3f60e31b8161137e846129fa565b93508360ff1681518110611394576113946128c6565b6001600160e01b03199092166020928302919091019091015263aeabb62160e01b816113bf846129fa565b93508360ff16815181106113d5576113d56128c6565b6001600160e01b031990921660209283029190910190910152635495a6d760e01b81611400846129fa565b93508360ff1681518110611416576114166128c6565b6001600160e01b03199092166020928302919091019091015263e187a7dd60e01b81611441846129fa565b93508360ff1681518110611457576114576128c6565b6001600160e01b031990921660209283029190910190910152631cb2622760e21b81611482846129fa565b93508360ff1681518110611498576114986128c6565b6001600160e01b031990921660209283029190910190910152632434cb7f60e01b816114c3846129fa565b93508360ff16815181106114d9576114d96128c6565b6001600160e01b03199092166020928302919091019091015263d7341acf60e01b81611504846129fa565b93508360ff168151811061151a5761151a6128c6565b6001600160e01b031990921660209283029190910190910152631b376d1760e11b81611545846129fa565b93508360ff168151811061155b5761155b6128c6565b6001600160e01b03199092166020928302919091019091015263514b49d960e01b81611586846129fa565b93508360ff168151811061159c5761159c6128c6565b6001600160e01b03199092166020928302919091019091015263a1bb91e360e01b816115c7846129fa565b93508360ff16815181106115dd576115dd6128c6565b6001600160e01b03199092166020928302919091019091015263249a0d0f60e21b81611608846129fa565b93508360ff168151811061161e5761161e6128c6565b6001600160e01b031990921660209283029190910190910152630b9386a560e21b81611649846129fa565b93508360ff168151811061165f5761165f6128c6565b6001600160e01b031990921660209283029190910190910152633cb0d04f60e01b8161168a846129fa565b93508360ff16815181106116a0576116a06128c6565b6001600160e01b0319909216602092830291909101909101526348963a3960e01b816116cb846129fa565b93508360ff16815181106116e1576116e16128c6565b6001600160e01b03199092166020928302919091019091015263800bc37360e01b8161170c846129fa565b93508360ff1681518110611722576117226128c6565b6001600160e01b031990921660209283029190910190910152633ca4ff3d60e11b8161174d846129fa565b93508360ff1681518110611763576117636128c6565b6001600160e01b03199092166020928302919091019091015263298ef0e560e11b8161178e846129fa565b93508360ff16815181106117a4576117a46128c6565b6001600160e01b031990921660209283029190910190910152630740c70960e31b816117cf846129fa565b93508360ff16815181106117e5576117e56128c6565b6001600160e01b03199092166020928302919091019091015260ff821615610cd15760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610bc8565b6001600160a01b038083166000908152600f602090815260408083209385168352928152908290208054835181840281018401909452808452606093928301828280156118c557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116118a7575b5050505050905092915050565b6118da612129565b84831480156118e857508281145b6119045760405162461bcd60e51b8152600401610bc89061291e565b60006119106009612115565b905060005b8151811015611a89576000828281518110611932576119326128c6565b60200260200101519050600061196b60086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015611a5057600082828151811061198d5761198d6128c6565b6020908102919091018101516001600160a01b03808216600090815260068452604080822092891682529190935290912080546001600160a01b03191690558351909150611a22908490849081106119e7576119e76128c6565b602002602001015160086000876001600160a01b03166001600160a01b0316815260200190815260200160002061218590919063ffffffff16565b506001600160a01b0316600090815260076020526040902080546001600160a01b0319169055600101611970565b50611a7e848481518110611a6657611a666128c6565b6020026020010151600961218590919063ffffffff16565b505050600101611915565b506000611a966003612115565b905060005b8151811015611ba8576000828281518110611ab857611ab86128c6565b602002602001015190506000816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b02573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b2a9190810190612967565b90506000600582604051611b3e91906129de565b908152602001604051809103902060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550611b9d848481518110611b8557611b856128c6565b6020026020010151600361218590919063ffffffff16565b505050600101611a9b565b5060005b87811015611c1f57611c17898983818110611bc957611bc96128c6565b9050602002016020810190611bde91906126d2565b888884818110611bf057611bf06128c6565b9050602002016020810190611c0591906126d2565b878785818110610c3f57610c3f6128c6565b600101611bac565b505050505050505050565b6000805b82811015611d0e57838382818110611c4857611c486128c6565b9050602002016020810190611c5d91906126d2565b6001600160a01b0316600e60008a8a85818110611c7c57611c7c6128c6565b9050602002016020810190611c9191906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000888885818110611cc557611cc56128c6565b9050602002016020810190611cda91906126d2565b6001600160a01b0390811682526020820192909252604001600020541614611d06576000915050610b8c565b600101611c2e565b506001979650505050505050565b611d24612129565b6000836001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d8c9190810190612967565b90506000600582604051611da091906129de565b9081526040805160209281900383018120546001600160a01b0388811660009081526006865284812089831682529095529290932080546001600160a01b031916898416179055911691508590600590611dfb9085906129de565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055611e35600382612185565b50611e416003866121bd565b506001600160a01b0384811660009081526007602052604090205416611e90576001600160a01b03848116600090815260076020526040902080546001600160a01b0319169185169190911790555b6001600160a01b0383166000908152600860205260409020611eb290856121bd565b50611ebe6009846121bd565b505050505050565b611ece612129565b8085148015611edc57508483145b611ef85760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c57828282818110611f1557611f156128c6565b9050602002016020810190611f2a9190612a17565b600d6000898985818110611f4057611f406128c6565b9050602002016020810190611f5591906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611f8957611f896128c6565b9050602002016020810190611f9e91906126d2565b6001600160a01b031681526020810191909152604001600020805462ffffff191662ffffff92909216919091179055600101611efb565b6000805b82811015611d0e57838382818110611ff357611ff36128c6565b90506020020135600d60008a8a85818110612010576120106128c6565b905060200201602081019061202591906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000888885818110612059576120596128c6565b905060200201602081019061206e91906126d2565b6001600160a01b0316815260208101919091526040016000205462ffffff161461209c576000915050610b8c565b600101611fd9565b6120ac612129565b600180546001600160a01b0383166001600160a01b031990911681179091556120dd6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60606000612122836121d2565b9392505050565b6000546001600160a01b031633146121835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610bc8565b565b6000612122836001600160a01b03841661222e565b6000610cd1825490565b600180546001600160a01b03191690556112bd81612321565b6000612122836001600160a01b038416612371565b60608160000180548060200260200160405190810160405280929190818152602001828054801561222257602002820191906000526020600020905b81548152602001906001019080831161220e575b50505050509050919050565b60008181526001830160205260408120548015612317576000612252600183612a3c565b855490915060009061226690600190612a3c565b90508181146122cb576000866000018281548110612286576122866128c6565b90600052602060002001549050808760000184815481106122a9576122a96128c6565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806122dc576122dc612a4f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610cd1565b6000915050610cd1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008181526001830160205260408120546123b857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cd1565b506000610cd1565b828054828255906000526020600020908101928215612413579160200282015b828111156124135781546001600160a01b0319166001600160a01b038435161782556020909201916001909101906123e0565b5061241f929150612423565b5090565b5b8082111561241f5760008155600101612424565b60008151808452602080850194506020840160005b838110156124725781516001600160a01b03168752958201959082019060010161244d565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b828110156124bf5781516001600160a01b03168452928401929084019060010161249a565b50505083810360208501526124d48187612438565b9150508281036040840152610b8c8185612438565b6001600160a01b03811681146112bd57600080fd5b6000806040838503121561251157600080fd5b823561251c816124e9565b9150602083013561252c816124e9565b809150509250929050565b60008083601f84011261254957600080fd5b50813567ffffffffffffffff81111561256157600080fd5b6020830191508360208260051b850101111561257c57600080fd5b9250929050565b6000806000806060858703121561259957600080fd5b84356125a4816124e9565b935060208501356125b4816124e9565b9250604085013567ffffffffffffffff8111156125d057600080fd5b6125dc87828801612537565b95989497509550505050565b6000806000806000806060878903121561260157600080fd5b863567ffffffffffffffff8082111561261957600080fd5b6126258a838b01612537565b9098509650602089013591508082111561263e57600080fd5b61264a8a838b01612537565b9096509450604089013591508082111561266357600080fd5b5061267089828a01612537565b979a9699509497509295939492505050565b60008060006060848603121561269757600080fd5b83356126a2816124e9565b925060208401356126b2816124e9565b9150604084013580151581146126c757600080fd5b809150509250925092565b6000602082840312156126e457600080fd5b8135612122816124e9565b60008060006060848603121561270457600080fd5b833561270f816124e9565b9250602084013561271f816124e9565b91506040840135600281900b81146126c757600080fd5b6020808252825182820181905260009190848201906040850190845b818110156127785783516001600160e01b03191683529284019291840191600101612752565b50909695505050505050565b6020815260006121226020830184612438565b6000806000606084860312156127ac57600080fd5b83356127b7816124e9565b925060208401356127c7816124e9565b915060408401356126c7816124e9565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612816576128166127d7565b604052919050565b600067ffffffffffffffff821115612838576128386127d7565b50601f01601f191660200190565b60006020828403121561285857600080fd5b813567ffffffffffffffff81111561286f57600080fd5b8201601f8101841361288057600080fd5b803561289361288e8261281e565b6127ed565b8181528560208385010111156128a857600080fd5b81602084016020830137600091810160200191909152949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610cd157610cd16128dc565b600060018201612917576129176128dc565b5060010190565b6020808252600b908201526a10b0b93930bcb9903632b760a91b604082015260600190565b60005b8381101561295e578181015183820152602001612946565b50506000910152565b60006020828403121561297957600080fd5b815167ffffffffffffffff81111561299057600080fd5b8201601f810184136129a157600080fd5b80516129af61288e8261281e565b8181528560208385010111156129c457600080fd5b6129d5826020830160208601612943565b95945050505050565b600082516129f0818460208701612943565b9190910192915050565b600060ff821680612a0d57612a0d6128dc565b6000190192915050565b600060208284031215612a2957600080fd5b813562ffffff8116811461212257600080fd5b81810381811115610cd157610cd16128dc565b634e487b7160e01b600052603160045260246000fdfea264697066735822122037ff898b98ba2e57f50f39199a926d1afc201fbafd9f4fa8f820c137ab42f08664736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c806379ba50971161010f578063aeabb621116100a2578063e187a7dd11610071578063e187a7dd14610536578063e30c397814610549578063eb29d9f81461055a578063f2fde38b1461056d57600080fd5b8063aeabb621146104a8578063c8ff6fee146104bb578063d7341acf146104ef578063dee7fe481461050257600080fd5b80638db87c27116100de5780638db87c27146104185780639268343c14610441578063a1bb91e314610461578063a700f9e41461047457600080fd5b806379ba5097146103ae578063800bc373146103b657806389f8132e146103f25780638da5cb5b1461040757600080fd5b80633cb0d04f116101875780635495a6d7116101565780635495a6d71461036d578063715018a61461038057806372c9889c146103885780637949fe7a1461039b57600080fd5b80633cb0d04f146102f557806348963a3914610321578063514b49d914610347578063531de1ca1461035a57600080fd5b8063366eda2e116101c3578063366eda2e14610260578063398cd955146102735780633a063848146102b75780633c4f743c146102ca57600080fd5b80630d856eef146101f55780632434cb7f146102155780632e4e1a941461022a5780633322d8771461023d575b600080fd5b6101fd610580565b60405161020c9392919061247d565b60405180910390f35b6102286102233660046124fe565b61084b565b005b610228610238366004612583565b610881565b61025061024b3660046125e8565b6108c0565b604051901515815260200161020c565b61022861026e3660046125e8565b610b96565b6102a36102813660046124fe565b600d60209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff909116815260200161020c565b6102286102c5366004612682565b610c65565b6002546102dd906001600160a01b031681565b6040516001600160a01b03909116815260200161020c565b6102dd6103033660046126d2565b6001600160a01b039081166000908152601060205260409020541690565b61033461032f3660046124fe565b610ca7565b60405160029190910b815260200161020c565b6102286103553660046126d2565b610cd7565b6102286103683660046126ef565b610f7b565b61022861037b3660046125e8565b610fc3565b6102286110af565b6102286103963660046125e8565b6110ff565b6102286103a93660046124fe565b611210565b610228611246565b6102506103c43660046124fe565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205460ff1690565b6103fa6112c0565b60405161020c9190612736565b6000546001600160a01b03166102dd565b6102dd6104263660046126d2565b6007602052600090815260409020546001600160a01b031681565b61045461044f3660046124fe565b61184f565b60405161020c9190612784565b61022861046f3660046125e8565b6118d2565b6102dd6104823660046124fe565b60066020908152600092835260408084209091529082529020546001600160a01b031681565b6102506104b63660046125e8565b611c2a565b6102dd6104c93660046124fe565b600e6020908152600092835260408084209091529082529020546001600160a01b031681565b6102286104fd366004612797565b611d1c565b6102dd610510366004612846565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6102286105443660046125e8565b611ec6565b6001546001600160a01b03166102dd565b6102506105683660046125e8565b611fd5565b61022861057b3660046126d2565b6120a4565b606080606060006105916009612115565b90506000805b82518110156106085760008382815181106105b4576105b46128c6565b6020026020010151905060006105ed60086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b90508051846105fc91906128f2565b93505050600101610597565b508067ffffffffffffffff811115610622576106226127d7565b60405190808252806020026020018201604052801561064b578160200160208202803683370190505b5094508067ffffffffffffffff811115610667576106676127d7565b604051908082528060200260200182016040528015610690578160200160208202803683370190505b5093508067ffffffffffffffff8111156106ac576106ac6127d7565b6040519080825280602002602001820160405280156106d5578160200160208202803683370190505b5092506000905060005b82518110156108435760008382815181106106fc576106fc6128c6565b60200260200101519050600061073560086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015610838576000828281518110610757576107576128c6565b6020908102919091018101516001600160a01b038082166000908152600684526040808220898416835290945292909220548c51919350909116908b90889081106107a4576107a46128c6565b60200260200101906001600160a01b031690816001600160a01b031681525050808987815181106107d7576107d76128c6565b60200260200101906001600160a01b031690816001600160a01b0316815250508388878151811061080a5761080a6128c6565b6001600160a01b03909216602092830291909101909101528561082c81612905565b9650505060010161073a565b5050506001016106df565b505050909192565b610853612129565b6001600160a01b03918216600090815260076020526040902080546001600160a01b03191691909216179055565b610889612129565b6001600160a01b038085166000908152600f602090815260408083209387168352929052206108b99083836123c0565b5050505050565b6000806000806108ce610580565b92509250925060005b89811015610a2b576000805b8551811015610a0e578c8c848181106108fe576108fe6128c6565b905060200201602081019061091391906126d2565b6001600160a01b031686828151811061092e5761092e6128c6565b60200260200101516001600160a01b031614801561099c57508a8a84818110610959576109596128c6565b905060200201602081019061096e91906126d2565b6001600160a01b0316858281518110610989576109896128c6565b60200260200101516001600160a01b0316145b80156109f857508888848181106109b5576109b56128c6565b90506020020160208101906109ca91906126d2565b6001600160a01b03168482815181106109e5576109e56128c6565b60200260200101516001600160a01b0316145b15610a065760019150610a0e565b6001016108e3565b5080610a2257600095505050505050610b8c565b506001016108d7565b5060005b8351811015610b83576000805b8b811015610b66578c8c82818110610a5657610a566128c6565b9050602002016020810190610a6b91906126d2565b6001600160a01b0316868481518110610a8657610a866128c6565b60200260200101516001600160a01b0316148015610af457508a8a82818110610ab157610ab16128c6565b9050602002016020810190610ac691906126d2565b6001600160a01b0316858481518110610ae157610ae16128c6565b60200260200101516001600160a01b0316145b8015610b505750888882818110610b0d57610b0d6128c6565b9050602002016020810190610b2291906126d2565b6001600160a01b0316848481518110610b3d57610b3d6128c6565b60200260200101516001600160a01b0316145b15610b5e5760019150610b66565b600101610a3c565b5080610b7a57600095505050505050610b8c565b50600101610a2f565b50600193505050505b9695505050505050565b610b9e612129565b8483148015610bac57508281145b610bd15760405162461bcd60e51b8152600401610bc89061291e565b60405180910390fd5b60005b85811015610c5c57610c54878783818110610bf157610bf16128c6565b9050602002016020810190610c0691906126d2565b868684818110610c1857610c186128c6565b9050602002016020810190610c2d91906126d2565b858585818110610c3f57610c3f6128c6565b90506020020160208101906104fd91906126d2565b600101610bd4565b50505050505050565b610c6d612129565b6001600160a01b03928316600090815260126020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6001600160a01b0380831660009081526011602090815260408083209385168352929052205460020b5b92915050565b610cdf612129565b6000610ceb6009612115565b905060005b8151811015610ec4576000828281518110610d0d57610d0d6128c6565b602002602001015190506000610d4660086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015610e84576000828281518110610d6857610d686128c6565b6020908102919091018101516001600160a01b0380821660009081526006845260408082208984168352909452929092205490925081169088168103610e7a576001600160a01b03808316600090815260066020908152604080832093891683529290522080546001600160a01b03191690558351610e2e90859085908110610df357610df36128c6565b602002602001015160086000886001600160a01b03166001600160a01b0316815260200190815260200160002061218590919063ffffffff16565b506001600160a01b03828116600090815260076020526040902054818716911603610e7a576001600160a01b038216600090815260076020526040902080546001600160a01b03191690555b5050600101610d4b565b506001600160a01b0382166000908152600860205260409020610ea69061219a565b600003610eba57610eb8600983612185565b505b5050600101610cf0565b5060006005836001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610f07573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f2f9190810190612967565b604051610f3c91906129de565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055610f76600383612185565b505050565b610f83612129565b6001600160a01b03928316600090815260116020908152604080832094909516825292909252919020805462ffffff191662ffffff909216919091179055565b610fcb612129565b8085148015610fd957508483145b610ff55760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c57828282818110611012576110126128c6565b90506020020135600b600089898581811061102f5761102f6128c6565b905060200201602081019061104491906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611078576110786128c6565b905060200201602081019061108d91906126d2565b6001600160a01b03168152602081019190915260400160002055600101610ff8565b6110b7612129565b60405162461bcd60e51b815260206004820152601e60248201527f72656e6f756e6365206f776e657273686970206e6f7420616c6c6f77656400006044820152606401610bc8565b611107612129565b808514801561111557508483145b6111315760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c5782828281811061114e5761114e6128c6565b905060200201602081019061116391906126d2565b600e6000898985818110611179576111796128c6565b905060200201602081019061118e91906126d2565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008787858181106111c2576111c26128c6565b90506020020160208101906111d791906126d2565b6001600160a01b039081168252602082019290925260400160002080546001600160a01b03191692909116919091179055600101611134565b611218612129565b6001600160a01b03918216600090815260106020526040902080546001600160a01b03191691909216179055565b60015433906001600160a01b031681146112b45760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610bc8565b6112bd816121a4565b50565b6040805160148082526102a0820190925260609190600090826020820161028080368337019050509050630d856eef60e01b816112fc846129fa565b93508360ff1681518110611312576113126128c6565b6001600160e01b031990921660209283029190910190910152633322d87760e01b8161133d846129fa565b93508360ff1681518110611353576113536128c6565b6001600160e01b031990921660209283029190910190910152631d653b3f60e31b8161137e846129fa565b93508360ff1681518110611394576113946128c6565b6001600160e01b03199092166020928302919091019091015263aeabb62160e01b816113bf846129fa565b93508360ff16815181106113d5576113d56128c6565b6001600160e01b031990921660209283029190910190910152635495a6d760e01b81611400846129fa565b93508360ff1681518110611416576114166128c6565b6001600160e01b03199092166020928302919091019091015263e187a7dd60e01b81611441846129fa565b93508360ff1681518110611457576114576128c6565b6001600160e01b031990921660209283029190910190910152631cb2622760e21b81611482846129fa565b93508360ff1681518110611498576114986128c6565b6001600160e01b031990921660209283029190910190910152632434cb7f60e01b816114c3846129fa565b93508360ff16815181106114d9576114d96128c6565b6001600160e01b03199092166020928302919091019091015263d7341acf60e01b81611504846129fa565b93508360ff168151811061151a5761151a6128c6565b6001600160e01b031990921660209283029190910190910152631b376d1760e11b81611545846129fa565b93508360ff168151811061155b5761155b6128c6565b6001600160e01b03199092166020928302919091019091015263514b49d960e01b81611586846129fa565b93508360ff168151811061159c5761159c6128c6565b6001600160e01b03199092166020928302919091019091015263a1bb91e360e01b816115c7846129fa565b93508360ff16815181106115dd576115dd6128c6565b6001600160e01b03199092166020928302919091019091015263249a0d0f60e21b81611608846129fa565b93508360ff168151811061161e5761161e6128c6565b6001600160e01b031990921660209283029190910190910152630b9386a560e21b81611649846129fa565b93508360ff168151811061165f5761165f6128c6565b6001600160e01b031990921660209283029190910190910152633cb0d04f60e01b8161168a846129fa565b93508360ff16815181106116a0576116a06128c6565b6001600160e01b0319909216602092830291909101909101526348963a3960e01b816116cb846129fa565b93508360ff16815181106116e1576116e16128c6565b6001600160e01b03199092166020928302919091019091015263800bc37360e01b8161170c846129fa565b93508360ff1681518110611722576117226128c6565b6001600160e01b031990921660209283029190910190910152633ca4ff3d60e11b8161174d846129fa565b93508360ff1681518110611763576117636128c6565b6001600160e01b03199092166020928302919091019091015263298ef0e560e11b8161178e846129fa565b93508360ff16815181106117a4576117a46128c6565b6001600160e01b031990921660209283029190910190910152630740c70960e31b816117cf846129fa565b93508360ff16815181106117e5576117e56128c6565b6001600160e01b03199092166020928302919091019091015260ff821615610cd15760405162461bcd60e51b815260206004820152601c60248201527f7573652074686520636f7272656374206172726179206c656e677468000000006044820152606401610bc8565b6001600160a01b038083166000908152600f602090815260408083209385168352928152908290208054835181840281018401909452808452606093928301828280156118c557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116118a7575b5050505050905092915050565b6118da612129565b84831480156118e857508281145b6119045760405162461bcd60e51b8152600401610bc89061291e565b60006119106009612115565b905060005b8151811015611a89576000828281518110611932576119326128c6565b60200260200101519050600061196b60086000846001600160a01b03166001600160a01b03168152602001908152602001600020612115565b905060005b8151811015611a5057600082828151811061198d5761198d6128c6565b6020908102919091018101516001600160a01b03808216600090815260068452604080822092891682529190935290912080546001600160a01b03191690558351909150611a22908490849081106119e7576119e76128c6565b602002602001015160086000876001600160a01b03166001600160a01b0316815260200190815260200160002061218590919063ffffffff16565b506001600160a01b0316600090815260076020526040902080546001600160a01b0319169055600101611970565b50611a7e848481518110611a6657611a666128c6565b6020026020010151600961218590919063ffffffff16565b505050600101611915565b506000611a966003612115565b905060005b8151811015611ba8576000828281518110611ab857611ab86128c6565b602002602001015190506000816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b02573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b2a9190810190612967565b90506000600582604051611b3e91906129de565b908152602001604051809103902060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550611b9d848481518110611b8557611b856128c6565b6020026020010151600361218590919063ffffffff16565b505050600101611a9b565b5060005b87811015611c1f57611c17898983818110611bc957611bc96128c6565b9050602002016020810190611bde91906126d2565b888884818110611bf057611bf06128c6565b9050602002016020810190611c0591906126d2565b878785818110610c3f57610c3f6128c6565b600101611bac565b505050505050505050565b6000805b82811015611d0e57838382818110611c4857611c486128c6565b9050602002016020810190611c5d91906126d2565b6001600160a01b0316600e60008a8a85818110611c7c57611c7c6128c6565b9050602002016020810190611c9191906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000888885818110611cc557611cc56128c6565b9050602002016020810190611cda91906126d2565b6001600160a01b0390811682526020820192909252604001600020541614611d06576000915050610b8c565b600101611c2e565b506001979650505050505050565b611d24612129565b6000836001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d8c9190810190612967565b90506000600582604051611da091906129de565b9081526040805160209281900383018120546001600160a01b0388811660009081526006865284812089831682529095529290932080546001600160a01b031916898416179055911691508590600590611dfb9085906129de565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055611e35600382612185565b50611e416003866121bd565b506001600160a01b0384811660009081526007602052604090205416611e90576001600160a01b03848116600090815260076020526040902080546001600160a01b0319169185169190911790555b6001600160a01b0383166000908152600860205260409020611eb290856121bd565b50611ebe6009846121bd565b505050505050565b611ece612129565b8085148015611edc57508483145b611ef85760405162461bcd60e51b8152600401610bc89061291e565b60005b81811015610c5c57828282818110611f1557611f156128c6565b9050602002016020810190611f2a9190612a17565b600d6000898985818110611f4057611f406128c6565b9050602002016020810190611f5591906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611f8957611f896128c6565b9050602002016020810190611f9e91906126d2565b6001600160a01b031681526020810191909152604001600020805462ffffff191662ffffff92909216919091179055600101611efb565b6000805b82811015611d0e57838382818110611ff357611ff36128c6565b90506020020135600d60008a8a85818110612010576120106128c6565b905060200201602081019061202591906126d2565b6001600160a01b03166001600160a01b031681526020019081526020016000206000888885818110612059576120596128c6565b905060200201602081019061206e91906126d2565b6001600160a01b0316815260208101919091526040016000205462ffffff161461209c576000915050610b8c565b600101611fd9565b6120ac612129565b600180546001600160a01b0383166001600160a01b031990911681179091556120dd6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60606000612122836121d2565b9392505050565b6000546001600160a01b031633146121835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610bc8565b565b6000612122836001600160a01b03841661222e565b6000610cd1825490565b600180546001600160a01b03191690556112bd81612321565b6000612122836001600160a01b038416612371565b60608160000180548060200260200160405190810160405280929190818152602001828054801561222257602002820191906000526020600020905b81548152602001906001019080831161220e575b50505050509050919050565b60008181526001830160205260408120548015612317576000612252600183612a3c565b855490915060009061226690600190612a3c565b90508181146122cb576000866000018281548110612286576122866128c6565b90600052602060002001549050808760000184815481106122a9576122a96128c6565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806122dc576122dc612a4f565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610cd1565b6000915050610cd1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008181526001830160205260408120546123b857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cd1565b506000610cd1565b828054828255906000526020600020908101928215612413579160200282015b828111156124135781546001600160a01b0319166001600160a01b038435161782556020909201916001909101906123e0565b5061241f929150612423565b5090565b5b8082111561241f5760008155600101612424565b60008151808452602080850194506020840160005b838110156124725781516001600160a01b03168752958201959082019060010161244d565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b828110156124bf5781516001600160a01b03168452928401929084019060010161249a565b50505083810360208501526124d48187612438565b9150508281036040840152610b8c8185612438565b6001600160a01b03811681146112bd57600080fd5b6000806040838503121561251157600080fd5b823561251c816124e9565b9150602083013561252c816124e9565b809150509250929050565b60008083601f84011261254957600080fd5b50813567ffffffffffffffff81111561256157600080fd5b6020830191508360208260051b850101111561257c57600080fd5b9250929050565b6000806000806060858703121561259957600080fd5b84356125a4816124e9565b935060208501356125b4816124e9565b9250604085013567ffffffffffffffff8111156125d057600080fd5b6125dc87828801612537565b95989497509550505050565b6000806000806000806060878903121561260157600080fd5b863567ffffffffffffffff8082111561261957600080fd5b6126258a838b01612537565b9098509650602089013591508082111561263e57600080fd5b61264a8a838b01612537565b9096509450604089013591508082111561266357600080fd5b5061267089828a01612537565b979a9699509497509295939492505050565b60008060006060848603121561269757600080fd5b83356126a2816124e9565b925060208401356126b2816124e9565b9150604084013580151581146126c757600080fd5b809150509250925092565b6000602082840312156126e457600080fd5b8135612122816124e9565b60008060006060848603121561270457600080fd5b833561270f816124e9565b9250602084013561271f816124e9565b91506040840135600281900b81146126c757600080fd5b6020808252825182820181905260009190848201906040850190845b818110156127785783516001600160e01b03191683529284019291840191600101612752565b50909695505050505050565b6020815260006121226020830184612438565b6000806000606084860312156127ac57600080fd5b83356127b7816124e9565b925060208401356127c7816124e9565b915060408401356126c7816124e9565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612816576128166127d7565b604052919050565b600067ffffffffffffffff821115612838576128386127d7565b50601f01601f191660200190565b60006020828403121561285857600080fd5b813567ffffffffffffffff81111561286f57600080fd5b8201601f8101841361288057600080fd5b803561289361288e8261281e565b6127ed565b8181528560208385010111156128a857600080fd5b81602084016020830137600091810160200191909152949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610cd157610cd16128dc565b600060018201612917576129176128dc565b5060010190565b6020808252600b908201526a10b0b93930bcb9903632b760a91b604082015260600190565b60005b8381101561295e578181015183820152602001612946565b50506000910152565b60006020828403121561297957600080fd5b815167ffffffffffffffff81111561299057600080fd5b8201601f810184136129a157600080fd5b80516129af61288e8261281e565b8181528560208385010111156129c457600080fd5b6129d5826020830160208601612943565b95945050505050565b600082516129f0818460208701612943565b9190910192915050565b600060ff821680612a0d57612a0d6128dc565b6000190192915050565b600060208284031215612a2957600080fd5b813562ffffff8116811461212257600080fd5b81810381811115610cd157610cd16128dc565b634e487b7160e01b600052603160045260246000fdfea264697066735822122037ff898b98ba2e57f50f39199a926d1afc201fbafd9f4fa8f820c137ab42f08664736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "_getExtensionFunctions()": { + "returns": { + "_0": "a list of all the function selectors that this logic extension exposes" + } + }, + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2741, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 2854, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 78123, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "ap", + "offset": 0, + "slot": "2", + "type": "t_contract(AddressesProvider)51667" + }, + { + "astId": 78126, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "redemptionStrategies", + "offset": 0, + "slot": "3", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78131, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "redemptionStrategiesByName", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)" + }, + { + "astId": 78140, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "redemptionStrategiesByTokens", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))" + }, + { + "astId": 78146, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "defaultOutputToken", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)" + }, + { + "astId": 78152, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "inputTokensByOutputToken", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)" + }, + { + "astId": 78155, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "outputTokensSet", + "offset": 0, + "slot": "9", + "type": "t_struct(AddressSet)7179_storage" + }, + { + "astId": 78163, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "conversionSlippage", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78171, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "conversionSlippageUpdated", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))" + }, + { + "astId": 78179, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "uniswapV3Fees", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))" + }, + { + "astId": 78187, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "customUniV3Router", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))" + }, + { + "astId": 78197, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_optimalSwapPath", + "offset": 0, + "slot": "15", + "type": "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))" + }, + { + "astId": 78201, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_wrappedToUnwrapped4626", + "offset": 0, + "slot": "16", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 78207, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_aeroCLTickSpacings", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_mapping(t_address,t_int24))" + }, + { + "astId": 78213, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_aeroV2IsStable", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_address,t_mapping(t_address,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_array(t_contract(IERC20Upgradeable)185186)dyn_storage": { + "base": "t_contract(IERC20Upgradeable)185186", + "encoding": "dynamic_array", + "label": "contract IERC20Upgradeable[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(AddressesProvider)51667": { + "encoding": "inplace", + "label": "contract AddressesProvider", + "numberOfBytes": "20" + }, + "t_contract(IERC20Upgradeable)185186": { + "encoding": "inplace", + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IRedemptionStrategy)69921": { + "encoding": "inplace", + "label": "contract IRedemptionStrategy", + "numberOfBytes": "20" + }, + "t_int24": { + "encoding": "inplace", + "label": "int24", + "numberOfBytes": "3" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_int24)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => int24)", + "numberOfBytes": "32", + "value": "t_int24" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_address,t_int24))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => int24))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_int24)" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[])", + "numberOfBytes": "32", + "value": "t_array(t_contract(IERC20Upgradeable)185186)dyn_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IERC20Upgradeable)185186)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IERC20Upgradeable)", + "numberOfBytes": "32", + "value": "t_contract(IERC20Upgradeable)185186" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_address))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_address)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IERC20Upgradeable[]))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_array(t_contract(IERC20Upgradeable)185186)dyn_storage)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => contract IRedemptionStrategy))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_contract(IRedemptionStrategy)69921)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint24))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256))": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => mapping(contract IERC20Upgradeable => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_struct(AddressSet)7179_storage)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)7179_storage" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint24)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint24)", + "numberOfBytes": "32", + "value": "t_uint24" + }, + "t_mapping(t_contract(IERC20Upgradeable)185186,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20Upgradeable)185186", + "label": "mapping(contract IERC20Upgradeable => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_string_memory_ptr,t_contract(IRedemptionStrategy)69921)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => contract IRedemptionStrategy)", + "numberOfBytes": "32", + "value": "t_contract(IRedemptionStrategy)69921" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(AddressSet)7179_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 7178, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)6864_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)6864_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 6859, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 6863, + "contract": "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol:LiquidatorsRegistrySecondExtension", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint24": { + "encoding": "inplace", + "label": "uint24", + "numberOfBytes": "3" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/LooplessFlywheelBooster.json b/packages/contracts/deployments/superseed/LooplessFlywheelBooster.json new file mode 100644 index 0000000000..e4d29bdc4f --- /dev/null +++ b/packages/contracts/deployments/superseed/LooplessFlywheelBooster.json @@ -0,0 +1,122 @@ +{ + "address": "0x1E2812B4dEcA77B5dD7Af9f2D6ec40102bcffD02", + "abi": [ + { + "inputs": [], + "name": "BOOSTER_TYPE", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "strategy", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "boostedBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "strategy", + "type": "address" + } + ], + "name": "boostedTotalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xaf73886f769d91ac35023e2c55023a3275d96de7b61267fd38663756b8d68ad4", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x1E2812B4dEcA77B5dD7Af9f2D6ec40102bcffD02", + "transactionIndex": 1, + "gasUsed": "282715", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x57fac9a74a990b6411b9c15d45161e44f90167a899b6f060a58c774c85cd59a7", + "transactionHash": "0xaf73886f769d91ac35023e2c55023a3275d96de7b61267fd38663756b8d68ad4", + "logs": [], + "blockNumber": 4135323, + "cumulativeGasUsed": "326593", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"BOOSTER_TYPE\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ERC20\",\"name\":\"strategy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"boostedBalanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ERC20\",\"name\":\"strategy\",\"type\":\"address\"}],\"name\":\"boostedTotalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"boostedBalanceOf(address,address)\":{\"params\":{\"strategy\":\"the strategy to calculate boosted balance of\",\"user\":\"the user to calculate boosted balance of\"},\"returns\":{\"_0\":\"the boosted balance\"}},\"boostedTotalSupply(address)\":{\"params\":{\"strategy\":\"the strategy to calculate boosted supply of\"},\"returns\":{\"_0\":\"the boosted supply\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"boostedBalanceOf(address,address)\":{\"notice\":\"calculate the boosted balance of a user in a given strategy.\"},\"boostedTotalSupply(address)\":{\"notice\":\"calculate the boosted supply of a strategy.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ionic/strategies/flywheel/LooplessFlywheelBooster.sol\":\"LooplessFlywheelBooster\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport {ERC20} from \\\"solmate/tokens/ERC20.sol\\\";\\n\\n/**\\n @title Balance Booster Module for Flywheel\\n @notice Flywheel is a general framework for managing token incentives.\\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\\n\\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \\n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\\n \\n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\\n\\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\\n*/\\ninterface IFlywheelBooster {\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xcdab1b4b5662148d74acc3491a810d263ec509f9f81a267e9f6c1542ba15eabc\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/strategies/flywheel/LooplessFlywheelBooster.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport \\\"./IFlywheelBooster.sol\\\";\\nimport { ICErc20 } from \\\"../../../compound/CTokenInterfaces.sol\\\";\\n\\ncontract LooplessFlywheelBooster is IFlywheelBooster {\\n string public constant BOOSTER_TYPE = \\\"LooplessFlywheelBooster\\\";\\n\\n /**\\n @notice calculate the boosted supply of a strategy.\\n @param strategy the strategy to calculate boosted supply of\\n @return the boosted supply\\n */\\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256) {\\n return strategy.totalSupply();\\n }\\n\\n /**\\n @notice calculate the boosted balance of a user in a given strategy.\\n @param strategy the strategy to calculate boosted balance of\\n @param user the user to calculate boosted balance of\\n @return the boosted balance\\n */\\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256) {\\n uint256 cTokensBalance = strategy.balanceOf(user);\\n ICErc20 asMarket = ICErc20(address(strategy));\\n uint256 cTokensBorrow = (asMarket.borrowBalanceCurrent(user) * 1e18) / asMarket.exchangeRateCurrent();\\n return (cTokensBalance > cTokensBorrow) ? cTokensBalance - cTokensBorrow : 0;\\n }\\n}\\n\",\"keccak256\":\"0x7f384a59a0a33182d65739bae1640b7f265e9baad551d2a0323ff4d792f0da9d\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610427806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631a50ef2f146100465780631e1932fb1461006c5780639a8cca551461007f575b600080fd5b6100596100543660046102ca565b6100c8565b6040519081526020015b60405180910390f35b61005961007a366004610303565b61024e565b6100bb6040518060400160405280601781526020017f4c6f6f706c657373466c79776865656c426f6f7374657200000000000000000081525081565b6040516100639190610327565b6040516370a0823160e01b81526001600160a01b03828116600483015260009182918516906370a0823190602401602060405180830381865afa158015610113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101379190610376565b905060008490506000816001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561017e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a29190610376565b6040516305eff7ef60e21b81526001600160a01b0387811660048301528416906317bfdfbc90602401602060405180830381865afa1580156101e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020c9190610376565b61021e90670de0b6b3a76400006103a5565b61022891906103bc565b9050808311610238576000610242565b61024281846103de565b93505050505b92915050565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561028e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102489190610376565b6001600160a01b03811681146102c757600080fd5b50565b600080604083850312156102dd57600080fd5b82356102e8816102b2565b915060208301356102f8816102b2565b809150509250929050565b60006020828403121561031557600080fd5b8135610320816102b2565b9392505050565b60006020808352835180602085015260005b8181101561035557858101830151858201604001528201610339565b506000604082860101526040601f19601f8301168501019250505092915050565b60006020828403121561038857600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176102485761024861038f565b6000826103d957634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156102485761024861038f56fea2646970667358221220ef25a8134ee0681154c6c3ab7ab097d2be8cd75f8a0dcbb31794e613ad4f6a4764736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80631a50ef2f146100465780631e1932fb1461006c5780639a8cca551461007f575b600080fd5b6100596100543660046102ca565b6100c8565b6040519081526020015b60405180910390f35b61005961007a366004610303565b61024e565b6100bb6040518060400160405280601781526020017f4c6f6f706c657373466c79776865656c426f6f7374657200000000000000000081525081565b6040516100639190610327565b6040516370a0823160e01b81526001600160a01b03828116600483015260009182918516906370a0823190602401602060405180830381865afa158015610113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101379190610376565b905060008490506000816001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561017e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a29190610376565b6040516305eff7ef60e21b81526001600160a01b0387811660048301528416906317bfdfbc90602401602060405180830381865afa1580156101e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020c9190610376565b61021e90670de0b6b3a76400006103a5565b61022891906103bc565b9050808311610238576000610242565b61024281846103de565b93505050505b92915050565b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561028e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102489190610376565b6001600160a01b03811681146102c757600080fd5b50565b600080604083850312156102dd57600080fd5b82356102e8816102b2565b915060208301356102f8816102b2565b809150509250929050565b60006020828403121561031557600080fd5b8135610320816102b2565b9392505050565b60006020808352835180602085015260005b8181101561035557858101830151858201604001528201610339565b506000604082860101526040601f19601f8301168501019250505092915050565b60006020828403121561038857600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176102485761024861038f565b6000826103d957634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156102485761024861038f56fea2646970667358221220ef25a8134ee0681154c6c3ab7ab097d2be8cd75f8a0dcbb31794e613ad4f6a4764736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "boostedBalanceOf(address,address)": { + "params": { + "strategy": "the strategy to calculate boosted balance of", + "user": "the user to calculate boosted balance of" + }, + "returns": { + "_0": "the boosted balance" + } + }, + "boostedTotalSupply(address)": { + "params": { + "strategy": "the strategy to calculate boosted supply of" + }, + "returns": { + "_0": "the boosted supply" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "boostedBalanceOf(address,address)": { + "notice": "calculate the boosted balance of a user in a given strategy." + }, + "boostedTotalSupply(address)": { + "notice": "calculate the boosted supply of a strategy." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/MasterPriceOracle.json b/packages/contracts/deployments/superseed/MasterPriceOracle.json new file mode 100644 index 0000000000..374de48624 --- /dev/null +++ b/packages/contracts/deployments/superseed/MasterPriceOracle.json @@ -0,0 +1,567 @@ +{ + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "NewDefaultOracle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "underlying", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "NewOracle", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + } + ], + "name": "add", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + } + ], + "name": "addFallbacks", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "canAdminOverwrite", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "defaultOracle", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "fallbackOracles", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle", + "name": "_defaultOracle", + "type": "address" + }, + { + "internalType": "address", + "name": "_admin", + "type": "address" + }, + { + "internalType": "bool", + "name": "_canAdminOverwrite", + "type": "bool" + }, + { + "internalType": "address", + "name": "_wtoken", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "oracles", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underlying", + "type": "address" + } + ], + "name": "price", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "setDefaultOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "wtoken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "transactionIndex": 1, + "gasUsed": "846709", + "logsBloom": "0x00000000000000002000000000000000400000008000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000008000800004000000000000000000000000000000000000000000000000000000400000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000080000000000000000000020000800000000000000000000000000", + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0", + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000bc97f93657186ad3614d05aab83ee744fc8cef48" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d3126" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480", + "logIndex": 1, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d3126" + ], + "data": "0x00000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480", + "logIndex": 2, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + } + ], + "blockNumber": 4135338, + "cumulativeGasUsed": "890587", + "status": 1, + "byzantium": true + }, + "args": [ + "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x882b92a700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7000000000000000000000000000000000000000000000000000000000000000100000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + [ + "0x0000000000000000000000000000000000000000", + "0x4200000000000000000000000000000000000006" + ], + [ + "0x431C87E08e2636733a945D742d25Ba77577ED480", + "0x431C87E08e2636733a945D742d25Ba77577ED480" + ], + "0x0000000000000000000000000000000000000000", + "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + true, + "0x4200000000000000000000000000000000000006" + ] + }, + "implementation": "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/MasterPriceOracle_Implementation.json b/packages/contracts/deployments/superseed/MasterPriceOracle_Implementation.json new file mode 100644 index 0000000000..37326989e3 --- /dev/null +++ b/packages/contracts/deployments/superseed/MasterPriceOracle_Implementation.json @@ -0,0 +1,516 @@ +{ + "address": "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "NewDefaultOracle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "underlying", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "NewOracle", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + } + ], + "name": "add", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + } + ], + "name": "addFallbacks", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "canAdminOverwrite", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "defaultOracle", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "fallbackOracles", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "underlyings", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle[]", + "name": "_oracles", + "type": "address[]" + }, + { + "internalType": "contract BasePriceOracle", + "name": "_defaultOracle", + "type": "address" + }, + { + "internalType": "address", + "name": "_admin", + "type": "address" + }, + { + "internalType": "bool", + "name": "_canAdminOverwrite", + "type": "bool" + }, + { + "internalType": "address", + "name": "_wtoken", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "oracles", + "outputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underlying", + "type": "address" + } + ], + "name": "price", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract BasePriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "setDefaultOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "wtoken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xf6ac7fe8d1ef9346a8a3908825f7e02ae3f01b097e4e19083b194ede3dcdcd85", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48", + "transactionIndex": 1, + "gasUsed": "1049506", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2cfc84b8627c139a7840e2e3cbbb95a795f95d85b14921d668ca6e8ac94f3010", + "transactionHash": "0xf6ac7fe8d1ef9346a8a3908825f7e02ae3f01b097e4e19083b194ede3dcdcd85", + "logs": [], + "blockNumber": 4135335, + "cumulativeGasUsed": "1093384", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOracle\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOracle\",\"type\":\"address\"}],\"name\":\"NewDefaultOracle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"underlying\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOracle\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOracle\",\"type\":\"address\"}],\"name\":\"NewOracle\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"underlyings\",\"type\":\"address[]\"},{\"internalType\":\"contract BasePriceOracle[]\",\"name\":\"_oracles\",\"type\":\"address[]\"}],\"name\":\"add\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"underlyings\",\"type\":\"address[]\"},{\"internalType\":\"contract BasePriceOracle[]\",\"name\":\"_oracles\",\"type\":\"address[]\"}],\"name\":\"addFallbacks\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"canAdminOverwrite\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"defaultOracle\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fallbackOracles\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"underlyings\",\"type\":\"address[]\"},{\"internalType\":\"contract BasePriceOracle[]\",\"name\":\"_oracles\",\"type\":\"address[]\"},{\"internalType\":\"contract BasePriceOracle\",\"name\":\"_defaultOracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_admin\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"_canAdminOverwrite\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"_wtoken\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"oracles\",\"outputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"underlying\",\"type\":\"address\"}],\"name\":\"price\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract BasePriceOracle\",\"name\":\"newOracle\",\"type\":\"address\"}],\"name\":\"setDefaultOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wtoken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"details\":\"Implements `PriceOracle`.\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"NewAdmin(address,address)\":{\"details\":\"Event emitted when `admin` is changed.\"},\"NewDefaultOracle(address,address)\":{\"details\":\"Event emitted when the default oracle is changed.\"},\"NewOracle(address,address,address)\":{\"details\":\"Event emitted when an underlying token's oracle is changed.\"}},\"kind\":\"dev\",\"methods\":{\"add(address[],address[])\":{\"details\":\"Sets `_oracles` for `underlyings`.\"},\"addFallbacks(address[],address[])\":{\"details\":\"Sets `_oracles` for `underlyings`.\"},\"canAdminOverwrite()\":{\"details\":\"Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin and emits an event.\"},\"getUnderlyingPrice(address)\":{\"details\":\"Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\",\"returns\":{\"_0\":\"Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\"}},\"initialize(address[],address[],address,address,bool,address)\":{\"details\":\"Initialize state variables.\",\"params\":{\"_admin\":\"The admin who can assign oracles to underlying tokens.\",\"_canAdminOverwrite\":\"Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\",\"_defaultOracle\":\"The default `PriceOracle` contract to use.\",\"_oracles\":\"The `PriceOracle` contracts to be assigned to `underlyings`.\",\"_wtoken\":\"The Wrapped native asset address\",\"underlyings\":\"The underlying ERC20 token addresses to link to `_oracles`.\"}},\"price(address)\":{\"details\":\"Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\"},\"setDefaultOracle(address)\":{\"details\":\"Changes the default price oracle\"}},\"stateVariables\":{\"admin\":{\"details\":\"The administrator of this `MasterPriceOracle`.\"},\"defaultOracle\":{\"details\":\"Default/fallback `PriceOracle`.\"},\"fallbackOracles\":{\"details\":\"Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\"},\"noAdminOverwrite\":{\"details\":\"Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\"},\"oracles\":{\"details\":\"Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\"},\"wtoken\":{\"details\":\"The Wrapped native asset address.\"}},\"title\":\"MasterPriceOracle\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getUnderlyingPrice(address)\":{\"notice\":\"Returns the price in ETH of the token underlying `cToken`.\"}},\"notice\":\"Use a combination of price oracles.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/MasterPriceOracle.sol\":\"MasterPriceOracle\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50611204806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80639c0591c81161008c578063aea9107811610066578063aea91078146101d5578063c44014d2146101f6578063f851a44014610209578063fc57d4df1461021c57600080fd5b80639c0591c8146101865780639c9192c614610199578063addd5099146101ac57600080fd5b8063656b0fd1146100d4578063727a259b146100f757806380dce16914610138578063882b92a71461014b5780638f283970146101605780639a5471fc14610173575b600080fd5b600354600160a01b900460ff161560405190151581526020015b60405180910390f35b610120610105366004610daa565b6005602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016100ee565b600254610120906001600160a01b031681565b61015e610159366004610ec1565b61022f565b005b61015e61016e366004610daa565b6104af565b61015e610181366004611010565b61053b565b600454610120906001600160a01b031681565b61015e6101a7366004611010565b6106ca565b6101206101ba366004610daa565b6001602052600090815260409020546001600160a01b031681565b6101e86101e3366004610daa565b610852565b6040519081526020016100ee565b61015e610204366004610daa565b610ad4565b600354610120906001600160a01b031681565b6101e861022a366004610daa565b610b58565b600054610100900460ff161580801561024f5750600054600160ff909116105b806102695750303b158015610269575060005460ff166001145b6102d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156102f4576000805461ff0019166101001790555b85518751146103535760405162461bcd60e51b815260206004820152602560248201527f4c656e67746873206f6620626f746820617272617973206d757374206265206560448201526438bab0b61760d91b60648201526084016102c8565b60005b87518110156104105760008882815181106103735761037361107c565b6020026020010151905060008883815181106103915761039161107c565b6020908102919091018101516001600160a01b03848116600081815260018552604080822080546001600160a01b03191694861694851790558051928352948201529283015291507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a15050600101610356565b50600280546001600160a01b038088166001600160a01b03199283161790925560038054600160a01b8715026001600160a81b031990911688851617179055600480549285169290911691909117905580156104a6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6003546001600160a01b031633146104d95760405162461bcd60e51b81526004016102c890611092565b600380546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc91015b60405180910390a15050565b6003546001600160a01b031633146105655760405162461bcd60e51b81526004016102c890611092565b821580159061057357508281145b61058f5760405162461bcd60e51b81526004016102c8906110c9565b60005b838110156106c35760008585838181106105ae576105ae61107c565b90506020020160208101906105c39190610daa565b6001600160a01b038181166000908152600560205260409020546003549293501690600160a01b900460ff161561061b576001600160a01b0381161561061b5760405162461bcd60e51b81526004016102c890611126565b600085858581811061062f5761062f61107c565b90506020020160208101906106449190610daa565b6001600160a01b0384811660008181526005602090815260409182902080546001600160a01b0319168686169081179091558251938452938716908301528101919091529091507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a1505050600101610592565b5050505050565b6003546001600160a01b031633146106f45760405162461bcd60e51b81526004016102c890611092565b821580159061070257508281145b61071e5760405162461bcd60e51b81526004016102c8906110c9565b60005b838110156106c357600085858381811061073d5761073d61107c565b90506020020160208101906107529190610daa565b6001600160a01b038181166000908152600160205260409020546003549293501690600160a01b900460ff16156107aa576001600160a01b038116156107aa5760405162461bcd60e51b81526004016102c890611126565b60008585858181106107be576107be61107c565b90506020020160208101906107d39190610daa565b6001600160a01b0384811660008181526001602090815260409182902080546001600160a01b0319168686169081179091558251938452938716908301528101919091529091507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a1505050600101610721565b6004546000906001600160a01b039081169083160361087a5750670de0b6b3a7640000919050565b6001600160a01b0380831660009081526001602090815260408083205460059092529091205490821691168115610a29576040516315d5220f60e31b81526001600160a01b03858116600483015283169063aea9107890602401602060405180830381865afa92505050801561090d575060408051601f3d908101601f1916820190925261090a91810190611198565b60015b610998576001600160a01b03811615610993576040516315d5220f60e31b81526001600160a01b03858116600483015282169063aea91078906024015b602060405180830381865afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b9190611198565b949350505050565b610a66565b8060000361098b576001600160a01b03821615610a23576040516315d5220f60e31b81526001600160a01b03868116600483015283169063aea91078906024015b602060405180830381865afa1580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a9190611198565b95945050505050565b50610a66565b6001600160a01b03811615610a66576040516315d5220f60e31b81526001600160a01b03858116600483015282169063aea910789060240161094a565b60405162461bcd60e51b815260206004820152603960248201527f5072696365206f7261636c65206e6f7420666f756e6420666f7220746869732060448201527f756e6465726c79696e6720746f6b656e20616464726573732e0000000000000060648201526084016102c8565b6003546001600160a01b03163314610afe5760405162461bcd60e51b81526004016102c890611092565b600280546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f0df2d61fdd201e9633368dca495e2c469e36c48039263448dd8a2a954c19ef1a910161052f565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbd91906111b1565b6004549091506001600160a01b0390811690821603610be65750670de0b6b3a764000092915050565b6001600160a01b0380821660009081526001602090815260408083205460059092529091205490821691168115610d455760405163fc57d4df60e01b81526001600160a01b03868116600483015283169063fc57d4df90602401602060405180830381865afa925050508015610c79575060408051601f3d908101601f19168201909252610c7691810190611198565b60015b610cba576001600160a01b038116156109935760405163fc57d4df60e01b81526001600160a01b03868116600483015282169063fc57d4df906024016109d9565b80600003610a1a576001600160a01b03821615610a235760405163fc57d4df60e01b81526001600160a01b03878116600483015283169063fc57d4df90602401602060405180830381865afa158015610d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3b9190611198565b9695505050505050565b6001600160a01b03811615610a665760405163fc57d4df60e01b81526001600160a01b03868116600483015282169063fc57d4df906024016109d9565b6001600160a01b0381168114610d9757600080fd5b50565b8035610da581610d82565b919050565b600060208284031215610dbc57600080fd5b8135610dc781610d82565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e0d57610e0d610dce565b604052919050565b600067ffffffffffffffff821115610e2f57610e2f610dce565b5060051b60200190565b600082601f830112610e4a57600080fd5b81356020610e5f610e5a83610e15565b610de4565b8083825260208201915060208460051b870101935086841115610e8157600080fd5b602086015b84811015610ea6578035610e9981610d82565b8352918301918301610e86565b509695505050505050565b80358015158114610da557600080fd5b60008060008060008060c08789031215610eda57600080fd5b863567ffffffffffffffff80821115610ef257600080fd5b818901915089601f830112610f0657600080fd5b81356020610f16610e5a83610e15565b82815260059290921b8401810191818101908d841115610f3557600080fd5b948201945b83861015610f5c578535610f4d81610d82565b82529482019490820190610f3a565b9a50508a013592505080821115610f7257600080fd5b50610f7f89828a01610e39565b955050610f8e60408801610d9a565b9350610f9c60608801610d9a565b9250610faa60808801610eb1565b9150610fb860a08801610d9a565b90509295509295509295565b60008083601f840112610fd657600080fd5b50813567ffffffffffffffff811115610fee57600080fd5b6020830191508360208260051b850101111561100957600080fd5b9250929050565b6000806000806040858703121561102657600080fd5b843567ffffffffffffffff8082111561103e57600080fd5b61104a88838901610fc4565b9096509450602087013591508082111561106357600080fd5b5061107087828801610fc4565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b60208082526018908201527f53656e646572206973206e6f74207468652061646d696e2e0000000000000000604082015260600190565b60208082526038908201527f4c656e67746873206f6620626f746820617272617973206d757374206265206560408201527f7175616c20616e642067726561746572207468616e20302e0000000000000000606082015260800190565b6020808252604c908201527f41646d696e2063616e6e6f74206f7665727772697465206578697374696e672060408201527f61737369676e6d656e7473206f66206f7261636c657320746f20756e6465726c60608201526b3cb4b733903a37b5b2b7399760a11b608082015260a00190565b6000602082840312156111aa57600080fd5b5051919050565b6000602082840312156111c357600080fd5b8151610dc781610d8256fea2646970667358221220c82cdc23b95df1f81da57164672dd908d15f868da63198f68a04590363dfccb064736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80639c0591c81161008c578063aea9107811610066578063aea91078146101d5578063c44014d2146101f6578063f851a44014610209578063fc57d4df1461021c57600080fd5b80639c0591c8146101865780639c9192c614610199578063addd5099146101ac57600080fd5b8063656b0fd1146100d4578063727a259b146100f757806380dce16914610138578063882b92a71461014b5780638f283970146101605780639a5471fc14610173575b600080fd5b600354600160a01b900460ff161560405190151581526020015b60405180910390f35b610120610105366004610daa565b6005602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016100ee565b600254610120906001600160a01b031681565b61015e610159366004610ec1565b61022f565b005b61015e61016e366004610daa565b6104af565b61015e610181366004611010565b61053b565b600454610120906001600160a01b031681565b61015e6101a7366004611010565b6106ca565b6101206101ba366004610daa565b6001602052600090815260409020546001600160a01b031681565b6101e86101e3366004610daa565b610852565b6040519081526020016100ee565b61015e610204366004610daa565b610ad4565b600354610120906001600160a01b031681565b6101e861022a366004610daa565b610b58565b600054610100900460ff161580801561024f5750600054600160ff909116105b806102695750303b158015610269575060005460ff166001145b6102d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156102f4576000805461ff0019166101001790555b85518751146103535760405162461bcd60e51b815260206004820152602560248201527f4c656e67746873206f6620626f746820617272617973206d757374206265206560448201526438bab0b61760d91b60648201526084016102c8565b60005b87518110156104105760008882815181106103735761037361107c565b6020026020010151905060008883815181106103915761039161107c565b6020908102919091018101516001600160a01b03848116600081815260018552604080822080546001600160a01b03191694861694851790558051928352948201529283015291507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a15050600101610356565b50600280546001600160a01b038088166001600160a01b03199283161790925560038054600160a01b8715026001600160a81b031990911688851617179055600480549285169290911691909117905580156104a6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6003546001600160a01b031633146104d95760405162461bcd60e51b81526004016102c890611092565b600380546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc91015b60405180910390a15050565b6003546001600160a01b031633146105655760405162461bcd60e51b81526004016102c890611092565b821580159061057357508281145b61058f5760405162461bcd60e51b81526004016102c8906110c9565b60005b838110156106c35760008585838181106105ae576105ae61107c565b90506020020160208101906105c39190610daa565b6001600160a01b038181166000908152600560205260409020546003549293501690600160a01b900460ff161561061b576001600160a01b0381161561061b5760405162461bcd60e51b81526004016102c890611126565b600085858581811061062f5761062f61107c565b90506020020160208101906106449190610daa565b6001600160a01b0384811660008181526005602090815260409182902080546001600160a01b0319168686169081179091558251938452938716908301528101919091529091507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a1505050600101610592565b5050505050565b6003546001600160a01b031633146106f45760405162461bcd60e51b81526004016102c890611092565b821580159061070257508281145b61071e5760405162461bcd60e51b81526004016102c8906110c9565b60005b838110156106c357600085858381811061073d5761073d61107c565b90506020020160208101906107529190610daa565b6001600160a01b038181166000908152600160205260409020546003549293501690600160a01b900460ff16156107aa576001600160a01b038116156107aa5760405162461bcd60e51b81526004016102c890611126565b60008585858181106107be576107be61107c565b90506020020160208101906107d39190610daa565b6001600160a01b0384811660008181526001602090815260409182902080546001600160a01b0319168686169081179091558251938452938716908301528101919091529091507f10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d31269060600160405180910390a1505050600101610721565b6004546000906001600160a01b039081169083160361087a5750670de0b6b3a7640000919050565b6001600160a01b0380831660009081526001602090815260408083205460059092529091205490821691168115610a29576040516315d5220f60e31b81526001600160a01b03858116600483015283169063aea9107890602401602060405180830381865afa92505050801561090d575060408051601f3d908101601f1916820190925261090a91810190611198565b60015b610998576001600160a01b03811615610993576040516315d5220f60e31b81526001600160a01b03858116600483015282169063aea91078906024015b602060405180830381865afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b9190611198565b949350505050565b610a66565b8060000361098b576001600160a01b03821615610a23576040516315d5220f60e31b81526001600160a01b03868116600483015283169063aea91078906024015b602060405180830381865afa1580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a9190611198565b95945050505050565b50610a66565b6001600160a01b03811615610a66576040516315d5220f60e31b81526001600160a01b03858116600483015282169063aea910789060240161094a565b60405162461bcd60e51b815260206004820152603960248201527f5072696365206f7261636c65206e6f7420666f756e6420666f7220746869732060448201527f756e6465726c79696e6720746f6b656e20616464726573732e0000000000000060648201526084016102c8565b6003546001600160a01b03163314610afe5760405162461bcd60e51b81526004016102c890611092565b600280546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f0df2d61fdd201e9633368dca495e2c469e36c48039263448dd8a2a954c19ef1a910161052f565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbd91906111b1565b6004549091506001600160a01b0390811690821603610be65750670de0b6b3a764000092915050565b6001600160a01b0380821660009081526001602090815260408083205460059092529091205490821691168115610d455760405163fc57d4df60e01b81526001600160a01b03868116600483015283169063fc57d4df90602401602060405180830381865afa925050508015610c79575060408051601f3d908101601f19168201909252610c7691810190611198565b60015b610cba576001600160a01b038116156109935760405163fc57d4df60e01b81526001600160a01b03868116600483015282169063fc57d4df906024016109d9565b80600003610a1a576001600160a01b03821615610a235760405163fc57d4df60e01b81526001600160a01b03878116600483015283169063fc57d4df90602401602060405180830381865afa158015610d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3b9190611198565b9695505050505050565b6001600160a01b03811615610a665760405163fc57d4df60e01b81526001600160a01b03868116600483015282169063fc57d4df906024016109d9565b6001600160a01b0381168114610d9757600080fd5b50565b8035610da581610d82565b919050565b600060208284031215610dbc57600080fd5b8135610dc781610d82565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e0d57610e0d610dce565b604052919050565b600067ffffffffffffffff821115610e2f57610e2f610dce565b5060051b60200190565b600082601f830112610e4a57600080fd5b81356020610e5f610e5a83610e15565b610de4565b8083825260208201915060208460051b870101935086841115610e8157600080fd5b602086015b84811015610ea6578035610e9981610d82565b8352918301918301610e86565b509695505050505050565b80358015158114610da557600080fd5b60008060008060008060c08789031215610eda57600080fd5b863567ffffffffffffffff80821115610ef257600080fd5b818901915089601f830112610f0657600080fd5b81356020610f16610e5a83610e15565b82815260059290921b8401810191818101908d841115610f3557600080fd5b948201945b83861015610f5c578535610f4d81610d82565b82529482019490820190610f3a565b9a50508a013592505080821115610f7257600080fd5b50610f7f89828a01610e39565b955050610f8e60408801610d9a565b9350610f9c60608801610d9a565b9250610faa60808801610eb1565b9150610fb860a08801610d9a565b90509295509295509295565b60008083601f840112610fd657600080fd5b50813567ffffffffffffffff811115610fee57600080fd5b6020830191508360208260051b850101111561100957600080fd5b9250929050565b6000806000806040858703121561102657600080fd5b843567ffffffffffffffff8082111561103e57600080fd5b61104a88838901610fc4565b9096509450602087013591508082111561106357600080fd5b5061107087828801610fc4565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b60208082526018908201527f53656e646572206973206e6f74207468652061646d696e2e0000000000000000604082015260600190565b60208082526038908201527f4c656e67746873206f6620626f746820617272617973206d757374206265206560408201527f7175616c20616e642067726561746572207468616e20302e0000000000000000606082015260800190565b6020808252604c908201527f41646d696e2063616e6e6f74206f7665727772697465206578697374696e672060408201527f61737369676e6d656e7473206f66206f7261636c657320746f20756e6465726c60608201526b3cb4b733903a37b5b2b7399760a11b608082015260a00190565b6000602082840312156111aa57600080fd5b5051919050565b6000602082840312156111c357600080fd5b8151610dc781610d8256fea2646970667358221220c82cdc23b95df1f81da57164672dd908d15f868da63198f68a04590363dfccb064736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "details": "Implements `PriceOracle`.", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "NewAdmin(address,address)": { + "details": "Event emitted when `admin` is changed." + }, + "NewDefaultOracle(address,address)": { + "details": "Event emitted when the default oracle is changed." + }, + "NewOracle(address,address,address)": { + "details": "Event emitted when an underlying token's oracle is changed." + } + }, + "kind": "dev", + "methods": { + "add(address[],address[])": { + "details": "Sets `_oracles` for `underlyings`." + }, + "addFallbacks(address[],address[])": { + "details": "Sets `_oracles` for `underlyings`." + }, + "canAdminOverwrite()": { + "details": "Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens." + }, + "changeAdmin(address)": { + "details": "Changes the admin and emits an event." + }, + "getUnderlyingPrice(address)": { + "details": "Implements the `PriceOracle` interface for Ionic pools (and Compound v2).", + "returns": { + "_0": "Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`." + } + }, + "initialize(address[],address[],address,address,bool,address)": { + "details": "Initialize state variables.", + "params": { + "_admin": "The admin who can assign oracles to underlying tokens.", + "_canAdminOverwrite": "Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.", + "_defaultOracle": "The default `PriceOracle` contract to use.", + "_oracles": "The `PriceOracle` contracts to be assigned to `underlyings`.", + "_wtoken": "The Wrapped native asset address", + "underlyings": "The underlying ERC20 token addresses to link to `_oracles`." + } + }, + "price(address)": { + "details": "Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`)." + }, + "setDefaultOracle(address)": { + "details": "Changes the default price oracle" + } + }, + "stateVariables": { + "admin": { + "details": "The administrator of this `MasterPriceOracle`." + }, + "defaultOracle": { + "details": "Default/fallback `PriceOracle`." + }, + "fallbackOracles": { + "details": "Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too)." + }, + "noAdminOverwrite": { + "details": "Controls if `admin` can overwrite existing assignments of oracles to underlying tokens." + }, + "oracles": { + "details": "Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too)." + }, + "wtoken": { + "details": "The Wrapped native asset address." + } + }, + "title": "MasterPriceOracle", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getUnderlyingPrice(address)": { + "notice": "Returns the price in ETH of the token underlying `cToken`." + } + }, + "notice": "Use a combination of price oracles.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 78423, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "oracles", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_contract(BasePriceOracle)78405)" + }, + { + "astId": 78427, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "defaultOracle", + "offset": 0, + "slot": "2", + "type": "t_contract(BasePriceOracle)78405" + }, + { + "astId": 78430, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "admin", + "offset": 0, + "slot": "3", + "type": "t_address" + }, + { + "astId": 78433, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "noAdminOverwrite", + "offset": 20, + "slot": "3", + "type": "t_bool" + }, + { + "astId": 78436, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "wtoken", + "offset": 0, + "slot": "4", + "type": "t_address" + }, + { + "astId": 78442, + "contract": "contracts/oracles/MasterPriceOracle.sol:MasterPriceOracle", + "label": "fallbackOracles", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_address,t_contract(BasePriceOracle)78405)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(BasePriceOracle)78405": { + "encoding": "inplace", + "label": "contract BasePriceOracle", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_contract(BasePriceOracle)78405)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => contract BasePriceOracle)", + "numberOfBytes": "32", + "value": "t_contract(BasePriceOracle)78405" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/MasterPriceOracle_Proxy.json b/packages/contracts/deployments/superseed/MasterPriceOracle_Proxy.json new file mode 100644 index 0000000000..9238f04922 --- /dev/null +++ b/packages/contracts/deployments/superseed/MasterPriceOracle_Proxy.json @@ -0,0 +1,271 @@ +{ + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "transactionIndex": 1, + "gasUsed": "846709", + "logsBloom": "0x00000000000000002000000000000000400000008000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000008000800004000000000000000000000000000000000000000000000000000000400000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000080000000000000000000020000800000000000000000000000000", + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0", + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000bc97f93657186ad3614d05aab83ee744fc8cef48" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d3126" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480", + "logIndex": 1, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x10e7c87bebf274db4de1b5f9fc731d6f83096e550bd871b681314578404d3126" + ], + "data": "0x00000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480", + "logIndex": 2, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + }, + { + "transactionIndex": 1, + "blockNumber": 4135338, + "transactionHash": "0xcbfed9c1392fcf7c0fb510fdf91d6057fa20d9bf431e4003edbb1a6c5fd48d26", + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0xc236ba9f31c61a86707ddf1af9b0b8eacf823bc5667f46cab5653cef10ed2df0" + } + ], + "blockNumber": 4135338, + "cumulativeGasUsed": "890587", + "status": 1, + "byzantium": true + }, + "args": [ + "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x882b92a700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7000000000000000000000000000000000000000000000000000000000000000100000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480000000000000000000000000431c87e08e2636733a945d742d25ba77577ed480" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/OracleRegistry.json b/packages/contracts/deployments/superseed/OracleRegistry.json new file mode 100644 index 0000000000..951a2d034b --- /dev/null +++ b/packages/contracts/deployments/superseed/OracleRegistry.json @@ -0,0 +1,294 @@ +{ + "address": "0x8Da0b2ca671F32afF847A61F845f1e99a152BDA9", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleAddressChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "OracleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "hypernativeOracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hypernativeOracleIsStrictMode", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "oracleRegister", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_mode", + "type": "bool" + } + ], + "name": "setIsStrictMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_oracle", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x4971a4fb89ab6c28a54d2dcbea83dbc61c46afcb0f69a44e37299a5b871163a4", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x8Da0b2ca671F32afF847A61F845f1e99a152BDA9", + "transactionIndex": 1, + "gasUsed": "395649", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000200000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000100000000000000000000000000400000000000000000000000002000000000000000000000000000000000400000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x0ae3fbda8154a0fc8926693df1c9830ed87a43ff0be11938d93863c518bd6f9f", + "transactionHash": "0x4971a4fb89ab6c28a54d2dcbea83dbc61c46afcb0f69a44e37299a5b871163a4", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4159580, + "transactionHash": "0x4971a4fb89ab6c28a54d2dcbea83dbc61c46afcb0f69a44e37299a5b871163a4", + "address": "0x8Da0b2ca671F32afF847A61F845f1e99a152BDA9", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x0ae3fbda8154a0fc8926693df1c9830ed87a43ff0be11938d93863c518bd6f9f" + } + ], + "blockNumber": 4159580, + "cumulativeGasUsed": "439491", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "5aaea447b85dccd5473e8e0eceb8e2df", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOracle\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOracle\",\"type\":\"address\"}],\"name\":\"OracleAddressChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"OracleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hypernativeOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hypernativeOracleIsStrictMode\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"oracleRegister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_mode\",\"type\":\"bool\"}],\"name\":\"setIsStrictMode\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_oracle\",\"type\":\"address\"}],\"name\":\"setOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/security/OracleRegistry.sol\":\"OracleRegistry\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.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 \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides 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} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() external {\\n address sender = _msgSender();\\n require(pendingOwner() == sender, \\\"Ownable2Step: caller is not the new owner\\\");\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x6adb35bab98e4b2aeafeba8d975dd22db19800b7bb15ec58e4fb78c837eeb054\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/external/hypernative/interfaces/IHypernativeOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\ninterface IHypernativeOracle {\\n function register(address account, bool isStrictMode) external;\\n function validateForbiddenAccountInteraction(address sender) external view;\\n function validateForbiddenContextInteraction(address origin, address sender) external view;\\n function validateBlacklistedAccountInteraction(address sender) external;\\n}\",\"keccak256\":\"0x0d0cabf23ce22f610eeea557c588d74011bb64cee59785f796635c2df5a6f5e3\",\"license\":\"MIT\"},\"contracts/security/OracleRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.22;\\n\\nimport { IHypernativeOracle } from \\\"../external/hypernative/interfaces/IHypernativeOracle.sol\\\";\\nimport { Ownable2Step } from \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\n\\ncontract OracleRegistry is Ownable2Step {\\n bytes32 private constant HYPERNATIVE_ORACLE_STORAGE_SLOT =\\n bytes32(uint256(keccak256(\\\"eip1967.hypernative.oracle\\\")) - 1);\\n bytes32 private constant HYPERNATIVE_MODE_STORAGE_SLOT =\\n bytes32(uint256(keccak256(\\\"eip1967.hypernative.is_strict_mode\\\")) - 1);\\n\\n event OracleAdminChanged(address indexed previousAdmin, address indexed newAdmin);\\n event OracleAddressChanged(address indexed previousOracle, address indexed newOracle);\\n\\n constructor() Ownable2Step() {}\\n\\n function oracleRegister(address _account) public {\\n address oracleAddress = hypernativeOracle();\\n bool isStrictMode = hypernativeOracleIsStrictMode();\\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\\n oracle.register(_account, isStrictMode);\\n }\\n\\n function setOracle(address _oracle) public onlyOwner {\\n _setOracle(_oracle);\\n }\\n\\n function setIsStrictMode(bool _mode) public onlyOwner {\\n _setIsStrictMode(_mode);\\n }\\n\\n function hypernativeOracleIsStrictMode() public view returns (bool) {\\n return _getValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT) == 1;\\n }\\n\\n function hypernativeOracle() public view returns (address) {\\n return _getAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT);\\n }\\n\\n /**\\n * @dev Admin only function, sets new oracle admin. set to address(0) to revoke oracle\\n */\\n function _setOracle(address _oracle) internal {\\n address oldOracle = hypernativeOracle();\\n _setAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT, _oracle);\\n emit OracleAddressChanged(oldOracle, _oracle);\\n }\\n\\n function _setIsStrictMode(bool _mode) internal {\\n _setValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT, _mode ? 1 : 0);\\n }\\n\\n function _setAddressBySlot(bytes32 slot, address newAddress) internal {\\n assembly {\\n sstore(slot, newAddress)\\n }\\n }\\n\\n function _setValueBySlot(bytes32 _slot, uint256 _value) internal {\\n assembly {\\n sstore(_slot, _value)\\n }\\n }\\n\\n function _getAddressBySlot(bytes32 slot) internal view returns (address addr) {\\n assembly {\\n addr := sload(slot)\\n }\\n }\\n\\n function _getValueBySlot(bytes32 _slot) internal view returns (uint256 _value) {\\n assembly {\\n _value := sload(_slot)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x31798eaddcc3e7f112afc7c32aeba6d88fd004b17aff916428739164daf308b8\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61008b565b600180546001600160a01b03191690556100388161003b565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6105b08061009a6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b146100f857806398fc32971461011d578063e30c397814610125578063f2fde38b14610136578063fbdb50db1461014957600080fd5b80631d1458dc146100a3578063715018a6146100c057806379ba5097146100ca5780637adbf973146100d2578063822afe5f146100e5575b600080fd5b6100ab61015c565b60405190151581526020015b60405180910390f35b6100c8610198565b005b6100c86101ac565b6100c86100e0366004610501565b61022b565b6100c86100f3366004610531565b61023c565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100b7565b61010561024d565b6001546001600160a01b0316610105565b6100c8610144366004610501565b610282565b6100c8610157366004610501565b6102f3565b600061019061018c60017fdb1894cb68118c2752c615f034b63d95c89febc7dbb8fd5e6ce41bdf3931d36f610553565b5490565b600114905090565b6101a0610377565b6101aa60006103d1565b565b60015433906001600160a01b0316811461021f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b610228816103d1565b50565b610233610377565b610228816103ea565b610244610377565b6102288161046d565b600061027d61018c60017ffa373e1ee49299afe249e16436ea939a0edb26953bec7179d544957654b3ba20610553565b905090565b61028a610377565b600180546001600160a01b0383166001600160a01b031990911681179091556102bb6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60006102fd61024d565b9050600061030961015c565b60405163ab01b46960e01b81526001600160a01b0385811660048301528215156024830152919250839182169063ab01b46990604401600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146101aa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610216565b600180546001600160a01b0319169055610228816104b1565b60006103f461024d565b905061042961042460017ffa373e1ee49299afe249e16436ea939a0edb26953bec7179d544957654b3ba20610553565b839055565b816001600160a01b0316816001600160a01b03167f39206e6a16d6663e5a80ef081a32ce35bc314fe842cc614df23e92da300729df60405160405180910390a35050565b61022861049b60017fdb1894cb68118c2752c615f034b63d95c89febc7dbb8fd5e6ce41bdf3931d36f610553565b826104a75760006104aa565b60015b60ff169055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051357600080fd5b81356001600160a01b038116811461052a57600080fd5b9392505050565b60006020828403121561054357600080fd5b8135801515811461052a57600080fd5b8181038181111561057457634e487b7160e01b600052601160045260246000fd5b9291505056fea2646970667358221220d59295146eacb0fa2cfbe69240bace9b375c2228306cfc58a517d5df77cc68a964736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b146100f857806398fc32971461011d578063e30c397814610125578063f2fde38b14610136578063fbdb50db1461014957600080fd5b80631d1458dc146100a3578063715018a6146100c057806379ba5097146100ca5780637adbf973146100d2578063822afe5f146100e5575b600080fd5b6100ab61015c565b60405190151581526020015b60405180910390f35b6100c8610198565b005b6100c86101ac565b6100c86100e0366004610501565b61022b565b6100c86100f3366004610531565b61023c565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100b7565b61010561024d565b6001546001600160a01b0316610105565b6100c8610144366004610501565b610282565b6100c8610157366004610501565b6102f3565b600061019061018c60017fdb1894cb68118c2752c615f034b63d95c89febc7dbb8fd5e6ce41bdf3931d36f610553565b5490565b600114905090565b6101a0610377565b6101aa60006103d1565b565b60015433906001600160a01b0316811461021f5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b610228816103d1565b50565b610233610377565b610228816103ea565b610244610377565b6102288161046d565b600061027d61018c60017ffa373e1ee49299afe249e16436ea939a0edb26953bec7179d544957654b3ba20610553565b905090565b61028a610377565b600180546001600160a01b0383166001600160a01b031990911681179091556102bb6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60006102fd61024d565b9050600061030961015c565b60405163ab01b46960e01b81526001600160a01b0385811660048301528215156024830152919250839182169063ab01b46990604401600060405180830381600087803b15801561035957600080fd5b505af115801561036d573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146101aa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610216565b600180546001600160a01b0319169055610228816104b1565b60006103f461024d565b905061042961042460017ffa373e1ee49299afe249e16436ea939a0edb26953bec7179d544957654b3ba20610553565b839055565b816001600160a01b0316816001600160a01b03167f39206e6a16d6663e5a80ef081a32ce35bc314fe842cc614df23e92da300729df60405160405180910390a35050565b61022861049b60017fdb1894cb68118c2752c615f034b63d95c89febc7dbb8fd5e6ce41bdf3931d36f610553565b826104a75760006104aa565b60015b60ff169055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051357600080fd5b81356001600160a01b038116811461052a57600080fd5b9392505050565b60006020828403121561054357600080fd5b8135801515811461052a57600080fd5b8181038181111561057457634e487b7160e01b600052601160045260246000fd5b9291505056fea2646970667358221220d59295146eacb0fa2cfbe69240bace9b375c2228306cfc58a517d5df77cc68a964736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/security/OracleRegistry.sol:OracleRegistry", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 120, + "contract": "contracts/security/OracleRegistry.sol:OracleRegistry", + "label": "_pendingOwner", + "offset": 0, + "slot": "1", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/PoolDirectory.json b/packages/contracts/deployments/superseed/PoolDirectory.json new file mode 100644 index 0000000000..9ff4610672 --- /dev/null +++ b/packages/contracts/deployments/superseed/PoolDirectory.json @@ -0,0 +1,1105 @@ +{ + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "admins", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "AdminWhitelistUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "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": "uint256", + "name": "index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct PoolDirectory.Pool", + "name": "pool", + "type": "tuple" + } + ], + "name": "PoolRegistered", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + } + ], + "name": "_deprecatePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "_deprecatePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "admins", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "_editAdminWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "deployers", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "_editDeployerWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "enforce", + "type": "bool" + } + ], + "name": "_setDeployerWhitelistEnforcement", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "adminWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "constructorData", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "enforceWhitelist", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "closeFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationIncentive", + "type": "uint256" + }, + { + "internalType": "address", + "name": "priceOracle", + "type": "address" + } + ], + "name": "deployPool", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "deployerWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enforceDeployerWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getActivePools", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllPools", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getPoolsByAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPoolsOfUser", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPublicPools", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "name": "getPublicPoolsByVerification", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVerifiedPoolsOfWhitelistedAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_enforceDeployerWhitelist", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "_deployerWhitelist", + "type": "address[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "poolExists", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "pools", + "outputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolsCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + } + ], + "name": "setPoolName", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "transactionIndex": 1, + "gasUsed": "775682", + "logsBloom": "0x00000000000000000000000000000000400000010000000000800000000200000000000000000000000000000000000000000000100000040000000000000000000000000000000000000000000002000001000000000000000000000000000000000000020000000000040000000800000000800000000000000040000000400000000000000000000000000000000000000000000080000000000000c00000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000001000000000000000000000000000000000000000000000", + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597", + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000aee8aa2c69caa9f6d2c6a78198243c348d0c07d2" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + } + ], + "blockNumber": 4135316, + "cumulativeGasUsed": "830748", + "status": 1, + "byzantium": true + }, + "args": [ + "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xb86579d4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [ + false, + [] + ] + }, + "implementation": "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/PoolDirectory_Implementation.json b/packages/contracts/deployments/superseed/PoolDirectory_Implementation.json new file mode 100644 index 0000000000..f734b2d9b2 --- /dev/null +++ b/packages/contracts/deployments/superseed/PoolDirectory_Implementation.json @@ -0,0 +1,1240 @@ +{ + "address": "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "admins", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "AdminWhitelistUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "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": "uint256", + "name": "index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct PoolDirectory.Pool", + "name": "pool", + "type": "tuple" + } + ], + "name": "PoolRegistered", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "comptroller", + "type": "address" + } + ], + "name": "_deprecatePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "_deprecatePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "admins", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "_editAdminWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "deployers", + "type": "address[]" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "_editDeployerWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "enforce", + "type": "bool" + } + ], + "name": "_setDeployerWhitelistEnforcement", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "adminWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "implementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "constructorData", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "enforceWhitelist", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "closeFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidationIncentive", + "type": "uint256" + }, + { + "internalType": "address", + "name": "priceOracle", + "type": "address" + } + ], + "name": "deployPool", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "deployerWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enforceDeployerWhitelist", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getActivePools", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllPools", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getPoolsByAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPoolsOfUser", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPublicPools", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "name": "getPublicPoolsByVerification", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVerifiedPoolsOfWhitelistedAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_enforceDeployerWhitelist", + "type": "bool" + }, + { + "internalType": "address[]", + "name": "_deployerWhitelist", + "type": "address[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "poolExists", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "pools", + "outputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolsCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + } + ], + "name": "setPoolName", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x3ca23fa349b2e199f0cf941ea06ba2ddf11b6829b3e312aef69342bebf2e9b69", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2", + "transactionIndex": 1, + "gasUsed": "4543364", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xd88fdca3bf101d040a29f04032943161cefad8b521d53fd4e033f586099d915c", + "transactionHash": "0x3ca23fa349b2e199f0cf941ea06ba2ddf11b6829b3e312aef69342bebf2e9b69", + "logs": [], + "blockNumber": 4135313, + "cumulativeGasUsed": "4587218", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"admins\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"AdminWhitelistUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"NewPendingOwner\",\"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\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"struct PoolDirectory.Pool\",\"name\":\"pool\",\"type\":\"tuple\"}],\"name\":\"PoolRegistered\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_acceptOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"_deprecatePool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"_deprecatePool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"admins\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"_editAdminWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"deployers\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"_editDeployerWhitelist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"enforce\",\"type\":\"bool\"}],\"name\":\"_setDeployerWhitelistEnforcement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"_setPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"adminWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"constructorData\",\"type\":\"bytes\"},{\"internalType\":\"bool\",\"name\":\"enforceWhitelist\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"closeFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidationIncentive\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"priceOracle\",\"type\":\"address\"}],\"name\":\"deployPool\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"deployerWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enforceDeployerWhitelist\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getActivePools\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllPools\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getPoolsByAccount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getPoolsOfUser\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPublicPools\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"name\":\"getPublicPoolsByVerification\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVerifiedPoolsOfWhitelistedAccount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_enforceDeployerWhitelist\",\"type\":\"bool\"},{\"internalType\":\"address[]\",\"name\":\"_deployerWhitelist\",\"type\":\"address[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"poolExists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"pools\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolsCounter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"setPoolName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"events\":{\"AdminWhitelistUpdated(address[],bool)\":{\"details\":\"Event emitted when the admin whitelist is updated.\"},\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"PoolRegistered(uint256,(string,address,address,uint256,uint256))\":{\"details\":\"Emitted when a new Ionic pool is added to the directory.\"}},\"kind\":\"dev\",\"methods\":{\"_acceptOwner()\":{\"details\":\"Owner function for pending owner to accept role and update owner\"},\"_editAdminWhitelist(address[],bool)\":{\"details\":\"Adds/removes Ethereum accounts to the admin whitelist.\",\"params\":{\"admins\":\"Array of Ethereum accounts to be whitelisted.\",\"status\":\"Whether to add or remove the accounts.\"}},\"_editDeployerWhitelist(address[],bool)\":{\"details\":\"Adds/removes Ethereum accounts to the deployer whitelist.\",\"params\":{\"deployers\":\"Array of Ethereum accounts to be whitelisted.\",\"status\":\"Whether to add or remove the accounts.\"}},\"_setDeployerWhitelistEnforcement(bool)\":{\"details\":\"Controls if the deployer whitelist is to be enforced.\",\"params\":{\"enforce\":\"Boolean indicating if the deployer whitelist is to be enforced.\"}},\"_setPendingOwner(address)\":{\"details\":\"Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\",\"params\":{\"newPendingOwner\":\"New pending owner.\"}},\"deployPool(string,address,bytes,bool,uint256,uint256,address)\":{\"details\":\"Deploys a new Ionic pool and adds to the directory.\",\"params\":{\"closeFactor\":\"The pool's close factor (scaled by 1e18).\",\"constructorData\":\"Encoded construction data for `Unitroller constructor()`\",\"enforceWhitelist\":\"Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\",\"implementation\":\"The Comptroller implementation contract address.\",\"liquidationIncentive\":\"The pool's liquidation incentive (scaled by 1e18).\",\"name\":\"The name of the pool.\",\"priceOracle\":\"The pool's PriceOracle contract address.\"},\"returns\":{\"_0\":\"Index of the registered Ionic pool and the Unitroller proxy address.\"}},\"getActivePools()\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getAllPools()\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getPoolsOfUser(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getPublicPools()\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getPublicPoolsByVerification(bool)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getVerifiedPoolsOfWhitelistedAccount(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\",\"params\":{\"account\":\"who is whitelisted in the returned verified whitelist-enabled pools.\"}},\"initialize(bool,address[])\":{\"details\":\"Initializes a deployer whitelist if desired.\",\"params\":{\"_deployerWhitelist\":\"Array of Ethereum accounts to be whitelisted.\",\"_enforceDeployerWhitelist\":\"Boolean indicating if the deployer whitelist is to be enforced.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"stateVariables\":{\"_poolsByAccount\":{\"details\":\"Maps Ethereum accounts to arrays of Ionic pool indexes.\"},\"adminWhitelist\":{\"details\":\"Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\"},\"deployerWhitelist\":{\"details\":\"Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\"},\"enforceDeployerWhitelist\":{\"details\":\"Booleans indicating if the deployer whitelist is enforced.\"},\"poolExists\":{\"details\":\"Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\"},\"pools\":{\"details\":\"Array of Ionic interest rate pools.\"},\"poolsCounter\":{\"details\":\"used as salt for the creation of new pools\"}},\"title\":\"PoolDirectory\",\"version\":1},\"userdoc\":{\"events\":{\"NewOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is accepted, which means owner is updated\"},\"NewPendingOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is changed\"}},\"kind\":\"user\",\"methods\":{\"_acceptOwner()\":{\"notice\":\"Accepts transfer of owner rights. msg.sender must be pendingOwner\"},\"_setPendingOwner(address)\":{\"notice\":\"Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\"},\"getActivePools()\":{\"notice\":\"Returns `ids` and directory information of all non-deprecated Ionic pools.\"},\"getAllPools()\":{\"notice\":\"Returns arrays of all Ionic pools' data.\"},\"getPoolsByAccount(address)\":{\"notice\":\"Returns arrays of Ionic pool indexes and data created by `account`.\"},\"getPoolsOfUser(address)\":{\"notice\":\"Returns arrays of all public Ionic pool indexes and data.\"},\"getPublicPools()\":{\"notice\":\"Returns arrays of all public Ionic pool indexes and data.\"},\"getPublicPoolsByVerification(bool)\":{\"notice\":\"Returns arrays of all Ionic pool indexes and data with whitelisted admins.\"},\"getVerifiedPoolsOfWhitelistedAccount(address)\":{\"notice\":\"Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\"},\"pendingOwner()\":{\"notice\":\"Pending owner of this contract\"},\"setPoolName(uint256,string)\":{\"notice\":\"Modify existing Ionic pool name.\"}},\"notice\":\"PoolDirectory is a directory for Ionic interest rate pools.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/PoolDirectory.sol\":\"PoolDirectory\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061515d806100206000396000f3fe60806040523480156200001157600080fd5b5060043610620001cc5760003560e01c80638da5cb5b116200010d578063b5f3f64011620000a3578063e30c3978116200007a578063e30c3978146200044a578063f2fde38b146200045e578063f348960d1462000475578063fc4d33f9146200048c57600080fd5b8063b5f3f6401462000403578063b86579d4146200041a578063d88ff1f4146200043157600080fd5b8063a155497c11620000e4578063a155497c1462000385578063a3ed91c6146200039c578063a970e76c14620003b3578063ac4afa3814620003d957600080fd5b80638da5cb5b146200033e5780638ec0835414620003645780639b29177f146200036e57600080fd5b806343e20a1d116200018357806358b896d3116200015a57806358b896d314620002cf5780635d0eb31a14620003045780636e96dfd7146200031d578063715018a6146200033457600080fd5b806343e20a1d1462000288578063448ca55814620002ae5780634ae26ea114620002c557600080fd5b806304f03c6f14620001d15780630a83d1b014620001ea5780631e1c6a07146200020157806320c32bfe146200023c578063218a3bbe146200025357806326bb81d7146200027a575b600080fd5b620001e8620001e236600462002dc3565b62000496565b005b620001e8620001fb36600462002de3565b620004b3565b620002276200021236600462002e92565b60686020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b620001e86200024d36600462002efd565b620005b7565b6200026a6200026436600462002dc3565b62000761565b6040516200023392919062003057565b606954620002279060ff1681565b620002276200029936600462002e92565b606b6020526000908152604090205460ff1681565b6200026a620002bf36600462002e92565b62000a4b565b6200026a62000dd5565b620002e6620002e0366004620030fc565b62001070565b604080519283526001600160a01b0390911660208301520162000233565b6200030e606c5481565b60405190815260200162000233565b620001e86200032e36600462002e92565b62001669565b620001e8620016d5565b6033546001600160a01b03165b6040516001600160a01b03909116815260200162000233565b6200026a6200171b565b620001e86200037f36600462002e92565b620019ee565b620001e86200039636600462002de3565b62001a61565b6200026a620003ad36600462002e92565b62001b27565b62000227620003c436600462002e92565b606a6020526000908152604090205460ff1681565b620003f0620003ea3660046200320f565b62001d22565b6040516200023395949392919062003229565b620001e8620004143660046200320f565b62001e08565b620001e86200042b3660046200326b565b62001fe9565b6200043b62002175565b60405162000233919062003340565b6065546200034b906001600160a01b031681565b620001e86200046f36600462002e92565b620023d2565b6200026a6200048636600462002e92565b62002445565b620001e862002707565b620004a062002821565b6069805460ff1916911515919091179055565b620004bd62002821565b81620005065760405162461bcd60e51b815260206004820152601360248201527227379030b236b4b7399039bab8383634b2b21760691b60448201526064015b60405180910390fd5b60005b82811015620005745781606b60008686858181106200052c576200052c62003355565b905060200201602081019062000543919062002e92565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010162000509565b507f31b67e6853df85403a8c4f4f46dc53f48f700d6917c8e3ec8c77a0e6fd56793b838383604051620005aa939291906200336b565b60405180910390a1505050565b600060668481548110620005cf57620005cf62003355565b600091825260209182902060026005909202010154604080516303e1469160e61b815290516001600160a01b039092169350839263f851a440926004808401938290030181865afa15801562000629573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200064f9190620033c8565b6001600160a01b0316336001600160a01b0316148015620006d05750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015620006aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006d09190620033e8565b80620006e657506033546001600160a01b031633145b620007225760405162461bcd60e51b815260206004820152600b60248201526a10b832b936b4b9b9b4b7b760a91b6044820152606401620004fd565b8282606686815481106200073a576200073a62003355565b906000526020600020906005020160000191826200075a92919062003498565b5050505050565b606080600080620007716200171b565b91505060005b81518110156200085457600082828151811062000798576200079862003355565b6020026020010151604001519050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000803575060408051601f3d908101601f191682019092526200080091810190620033c8565b60015b156200083a576001600160a01b0381166000908152606b602052604090205460ff16151588151514620008385750506200084b565b505b8362000846816200357a565b945050505b60010162000777565b506000826001600160401b03811115620008725762000872620030b3565b6040519080825280602002602001820160405280156200089c578160200160208202803683370190505b5090506000836001600160401b03811115620008bc57620008bc620030b3565b604051908082528060200260200182016040528015620008f957816020015b620008e562002d53565b815260200190600190039081620008db5790505b5090506000805b845181101562000a3d57600085828151811062000921576200092162003355565b6020026020010151604001519050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200098c575060408051601f3d908101601f191682019092526200098991810190620033c8565b60015b15620009c3576001600160a01b0381166000908152606b602052604090205460ff1615158b151514620009c157505062000a34565b505b81858481518110620009d957620009d962003355565b602002602001018181525050858281518110620009fa57620009fa62003355565b602002602001015184848151811062000a175762000a1762003355565b6020026020010181905250828062000a2f906200357a565b935050505b60010162000900565b509197909650945050505050565b60608060008062000a5b6200171b565b91505060005b815181101562000b9557600082828151811062000a825762000a8262003355565b6020026020010151604001519050806001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000aed575060408051601f3d908101601f1916820190925262000aea91810190620033e8565b60015b1562000b7b5780158062000b6b5750604051634d8c928d60e11b81526001600160a01b038981166004830152831690639b19251a90602401602060405180830381865afa15801562000b43573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b699190620033e8565b155b1562000b7957505062000b8c565b505b8362000b87816200357a565b945050505b60010162000a61565b506000826001600160401b0381111562000bb35762000bb3620030b3565b60405190808252806020026020018201604052801562000bdd578160200160208202803683370190505b5090506000836001600160401b0381111562000bfd5762000bfd620030b3565b60405190808252806020026020018201604052801562000c3a57816020015b62000c2662002d53565b81526020019060019003908162000c1c5790505b5090506000805b845181101562000a3d57600085828151811062000c625762000c6262003355565b6020026020010151604001519050806001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000ccd575060408051601f3d908101601f1916820190925262000cca91810190620033e8565b60015b1562000d5b5780158062000d4b5750604051634d8c928d60e11b81526001600160a01b038c81166004830152831690639b19251a90602401602060405180830381865afa15801562000d23573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000d499190620033e8565b155b1562000d5957505062000dcc565b505b8185848151811062000d715762000d7162003355565b60200260200101818152505085828151811062000d925762000d9262003355565b602002602001015184848151811062000daf5762000daf62003355565b6020026020010181905250828062000dc7906200357a565b935050505b60010162000c41565b60608060008062000de56200171b565b91505060005b815181101562000ea15781818151811062000e0a5762000e0a62003355565b6020026020010151604001516001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000e72575060408051601f3d908101601f1916820190925262000e6f91810190620033e8565b60015b1562000e8857801562000e86575062000e98565b505b8262000e94816200357a565b9350505b60010162000deb565b506000826001600160401b0381111562000ebf5762000ebf620030b3565b60405190808252806020026020018201604052801562000ee9578160200160208202803683370190505b5090506000836001600160401b0381111562000f095762000f09620030b3565b60405190808252806020026020018201604052801562000f4657816020015b62000f3262002d53565b81526020019060019003908162000f285790505b5090506000805b8451811015620010635784818151811062000f6c5762000f6c62003355565b6020026020010151604001516001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000fd4575060408051601f3d908101601f1916820190925262000fd191810190620033e8565b60015b1562000fea57801562000fe857506200105a565b505b8084838151811062001000576200100062003355565b60200260200101818152505084818151811062001021576200102162003355565b60200260200101518383815181106200103e576200103e62003355565b6020026020010181905250818062001056906200357a565b9250505b60010162000f4d565b5091969095509350505050565b6000806001600160a01b038916620010f15760405162461bcd60e51b815260206004820152603960248201527f4e6f20436f6d7074726f6c6c657220696d706c656d656e746174696f6e20636f60448201527f6e74726163742061646472657373207370656369666965642e000000000000006064820152608401620004fd565b6001600160a01b0383166200115c5760405162461bcd60e51b815260206004820152602a60248201527f4e6f2050726963654f7261636c6520636f6e747261637420616464726573732060448201526939b832b1b4b334b2b21760b11b6064820152608401620004fd565b600060405180602001620011709062002d94565b601f1982820381018352601f9091011660408190526200119891908b908b9060200162003596565b60405160208183030381529060405290506000620011fa6000338e606c60008154620011c4906200357a565b9182905550604051620011dd93929190602001620035c0565b60405160208183030381529060405280519060200120846200287f565b90506000819050806001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156200123d57600080fd5b505af115801562001252573d6000803e3d6000fd5b505060405163317b0b7760e01b8152600481018b90526001600160a01b038416925063317b0b7791506024016020604051808303816000875af11580156200129e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620012c4919062003601565b15620013135760405162461bcd60e51b815260206004820181905260248201527f4661696c656420746f2073657420706f6f6c20636c6f736520666163746f722e6044820152606401620004fd565b604051634fd42e1760e01b8152600481018890526001600160a01b03821690634fd42e17906024016020604051808303816000875af11580156200135b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001381919062003601565b15620013e25760405162461bcd60e51b815260206004820152602960248201527f4661696c656420746f2073657420706f6f6c206c69717569646174696f6e20696044820152683731b2b73a34bb329760b91b6064820152608401620004fd565b6040516355ee1fe160e01b81526001600160a01b0387811660048301528216906355ee1fe1906024016020604051808303816000875af11580156200142b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001451919062003601565b15620014a05760405162461bcd60e51b815260206004820181905260248201527f4661696c656420746f2073657420706f6f6c207072696365206f7261636c652e6044820152606401620004fd565b88156200157b57604051634a956fad60e11b8152600160048201526001600160a01b0382169063952adf5a906024016020604051808303816000875af1158015620014ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001515919062003601565b156200157b5760405162461bcd60e51b815260206004820152602e60248201527f4661696c656420746f20656e666f72636520737570706c6965722f626f72726f60448201526d3bb2b9103bb434ba32b634b9ba1760911b6064820152608401620004fd565b604051632dc7468360e21b81523360048201526001600160a01b0382169063b71d1a0c906024016020604051808303816000875af1158015620015c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015e8919062003601565b156200164a5760405162461bcd60e51b815260206004820152602a60248201527f4661696c656420746f207365742070656e64696e672061646d696e206f6e20556044820152693734ba3937b63632b91760b11b6064820152608401620004fd565b620016568d8362002990565b9d919c50909a5050505050505050505050565b6200167362002821565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b620016df62002821565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b6044820152606401620004fd565b6060806000805b6066548110156200178a5760006001600160a01b0316606682815481106200174e576200174e62003355565b60009182526020909120600260059092020101546001600160a01b0316146200178157816200177d816200357a565b9250505b60010162001722565b506000816001600160401b03811115620017a857620017a8620030b3565b604051908082528060200260200182016040528015620017e557816020015b620017d162002d53565b815260200190600190039081620017c75790505b5090506000826001600160401b03811115620018055762001805620030b3565b6040519080825280602002602001820160405280156200182f578160200160208202803683370190505b5090506000805b606654811015620019e15760006001600160a01b03166066828154811062001862576200186262003355565b60009182526020909120600260059092020101546001600160a01b031614620019d857808383815181106200189b576200189b62003355565b60200260200101818152505060668181548110620018bd57620018bd62003355565b90600052602060002090600502016040518060a0016040529081600082018054620018e89062003408565b80601f0160208091040260200160405190810160405280929190818152602001828054620019169062003408565b8015620019675780601f106200193b5761010080835404028352916020019162001967565b820191906000526020600020905b8154815290600101906020018083116200194957829003601f168201915b505050918352505060018201546001600160a01b0390811660208301526002830154166040820152600382015460608201526004909101546080909101528451859084908110620019bc57620019bc62003355565b60200260200101819052508180620019d4906200357a565b9250505b60010162001836565b5090959194509092505050565b620019f862002821565b60005b60665481101562001a5457816001600160a01b03166066828154811062001a265762001a2662003355565b60009182526020909120600260059092020101546001600160a01b03160362001a585762001a548162001e08565b5050565b600101620019fb565b62001a6b62002821565b8162001ab35760405162461bcd60e51b81526020600482015260166024820152752737903232b83637bcb2b9399039bab8383634b2b21760511b6044820152606401620004fd565b60005b8281101562001b215781606a600086868581811062001ad95762001ad962003355565b905060200201602081019062001af0919062002e92565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010162001ab6565b50505050565b6001600160a01b03811660009081526067602052604081205460609182916001600160401b0381111562001b5f5762001b5f620030b3565b60405190808252806020026020018201604052801562001b89578160200160208202803683370190505b506001600160a01b038516600090815260676020526040812054919250906001600160401b0381111562001bc15762001bc1620030b3565b60405190808252806020026020018201604052801562001bfe57816020015b62001bea62002d53565b81526020019060019003908162001be05790505b509050600062001c0d6200171b565b91505060005b6001600160a01b03871660009081526067602052604090205481101562001d16576001600160a01b038716600090815260676020526040902080548290811062001c615762001c6162003355565b906000526020600020015484828151811062001c815762001c8162003355565b6020026020010181815250508160676000896001600160a01b03166001600160a01b03168152602001908152602001600020828154811062001cc75762001cc762003355565b90600052602060002001548151811062001ce55762001ce562003355565b602002602001015183828151811062001d025762001d0262003355565b602090810291909101015260010162001c13565b50919590945092505050565b6066818154811062001d3357600080fd5b906000526020600020906005020160009150905080600001805462001d589062003408565b80601f016020809104026020016040519081016040528092919081815260200182805462001d869062003408565b801562001dd75780601f1062001dab5761010080835404028352916020019162001dd7565b820191906000526020600020905b81548152906001019060200180831162001db957829003601f168201915b5050505060018301546002840154600385015460049095015493946001600160a01b03928316949290911692509085565b62001e1262002821565b60006066828154811062001e2a5762001e2a62003355565b6000918252602090912060059091020160028101549091506001600160a01b031662001e995760405162461bcd60e51b815260206004820152601760248201527f706f6f6c20616c726561647920646570726563617465640000000000000000006044820152606401620004fd565b60018101546001600160a01b03166000908152606760205260408120905b815481101562001f73578382828154811062001ed75762001ed762003355565b90600052602060002001540362001f6a578154829062001efa906001906200361b565b8154811062001f0d5762001f0d62003355565b906000526020600020015482828154811062001f2d5762001f2d62003355565b90600052602060002001819055508180548062001f4e5762001f4e62003631565b6001900381819060005260206000200160009055905562001f73565b60010162001eb7565b506002820180546001600160a01b03166000908152606860209081526040808320805460ff1916600190811790915584546001600160a01b03199081169095558601805490941690935582519081019092528152829062001fd5908262003647565b505060006003820181905560049091015550565b600054610100900460ff16158080156200200a5750600054600160ff909116105b80620020265750303b15801562002026575060005460ff166001145b6200208b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620004fd565b6000805460ff191660011790558015620020af576000805461ff0019166101001790555b620020ba3362002c5c565b6069805460ff191684151517905560005b82518110156200212b576001606a6000858481518110620020f057620020f062003355565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101620020cb565b50801562002170576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001620005aa565b505050565b60606000805b606654811015620021e35760006001600160a01b031660668281548110620021a757620021a762003355565b60009182526020909120600260059092020101546001600160a01b031614620021da5781620021d6816200357a565b9250505b6001016200217b565b506000816001600160401b03811115620022015762002201620030b3565b6040519080825280602002602001820160405280156200223e57816020015b6200222a62002d53565b815260200190600190039081620022205790505b5090506000805b606654811015620023c95760006001600160a01b03166066828154811062002271576200227162003355565b60009182526020909120600260059092020101546001600160a01b031614620023c05760668181548110620022aa57620022aa62003355565b90600052602060002090600502016040518060a0016040529081600082018054620022d59062003408565b80601f0160208091040260200160405190810160405280929190818152602001828054620023039062003408565b8015620023545780601f10620023285761010080835404028352916020019162002354565b820191906000526020600020905b8154815290600101906020018083116200233657829003601f168201915b505050918352505060018201546001600160a01b03908116602083015260028301541660408201526003820154606082015260049091015460809091015283836200239f816200357a565b945081518110620023b457620023b462003355565b60200260200101819052505b60010162002245565b50909392505050565b620023dc62002821565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b606080600080620024556200171b565b91505060005b81518110156200252b578181815181106200247a576200247a62003355565b6020026020010151604001516001600160a01b031663d9e0ea6b876040518263ffffffff1660e01b8152600401620024c191906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015620024fd575060408051601f3d908101601f19168201909252620024fa91810190620033e8565b60015b1562002512578062002510575062002522565b505b826200251e816200357a565b9350505b6001016200245b565b506000826001600160401b03811115620025495762002549620030b3565b60405190808252806020026020018201604052801562002573578160200160208202803683370190505b5090506000836001600160401b03811115620025935762002593620030b3565b604051908082528060200260200182016040528015620025d057816020015b620025bc62002d53565b815260200190600190039081620025b25790505b5090506000805b845181101562000a3d57848181518110620025f657620025f662003355565b6020026020010151604001516001600160a01b031663d9e0ea6b8a6040518263ffffffff1660e01b81526004016200263d91906001600160a01b0391909116815260200190565b602060405180830381865afa92505050801562002679575060408051601f3d908101601f191682019092526200267691810190620033e8565b60015b156200268e57806200268c5750620026fe565b505b80848381518110620026a457620026a462003355565b602002602001018181525050848181518110620026c557620026c562003355565b6020026020010151838381518110620026e257620026e262003355565b60200260200101819052508180620026fa906200357a565b9250505b600101620025d7565b6065546001600160a01b031633146200275b5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b6044820152606401620004fd565b6000620027706033546001600160a01b031690565b6065549091506001600160a01b03166200278a8162002c9e565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101620016c9565b6033546001600160a01b031633146200287d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620004fd565b565b600083471015620028d35760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401620004fd565b8151600003620029265760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401620004fd565b8282516020840186f590506001600160a01b038116620029895760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401620004fd565b9392505050565b6001600160a01b03811660009081526068602052604081205460ff161562002a095760405162461bcd60e51b815260206004820152602560248201527f506f6f6c20616c72656164792065786973747320696e207468652064697265636044820152643a37b93c9760d91b6064820152608401620004fd565b60695460ff16158062002a2b5750336000908152606a602052604090205460ff165b62002a855760405162461bcd60e51b8152602060048201526024808201527f53656e646572206973206e6f74206f6e206465706c6f7965722077686974656c60448201526334b9ba1760e11b6064820152608401620004fd565b60648351111562002ad25760405162461bcd60e51b81526020600482015260166024820152752737903837b7b6103730b6b29039bab8383634b2b21760511b6044820152606401620004fd565b6040805160a0810182528481523360208201526001600160a01b0384169181019190915243606082015242608082015260668054600181018255600091909152815182916005027f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e943540190819062002b4a908262003647565b50602082810151600183810180546001600160a01b03199081166001600160a01b0394851617909155604080870151600287018054909316941693909317905560608501516003850155608090940151600490930192909255336000908152606790915220606654909162002bbf916200361b565b81546001818101845560009384526020808520909201929092556001600160a01b0386168352606890526040909120805460ff1916821790556066547f18075ab463b4dc5842f37ecd67abeb192eda5d073f2c08509e189ad173d5c0209162002c28916200361b565b8260405162002c3992919062003713565b60405180910390a160665462002c52906001906200361b565b9150505b92915050565b600054610100900460ff1662002c865760405162461bcd60e51b8152600401620004fd9062003736565b62002c9062002cf0565b62002c9b8162002c9e565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1662002d1a5760405162461bcd60e51b8152600401620004fd9062003736565b6200287d600054610100900460ff1662002d485760405162461bcd60e51b8152600401620004fd9062003736565b6200287d3362002c9e565b6040518060a001604052806060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b6119a6806200378283390190565b801515811462002c9b57600080fd5b803562002dbe8162002da2565b919050565b60006020828403121562002dd657600080fd5b8135620029898162002da2565b60008060006040848603121562002df957600080fd5b83356001600160401b038082111562002e1157600080fd5b818601915086601f83011262002e2657600080fd5b81358181111562002e3657600080fd5b8760208260051b850101111562002e4c57600080fd5b6020928301955093505084013562002e648162002da2565b809150509250925092565b6001600160a01b038116811462002c9b57600080fd5b803562002dbe8162002e6f565b60006020828403121562002ea557600080fd5b8135620029898162002e6f565b60008083601f84011262002ec557600080fd5b5081356001600160401b0381111562002edd57600080fd5b60208301915083602082850101111562002ef657600080fd5b9250929050565b60008060006040848603121562002f1357600080fd5b8335925060208401356001600160401b0381111562002f3157600080fd5b62002f3f8682870162002eb2565b9497909650939450505050565b60005b8381101562002f6957818101518382015260200162002f4f565b50506000910152565b6000815180845262002f8c81602086016020860162002f4c565b601f01601f19169290920160200192915050565b6000815160a0845262002fb760a085018262002f72565b9050602083015160018060a01b038082166020870152806040860151166040870152505060608301516060850152608083015160808501528091505092915050565b60008282518085526020808601955060208260051b8401016020860160005b848110156200304a57601f198684030189526200303783835162002fa0565b9884019892509083019060010162003018565b5090979650505050505050565b604080825283519082018190526000906020906060840190828701845b82811015620030925781518452928401929084019060010162003074565b5050508381036020850152620030a9818662002ff9565b9695505050505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620030f457620030f4620030b3565b604052919050565b60008060008060008060008060e0898b0312156200311957600080fd5b88356001600160401b03808211156200313157600080fd5b818b0191508b601f8301126200314657600080fd5b81356020828211156200315d576200315d620030b3565b62003171601f8301601f19168201620030c9565b8281528e828487010111156200318657600080fd5b828286018383013760008184018301529b50620031a58d820162002e85565b9a50505060408b0135915080821115620031be57600080fd5b50620031cd8b828c0162002eb2565b9097509550620031e2905060608a0162002db1565b93506080890135925060a089013591506200320060c08a0162002e85565b90509295985092959890939650565b6000602082840312156200322257600080fd5b5035919050565b60a0815260006200323e60a083018862002f72565b6001600160a01b039687166020840152949095166040820152606081019290925260809091015292915050565b600080604083850312156200327f57600080fd5b82356200328c8162002da2565b91506020838101356001600160401b0380821115620032aa57600080fd5b818601915086601f830112620032bf57600080fd5b813581811115620032d457620032d4620030b3565b8060051b9150620032e7848301620030c9565b81815291830184019184810190898411156200330257600080fd5b938501935b838510156200333057843592506200331f8362002e6f565b828252938501939085019062003307565b8096505050505050509250929050565b60208152600062002989602083018462002ff9565b634e487b7160e01b600052603260045260246000fd5b6040808252810183905260008460608301825b86811015620033b2578235620033948162002e6f565b6001600160a01b03168252602092830192909101906001016200337e565b5080925050508215156020830152949350505050565b600060208284031215620033db57600080fd5b8151620029898162002e6f565b600060208284031215620033fb57600080fd5b8151620029898162002da2565b600181811c908216806200341d57607f821691505b6020821081036200343e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562002170576000816000526020600020601f850160051c810160208610156200346f5750805b601f850160051c820191505b8181101562003490578281556001016200347b565b505050505050565b6001600160401b03831115620034b257620034b2620030b3565b620034ca83620034c3835462003408565b8362003444565b6000601f841160018114620035015760008515620034e85750838201355b600019600387901b1c1916600186901b1783556200075a565b600083815260209020601f19861690835b8281101562003534578685013582556020948501946001909201910162003512565b5086821015620035525760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016200358f576200358f62003564565b5060010190565b60008451620035aa81846020890162002f4c565b8201838582376000930192835250909392505050565b6bffffffffffffffffffffffff198460601b16815260008351620035ec81601485016020880162002f4c565b60149201918201929092526034019392505050565b6000602082840312156200361457600080fd5b5051919050565b8181038181111562002c565762002c5662003564565b634e487b7160e01b600052603160045260246000fd5b81516001600160401b03811115620036635762003663620030b3565b6200367b8162003674845462003408565b8462003444565b602080601f831160018114620036b357600084156200369a5750858301515b600019600386901b1c1916600185901b17855562003490565b600085815260208120601f198616915b82811015620036e457888601518255948401946001909101908401620036c3565b5085821015620037035787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8281526040602082015260006200372e604083018462002fa0565b949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe60806040526002805461ffff60a01b191661010160a01b17905534801561002557600080fd5b506040516119a63803806119a683398101604081905261004491610077565b60018054336001600160a01b031991821617909155600080549091166001600160a01b03929092169190911790556100a7565b60006020828403121561008957600080fd5b81516001600160a01b03811681146100a057600080fd5b9392505050565b6118f0806100b66000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c806387f7630311610130578063bb82aa5e116100b8578063dce154491161007c578063dce154491461060e578063e6653f3d14610621578063e875544614610635578063e9c714f21461063e578063f851a4401461064657610232565b8063bb82aa5e146105b9578063c6c5b0dd146105c1578063c91a424f146105d4578063cf6bfd2d146105e7578063d251fefc146105fb57610232565b80639b19251a116100ff5780639b19251a1461055a578063ac0b0bb71461057d578063b095721014610591578063b71d1a0c1461059e578063ba49f54a146105b157610232565b806387f76303146104c457806389cd9855146104d85780638e8f294b146104eb578063940cd6f11461052f57610232565b80633c94786f116101be5780636bd02b8a116101825780636bd02b8a146104455780636d154ea514610458578063731f0c2b1461047b5780637515bafa1461049e5780637dc0d1d0146104b157610232565b80633c94786f146103e05780634a584432146103f45780634ada90af1461041457806352d84d1e1461041d5780636333d0011461043057610232565b80631c819e43116102055780631c819e431461033857806321af45691461036657806324a3d6221461039157806326782247146103a457806331ff47fa146103b757610232565b80630225ab9d146102ab57806302c3bcbb146102d15780630a755ec2146102f157806316dc15fe14610315575b60006102496000356001600160e01b031916610659565b90506001600160a01b03811661028557604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156102a4573d6000f35b3d6000fd5b005b6102be6102b9366004611458565b610679565b6040519081526020015b60405180910390f35b6102be6102df366004611492565b60186020526000908152604090205481565b60025461030590600160a81b900460ff1681565b60405190151581526020016102c8565b610305610323366004611492565b600d6020526000908152604090205460ff1681565b6103056103463660046114af565b601d60209081526000928352604080842090915290825290205460ff1681565b601654610379906001600160a01b031681565b6040516001600160a01b0390911681526020016102c8565b601354610379906001600160a01b031681565b600254610379906001600160a01b031681565b6103796103c5366004611492565b600e602052600090815260409020546001600160a01b031681565b60135461030590600160a01b900460ff1681565b6102be610402366004611492565b60176020526000908152604090205481565b6102be60055481565b61037961042b3660046114e8565b610710565b61043861073a565b6040516102c89190611501565b6103796104533660046114e8565b610749565b610305610466366004611492565b60156020526000908152604090205460ff1681565b610305610489366004611492565b60146020526000908152604090205460ff1681565b6103796104ac3660046114e8565b610759565b600354610379906001600160a01b031681565b60135461030590600160b01b900460ff1681565b6102a96104e63660046114af565b610769565b6105186104f9366004611492565b6008602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016102c8565b6102be61053d3660046114af565b601c60209081526000928352604080842090915290825290205481565b610305610568366004611492565b60106020526000908152604090205460ff1681565b60135461030590600160b81b900460ff1681565b600f546103059060ff1681565b6102be6105ac366004611492565b6107bb565b6102a961083c565b610379610985565b6103796105cf3660046114e8565b6109af565b600054610379906001600160a01b031681565b60025461030590600160a01b900460ff1681565b6103796106093660046114e8565b6109bf565b61037961061c36600461154e565b6109cf565b60135461030590600160a81b900460ff1681565b6102be60045481565b6102be610a07565b600154610379906001600160a01b031681565b600061067382600080516020611873833981519152610aed565b92915050565b6000610683610b88565b6106935761067360016005610bda565b811515600260159054906101000a900460ff161515036106b4576000610673565b60028054831515600160a81b0260ff60a81b199091161790556040517f10f9a0a95673b0837d1dce21fd3bffcb6d760435e9b5300b75a271182f75f8229061070190841515815260200190565b60405180910390a16000610673565b6009818154811061072057600080fd5b6000918252602090912001546001600160a01b0316905081565b6060610744610c53565b905090565b601b818154811061072057600080fd5b600b818154811061072057600080fd5b610771610b88565b6107ad5760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b604482015260640161027c565b6107b78282610cc5565b5050565b60006107c5610b88565b6107d5576106736001600f610bda565b600280546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a160005b9392505050565b3330148061084d575061084d610b88565b61088b5760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b604482015260640161027c565b6000610895610985565b6000805460405163bbcdd6d360e01b81526001600160a01b0380851660048301529394509192169063bbcdd6d390602401602060405180830381865afa1580156108e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109079190611590565b905061091281610ce6565b806001600160a01b0316826001600160a01b0316146107b7576040805160048152602481018252602080820180516001600160e01b0316632eb96f3160e11b1790528251808401909352600c83526b08589958dbdb59481a5b5c1b60a21b9083015261098091309190610dda565b505050565b60006107446040518060600160405280602881526020016118936028913980519060200120610659565b6019818154811061072057600080fd5b6011818154811061072057600080fd5b600760205281600052604060002081815481106109eb57600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546000906001600160a01b031633141580610a22575033155b15610a335761074460016000610bda565b60018054600280546001600160a01b038082166001600160a01b031980861682179096559490911690915560408051919092168082526020820184905292917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600254604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a160009250505090565b8054600090815b81811015610b7d57846001600160e01b031916846000018281548110610b1c57610b1c6115ad565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610b7557836000018181548110610b5657610b566115ad565b6000918252602090912001546001600160a01b03169250610673915050565b600101610af4565b506000949350505050565b6001546000906001600160a01b031633148015610bae5750600254600160a81b900460ff165b8061074457506000546001600160a01b031633148015610744575050600254600160a01b900460ff1690565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836014811115610c0f57610c0f61157a565b83601a811115610c2157610c2161157a565b60408051928352602083019190915260009082015260600160405180910390a18260148111156108355761083561157a565b6060600080516020611873833981519152600101805480602002602001604051908101604052809291908181526020018280548015610cbb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610c9d575b5050505050905090565b6001600160a01b03811615610cdd57610cdd81610e76565b6107b782610fa5565b60008054604051631978a0bf60e31b81526001600160a01b0384811660048301529091169063cbc505f890602401600060405180830381865afa158015610d31573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d59919081019061162e565b90506000610d65610c53565b905060005b8151811015610d9d57610d95828281518110610d8857610d886115ad565b6020026020010151610e76565b600101610d6a565b5060005b8251811015610dd457610dcc838281518110610dbf57610dbf6115ad565b6020026020010151610fa5565b600101610da1565b50505050565b6060600080856001600160a01b031685604051610df791906116f1565b6000604051808303816000865af19150503d8060008114610e34576040519150601f19603f3d011682016040523d82523d6000602084013e610e39565b606091505b509150915081610e6d57805115610e535780518082602001fd5b8360405162461bcd60e51b815260040161027c919061170d565b95945050505050565b600080516020611873833981519152610e8e8261109c565b60005b600182015460ff8216101561098057826001600160a01b0316826001018260ff1681548110610ec257610ec26115ad565b6000918252602090912001546001600160a01b031603610f9357600180830180549091610eee91611756565b81548110610efe57610efe6115ad565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610f2f57610f2f6115ad565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610f7057610f70611769565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610f9d8161177f565b915050610e91565b60008051602061187383398151915260005b600182015460ff8216101561105c57826001600160a01b0316826001018260ff1681548110610fe857610fe86115ad565b6000918252602090912001546001600160a01b03160361104a5760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c7265616479206164646564000000000000000000604482015260640161027c565b806110548161177f565b915050610fb7565b506110668261125b565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156110dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611104919081019061179e565b905060008051602061187383398151915260005b82518161ffff161015610dd4576000838261ffff168151811061113d5761113d6115ad565b602002602001015190506111518184610aed565b6001600160a01b0316856001600160a01b0316146111715761117161183b565b600061117d82856113db565b8454909150849061119090600190611756565b815481106111a0576111a06115ad565b90600052602060002001846000018261ffff16815481106111c3576111c36115ad565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff16909102179055835484908061122457611224611769565b600082815260209020810160001990810180546001600160c01b03191690550190555081905061125381611851565b915050611118565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561129b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112c3919081019061179e565b60008051602061187383398151915280549192509060005b83518110156113d45760008482815181106112f8576112f86115ad565b60200260200101519050600061130e8286610aed565b90506001600160a01b0381161561135357604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b038216602482015260440161027c565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836113c381611851565b945050600190920191506112db9050565b5050505050565b8054600090815b8161ffff168161ffff16101561144c57846001600160e01b031916846000018261ffff1681548110611416576114166115ad565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036114445791506106739050565b6001016113e2565b5061ffff949350505050565b60006020828403121561146a57600080fd5b8135801515811461083557600080fd5b6001600160a01b038116811461148f57600080fd5b50565b6000602082840312156114a457600080fd5b81356108358161147a565b600080604083850312156114c257600080fd5b82356114cd8161147a565b915060208301356114dd8161147a565b809150509250929050565b6000602082840312156114fa57600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156115425783516001600160a01b03168352928401929184019160010161151d565b50909695505050505050565b6000806040838503121561156157600080fd5b823561156c8161147a565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156115a257600080fd5b81516108358161147a565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611602576116026115c3565b604052919050565b600067ffffffffffffffff821115611624576116246115c3565b5060051b60200190565b6000602080838503121561164157600080fd5b825167ffffffffffffffff81111561165857600080fd5b8301601f8101851361166957600080fd5b805161167c6116778261160a565b6115d9565b81815260059190911b8201830190838101908783111561169b57600080fd5b928401925b828410156116c25783516116b38161147a565b825292840192908401906116a0565b979650505050505050565b60005b838110156116e85781810151838201526020016116d0565b50506000910152565b600082516117038184602087016116cd565b9190910192915050565b602081526000825180602084015261172c8160408501602087016116cd565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561067357610673611740565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff810361179557611795611740565b60010192915050565b600060208083850312156117b157600080fd5b825167ffffffffffffffff8111156117c857600080fd5b8301601f810185136117d957600080fd5b80516117e76116778261160a565b81815260059190911b8201830190838101908783111561180657600080fd5b928401925b828410156116c25783516001600160e01b03198116811461182c5760008081fd5b8252928401929084019061180b565b634e487b7160e01b600052600160045260246000fd5b600061ffff80831681810361186857611868611740565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b26155f6465706c6f794d61726b65742875696e74382c62797465732c62797465732c75696e7432353629a264697066735822122085884369b38ba3ff035c759da7b88b4ab5d1400b73117a5dbcbcdf01237e98a164736f6c63430008160033a2646970667358221220447b84940e429605f7ff0777dc8288173eab5ac9f7944e7005199221ea09a6d964736f6c63430008160033", + "deployedBytecode": "0x60806040523480156200001157600080fd5b5060043610620001cc5760003560e01c80638da5cb5b116200010d578063b5f3f64011620000a3578063e30c3978116200007a578063e30c3978146200044a578063f2fde38b146200045e578063f348960d1462000475578063fc4d33f9146200048c57600080fd5b8063b5f3f6401462000403578063b86579d4146200041a578063d88ff1f4146200043157600080fd5b8063a155497c11620000e4578063a155497c1462000385578063a3ed91c6146200039c578063a970e76c14620003b3578063ac4afa3814620003d957600080fd5b80638da5cb5b146200033e5780638ec0835414620003645780639b29177f146200036e57600080fd5b806343e20a1d116200018357806358b896d3116200015a57806358b896d314620002cf5780635d0eb31a14620003045780636e96dfd7146200031d578063715018a6146200033457600080fd5b806343e20a1d1462000288578063448ca55814620002ae5780634ae26ea114620002c557600080fd5b806304f03c6f14620001d15780630a83d1b014620001ea5780631e1c6a07146200020157806320c32bfe146200023c578063218a3bbe146200025357806326bb81d7146200027a575b600080fd5b620001e8620001e236600462002dc3565b62000496565b005b620001e8620001fb36600462002de3565b620004b3565b620002276200021236600462002e92565b60686020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b620001e86200024d36600462002efd565b620005b7565b6200026a6200026436600462002dc3565b62000761565b6040516200023392919062003057565b606954620002279060ff1681565b620002276200029936600462002e92565b606b6020526000908152604090205460ff1681565b6200026a620002bf36600462002e92565b62000a4b565b6200026a62000dd5565b620002e6620002e0366004620030fc565b62001070565b604080519283526001600160a01b0390911660208301520162000233565b6200030e606c5481565b60405190815260200162000233565b620001e86200032e36600462002e92565b62001669565b620001e8620016d5565b6033546001600160a01b03165b6040516001600160a01b03909116815260200162000233565b6200026a6200171b565b620001e86200037f36600462002e92565b620019ee565b620001e86200039636600462002de3565b62001a61565b6200026a620003ad36600462002e92565b62001b27565b62000227620003c436600462002e92565b606a6020526000908152604090205460ff1681565b620003f0620003ea3660046200320f565b62001d22565b6040516200023395949392919062003229565b620001e8620004143660046200320f565b62001e08565b620001e86200042b3660046200326b565b62001fe9565b6200043b62002175565b60405162000233919062003340565b6065546200034b906001600160a01b031681565b620001e86200046f36600462002e92565b620023d2565b6200026a6200048636600462002e92565b62002445565b620001e862002707565b620004a062002821565b6069805460ff1916911515919091179055565b620004bd62002821565b81620005065760405162461bcd60e51b815260206004820152601360248201527227379030b236b4b7399039bab8383634b2b21760691b60448201526064015b60405180910390fd5b60005b82811015620005745781606b60008686858181106200052c576200052c62003355565b905060200201602081019062000543919062002e92565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010162000509565b507f31b67e6853df85403a8c4f4f46dc53f48f700d6917c8e3ec8c77a0e6fd56793b838383604051620005aa939291906200336b565b60405180910390a1505050565b600060668481548110620005cf57620005cf62003355565b600091825260209182902060026005909202010154604080516303e1469160e61b815290516001600160a01b039092169350839263f851a440926004808401938290030181865afa15801562000629573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200064f9190620033c8565b6001600160a01b0316336001600160a01b0316148015620006d05750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015620006aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006d09190620033e8565b80620006e657506033546001600160a01b031633145b620007225760405162461bcd60e51b815260206004820152600b60248201526a10b832b936b4b9b9b4b7b760a91b6044820152606401620004fd565b8282606686815481106200073a576200073a62003355565b906000526020600020906005020160000191826200075a92919062003498565b5050505050565b606080600080620007716200171b565b91505060005b81518110156200085457600082828151811062000798576200079862003355565b6020026020010151604001519050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000803575060408051601f3d908101601f191682019092526200080091810190620033c8565b60015b156200083a576001600160a01b0381166000908152606b602052604090205460ff16151588151514620008385750506200084b565b505b8362000846816200357a565b945050505b60010162000777565b506000826001600160401b03811115620008725762000872620030b3565b6040519080825280602002602001820160405280156200089c578160200160208202803683370190505b5090506000836001600160401b03811115620008bc57620008bc620030b3565b604051908082528060200260200182016040528015620008f957816020015b620008e562002d53565b815260200190600190039081620008db5790505b5090506000805b845181101562000a3d57600085828151811062000921576200092162003355565b6020026020010151604001519050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200098c575060408051601f3d908101601f191682019092526200098991810190620033c8565b60015b15620009c3576001600160a01b0381166000908152606b602052604090205460ff1615158b151514620009c157505062000a34565b505b81858481518110620009d957620009d962003355565b602002602001018181525050858281518110620009fa57620009fa62003355565b602002602001015184848151811062000a175762000a1762003355565b6020026020010181905250828062000a2f906200357a565b935050505b60010162000900565b509197909650945050505050565b60608060008062000a5b6200171b565b91505060005b815181101562000b9557600082828151811062000a825762000a8262003355565b6020026020010151604001519050806001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000aed575060408051601f3d908101601f1916820190925262000aea91810190620033e8565b60015b1562000b7b5780158062000b6b5750604051634d8c928d60e11b81526001600160a01b038981166004830152831690639b19251a90602401602060405180830381865afa15801562000b43573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b699190620033e8565b155b1562000b7957505062000b8c565b505b8362000b87816200357a565b945050505b60010162000a61565b506000826001600160401b0381111562000bb35762000bb3620030b3565b60405190808252806020026020018201604052801562000bdd578160200160208202803683370190505b5090506000836001600160401b0381111562000bfd5762000bfd620030b3565b60405190808252806020026020018201604052801562000c3a57816020015b62000c2662002d53565b81526020019060019003908162000c1c5790505b5090506000805b845181101562000a3d57600085828151811062000c625762000c6262003355565b6020026020010151604001519050806001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000ccd575060408051601f3d908101601f1916820190925262000cca91810190620033e8565b60015b1562000d5b5780158062000d4b5750604051634d8c928d60e11b81526001600160a01b038c81166004830152831690639b19251a90602401602060405180830381865afa15801562000d23573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000d499190620033e8565b155b1562000d5957505062000dcc565b505b8185848151811062000d715762000d7162003355565b60200260200101818152505085828151811062000d925762000d9262003355565b602002602001015184848151811062000daf5762000daf62003355565b6020026020010181905250828062000dc7906200357a565b935050505b60010162000c41565b60608060008062000de56200171b565b91505060005b815181101562000ea15781818151811062000e0a5762000e0a62003355565b6020026020010151604001516001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000e72575060408051601f3d908101601f1916820190925262000e6f91810190620033e8565b60015b1562000e8857801562000e86575062000e98565b505b8262000e94816200357a565b9350505b60010162000deb565b506000826001600160401b0381111562000ebf5762000ebf620030b3565b60405190808252806020026020018201604052801562000ee9578160200160208202803683370190505b5090506000836001600160401b0381111562000f095762000f09620030b3565b60405190808252806020026020018201604052801562000f4657816020015b62000f3262002d53565b81526020019060019003908162000f285790505b5090506000805b8451811015620010635784818151811062000f6c5762000f6c62003355565b6020026020010151604001516001600160a01b031663b09572106040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000fd4575060408051601f3d908101601f1916820190925262000fd191810190620033e8565b60015b1562000fea57801562000fe857506200105a565b505b8084838151811062001000576200100062003355565b60200260200101818152505084818151811062001021576200102162003355565b60200260200101518383815181106200103e576200103e62003355565b6020026020010181905250818062001056906200357a565b9250505b60010162000f4d565b5091969095509350505050565b6000806001600160a01b038916620010f15760405162461bcd60e51b815260206004820152603960248201527f4e6f20436f6d7074726f6c6c657220696d706c656d656e746174696f6e20636f60448201527f6e74726163742061646472657373207370656369666965642e000000000000006064820152608401620004fd565b6001600160a01b0383166200115c5760405162461bcd60e51b815260206004820152602a60248201527f4e6f2050726963654f7261636c6520636f6e747261637420616464726573732060448201526939b832b1b4b334b2b21760b11b6064820152608401620004fd565b600060405180602001620011709062002d94565b601f1982820381018352601f9091011660408190526200119891908b908b9060200162003596565b60405160208183030381529060405290506000620011fa6000338e606c60008154620011c4906200357a565b9182905550604051620011dd93929190602001620035c0565b60405160208183030381529060405280519060200120846200287f565b90506000819050806001600160a01b031663ba49f54a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156200123d57600080fd5b505af115801562001252573d6000803e3d6000fd5b505060405163317b0b7760e01b8152600481018b90526001600160a01b038416925063317b0b7791506024016020604051808303816000875af11580156200129e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620012c4919062003601565b15620013135760405162461bcd60e51b815260206004820181905260248201527f4661696c656420746f2073657420706f6f6c20636c6f736520666163746f722e6044820152606401620004fd565b604051634fd42e1760e01b8152600481018890526001600160a01b03821690634fd42e17906024016020604051808303816000875af11580156200135b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001381919062003601565b15620013e25760405162461bcd60e51b815260206004820152602960248201527f4661696c656420746f2073657420706f6f6c206c69717569646174696f6e20696044820152683731b2b73a34bb329760b91b6064820152608401620004fd565b6040516355ee1fe160e01b81526001600160a01b0387811660048301528216906355ee1fe1906024016020604051808303816000875af11580156200142b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001451919062003601565b15620014a05760405162461bcd60e51b815260206004820181905260248201527f4661696c656420746f2073657420706f6f6c207072696365206f7261636c652e6044820152606401620004fd565b88156200157b57604051634a956fad60e11b8152600160048201526001600160a01b0382169063952adf5a906024016020604051808303816000875af1158015620014ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001515919062003601565b156200157b5760405162461bcd60e51b815260206004820152602e60248201527f4661696c656420746f20656e666f72636520737570706c6965722f626f72726f60448201526d3bb2b9103bb434ba32b634b9ba1760911b6064820152608401620004fd565b604051632dc7468360e21b81523360048201526001600160a01b0382169063b71d1a0c906024016020604051808303816000875af1158015620015c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015e8919062003601565b156200164a5760405162461bcd60e51b815260206004820152602a60248201527f4661696c656420746f207365742070656e64696e672061646d696e206f6e20556044820152693734ba3937b63632b91760b11b6064820152608401620004fd565b620016568d8362002990565b9d919c50909a5050505050505050505050565b6200167362002821565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b620016df62002821565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b6044820152606401620004fd565b6060806000805b6066548110156200178a5760006001600160a01b0316606682815481106200174e576200174e62003355565b60009182526020909120600260059092020101546001600160a01b0316146200178157816200177d816200357a565b9250505b60010162001722565b506000816001600160401b03811115620017a857620017a8620030b3565b604051908082528060200260200182016040528015620017e557816020015b620017d162002d53565b815260200190600190039081620017c75790505b5090506000826001600160401b03811115620018055762001805620030b3565b6040519080825280602002602001820160405280156200182f578160200160208202803683370190505b5090506000805b606654811015620019e15760006001600160a01b03166066828154811062001862576200186262003355565b60009182526020909120600260059092020101546001600160a01b031614620019d857808383815181106200189b576200189b62003355565b60200260200101818152505060668181548110620018bd57620018bd62003355565b90600052602060002090600502016040518060a0016040529081600082018054620018e89062003408565b80601f0160208091040260200160405190810160405280929190818152602001828054620019169062003408565b8015620019675780601f106200193b5761010080835404028352916020019162001967565b820191906000526020600020905b8154815290600101906020018083116200194957829003601f168201915b505050918352505060018201546001600160a01b0390811660208301526002830154166040820152600382015460608201526004909101546080909101528451859084908110620019bc57620019bc62003355565b60200260200101819052508180620019d4906200357a565b9250505b60010162001836565b5090959194509092505050565b620019f862002821565b60005b60665481101562001a5457816001600160a01b03166066828154811062001a265762001a2662003355565b60009182526020909120600260059092020101546001600160a01b03160362001a585762001a548162001e08565b5050565b600101620019fb565b62001a6b62002821565b8162001ab35760405162461bcd60e51b81526020600482015260166024820152752737903232b83637bcb2b9399039bab8383634b2b21760511b6044820152606401620004fd565b60005b8281101562001b215781606a600086868581811062001ad95762001ad962003355565b905060200201602081019062001af0919062002e92565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905560010162001ab6565b50505050565b6001600160a01b03811660009081526067602052604081205460609182916001600160401b0381111562001b5f5762001b5f620030b3565b60405190808252806020026020018201604052801562001b89578160200160208202803683370190505b506001600160a01b038516600090815260676020526040812054919250906001600160401b0381111562001bc15762001bc1620030b3565b60405190808252806020026020018201604052801562001bfe57816020015b62001bea62002d53565b81526020019060019003908162001be05790505b509050600062001c0d6200171b565b91505060005b6001600160a01b03871660009081526067602052604090205481101562001d16576001600160a01b038716600090815260676020526040902080548290811062001c615762001c6162003355565b906000526020600020015484828151811062001c815762001c8162003355565b6020026020010181815250508160676000896001600160a01b03166001600160a01b03168152602001908152602001600020828154811062001cc75762001cc762003355565b90600052602060002001548151811062001ce55762001ce562003355565b602002602001015183828151811062001d025762001d0262003355565b602090810291909101015260010162001c13565b50919590945092505050565b6066818154811062001d3357600080fd5b906000526020600020906005020160009150905080600001805462001d589062003408565b80601f016020809104026020016040519081016040528092919081815260200182805462001d869062003408565b801562001dd75780601f1062001dab5761010080835404028352916020019162001dd7565b820191906000526020600020905b81548152906001019060200180831162001db957829003601f168201915b5050505060018301546002840154600385015460049095015493946001600160a01b03928316949290911692509085565b62001e1262002821565b60006066828154811062001e2a5762001e2a62003355565b6000918252602090912060059091020160028101549091506001600160a01b031662001e995760405162461bcd60e51b815260206004820152601760248201527f706f6f6c20616c726561647920646570726563617465640000000000000000006044820152606401620004fd565b60018101546001600160a01b03166000908152606760205260408120905b815481101562001f73578382828154811062001ed75762001ed762003355565b90600052602060002001540362001f6a578154829062001efa906001906200361b565b8154811062001f0d5762001f0d62003355565b906000526020600020015482828154811062001f2d5762001f2d62003355565b90600052602060002001819055508180548062001f4e5762001f4e62003631565b6001900381819060005260206000200160009055905562001f73565b60010162001eb7565b506002820180546001600160a01b03166000908152606860209081526040808320805460ff1916600190811790915584546001600160a01b03199081169095558601805490941690935582519081019092528152829062001fd5908262003647565b505060006003820181905560049091015550565b600054610100900460ff16158080156200200a5750600054600160ff909116105b80620020265750303b15801562002026575060005460ff166001145b6200208b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620004fd565b6000805460ff191660011790558015620020af576000805461ff0019166101001790555b620020ba3362002c5c565b6069805460ff191684151517905560005b82518110156200212b576001606a6000858481518110620020f057620020f062003355565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101620020cb565b50801562002170576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001620005aa565b505050565b60606000805b606654811015620021e35760006001600160a01b031660668281548110620021a757620021a762003355565b60009182526020909120600260059092020101546001600160a01b031614620021da5781620021d6816200357a565b9250505b6001016200217b565b506000816001600160401b03811115620022015762002201620030b3565b6040519080825280602002602001820160405280156200223e57816020015b6200222a62002d53565b815260200190600190039081620022205790505b5090506000805b606654811015620023c95760006001600160a01b03166066828154811062002271576200227162003355565b60009182526020909120600260059092020101546001600160a01b031614620023c05760668181548110620022aa57620022aa62003355565b90600052602060002090600502016040518060a0016040529081600082018054620022d59062003408565b80601f0160208091040260200160405190810160405280929190818152602001828054620023039062003408565b8015620023545780601f10620023285761010080835404028352916020019162002354565b820191906000526020600020905b8154815290600101906020018083116200233657829003601f168201915b505050918352505060018201546001600160a01b03908116602083015260028301541660408201526003820154606082015260049091015460809091015283836200239f816200357a565b945081518110620023b457620023b462003355565b60200260200101819052505b60010162002245565b50909392505050565b620023dc62002821565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b606080600080620024556200171b565b91505060005b81518110156200252b578181815181106200247a576200247a62003355565b6020026020010151604001516001600160a01b031663d9e0ea6b876040518263ffffffff1660e01b8152600401620024c191906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015620024fd575060408051601f3d908101601f19168201909252620024fa91810190620033e8565b60015b1562002512578062002510575062002522565b505b826200251e816200357a565b9350505b6001016200245b565b506000826001600160401b03811115620025495762002549620030b3565b60405190808252806020026020018201604052801562002573578160200160208202803683370190505b5090506000836001600160401b03811115620025935762002593620030b3565b604051908082528060200260200182016040528015620025d057816020015b620025bc62002d53565b815260200190600190039081620025b25790505b5090506000805b845181101562000a3d57848181518110620025f657620025f662003355565b6020026020010151604001516001600160a01b031663d9e0ea6b8a6040518263ffffffff1660e01b81526004016200263d91906001600160a01b0391909116815260200190565b602060405180830381865afa92505050801562002679575060408051601f3d908101601f191682019092526200267691810190620033e8565b60015b156200268e57806200268c5750620026fe565b505b80848381518110620026a457620026a462003355565b602002602001018181525050848181518110620026c557620026c562003355565b6020026020010151838381518110620026e257620026e262003355565b60200260200101819052508180620026fa906200357a565b9250505b600101620025d7565b6065546001600160a01b031633146200275b5760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b6044820152606401620004fd565b6000620027706033546001600160a01b031690565b6065549091506001600160a01b03166200278a8162002c9e565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101620016c9565b6033546001600160a01b031633146200287d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620004fd565b565b600083471015620028d35760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401620004fd565b8151600003620029265760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401620004fd565b8282516020840186f590506001600160a01b038116620029895760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401620004fd565b9392505050565b6001600160a01b03811660009081526068602052604081205460ff161562002a095760405162461bcd60e51b815260206004820152602560248201527f506f6f6c20616c72656164792065786973747320696e207468652064697265636044820152643a37b93c9760d91b6064820152608401620004fd565b60695460ff16158062002a2b5750336000908152606a602052604090205460ff165b62002a855760405162461bcd60e51b8152602060048201526024808201527f53656e646572206973206e6f74206f6e206465706c6f7965722077686974656c60448201526334b9ba1760e11b6064820152608401620004fd565b60648351111562002ad25760405162461bcd60e51b81526020600482015260166024820152752737903837b7b6103730b6b29039bab8383634b2b21760511b6044820152606401620004fd565b6040805160a0810182528481523360208201526001600160a01b0384169181019190915243606082015242608082015260668054600181018255600091909152815182916005027f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e943540190819062002b4a908262003647565b50602082810151600183810180546001600160a01b03199081166001600160a01b0394851617909155604080870151600287018054909316941693909317905560608501516003850155608090940151600490930192909255336000908152606790915220606654909162002bbf916200361b565b81546001818101845560009384526020808520909201929092556001600160a01b0386168352606890526040909120805460ff1916821790556066547f18075ab463b4dc5842f37ecd67abeb192eda5d073f2c08509e189ad173d5c0209162002c28916200361b565b8260405162002c3992919062003713565b60405180910390a160665462002c52906001906200361b565b9150505b92915050565b600054610100900460ff1662002c865760405162461bcd60e51b8152600401620004fd9062003736565b62002c9062002cf0565b62002c9b8162002c9e565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1662002d1a5760405162461bcd60e51b8152600401620004fd9062003736565b6200287d600054610100900460ff1662002d485760405162461bcd60e51b8152600401620004fd9062003736565b6200287d3362002c9e565b6040518060a001604052806060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b6119a6806200378283390190565b801515811462002c9b57600080fd5b803562002dbe8162002da2565b919050565b60006020828403121562002dd657600080fd5b8135620029898162002da2565b60008060006040848603121562002df957600080fd5b83356001600160401b038082111562002e1157600080fd5b818601915086601f83011262002e2657600080fd5b81358181111562002e3657600080fd5b8760208260051b850101111562002e4c57600080fd5b6020928301955093505084013562002e648162002da2565b809150509250925092565b6001600160a01b038116811462002c9b57600080fd5b803562002dbe8162002e6f565b60006020828403121562002ea557600080fd5b8135620029898162002e6f565b60008083601f84011262002ec557600080fd5b5081356001600160401b0381111562002edd57600080fd5b60208301915083602082850101111562002ef657600080fd5b9250929050565b60008060006040848603121562002f1357600080fd5b8335925060208401356001600160401b0381111562002f3157600080fd5b62002f3f8682870162002eb2565b9497909650939450505050565b60005b8381101562002f6957818101518382015260200162002f4f565b50506000910152565b6000815180845262002f8c81602086016020860162002f4c565b601f01601f19169290920160200192915050565b6000815160a0845262002fb760a085018262002f72565b9050602083015160018060a01b038082166020870152806040860151166040870152505060608301516060850152608083015160808501528091505092915050565b60008282518085526020808601955060208260051b8401016020860160005b848110156200304a57601f198684030189526200303783835162002fa0565b9884019892509083019060010162003018565b5090979650505050505050565b604080825283519082018190526000906020906060840190828701845b82811015620030925781518452928401929084019060010162003074565b5050508381036020850152620030a9818662002ff9565b9695505050505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620030f457620030f4620030b3565b604052919050565b60008060008060008060008060e0898b0312156200311957600080fd5b88356001600160401b03808211156200313157600080fd5b818b0191508b601f8301126200314657600080fd5b81356020828211156200315d576200315d620030b3565b62003171601f8301601f19168201620030c9565b8281528e828487010111156200318657600080fd5b828286018383013760008184018301529b50620031a58d820162002e85565b9a50505060408b0135915080821115620031be57600080fd5b50620031cd8b828c0162002eb2565b9097509550620031e2905060608a0162002db1565b93506080890135925060a089013591506200320060c08a0162002e85565b90509295985092959890939650565b6000602082840312156200322257600080fd5b5035919050565b60a0815260006200323e60a083018862002f72565b6001600160a01b039687166020840152949095166040820152606081019290925260809091015292915050565b600080604083850312156200327f57600080fd5b82356200328c8162002da2565b91506020838101356001600160401b0380821115620032aa57600080fd5b818601915086601f830112620032bf57600080fd5b813581811115620032d457620032d4620030b3565b8060051b9150620032e7848301620030c9565b81815291830184019184810190898411156200330257600080fd5b938501935b838510156200333057843592506200331f8362002e6f565b828252938501939085019062003307565b8096505050505050509250929050565b60208152600062002989602083018462002ff9565b634e487b7160e01b600052603260045260246000fd5b6040808252810183905260008460608301825b86811015620033b2578235620033948162002e6f565b6001600160a01b03168252602092830192909101906001016200337e565b5080925050508215156020830152949350505050565b600060208284031215620033db57600080fd5b8151620029898162002e6f565b600060208284031215620033fb57600080fd5b8151620029898162002da2565b600181811c908216806200341d57607f821691505b6020821081036200343e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562002170576000816000526020600020601f850160051c810160208610156200346f5750805b601f850160051c820191505b8181101562003490578281556001016200347b565b505050505050565b6001600160401b03831115620034b257620034b2620030b3565b620034ca83620034c3835462003408565b8362003444565b6000601f841160018114620035015760008515620034e85750838201355b600019600387901b1c1916600186901b1783556200075a565b600083815260209020601f19861690835b8281101562003534578685013582556020948501946001909201910162003512565b5086821015620035525760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016200358f576200358f62003564565b5060010190565b60008451620035aa81846020890162002f4c565b8201838582376000930192835250909392505050565b6bffffffffffffffffffffffff198460601b16815260008351620035ec81601485016020880162002f4c565b60149201918201929092526034019392505050565b6000602082840312156200361457600080fd5b5051919050565b8181038181111562002c565762002c5662003564565b634e487b7160e01b600052603160045260246000fd5b81516001600160401b03811115620036635762003663620030b3565b6200367b8162003674845462003408565b8462003444565b602080601f831160018114620036b357600084156200369a5750858301515b600019600386901b1c1916600185901b17855562003490565b600085815260208120601f198616915b82811015620036e457888601518255948401946001909101908401620036c3565b5085821015620037035787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8281526040602082015260006200372e604083018462002fa0565b949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe60806040526002805461ffff60a01b191661010160a01b17905534801561002557600080fd5b506040516119a63803806119a683398101604081905261004491610077565b60018054336001600160a01b031991821617909155600080549091166001600160a01b03929092169190911790556100a7565b60006020828403121561008957600080fd5b81516001600160a01b03811681146100a057600080fd5b9392505050565b6118f0806100b66000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c806387f7630311610130578063bb82aa5e116100b8578063dce154491161007c578063dce154491461060e578063e6653f3d14610621578063e875544614610635578063e9c714f21461063e578063f851a4401461064657610232565b8063bb82aa5e146105b9578063c6c5b0dd146105c1578063c91a424f146105d4578063cf6bfd2d146105e7578063d251fefc146105fb57610232565b80639b19251a116100ff5780639b19251a1461055a578063ac0b0bb71461057d578063b095721014610591578063b71d1a0c1461059e578063ba49f54a146105b157610232565b806387f76303146104c457806389cd9855146104d85780638e8f294b146104eb578063940cd6f11461052f57610232565b80633c94786f116101be5780636bd02b8a116101825780636bd02b8a146104455780636d154ea514610458578063731f0c2b1461047b5780637515bafa1461049e5780637dc0d1d0146104b157610232565b80633c94786f146103e05780634a584432146103f45780634ada90af1461041457806352d84d1e1461041d5780636333d0011461043057610232565b80631c819e43116102055780631c819e431461033857806321af45691461036657806324a3d6221461039157806326782247146103a457806331ff47fa146103b757610232565b80630225ab9d146102ab57806302c3bcbb146102d15780630a755ec2146102f157806316dc15fe14610315575b60006102496000356001600160e01b031916610659565b90506001600160a01b03811661028557604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156102a4573d6000f35b3d6000fd5b005b6102be6102b9366004611458565b610679565b6040519081526020015b60405180910390f35b6102be6102df366004611492565b60186020526000908152604090205481565b60025461030590600160a81b900460ff1681565b60405190151581526020016102c8565b610305610323366004611492565b600d6020526000908152604090205460ff1681565b6103056103463660046114af565b601d60209081526000928352604080842090915290825290205460ff1681565b601654610379906001600160a01b031681565b6040516001600160a01b0390911681526020016102c8565b601354610379906001600160a01b031681565b600254610379906001600160a01b031681565b6103796103c5366004611492565b600e602052600090815260409020546001600160a01b031681565b60135461030590600160a01b900460ff1681565b6102be610402366004611492565b60176020526000908152604090205481565b6102be60055481565b61037961042b3660046114e8565b610710565b61043861073a565b6040516102c89190611501565b6103796104533660046114e8565b610749565b610305610466366004611492565b60156020526000908152604090205460ff1681565b610305610489366004611492565b60146020526000908152604090205460ff1681565b6103796104ac3660046114e8565b610759565b600354610379906001600160a01b031681565b60135461030590600160b01b900460ff1681565b6102a96104e63660046114af565b610769565b6105186104f9366004611492565b6008602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016102c8565b6102be61053d3660046114af565b601c60209081526000928352604080842090915290825290205481565b610305610568366004611492565b60106020526000908152604090205460ff1681565b60135461030590600160b81b900460ff1681565b600f546103059060ff1681565b6102be6105ac366004611492565b6107bb565b6102a961083c565b610379610985565b6103796105cf3660046114e8565b6109af565b600054610379906001600160a01b031681565b60025461030590600160a01b900460ff1681565b6103796106093660046114e8565b6109bf565b61037961061c36600461154e565b6109cf565b60135461030590600160a81b900460ff1681565b6102be60045481565b6102be610a07565b600154610379906001600160a01b031681565b600061067382600080516020611873833981519152610aed565b92915050565b6000610683610b88565b6106935761067360016005610bda565b811515600260159054906101000a900460ff161515036106b4576000610673565b60028054831515600160a81b0260ff60a81b199091161790556040517f10f9a0a95673b0837d1dce21fd3bffcb6d760435e9b5300b75a271182f75f8229061070190841515815260200190565b60405180910390a16000610673565b6009818154811061072057600080fd5b6000918252602090912001546001600160a01b0316905081565b6060610744610c53565b905090565b601b818154811061072057600080fd5b600b818154811061072057600080fd5b610771610b88565b6107ad5760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b604482015260640161027c565b6107b78282610cc5565b5050565b60006107c5610b88565b6107d5576106736001600f610bda565b600280546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a160005b9392505050565b3330148061084d575061084d610b88565b61088b5760405162461bcd60e51b815260206004820152600f60248201526e10b9b2b633103e3e1010b0b236b4b760891b604482015260640161027c565b6000610895610985565b6000805460405163bbcdd6d360e01b81526001600160a01b0380851660048301529394509192169063bbcdd6d390602401602060405180830381865afa1580156108e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109079190611590565b905061091281610ce6565b806001600160a01b0316826001600160a01b0316146107b7576040805160048152602481018252602080820180516001600160e01b0316632eb96f3160e11b1790528251808401909352600c83526b08589958dbdb59481a5b5c1b60a21b9083015261098091309190610dda565b505050565b60006107446040518060600160405280602881526020016118936028913980519060200120610659565b6019818154811061072057600080fd5b6011818154811061072057600080fd5b600760205281600052604060002081815481106109eb57600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546000906001600160a01b031633141580610a22575033155b15610a335761074460016000610bda565b60018054600280546001600160a01b038082166001600160a01b031980861682179096559490911690915560408051919092168082526020820184905292917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600254604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a160009250505090565b8054600090815b81811015610b7d57846001600160e01b031916846000018281548110610b1c57610b1c6115ad565b600091825260209091200154600160a01b900460e01b6001600160e01b03191603610b7557836000018181548110610b5657610b566115ad565b6000918252602090912001546001600160a01b03169250610673915050565b600101610af4565b506000949350505050565b6001546000906001600160a01b031633148015610bae5750600254600160a81b900460ff165b8061074457506000546001600160a01b031633148015610744575050600254600160a01b900460ff1690565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836014811115610c0f57610c0f61157a565b83601a811115610c2157610c2161157a565b60408051928352602083019190915260009082015260600160405180910390a18260148111156108355761083561157a565b6060600080516020611873833981519152600101805480602002602001604051908101604052809291908181526020018280548015610cbb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610c9d575b5050505050905090565b6001600160a01b03811615610cdd57610cdd81610e76565b6107b782610fa5565b60008054604051631978a0bf60e31b81526001600160a01b0384811660048301529091169063cbc505f890602401600060405180830381865afa158015610d31573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d59919081019061162e565b90506000610d65610c53565b905060005b8151811015610d9d57610d95828281518110610d8857610d886115ad565b6020026020010151610e76565b600101610d6a565b5060005b8251811015610dd457610dcc838281518110610dbf57610dbf6115ad565b6020026020010151610fa5565b600101610da1565b50505050565b6060600080856001600160a01b031685604051610df791906116f1565b6000604051808303816000865af19150503d8060008114610e34576040519150601f19603f3d011682016040523d82523d6000602084013e610e39565b606091505b509150915081610e6d57805115610e535780518082602001fd5b8360405162461bcd60e51b815260040161027c919061170d565b95945050505050565b600080516020611873833981519152610e8e8261109c565b60005b600182015460ff8216101561098057826001600160a01b0316826001018260ff1681548110610ec257610ec26115ad565b6000918252602090912001546001600160a01b031603610f9357600180830180549091610eee91611756565b81548110610efe57610efe6115ad565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610f2f57610f2f6115ad565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610f7057610f70611769565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610f9d8161177f565b915050610e91565b60008051602061187383398151915260005b600182015460ff8216101561105c57826001600160a01b0316826001018260ff1681548110610fe857610fe86115ad565b6000918252602090912001546001600160a01b03160361104a5760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c7265616479206164646564000000000000000000604482015260640161027c565b806110548161177f565b915050610fb7565b506110668261125b565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156110dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611104919081019061179e565b905060008051602061187383398151915260005b82518161ffff161015610dd4576000838261ffff168151811061113d5761113d6115ad565b602002602001015190506111518184610aed565b6001600160a01b0316856001600160a01b0316146111715761117161183b565b600061117d82856113db565b8454909150849061119090600190611756565b815481106111a0576111a06115ad565b90600052602060002001846000018261ffff16815481106111c3576111c36115ad565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff16909102179055835484908061122457611224611769565b600082815260209020810160001990810180546001600160c01b03191690550190555081905061125381611851565b915050611118565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561129b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112c3919081019061179e565b60008051602061187383398151915280549192509060005b83518110156113d45760008482815181106112f8576112f86115ad565b60200260200101519050600061130e8286610aed565b90506001600160a01b0381161561135357604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b038216602482015260440161027c565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836113c381611851565b945050600190920191506112db9050565b5050505050565b8054600090815b8161ffff168161ffff16101561144c57846001600160e01b031916846000018261ffff1681548110611416576114166115ad565b600091825260209091200154600160a01b900460e01b6001600160e01b031916036114445791506106739050565b6001016113e2565b5061ffff949350505050565b60006020828403121561146a57600080fd5b8135801515811461083557600080fd5b6001600160a01b038116811461148f57600080fd5b50565b6000602082840312156114a457600080fd5b81356108358161147a565b600080604083850312156114c257600080fd5b82356114cd8161147a565b915060208301356114dd8161147a565b809150509250929050565b6000602082840312156114fa57600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156115425783516001600160a01b03168352928401929184019160010161151d565b50909695505050505050565b6000806040838503121561156157600080fd5b823561156c8161147a565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156115a257600080fd5b81516108358161147a565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611602576116026115c3565b604052919050565b600067ffffffffffffffff821115611624576116246115c3565b5060051b60200190565b6000602080838503121561164157600080fd5b825167ffffffffffffffff81111561165857600080fd5b8301601f8101851361166957600080fd5b805161167c6116778261160a565b6115d9565b81815260059190911b8201830190838101908783111561169b57600080fd5b928401925b828410156116c25783516116b38161147a565b825292840192908401906116a0565b979650505050505050565b60005b838110156116e85781810151838201526020016116d0565b50506000910152565b600082516117038184602087016116cd565b9190910192915050565b602081526000825180602084015261172c8160408501602087016116cd565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561067357610673611740565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff810361179557611795611740565b60010192915050565b600060208083850312156117b157600080fd5b825167ffffffffffffffff8111156117c857600080fd5b8301601f810185136117d957600080fd5b80516117e76116778261160a565b81815260059190911b8201830190838101908783111561180657600080fd5b928401925b828410156116c25783516001600160e01b03198116811461182c5760008081fd5b8252928401929084019061180b565b634e487b7160e01b600052600160045260246000fd5b600061ffff80831681810361186857611868611740565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b26155f6465706c6f794d61726b65742875696e74382c62797465732c62797465732c75696e7432353629a264697066735822122085884369b38ba3ff035c759da7b88b4ab5d1400b73117a5dbcbcdf01237e98a164736f6c63430008160033a2646970667358221220447b84940e429605f7ff0777dc8288173eab5ac9f7944e7005199221ea09a6d964736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "events": { + "AdminWhitelistUpdated(address[],bool)": { + "details": "Event emitted when the admin whitelist is updated." + }, + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + }, + "PoolRegistered(uint256,(string,address,address,uint256,uint256))": { + "details": "Emitted when a new Ionic pool is added to the directory." + } + }, + "kind": "dev", + "methods": { + "_acceptOwner()": { + "details": "Owner function for pending owner to accept role and update owner" + }, + "_editAdminWhitelist(address[],bool)": { + "details": "Adds/removes Ethereum accounts to the admin whitelist.", + "params": { + "admins": "Array of Ethereum accounts to be whitelisted.", + "status": "Whether to add or remove the accounts." + } + }, + "_editDeployerWhitelist(address[],bool)": { + "details": "Adds/removes Ethereum accounts to the deployer whitelist.", + "params": { + "deployers": "Array of Ethereum accounts to be whitelisted.", + "status": "Whether to add or remove the accounts." + } + }, + "_setDeployerWhitelistEnforcement(bool)": { + "details": "Controls if the deployer whitelist is to be enforced.", + "params": { + "enforce": "Boolean indicating if the deployer whitelist is to be enforced." + } + }, + "_setPendingOwner(address)": { + "details": "Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.", + "params": { + "newPendingOwner": "New pending owner." + } + }, + "deployPool(string,address,bytes,bool,uint256,uint256,address)": { + "details": "Deploys a new Ionic pool and adds to the directory.", + "params": { + "closeFactor": "The pool's close factor (scaled by 1e18).", + "constructorData": "Encoded construction data for `Unitroller constructor()`", + "enforceWhitelist": "Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.", + "implementation": "The Comptroller implementation contract address.", + "liquidationIncentive": "The pool's liquidation incentive (scaled by 1e18).", + "name": "The name of the pool.", + "priceOracle": "The pool's PriceOracle contract address." + }, + "returns": { + "_0": "Index of the registered Ionic pool and the Unitroller proxy address." + } + }, + "getActivePools()": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getAllPools()": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getPoolsOfUser(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getPublicPools()": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getPublicPoolsByVerification(bool)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getVerifiedPoolsOfWhitelistedAccount(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive.", + "params": { + "account": "who is whitelisted in the returned verified whitelist-enabled pools." + } + }, + "initialize(bool,address[])": { + "details": "Initializes a deployer whitelist if desired.", + "params": { + "_deployerWhitelist": "Array of Ethereum accounts to be whitelisted.", + "_enforceDeployerWhitelist": "Boolean indicating if the deployer whitelist is to be enforced." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "stateVariables": { + "_poolsByAccount": { + "details": "Maps Ethereum accounts to arrays of Ionic pool indexes." + }, + "adminWhitelist": { + "details": "Maps Ethereum accounts to booleans indicating if they are a whitelisted admin." + }, + "deployerWhitelist": { + "details": "Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools." + }, + "enforceDeployerWhitelist": { + "details": "Booleans indicating if the deployer whitelist is enforced." + }, + "poolExists": { + "details": "Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory." + }, + "pools": { + "details": "Array of Ionic interest rate pools." + }, + "poolsCounter": { + "details": "used as salt for the creation of new pools" + } + }, + "title": "PoolDirectory", + "version": 1 + }, + "userdoc": { + "events": { + "NewOwner(address,address)": { + "notice": "Emitted when pendingOwner is accepted, which means owner is updated" + }, + "NewPendingOwner(address,address)": { + "notice": "Emitted when pendingOwner is changed" + } + }, + "kind": "user", + "methods": { + "_acceptOwner()": { + "notice": "Accepts transfer of owner rights. msg.sender must be pendingOwner" + }, + "_setPendingOwner(address)": { + "notice": "Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer." + }, + "getActivePools()": { + "notice": "Returns `ids` and directory information of all non-deprecated Ionic pools." + }, + "getAllPools()": { + "notice": "Returns arrays of all Ionic pools' data." + }, + "getPoolsByAccount(address)": { + "notice": "Returns arrays of Ionic pool indexes and data created by `account`." + }, + "getPoolsOfUser(address)": { + "notice": "Returns arrays of all public Ionic pool indexes and data." + }, + "getPublicPools()": { + "notice": "Returns arrays of all public Ionic pool indexes and data." + }, + "getPublicPoolsByVerification(bool)": { + "notice": "Returns arrays of all Ionic pool indexes and data with whitelisted admins." + }, + "getVerifiedPoolsOfWhitelistedAccount(address)": { + "notice": "Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted" + }, + "pendingOwner()": { + "notice": "Pending owner of this contract" + }, + "setPoolName(uint256,string)": { + "notice": "Modify existing Ionic pool name." + } + }, + "notice": "PoolDirectory is a directory for Ionic interest rate pools.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 54261, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 13288, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "pools", + "offset": 0, + "slot": "102", + "type": "t_array(t_struct(Pool)13283_storage)dyn_storage" + }, + { + "astId": 13294, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "_poolsByAccount", + "offset": 0, + "slot": "103", + "type": "t_mapping(t_address,t_array(t_uint256)dyn_storage)" + }, + { + "astId": 13299, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "poolExists", + "offset": 0, + "slot": "104", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 13310, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "enforceDeployerWhitelist", + "offset": 0, + "slot": "105", + "type": "t_bool" + }, + { + "astId": 13315, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "deployerWhitelist", + "offset": 0, + "slot": "106", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 14387, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "adminWhitelist", + "offset": 0, + "slot": "107", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 14390, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "poolsCounter", + "offset": 0, + "slot": "108", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(Pool)13283_storage)dyn_storage": { + "base": "t_struct(Pool)13283_storage", + "encoding": "dynamic_array", + "label": "struct PoolDirectory.Pool[]", + "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_mapping(t_address,t_array(t_uint256)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256[])", + "numberOfBytes": "32", + "value": "t_array(t_uint256)dyn_storage" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(Pool)13283_storage": { + "encoding": "inplace", + "label": "struct PoolDirectory.Pool", + "members": [ + { + "astId": 13274, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "name", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 13276, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "creator", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 13278, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "comptroller", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 13280, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "blockPosted", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 13282, + "contract": "contracts/PoolDirectory.sol:PoolDirectory", + "label": "timestampPosted", + "offset": 0, + "slot": "4", + "type": "t_uint256" + } + ], + "numberOfBytes": "160" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/PoolDirectory_Proxy.json b/packages/contracts/deployments/superseed/PoolDirectory_Proxy.json new file mode 100644 index 0000000000..1690152629 --- /dev/null +++ b/packages/contracts/deployments/superseed/PoolDirectory_Proxy.json @@ -0,0 +1,275 @@ +{ + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "transactionIndex": 1, + "gasUsed": "775682", + "logsBloom": "0x00000000000000000000000000000000400000010000000000800000000200000000000000000000000000000000000000000000100000040000000000000000000000000000000000000000000002000001000000000000000000000000000000000000020000000000040000000800000000800000000000000040000000400000000000000000000000000000000000000000000080000000000000c00000000000000000000000000000000400000000000000800000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000001000000000000000000000000000000000000000000000", + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597", + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000aee8aa2c69caa9f6d2c6a78198243c348d0c07d2" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + }, + { + "transactionIndex": 1, + "blockNumber": 4135316, + "transactionHash": "0x34a5a2c0c4161d4afd3d5628b612a9cb824d5257af72c71e46b55f3c7a62bb18", + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x41b8ae8f340e8c3f3c4ce0a7d31f3ed3d961b7f58c76b0690abd666b86325597" + } + ], + "blockNumber": 4135316, + "cumulativeGasUsed": "830748", + "status": 1, + "byzantium": true + }, + "args": [ + "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0xb86579d4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/PoolLens.json b/packages/contracts/deployments/superseed/PoolLens.json new file mode 100644 index 0000000000..0775051505 --- /dev/null +++ b/packages/contracts/deployments/superseed/PoolLens.json @@ -0,0 +1,1412 @@ +{ + "address": "0x1D7669b6BDfdb83066dd7C0aDa4B630b25cBc28a", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "errCode", + "type": "uint256" + } + ], + "name": "ComptrollerError", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "directory", + "outputs": [ + { + "internalType": "contract PoolDirectory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "asset", + "type": "address" + } + ], + "name": "getBorrowCapsDataForAsset", + "outputs": [ + { + "internalType": "address[]", + "name": "collateral", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "borrowCapsPerCollateral", + "type": "uint256[]" + }, + { + "internalType": "bool[]", + "name": "collateralBlacklisted", + "type": "bool[]" + }, + { + "internalType": "uint256", + "name": "totalBorrowCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonWhitelistedTotalBorrows", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "asset", + "type": "address" + } + ], + "name": "getBorrowCapsForAsset", + "outputs": [ + { + "internalType": "address[]", + "name": "collateral", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "borrowCapsPerCollateral", + "type": "uint256[]" + }, + { + "internalType": "bool[]", + "name": "collateralBlacklisted", + "type": "bool[]" + }, + { + "internalType": "uint256", + "name": "totalBorrowCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "contract IonicComptroller", + "name": "pool", + "type": "address" + } + ], + "name": "getHealthFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "pool", + "type": "address" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "cTokenModify", + "type": "address" + }, + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "getHealthFactorHypothetical", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPoolAssetsByUser", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingToken", + "type": "address" + }, + { + "internalType": "string", + "name": "underlyingName", + "type": "string" + }, + { + "internalType": "string", + "name": "underlyingSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "membership", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "exchangeRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ionicFee", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "borrowGuardianPaused", + "type": "bool" + }, + { + "internalType": "bool", + "name": "mintGuardianPaused", + "type": "bool" + } + ], + "internalType": "struct PoolLens.PoolAsset[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getPoolAssetsWithData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "underlyingToken", + "type": "address" + }, + { + "internalType": "string", + "name": "underlyingName", + "type": "string" + }, + { + "internalType": "string", + "name": "underlyingSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "underlyingDecimals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowRatePerBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "membership", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "exchangeRate", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "underlyingPrice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "oracle", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "reserveFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ionicFee", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "borrowGuardianPaused", + "type": "bool" + }, + { + "internalType": "bool", + "name": "mintGuardianPaused", + "type": "bool" + } + ], + "internalType": "struct PoolLens.PoolAsset[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getPoolSummary", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getPoolsByAccountWithData", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "underlyingSymbols", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "internalType": "struct PoolLens.IonicPoolData[]", + "name": "", + "type": "tuple[]" + }, + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getPoolsOIonicrWithData", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "underlyingSymbols", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "internalType": "struct PoolLens.IonicPoolData[]", + "name": "", + "type": "tuple[]" + }, + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "name": "getPublicPoolsByVerificationWithData", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "underlyingSymbols", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "internalType": "struct PoolLens.IonicPoolData[]", + "name": "", + "type": "tuple[]" + }, + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getPublicPoolsWithData", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "underlyingSymbols", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "internalType": "struct PoolLens.IonicPoolData[]", + "name": "", + "type": "tuple[]" + }, + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getSupplyCapsDataForPool", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getSupplyCapsForPool", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getWhitelistedPoolsByAccount", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getWhitelistedPoolsByAccountWithData", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "creator", + "type": "address" + }, + { + "internalType": "address", + "name": "comptroller", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockPosted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestampPosted", + "type": "uint256" + } + ], + "internalType": "struct PoolDirectory.Pool[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "totalSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBorrow", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "underlyingSymbols", + "type": "string[]" + }, + { + "internalType": "bool", + "name": "whitelistedAdmin", + "type": "bool" + } + ], + "internalType": "struct PoolLens.IonicPoolData[]", + "name": "", + "type": "tuple[]" + }, + { + "internalType": "bool[]", + "name": "", + "type": "bool[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract PoolDirectory", + "name": "_directory", + "type": "address" + }, + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "address[]", + "name": "_hardcodedAddresses", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "_hardcodedNames", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "_hardcodedSymbols", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "_uniswapLPTokenNames", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "_uniswapLPTokenSymbols", + "type": "string[]" + }, + { + "internalType": "string[]", + "name": "_uniswapLPTokenDisplayNames", + "type": "string[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x395cb4b62aea24a18f7e28a90f1fca2964dc5030ba5f5d1abc484abb0ea4c08d", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x1D7669b6BDfdb83066dd7C0aDa4B630b25cBc28a", + "transactionIndex": 1, + "gasUsed": "3885730", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x4e035343e95a388d01f58710d7fbda4bc213d4678c2e7f79c5d2a94873cb38ea", + "transactionHash": "0x395cb4b62aea24a18f7e28a90f1fca2964dc5030ba5f5d1abc484abb0ea4c08d", + "logs": [], + "blockNumber": 4135354, + "cumulativeGasUsed": "3929608", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"errCode\",\"type\":\"uint256\"}],\"name\":\"ComptrollerError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"directory\",\"outputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getBorrowCapsDataForAsset\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"collateral\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"borrowCapsPerCollateral\",\"type\":\"uint256[]\"},{\"internalType\":\"bool[]\",\"name\":\"collateralBlacklisted\",\"type\":\"bool[]\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrowCap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonWhitelistedTotalBorrows\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getBorrowCapsForAsset\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"collateral\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"borrowCapsPerCollateral\",\"type\":\"uint256[]\"},{\"internalType\":\"bool[]\",\"name\":\"collateralBlacklisted\",\"type\":\"bool[]\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrowCap\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"contract IonicComptroller\",\"name\":\"pool\",\"type\":\"address\"}],\"name\":\"getHealthFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cTokenModify\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"redeemTokens\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"repayAmount\",\"type\":\"uint256\"}],\"name\":\"getHealthFactorHypothetical\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getPoolAssetsByUser\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"underlyingToken\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"underlyingName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"underlyingSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"underlyingDecimals\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"underlyingBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyRatePerBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowRatePerBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"membership\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"exchangeRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"underlyingPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserveFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ionicFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"borrowGuardianPaused\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"mintGuardianPaused\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.PoolAsset[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getPoolAssetsWithData\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"underlyingToken\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"underlyingName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"underlyingSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"underlyingDecimals\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"underlyingBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyRatePerBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowRatePerBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplyBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"membership\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"exchangeRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"underlyingPrice\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reserveFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ionicFee\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"borrowGuardianPaused\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"mintGuardianPaused\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.PoolAsset[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getPoolSummary\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getPoolsByAccountWithData\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"underlyingSymbols\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.IonicPoolData[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getPoolsOIonicrWithData\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"underlyingSymbols\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.IonicPoolData[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"name\":\"getPublicPoolsByVerificationWithData\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"underlyingSymbols\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.IonicPoolData[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPublicPoolsWithData\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"underlyingSymbols\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.IonicPoolData[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getSupplyCapsDataForPool\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getSupplyCapsForPool\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getWhitelistedPoolsByAccount\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getWhitelistedPoolsByAccountWithData\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"comptroller\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockPosted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestampPosted\",\"type\":\"uint256\"}],\"internalType\":\"struct PoolDirectory.Pool[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"totalSupply\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalBorrow\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"underlyingSymbols\",\"type\":\"string[]\"},{\"internalType\":\"bool\",\"name\":\"whitelistedAdmin\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLens.IonicPoolData[]\",\"name\":\"\",\"type\":\"tuple[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"_directory\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"_hardcodedAddresses\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"_hardcodedNames\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"_hardcodedSymbols\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"_uniswapLPTokenNames\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"_uniswapLPTokenSymbols\",\"type\":\"string[]\"},{\"internalType\":\"string[]\",\"name\":\"_uniswapLPTokenDisplayNames\",\"type\":\"string[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"getBorrowCapsDataForAsset(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getBorrowCapsForAsset(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getPoolAssetsByUser(address,address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getPoolAssetsWithData(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\",\"params\":{\"comptroller\":\"The Comptroller proxy contract of the Ionic pool.\"},\"returns\":{\"_0\":\"An array of Ionic pool assets.\"}},\"getPoolsByAccountWithData(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"getPoolsOIonicrWithData(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"getPublicPoolsByVerificationWithData(bool)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"getPublicPoolsWithData()\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"getSupplyCapsDataForPool(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getSupplyCapsForPool(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getWhitelistedPoolsByAccount(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getWhitelistedPoolsByAccountWithData(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"initialize(address,string,string,address[],string[],string[],string[],string[],string[])\":{\"params\":{\"_directory\":\"The PoolDirectory\",\"_hardcodedAddresses\":\"Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\",\"_hardcodedNames\":\"Harcoded name for these tokens\",\"_hardcodedSymbols\":\"Harcoded symbol for these tokens\",\"_name\":\"Name for the nativeToken\",\"_symbol\":\"Symbol for the nativeToken\",\"_uniswapLPTokenDisplayNames\":\"Harcoded display names for underlying uniswap LpToken\",\"_uniswapLPTokenNames\":\"Harcoded names for underlying uniswap LpToken\",\"_uniswapLPTokenSymbols\":\"Harcoded symbols for underlying uniswap LpToken\"}}},\"title\":\"PoolLens\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"directory()\":{\"notice\":\"`PoolDirectory` contract object.\"},\"getBorrowCapsDataForAsset(address)\":{\"notice\":\"returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\"},\"getBorrowCapsForAsset(address)\":{\"notice\":\"returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\"},\"getPoolAssetsByUser(address,address)\":{\"notice\":\"Returns arrays of PoolAsset for a specific user\"},\"getPoolAssetsWithData(address)\":{\"notice\":\"Returns the assets of the specified Ionic pool.\"},\"getPoolSummary(address)\":{\"notice\":\"Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\"},\"getPoolsByAccountWithData(address)\":{\"notice\":\"Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\"},\"getPoolsOIonicrWithData(address)\":{\"notice\":\"Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\"},\"getPublicPoolsByVerificationWithData(bool)\":{\"notice\":\"Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\"},\"getPublicPoolsWithData()\":{\"notice\":\"Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\"},\"getSupplyCapsDataForPool(address)\":{\"notice\":\"returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\"},\"getSupplyCapsForPool(address)\":{\"notice\":\"returns the total supply cap for each asset in the pool\"},\"getWhitelistedPoolsByAccount(address)\":{\"notice\":\"Returns arrays of Ionic pool indexes and data with a whitelist containing `account`. Note that the whitelist does not have to be enforced.\"},\"getWhitelistedPoolsByAccountWithData(address)\":{\"notice\":\"Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\"},\"initialize(address,string,string,address[],string[],string[],string[],string[],string[])\":{\"notice\":\"Initialize the `PoolDirectory` contract object.\"}},\"notice\":\"PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/PoolLens.sol\":\"PoolLens\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLens.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\nimport { MasterPriceOracle } from \\\"./oracles/MasterPriceOracle.sol\\\";\\n\\n/**\\n * @title PoolLens\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLens is Initializable {\\n error ComptrollerError(uint256 errCode);\\n\\n /**\\n * @notice Initialize the `PoolDirectory` contract object.\\n * @param _directory The PoolDirectory\\n * @param _name Name for the nativeToken\\n * @param _symbol Symbol for the nativeToken\\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\\n * @param _hardcodedNames Harcoded name for these tokens\\n * @param _hardcodedSymbols Harcoded symbol for these tokens\\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\\n */\\n function initialize(\\n PoolDirectory _directory,\\n string memory _name,\\n string memory _symbol,\\n address[] memory _hardcodedAddresses,\\n string[] memory _hardcodedNames,\\n string[] memory _hardcodedSymbols,\\n string[] memory _uniswapLPTokenNames,\\n string[] memory _uniswapLPTokenSymbols,\\n string[] memory _uniswapLPTokenDisplayNames\\n ) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n require(\\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\\n \\\"Hardcoded addresses lengths not equal.\\\"\\n );\\n require(\\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\\n \\\"Uniswap LP token names lengths not equal.\\\"\\n );\\n\\n directory = _directory;\\n name = _name;\\n symbol = _symbol;\\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\\n }\\n\\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\\n uniswapData.push(\\n UniswapData({\\n name: _uniswapLPTokenNames[i],\\n symbol: _uniswapLPTokenSymbols[i],\\n displayName: _uniswapLPTokenDisplayNames[i]\\n })\\n );\\n }\\n }\\n\\n string public name;\\n string public symbol;\\n\\n struct TokenData {\\n string name;\\n string symbol;\\n }\\n mapping(address => TokenData) hardcoded;\\n\\n struct UniswapData {\\n string name; // ie \\\"Uniswap V2\\\" or \\\"SushiSwap LP Token\\\"\\n string symbol; // ie \\\"UNI-V2\\\" or \\\"SLP\\\"\\n string displayName; // ie \\\"SushiSwap\\\" or \\\"Uniswap\\\"\\n }\\n UniswapData[] uniswapData;\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @dev Struct for Ionic pool summary data.\\n */\\n struct IonicPoolData {\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n address[] underlyingTokens;\\n string[] underlyingSymbols;\\n bool whitelistedAdmin;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsWithData()\\n external\\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\\n {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPublicPoolsByVerificationWithData(\\n bool whitelistedAdmin\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\\n whitelistedAdmin\\n );\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\\n return (indexes, publicPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsOIonicrWithData(\\n address user\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\\n return (indexes, userPools, data, errored);\\n }\\n\\n /**\\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\\n bool[] memory errored = new bool[](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\\n uint256 _totalSupply,\\n uint256 _totalBorrow,\\n address[] memory _underlyingTokens,\\n string[] memory _underlyingSymbols,\\n bool _whitelistedAdmin\\n ) {\\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\\n } catch {\\n errored[i] = true;\\n }\\n }\\n\\n return (data, errored);\\n }\\n\\n /**\\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\\n */\\n function getPoolSummary(\\n IonicComptroller comptroller\\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\\n uint256 totalBorrow = 0;\\n uint256 totalSupply = 0;\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n address[] memory underlyingTokens = new address[](cTokens.length);\\n string[] memory underlyingSymbols = new string[](cTokens.length);\\n BasePriceOracle oracle = comptroller.oracle();\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n cToken.accrueInterest();\\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\\n uint256 assetTotalSupply = cToken.getCash() +\\n assetTotalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\\n\\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\\n }\\n\\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool asset.\\n */\\n struct PoolAsset {\\n address cToken;\\n address underlyingToken;\\n string underlyingName;\\n string underlyingSymbol;\\n uint256 underlyingDecimals;\\n uint256 underlyingBalance;\\n uint256 supplyRatePerBlock;\\n uint256 borrowRatePerBlock;\\n uint256 totalSupply;\\n uint256 totalBorrow;\\n uint256 supplyBalance;\\n uint256 borrowBalance;\\n uint256 liquidity;\\n bool membership;\\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\\n address oracle;\\n uint256 collateralFactor;\\n uint256 reserveFactor;\\n uint256 adminFee;\\n uint256 ionicFee;\\n bool borrowGuardianPaused;\\n bool mintGuardianPaused;\\n }\\n\\n /**\\n * @notice Returns data on the specified assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\\n * @param cTokens The cToken contract addresses of the assets to query.\\n * @param user The user for which to get account data.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(\\n IonicComptroller comptroller,\\n ICErc20[] memory cTokens,\\n address user\\n ) internal returns (PoolAsset[] memory) {\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\\n if (isListed) arrayLength++;\\n }\\n\\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\\n uint256 index = 0;\\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n // Check if market is listed and get collateral factor\\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\\n if (!isListed) continue;\\n\\n // Start adding data to PoolAsset\\n PoolAsset memory asset;\\n ICErc20 cToken = cTokens[i];\\n asset.cToken = address(cToken);\\n\\n cToken.accrueInterest();\\n\\n // Get underlying asset data\\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\\n asset.underlyingDecimals = underlying.decimals();\\n asset.underlyingBalance = underlying.balanceOf(user);\\n\\n // Get cToken data\\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\\n asset.liquidity = cToken.getCash();\\n asset.totalBorrow = cToken.totalBorrowsCurrent();\\n asset.totalSupply =\\n asset.liquidity +\\n asset.totalBorrow -\\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\\n asset.membership = comptroller.checkMembership(user, cToken);\\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\\n\\n // Get oracle for this cToken\\n asset.oracle = address(oracle);\\n\\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\\n asset.oracle = address(_oracle);\\n } catch {}\\n\\n // More cToken data\\n asset.collateralFactor = collateralFactorMantissa;\\n asset.reserveFactor = cToken.reserveFactorMantissa();\\n asset.adminFee = cToken.adminFeeMantissa();\\n asset.ionicFee = cToken.ionicFeeMantissa();\\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\\n\\n // Add to assets array and increment index\\n detailedAssets[index] = asset;\\n index++;\\n }\\n\\n return (detailedAssets);\\n }\\n\\n function getBorrowCapsPerCollateral(\\n ICErc20 borrowedAsset,\\n IonicComptroller comptroller\\n )\\n internal\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsAgainstCollateral,\\n bool[] memory borrowingBlacklistedAgainstCollateral\\n )\\n {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n collateral = new address[](poolMarkets.length);\\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\\n\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n address collateralAddress = address(poolMarkets[i]);\\n if (collateralAddress != address(borrowedAsset)) {\\n collateral[i] = collateralAddress;\\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\\n address(borrowedAsset),\\n collateralAddress\\n );\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the `name` and `symbol` of `token`.\\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\\n * @param token An ERC20 token contract object.\\n * @return The `name` and `symbol`.\\n */\\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\\n // i.e. MKR is a DSToken and uses bytes32\\n if (bytes(hardcoded[token].symbol).length != 0) {\\n return (hardcoded[token].name, hardcoded[token].symbol);\\n }\\n\\n // Get name and symbol from token contract\\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\\n string memory _name = tokenContract.name();\\n string memory _symbol = tokenContract.symbol();\\n\\n return (_name, _symbol);\\n }\\n\\n /**\\n * @notice Returns the assets of the specified Ionic pool.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\\n * @return An array of Ionic pool assets.\\n */\\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\\n }\\n\\n /**\\n * @dev Struct for a Ionic pool user.\\n */\\n struct IonicPoolUser {\\n address account;\\n uint256 totalBorrow;\\n uint256 totalCollateral;\\n uint256 health;\\n }\\n\\n /**\\n * @notice Returns arrays of PoolAsset for a specific user\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\\n return assets;\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n }\\n\\n return (assets, supplyCapsPerAsset);\\n }\\n\\n /**\\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getSupplyCapsDataForPool(\\n IonicComptroller comptroller\\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\\n\\n address[] memory assets = new address[](poolMarkets.length);\\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\\n for (uint256 i = 0; i < poolMarkets.length; i++) {\\n assets[i] = address(poolMarkets[i]);\\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\\n }\\n\\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\\n }\\n\\n /**\\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n }\\n\\n /**\\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getBorrowCapsDataForAsset(\\n ICErc20 asset\\n )\\n public\\n view\\n returns (\\n address[] memory collateral,\\n uint256[] memory borrowCapsPerCollateral,\\n bool[] memory collateralBlacklisted,\\n uint256 totalBorrowCap,\\n uint256 nonWhitelistedTotalBorrows\\n )\\n {\\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\\n uint256 totalBorrows = asset.totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\\n * Note that the whitelist does not have to be enforced.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getWhitelistedPoolsByAccount(\\n address account\\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n if (comptroller.whitelist(account)) {\\n indexes[index] = i;\\n accountPools[index] = pools[i];\\n index++;\\n break;\\n }\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getWhitelistedPoolsByAccountWithData(\\n address account\\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\\n return (indexes, accountPools, data, errored);\\n }\\n\\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\\n }\\n\\n function getHealthFactorHypothetical(\\n IonicComptroller pool,\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256) {\\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\\n account,\\n cTokenModify,\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n\\n if (err != 0) revert ComptrollerError(err);\\n\\n if (shortfall > 0) {\\n // HF < 1.0\\n return (collateralValue * 1e18) / (collateralValue + shortfall);\\n } else {\\n // HF >= 1.0\\n if (collateralValue <= liquidity) return type(uint256).max;\\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x62702fad5f5f2823af735e25755839dc24bd1b16a2d2be82395a07061a055461\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/MasterPriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\nimport { ICErc20 } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { BasePriceOracle } from \\\"./BasePriceOracle.sol\\\";\\n\\n/**\\n * @title MasterPriceOracle\\n * @notice Use a combination of price oracles.\\n * @dev Implements `PriceOracle`.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public oracles;\\n\\n /**\\n * @dev Default/fallback `PriceOracle`.\\n */\\n BasePriceOracle public defaultOracle;\\n\\n /**\\n * @dev The administrator of this `MasterPriceOracle`.\\n */\\n address public admin;\\n\\n /**\\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n bool internal noAdminOverwrite;\\n\\n /**\\n * @dev The Wrapped native asset address.\\n */\\n address public wtoken;\\n\\n /**\\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\\n */\\n mapping(address => BasePriceOracle) public fallbackOracles;\\n\\n /**\\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n */\\n function canAdminOverwrite() external view returns (bool) {\\n return !noAdminOverwrite;\\n }\\n\\n /**\\n * @dev Event emitted when `admin` is changed.\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n /**\\n * @dev Event emitted when the default oracle is changed.\\n */\\n event NewDefaultOracle(address oldOracle, address newOracle);\\n\\n /**\\n * @dev Event emitted when an underlying token's oracle is changed.\\n */\\n event NewOracle(address underlying, address oldOracle, address newOracle);\\n\\n /**\\n * @dev Initialize state variables.\\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\\n * @param _defaultOracle The default `PriceOracle` contract to use.\\n * @param _admin The admin who can assign oracles to underlying tokens.\\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\\n * @param _wtoken The Wrapped native asset address\\n */\\n function initialize(\\n address[] memory underlyings,\\n BasePriceOracle[] memory _oracles,\\n BasePriceOracle _defaultOracle,\\n address _admin,\\n bool _canAdminOverwrite,\\n address _wtoken\\n ) external initializer {\\n // Input validation\\n require(underlyings.length == _oracles.length, \\\"Lengths of both arrays must be equal.\\\");\\n\\n // Initialize state variables\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, address(0), address(newOracle));\\n }\\n\\n defaultOracle = _defaultOracle;\\n admin = _admin;\\n noAdminOverwrite = !_canAdminOverwrite;\\n wtoken = _wtoken;\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(oracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n oracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Sets `_oracles` for `underlyings`.\\n */\\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\\n // Input validation\\n require(\\n underlyings.length > 0 && underlyings.length == _oracles.length,\\n \\\"Lengths of both arrays must be equal and greater than 0.\\\"\\n );\\n\\n // Assign oracles to underlying tokens\\n for (uint256 i = 0; i < underlyings.length; i++) {\\n address underlying = underlyings[i];\\n address oldOracle = address(fallbackOracles[underlying]);\\n if (noAdminOverwrite)\\n require(\\n oldOracle == address(0),\\n \\\"Admin cannot overwrite existing assignments of oracles to underlying tokens.\\\"\\n );\\n BasePriceOracle newOracle = _oracles[i];\\n fallbackOracles[underlying] = newOracle;\\n emit NewOracle(underlying, oldOracle, address(newOracle));\\n }\\n }\\n\\n /**\\n * @dev Changes the default price oracle\\n */\\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\\n BasePriceOracle oldOracle = defaultOracle;\\n defaultOracle = newOracle;\\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\\n }\\n\\n /**\\n * @dev Changes the admin and emits an event.\\n */\\n function changeAdmin(address newAdmin) external onlyAdmin {\\n address oldAdmin = admin;\\n admin = newAdmin;\\n emit NewAdmin(oldAdmin, newAdmin);\\n }\\n\\n /**\\n * @dev Modifier that checks if `msg.sender == admin`.\\n */\\n modifier onlyAdmin() {\\n require(msg.sender == admin, \\\"Sender is not the admin.\\\");\\n _;\\n }\\n\\n /**\\n * @notice Returns the price in ETH of the token underlying `cToken`.\\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\\n // Get underlying ERC20 token address\\n address underlying = address(ICErc20(address(cToken)).underlying());\\n\\n if (underlying == wtoken) return 1e18;\\n\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n\\n /**\\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\\n */\\n function price(address underlying) public view override returns (uint256) {\\n // Return 1e18 for WETH\\n if (underlying == wtoken) return 1e18;\\n\\n // Get underlying price from assigned oracle\\n BasePriceOracle oracle = oracles[underlying];\\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\\n\\n if (address(oracle) != address(0)) {\\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\\n if (underlyingPrice == 0) {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n } else {\\n return underlyingPrice;\\n }\\n } catch {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n } else {\\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\\n }\\n revert(\\\"Price oracle not found for this underlying token address.\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8748b7e74b8f789617f0b387cd2e2259a0fa3639d54234d7e6c99cb3eae6fc9a\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061454f806100206000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c806370733375116100ad578063c3530a6311610071578063c3530a63146102ac578063c41c2f24146102cd578063d0a164fb146102f8578063d64996e514610300578063ef88b53c1461031357600080fd5b8063707333751461022a578063798b97801461023d57806395d89b411461025e578063a079548714610266578063a505596a1461028857600080fd5b806327e16c1f116100f457806327e16c1f146101a85780633a1eb656146101bb57806351678684146101d057806357c89a7d146101f357806359d2fea61461020657600080fd5b806306fdde03146101265780630c5eb5a4146101445780631568683a146101645780631bb998ba14610187575b600080fd5b61012e610326565b60405161013b9190613438565b60405180910390f35b610157610152366004613463565b6103b4565b60405161013b919061349c565b61017761017236600461362b565b61043e565b60405161013b94939291906136f1565b61019a61019536600461373c565b610531565b60405190815260200161013b565b6101576101b636600461362b565b610655565b6101ce6101c93660046139b1565b6106c7565b005b6101e36101de36600461362b565b610ae9565b60405161013b9493929190613be8565b61019a610201366004613463565b610b8c565b61021961021436600461362b565b610ba5565b60405161013b959493929190613cca565b6101e361023836600461362b565b6112fe565b61025061024b36600461362b565b611310565b60405161013b929190613d10565b61012e611529565b61027961027436600461362b565b611536565b60405161013b93929190613d3e565b61029b61029636600461362b565b61190b565b60405161013b959493929190613d77565b6102bf6102ba36600461362b565b611af7565b60405161013b929190613dc5565b6005546102e0906001600160a01b031681565b6040516001600160a01b03909116815260200161013b565b6101e3611e4b565b6101e361030e366004613df8565b611ef0565b6101e361032136600461362b565b611f30565b6001805461033390613e15565b80601f016020809104026020016040519081016040528092919081815260200182805461035f90613e15565b80156103ac5780601f10610381576101008083540402835291602001916103ac565b820191906000526020600020905b81548152906001019060200180831161038f57829003601f168201915b505050505081565b604051632aff3bff60e21b81526001600160a01b03828116600483015260609160009161043491869182169063abfceffc90602401600060405180830381865afa158015610406573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261042e9190810190613e4f565b85611f70565b9150505b92915050565b6060806060600080856001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610484573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a89190613ee8565b90506104b48682612bee565b604051635881a44160e11b81526001600160a01b038a8116600483015293985091965094509082169063b103488290602401602060405180830381865afa158015610503573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105279190613f05565b9150509193509193565b604051637e361b1160e01b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052608482018390526000918291829182918291908c1690637e361b119060a401608060405180830381865afa1580156105a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c49190613f1e565b9350935093509350836000146105f55760405163255a0eef60e11b8152600481018590526024015b60405180910390fd5b801561062c576106058184613f6a565b61061784670de0b6b3a7640000613f7d565b6106219190613f94565b94505050505061064b565b8183116106415760001994505050505061064b565b6106058284613fb6565b9695505050505050565b606061043882836001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610699573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106c19190810190613e4f565b33611f70565b600054610100900460ff16158080156106e75750600054600160ff909116105b806107015750303b158015610701575060005460ff166001145b6107645760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105ec565b6000805460ff191660011790558015610787576000805461ff0019166101001790555b6001600160a01b038a166107f85760405162461bcd60e51b815260206004820152603260248201527f506f6f6c4469726563746f727920696e7374616e63652063616e6e6f74206265604482015271103a3432903d32b9379030b2323932b9b99760711b60648201526084016105ec565b8551875114801561080a575084518751145b6108655760405162461bcd60e51b815260206004820152602660248201527f48617264636f64656420616464726573736573206c656e67746873206e6f742060448201526532b8bab0b61760d11b60648201526084016105ec565b82518451148015610877575081518451145b6108d55760405162461bcd60e51b815260206004820152602960248201527f556e6973776170204c5020746f6b656e206e616d6573206c656e67746873206e60448201526837ba1032b8bab0b61760b91b60648201526084016105ec565b600580546001600160a01b0319166001600160a01b038c1617905560016108fc8a8261401a565b506002610909898261401a565b5060005b87518110156109c4576040518060400160405280888381518110610933576109336140d9565b60200260200101518152602001878381518110610952576109526140d9565b6020026020010151815250600360008a8481518110610973576109736140d9565b6020908102919091018101516001600160a01b03168252810191909152604001600020815181906109a4908261401a565b50602082015160018201906109b9908261401a565b50505060010161090d565b5060005b8451811015610a9657600460405180606001604052808784815181106109f0576109f06140d9565b60200260200101518152602001868481518110610a0f57610a0f6140d9565b60200260200101518152602001858481518110610a2e57610a2e6140d9565b6020908102919091018101519091528254600181018455600093845292208151919260030201908190610a61908261401a565b5060208201516001820190610a76908261401a565b5060408201516002820190610a8b908261401a565b5050506001016109c8565b508015610add576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6005546040516351f6c8e360e11b81526001600160a01b03838116600483015260609283928392839260009283929091169063a3ed91c6906024015b600060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b6a9190810190614231565b91509150600080610b7a83612ec7565b949a9399509750929550909350505050565b6000610b9e8284600080600080610531565b9392505050565b60008060608060008060009050600080886001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bf3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c1b9190810190613e4f565b9050600081516001600160401b03811115610c3857610c386137b1565b604051908082528060200260200182016040528015610c61578160200160208202803683370190505b509050600082516001600160401b03811115610c7f57610c7f6137b1565b604051908082528060200260200182016040528015610cb257816020015b6060815260200190600190039081610c9d5790505b50905060008b6001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cf5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d199190613ee8565b905060005b84518110156111f6576000858281518110610d3b57610d3b6140d9565b6020026020010151905060008e6001600160a01b0316638e8f294b836040518263ffffffff1660e01b8152600401610d8291906001600160a01b0391909116815260200190565b6040805180830381865afa158015610d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc291906142f7565b50905080610dd15750506111ee565b816001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e359190613f05565b506000826001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9a9190613f05565b90506000836001600160a01b0316639826394b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f009190613f05565b846001600160a01b03166361feacff6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f629190613f05565b856001600160a01b0316638f840ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc49190613f05565b610fce9190613f6a565b610fd89190613f6a565b82856001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103b9190613f05565b6110459190613f6a565b61104f9190613fb6565b60405163fc57d4df60e01b81526001600160a01b03868116600483015291925060009188169063fc57d4df90602401602060405180830381865afa15801561109b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bf9190613f05565b9050670de0b6b3a76400006110d48285613f7d565b6110de9190613f94565b6110e8908d613f6a565b9b50670de0b6b3a76400006110fd8284613f7d565b6111079190613f94565b611111908c613f6a565b9a50846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611151573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111759190613ee8565b898781518110611187576111876140d9565b60200260200101906001600160a01b031690816001600160a01b0316815250506111c98987815181106111bc576111bc6140d9565b60200260200101516130c4565b90508887815181106111dd576111dd6140d9565b602002602001018190525050505050505b600101610d1e565b506000600560009054906101000a90046001600160a01b03166001600160a01b03166343e20a1d8e6001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561125b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127f9190613ee8565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156112c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e79190614325565b959d969c50929a5090985092965092945050505050565b606080606080600080610b6a87611af7565b6060806000836001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611353573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261137b9190810190613e4f565b9050600081516001600160401b03811115611398576113986137b1565b6040519080825280602002602001820160405280156113c1578160200160208202803683370190505b509050600082516001600160401b038111156113df576113df6137b1565b604051908082528060200260200182016040528015611408578160200160208202803683370190505b50905060005b835181101561151d57838181518110611429576114296140d9565b6020026020010151838281518110611443576114436140d9565b60200260200101906001600160a01b031690816001600160a01b031681525050866001600160a01b0316632ccf47a4848381518110611484576114846140d9565b60200260200101516040518263ffffffff1660e01b81526004016114b791906001600160a01b0391909116815260200190565b602060405180830381865afa1580156114d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f89190613f05565b82828151811061150a5761150a6140d9565b602090810291909101015260010161140e565b50909590945092505050565b6002805461033390613e15565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561157b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115a39190810190613e4f565b9050600081516001600160401b038111156115c0576115c06137b1565b6040519080825280602002602001820160405280156115e9578160200160208202803683370190505b509050600082516001600160401b03811115611607576116076137b1565b604051908082528060200260200182016040528015611630578160200160208202803683370190505b509050600083516001600160401b0381111561164e5761164e6137b1565b604051908082528060200260200182016040528015611677578160200160208202803683370190505b50905060005b84518110156118fc57848181518110611698576116986140d9565b60200260200101518482815181106116b2576116b26140d9565b60200260200101906001600160a01b031690816001600160a01b031681525050886001600160a01b0316632ccf47a48583815181106116f3576116f36140d9565b60200260200101516040518263ffffffff1660e01b815260040161172691906001600160a01b0391909116815260200190565b602060405180830381865afa158015611743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117679190613f05565b838281518110611779576117796140d9565b6020026020010181815250506000858281518110611799576117996140d9565b60200260200101516001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118029190613f05565b905060008a6001600160a01b031663fb6243fa878581518110611827576118276140d9565b60200260200101516040518263ffffffff1660e01b815260040161185a91906001600160a01b0391909116815260200190565b602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b9190613f05565b90508181106118c95760008484815181106118b8576118b86140d9565b6020026020010181815250506118f2565b6118d38183613fb6565b8484815181106118e5576118e56140d9565b6020026020010181815250505b505060010161167d565b50919790965090945092505050565b60608060606000806000866001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119779190613ee8565b90506119838782612bee565b604051635881a44160e11b81526001600160a01b038b8116600483015293995091975095509082169063b103488290602401602060405180830381865afa1580156119d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f69190613f05565b92506000876001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5c9190613f05565b604051631d3965af60e11b81526001600160a01b038a81166004830152919250600091841690633a72cb5e90602401602060405180830381865afa158015611aa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611acc9190613f05565b9050818110611ade5760009350611aeb565b611ae88183613fb6565b93505b50505091939590929450565b6060806000600560009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b4f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b779190810190614231565b9150506000805b8251811015611c41576000838281518110611b9b57611b9b6140d9565b6020026020010151604001519050806001600160a01b0316639b19251a886040518263ffffffff1660e01b8152600401611be491906001600160a01b0391909116815260200190565b602060405180830381865afa158015611c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c259190614325565b15611c385782611c3481614342565b9350505b50600101611b7e565b506000816001600160401b03811115611c5c57611c5c6137b1565b604051908082528060200260200182016040528015611c85578160200160208202803683370190505b5090506000826001600160401b03811115611ca257611ca26137b1565b604051908082528060200260200182016040528015611d1757816020015b611d046040518060a001604052806060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b815260200190600190039081611cc05790505b5090506000805b8551811015611e3d576000868281518110611d3b57611d3b6140d9565b6020026020010151604001519050806001600160a01b0316639b19251a8b6040518263ffffffff1660e01b8152600401611d8491906001600160a01b0391909116815260200190565b602060405180830381865afa158015611da1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc59190614325565b15611e345781858481518110611ddd57611ddd6140d9565b602002602001018181525050868281518110611dfb57611dfb6140d9565b6020026020010151848481518110611e1557611e156140d9565b60200260200101819052508280611e2b90614342565b93505050611e3d565b50600101611d1e565b509197909650945050505050565b606080606080600080600560009054906101000a90046001600160a01b03166001600160a01b0316634ae26ea16040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ea7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ecf9190810190614231565b91509150600080611edf83612ec7565b949993985096509294509092505050565b6005546040516310c51ddf60e11b8152821515600482015260609182918291829160009182916001600160a01b039091169063218a3bbe90602401610b25565b60055460405163f348960d60e01b81526001600160a01b03838116600483015260609283928392839260009283929091169063f348960d90602401610b25565b60606000805b8451811015612035576000866001600160a01b0316638e8f294b878481518110611fa257611fa26140d9565b60200260200101516040518263ffffffff1660e01b8152600401611fd591906001600160a01b0391909116815260200190565b6040805180830381865afa158015611ff1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201591906142f7565b509050801561202c578261202881614342565b9350505b50600101611f76565b506000816001600160401b03811115612050576120506137b1565b60405190808252806020026020018201604052801561208957816020015b612076613319565b81526020019060019003908161206e5790505b509050600080876001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f19190613ee8565b905060005b8751811015612be1576000808a6001600160a01b0316638e8f294b8b8581518110612123576121236140d9565b60200260200101516040518263ffffffff1660e01b815260040161215691906001600160a01b0391909116815260200190565b6040805180830381865afa158015612172573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219691906142f7565b91509150816121a6575050612bd9565b6121ae613319565b60008b85815181106121c2576121c26140d9565b6020908102919091018101516001600160a01b0381168085526040805163a6afed9560e01b81529051929450909263a6afed959260048084019382900301816000875af1158015612217573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223b9190613f05565b50806001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229e9190613ee8565b6001600160a01b0316602083018190526122b7816130c4565b84604001856060018290528290525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612305573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612329919061435b565b60ff1660808401526040516370a0823160e01b81526001600160a01b038d811660048301528216906370a0823190602401602060405180830381865afa158015612377573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239b9190613f05565b8360a0018181525050816001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124069190613f05565b8360c0018181525050816001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa15801561244d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124719190613f05565b8360e0018181525050816001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124dc9190613f05565b83610180018181525050816001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015612524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125489190613f05565b83610120018181525050816001600160a01b0316639826394b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612590573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b49190613f05565b826001600160a01b03166361feacff6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126169190613f05565b836001600160a01b0316638f840ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612654573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126789190613f05565b6126829190613f6a565b61268c9190613f6a565b8361012001518461018001516126a29190613f6a565b6126ac9190613fb6565b610100840152604051633af9e66960e01b81526001600160a01b038d81166004830152831690633af9e66990602401602060405180830381865afa1580156126f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271c9190613f05565b6101408401526040516305eff7ef60e21b81526001600160a01b038d811660048301528316906317bfdfbc90602401602060405180830381865afa158015612768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278c9190613f05565b61016084015260405163929fe9a160e01b81526001600160a01b038d8116600483015283811660248301528f169063929fe9a190604401602060405180830381865afa1580156127e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128049190614325565b15156101a08401526040805163bd6d894d60e01b815290516001600160a01b0384169163bd6d894d9160048083019260209291908290030181865afa158015612851573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128759190613f05565b6101c084015260208301516040516315d5220f60e31b81526001600160a01b0391821660048201529088169063aea9107890602401602060405180830381865afa1580156128c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128eb9190613f05565b6101e08401526001600160a01b038781166102008501819052602085015160405163addd509960e01b8152921660048301529063addd509990602401602060405180830381865afa925050508015612960575060408051601f3d908101601f1916820190925261295d91810190613ee8565b60015b15612975576001600160a01b03166102008401525b8383610220018181525050816001600160a01b031663173b99046040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e29190613f05565b83610240018181525050816001600160a01b0316638d02d9a16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4e9190613f05565b83610260018181525050816001600160a01b031663c3bf11cd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aba9190613f05565b610280840152604051636d154ea560e01b81526001600160a01b0383811660048301528f1690636d154ea590602401602060405180830381865afa158015612b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2a9190614325565b15156102a084015260405163731f0c2b60e01b81526001600160a01b0383811660048301528f169063731f0c2b90602401602060405180830381865afa158015612b78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9c9190614325565b15156102c0840152885183908a908a908110612bba57612bba6140d9565b60200260200101819052508780612bd090614342565b98505050505050505b6001016120f6565b5091979650505050505050565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612c33573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612c5b9190810190613e4f565b905080516001600160401b03811115612c7657612c766137b1565b604051908082528060200260200182016040528015612c9f578160200160208202803683370190505b50935080516001600160401b03811115612cbb57612cbb6137b1565b604051908082528060200260200182016040528015612ce4578160200160208202803683370190505b50925080516001600160401b03811115612d0057612d006137b1565b604051908082528060200260200182016040528015612d29578160200160208202803683370190505b50915060005b8151811015612ebe576000828281518110612d4c57612d4c6140d9565b60200260200101519050876001600160a01b0316816001600160a01b031614612eb55780868381518110612d8257612d826140d9565b6001600160a01b03928316602091820292909201015260405163940cd6f160e01b8152898216600482015282821660248201529088169063940cd6f190604401602060405180830381865afa158015612ddf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e039190613f05565b858381518110612e1557612e156140d9565b6020908102919091010152604051631c819e4360e01b81526001600160a01b0389811660048301528281166024830152881690631c819e4390604401602060405180830381865afa158015612e6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e929190614325565b848381518110612ea457612ea46140d9565b911515602092830291909101909101525b50600101612d2f565b50509250925092565b606080600083516001600160401b03811115612ee557612ee56137b1565b604051908082528060200260200182016040528015612f4a57816020015b612f376040518060a00160405280600081526020016000815260200160608152602001606081526020016000151581525090565b815260200190600190039081612f035790505b509050600084516001600160401b03811115612f6857612f686137b1565b604051908082528060200260200182016040528015612f91578160200160208202803683370190505b50905060005b85518110156130b957306001600160a01b03166359d2fea6878381518110612fc157612fc16140d9565b6020026020010151604001516040518263ffffffff1660e01b8152600401612ff891906001600160a01b0391909116815260200190565b6000604051808303816000875af192505050801561303857506040513d6000823e601f3d908101601f1916820160405261303591908101906143fd565b60015b613065576001828281518110613050576130506140d9565b911515602092830291909101909101526130b1565b6040518060a001604052808681526020018581526020018481526020018381526020018215158152508887815181106130a0576130a06140d9565b602002602001018190525050505050505b600101612f97565b509094909350915050565b6001600160a01b0381166000908152600360205260409020600101805460609182916130ef90613e15565b159050613235576001600160a01b038316600090815260036020526040902080546001820190829061312090613e15565b80601f016020809104026020016040519081016040528092919081815260200182805461314c90613e15565b80156131995780601f1061316e57610100808354040283529160200191613199565b820191906000526020600020905b81548152906001019060200180831161317c57829003601f168201915b505050505091508080546131ac90613e15565b80601f01602080910402602001604051908101604052809291908181526020018280546131d890613e15565b80156132255780601f106131fa57610100808354040283529160200191613225565b820191906000526020600020905b81548152906001019060200180831161320857829003601f168201915b5050505050905091509150915091565b60008390506000816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561327a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526132a291908101906144e5565b90506000826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156132e4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261330c91908101906144e5565b9196919550909350505050565b604051806102e0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600015158152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b60005b838110156134035781810151838201526020016133eb565b50506000910152565b600081518084526134248160208601602086016133e8565b601f01601f19169290920160200192915050565b602081526000610b9e602083018461340c565b6001600160a01b038116811461346057600080fd5b50565b6000806040838503121561347657600080fd5b82356134818161344b565b915060208301356134918161344b565b809150509250929050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561361d57888303603f19018552815180516001600160a01b031684526102e0818901516001600160a01b038116868b0152508782015181898701526135108287018261340c565b9150506060808301518683038288015261352a838261340c565b6080858101519089015260a0808601519089015260c0808601519089015260e08086015190890152610100808601519089015261012080860151908901526101408086015190890152610160808601519089015261018080860151908901526101a0808601511515908901526101c080860151908901526101e08086015190890152610200808601516001600160a01b03169089015261022080860151908901526102408086015190890152610260808601519089015261028080860151908901526102a0808601511515908901526102c0948501511515949097019390935250505093860193908601906001016134c5565b509098975050505050505050565b60006020828403121561363d57600080fd5b8135610b9e8161344b565b60008151808452602080850194506020840160005b838110156136825781516001600160a01b03168752958201959082019060010161365d565b509495945050505050565b60008151808452602080850194506020840160005b83811015613682578151875295820195908201906001016136a2565b60008151808452602080850194506020840160005b838110156136825781511515875295820195908201906001016136d3565b6080815260006137046080830187613648565b8281036020840152613716818761368d565b9050828103604084015261372a81866136be565b91505082606083015295945050505050565b60008060008060008060c0878903121561375557600080fd5b86356137608161344b565b955060208701356137708161344b565b945060408701356137808161344b565b959894975094956060810135955060808101359460a0909101359350915050565b80356137ac8161344b565b919050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156137e9576137e96137b1565b60405290565b604051601f8201601f191681016001600160401b0381118282101715613817576138176137b1565b604052919050565b60006001600160401b03821115613838576138386137b1565b50601f01601f191660200190565b600082601f83011261385757600080fd5b813561386a6138658261381f565b6137ef565b81815284602083860101111561387f57600080fd5b816020850160208301376000918101602001919091529392505050565b60006001600160401b038211156138b5576138b56137b1565b5060051b60200190565b600082601f8301126138d057600080fd5b813560206138e06138658361389c565b8083825260208201915060208460051b87010193508684111561390257600080fd5b602086015b8481101561392757803561391a8161344b565b8352918301918301613907565b509695505050505050565b600082601f83011261394357600080fd5b813560206139536138658361389c565b82815260059290921b8401810191818101908684111561397257600080fd5b8286015b848110156139275780356001600160401b038111156139955760008081fd5b6139a38986838b0101613846565b845250918301918301613976565b60008060008060008060008060006101208a8c0312156139d057600080fd5b6139d98a6137a1565b985060208a01356001600160401b03808211156139f557600080fd5b613a018d838e01613846565b995060408c0135915080821115613a1757600080fd5b613a238d838e01613846565b985060608c0135915080821115613a3957600080fd5b613a458d838e016138bf565b975060808c0135915080821115613a5b57600080fd5b613a678d838e01613932565b965060a08c0135915080821115613a7d57600080fd5b613a898d838e01613932565b955060c08c0135915080821115613a9f57600080fd5b613aab8d838e01613932565b945060e08c0135915080821115613ac157600080fd5b613acd8d838e01613932565b93506101008c0135915080821115613ae457600080fd5b50613af18c828d01613932565b9150509295985092959850929598565b600082825180855260208086019550808260051b84010181860160005b84811015613b8e57601f19868403018952815160a08151818652613b448287018261340c565b838801516001600160a01b03908116888a01526040808601519091169088015260608085015190880152608093840151939096019290925250509783019790830190600101613b1e565b5090979650505050505050565b60008282518085526020808601955060208260051b8401016020860160005b84811015613b8e57601f19868403018952613bd683835161340c565b98840198925090830190600101613bba565b60006080808352613bfc608084018861368d565b602084820381860152613c0f8289613b01565b9150604085830360408701528288518085528385019150838160051b860101848b0160005b83811015613ca557601f19888403018552815160a0815185528882015189860152878201518189870152613c6a82870182613648565b91505060608083015186830382880152613c848382613b9b565b938d01511515968d0196909652505094870194925090860190600101613c34565b505088810360608a0152613cb9818b6136be565b9d9c50505050505050505050505050565b85815284602082015260a060408201526000613ce960a0830186613648565b8281036060840152613cfb8186613b9b565b91505082151560808301529695505050505050565b604081526000613d236040830185613648565b8281036020840152613d35818561368d565b95945050505050565b606081526000613d516060830186613648565b8281036020840152613d63818661368d565b9050828103604084015261064b818561368d565b60a081526000613d8a60a0830188613648565b8281036020840152613d9c818861368d565b90508281036040840152613db081876136be565b60608401959095525050608001529392505050565b604081526000613dd8604083018561368d565b8281036020840152613d358185613b01565b801515811461346057600080fd5b600060208284031215613e0a57600080fd5b8135610b9e81613dea565b600181811c90821680613e2957607f821691505b602082108103613e4957634e487b7160e01b600052602260045260246000fd5b50919050565b60006020808385031215613e6257600080fd5b82516001600160401b03811115613e7857600080fd5b8301601f81018513613e8957600080fd5b8051613e976138658261389c565b81815260059190911b82018301908381019087831115613eb657600080fd5b928401925b82841015613edd578351613ece8161344b565b82529284019290840190613ebb565b979650505050505050565b600060208284031215613efa57600080fd5b8151610b9e8161344b565b600060208284031215613f1757600080fd5b5051919050565b60008060008060808587031215613f3457600080fd5b505082516020840151604085015160609095015191969095509092509050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561043857610438613f54565b808202811582820484141761043857610438613f54565b600082613fb157634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561043857610438613f54565b601f821115614015576000816000526020600020601f850160051c81016020861015613ff25750805b601f850160051c820191505b8181101561401157828155600101613ffe565b5050505b505050565b81516001600160401b03811115614033576140336137b1565b614047816140418454613e15565b84613fc9565b602080601f83116001811461407c57600084156140645750858301515b600019600386901b1c1916600185901b178555614011565b600085815260208120601f198616915b828110156140ab5788860151825594840194600190910190840161408c565b50858210156140c95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b600082601f83011261410057600080fd5b815161410e6138658261381f565b81815284602083860101111561412357600080fd5b6141348260208301602087016133e8565b949350505050565b600082601f83011261414d57600080fd5b8151602061415d6138658361389c565b82815260059290921b8401810191818101908684111561417c57600080fd5b8286015b848110156139275780516001600160401b03808211156141a05760008081fd5b9088019060a0828b03601f19018113156141ba5760008081fd5b6141c26137c7565b87840151838111156141d45760008081fd5b6141e28d8a838801016140ef565b82525060409250828401516141f68161344b565b818901526060848101516142098161344b565b9382019390935260808481015193820193909352920151908201528352918301918301614180565b6000806040838503121561424457600080fd5b82516001600160401b038082111561425b57600080fd5b818501915085601f83011261426f57600080fd5b8151602061427f6138658361389c565b82815260059290921b8401810191818101908984111561429e57600080fd5b948201945b838610156142bc578551825294820194908201906142a3565b918801519196509093505050808211156142d557600080fd5b506142e28582860161413c565b9150509250929050565b80516137ac81613dea565b6000806040838503121561430a57600080fd5b825161431581613dea565b6020939093015192949293505050565b60006020828403121561433757600080fd5b8151610b9e81613dea565b60006001820161435457614354613f54565b5060010190565b60006020828403121561436d57600080fd5b815160ff81168114610b9e57600080fd5b600082601f83011261438f57600080fd5b8151602061439f6138658361389c565b82815260059290921b840181019181810190868411156143be57600080fd5b8286015b848110156139275780516001600160401b038111156143e15760008081fd5b6143ef8986838b01016140ef565b8452509183019183016143c2565b600080600080600060a0868803121561441557600080fd5b85519450602080870151945060408701516001600160401b038082111561443b57600080fd5b818901915089601f83011261444f57600080fd5b815161445d6138658261389c565b81815260059190911b8301840190848101908c83111561447c57600080fd5b938501935b828510156144a35784516144948161344b565b82529385019390850190614481565b60608c015190985094505050808311156144bc57600080fd5b50506144ca8882890161437e565b9250506144d9608087016142ec565b90509295509295909350565b6000602082840312156144f757600080fd5b81516001600160401b0381111561450d57600080fd5b614134848285016140ef56fea2646970667358221220f0a13980ddfec3912a00add4529fd287eb3a29595ecef3f60ab7848c9e497d4a64736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101215760003560e01c806370733375116100ad578063c3530a6311610071578063c3530a63146102ac578063c41c2f24146102cd578063d0a164fb146102f8578063d64996e514610300578063ef88b53c1461031357600080fd5b8063707333751461022a578063798b97801461023d57806395d89b411461025e578063a079548714610266578063a505596a1461028857600080fd5b806327e16c1f116100f457806327e16c1f146101a85780633a1eb656146101bb57806351678684146101d057806357c89a7d146101f357806359d2fea61461020657600080fd5b806306fdde03146101265780630c5eb5a4146101445780631568683a146101645780631bb998ba14610187575b600080fd5b61012e610326565b60405161013b9190613438565b60405180910390f35b610157610152366004613463565b6103b4565b60405161013b919061349c565b61017761017236600461362b565b61043e565b60405161013b94939291906136f1565b61019a61019536600461373c565b610531565b60405190815260200161013b565b6101576101b636600461362b565b610655565b6101ce6101c93660046139b1565b6106c7565b005b6101e36101de36600461362b565b610ae9565b60405161013b9493929190613be8565b61019a610201366004613463565b610b8c565b61021961021436600461362b565b610ba5565b60405161013b959493929190613cca565b6101e361023836600461362b565b6112fe565b61025061024b36600461362b565b611310565b60405161013b929190613d10565b61012e611529565b61027961027436600461362b565b611536565b60405161013b93929190613d3e565b61029b61029636600461362b565b61190b565b60405161013b959493929190613d77565b6102bf6102ba36600461362b565b611af7565b60405161013b929190613dc5565b6005546102e0906001600160a01b031681565b6040516001600160a01b03909116815260200161013b565b6101e3611e4b565b6101e361030e366004613df8565b611ef0565b6101e361032136600461362b565b611f30565b6001805461033390613e15565b80601f016020809104026020016040519081016040528092919081815260200182805461035f90613e15565b80156103ac5780601f10610381576101008083540402835291602001916103ac565b820191906000526020600020905b81548152906001019060200180831161038f57829003601f168201915b505050505081565b604051632aff3bff60e21b81526001600160a01b03828116600483015260609160009161043491869182169063abfceffc90602401600060405180830381865afa158015610406573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261042e9190810190613e4f565b85611f70565b9150505b92915050565b6060806060600080856001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610484573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a89190613ee8565b90506104b48682612bee565b604051635881a44160e11b81526001600160a01b038a8116600483015293985091965094509082169063b103488290602401602060405180830381865afa158015610503573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105279190613f05565b9150509193509193565b604051637e361b1160e01b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052608482018390526000918291829182918291908c1690637e361b119060a401608060405180830381865afa1580156105a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c49190613f1e565b9350935093509350836000146105f55760405163255a0eef60e11b8152600481018590526024015b60405180910390fd5b801561062c576106058184613f6a565b61061784670de0b6b3a7640000613f7d565b6106219190613f94565b94505050505061064b565b8183116106415760001994505050505061064b565b6106058284613fb6565b9695505050505050565b606061043882836001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610699573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106c19190810190613e4f565b33611f70565b600054610100900460ff16158080156106e75750600054600160ff909116105b806107015750303b158015610701575060005460ff166001145b6107645760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105ec565b6000805460ff191660011790558015610787576000805461ff0019166101001790555b6001600160a01b038a166107f85760405162461bcd60e51b815260206004820152603260248201527f506f6f6c4469726563746f727920696e7374616e63652063616e6e6f74206265604482015271103a3432903d32b9379030b2323932b9b99760711b60648201526084016105ec565b8551875114801561080a575084518751145b6108655760405162461bcd60e51b815260206004820152602660248201527f48617264636f64656420616464726573736573206c656e67746873206e6f742060448201526532b8bab0b61760d11b60648201526084016105ec565b82518451148015610877575081518451145b6108d55760405162461bcd60e51b815260206004820152602960248201527f556e6973776170204c5020746f6b656e206e616d6573206c656e67746873206e60448201526837ba1032b8bab0b61760b91b60648201526084016105ec565b600580546001600160a01b0319166001600160a01b038c1617905560016108fc8a8261401a565b506002610909898261401a565b5060005b87518110156109c4576040518060400160405280888381518110610933576109336140d9565b60200260200101518152602001878381518110610952576109526140d9565b6020026020010151815250600360008a8481518110610973576109736140d9565b6020908102919091018101516001600160a01b03168252810191909152604001600020815181906109a4908261401a565b50602082015160018201906109b9908261401a565b50505060010161090d565b5060005b8451811015610a9657600460405180606001604052808784815181106109f0576109f06140d9565b60200260200101518152602001868481518110610a0f57610a0f6140d9565b60200260200101518152602001858481518110610a2e57610a2e6140d9565b6020908102919091018101519091528254600181018455600093845292208151919260030201908190610a61908261401a565b5060208201516001820190610a76908261401a565b5060408201516002820190610a8b908261401a565b5050506001016109c8565b508015610add576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6005546040516351f6c8e360e11b81526001600160a01b03838116600483015260609283928392839260009283929091169063a3ed91c6906024015b600060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b6a9190810190614231565b91509150600080610b7a83612ec7565b949a9399509750929550909350505050565b6000610b9e8284600080600080610531565b9392505050565b60008060608060008060009050600080886001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bf3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c1b9190810190613e4f565b9050600081516001600160401b03811115610c3857610c386137b1565b604051908082528060200260200182016040528015610c61578160200160208202803683370190505b509050600082516001600160401b03811115610c7f57610c7f6137b1565b604051908082528060200260200182016040528015610cb257816020015b6060815260200190600190039081610c9d5790505b50905060008b6001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cf5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d199190613ee8565b905060005b84518110156111f6576000858281518110610d3b57610d3b6140d9565b6020026020010151905060008e6001600160a01b0316638e8f294b836040518263ffffffff1660e01b8152600401610d8291906001600160a01b0391909116815260200190565b6040805180830381865afa158015610d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc291906142f7565b50905080610dd15750506111ee565b816001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e359190613f05565b506000826001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9a9190613f05565b90506000836001600160a01b0316639826394b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f009190613f05565b846001600160a01b03166361feacff6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f629190613f05565b856001600160a01b0316638f840ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc49190613f05565b610fce9190613f6a565b610fd89190613f6a565b82856001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103b9190613f05565b6110459190613f6a565b61104f9190613fb6565b60405163fc57d4df60e01b81526001600160a01b03868116600483015291925060009188169063fc57d4df90602401602060405180830381865afa15801561109b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bf9190613f05565b9050670de0b6b3a76400006110d48285613f7d565b6110de9190613f94565b6110e8908d613f6a565b9b50670de0b6b3a76400006110fd8284613f7d565b6111079190613f94565b611111908c613f6a565b9a50846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611151573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111759190613ee8565b898781518110611187576111876140d9565b60200260200101906001600160a01b031690816001600160a01b0316815250506111c98987815181106111bc576111bc6140d9565b60200260200101516130c4565b90508887815181106111dd576111dd6140d9565b602002602001018190525050505050505b600101610d1e565b506000600560009054906101000a90046001600160a01b03166001600160a01b03166343e20a1d8e6001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561125b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127f9190613ee8565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156112c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e79190614325565b959d969c50929a5090985092965092945050505050565b606080606080600080610b6a87611af7565b6060806000836001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611353573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261137b9190810190613e4f565b9050600081516001600160401b03811115611398576113986137b1565b6040519080825280602002602001820160405280156113c1578160200160208202803683370190505b509050600082516001600160401b038111156113df576113df6137b1565b604051908082528060200260200182016040528015611408578160200160208202803683370190505b50905060005b835181101561151d57838181518110611429576114296140d9565b6020026020010151838281518110611443576114436140d9565b60200260200101906001600160a01b031690816001600160a01b031681525050866001600160a01b0316632ccf47a4848381518110611484576114846140d9565b60200260200101516040518263ffffffff1660e01b81526004016114b791906001600160a01b0391909116815260200190565b602060405180830381865afa1580156114d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f89190613f05565b82828151811061150a5761150a6140d9565b602090810291909101015260010161140e565b50909590945092505050565b6002805461033390613e15565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561157b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115a39190810190613e4f565b9050600081516001600160401b038111156115c0576115c06137b1565b6040519080825280602002602001820160405280156115e9578160200160208202803683370190505b509050600082516001600160401b03811115611607576116076137b1565b604051908082528060200260200182016040528015611630578160200160208202803683370190505b509050600083516001600160401b0381111561164e5761164e6137b1565b604051908082528060200260200182016040528015611677578160200160208202803683370190505b50905060005b84518110156118fc57848181518110611698576116986140d9565b60200260200101518482815181106116b2576116b26140d9565b60200260200101906001600160a01b031690816001600160a01b031681525050886001600160a01b0316632ccf47a48583815181106116f3576116f36140d9565b60200260200101516040518263ffffffff1660e01b815260040161172691906001600160a01b0391909116815260200190565b602060405180830381865afa158015611743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117679190613f05565b838281518110611779576117796140d9565b6020026020010181815250506000858281518110611799576117996140d9565b60200260200101516001600160a01b0316634aeb3d9a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118029190613f05565b905060008a6001600160a01b031663fb6243fa878581518110611827576118276140d9565b60200260200101516040518263ffffffff1660e01b815260040161185a91906001600160a01b0391909116815260200190565b602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b9190613f05565b90508181106118c95760008484815181106118b8576118b86140d9565b6020026020010181815250506118f2565b6118d38183613fb6565b8484815181106118e5576118e56140d9565b6020026020010181815250505b505060010161167d565b50919790965090945092505050565b60608060606000806000866001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119779190613ee8565b90506119838782612bee565b604051635881a44160e11b81526001600160a01b038b8116600483015293995091975095509082169063b103488290602401602060405180830381865afa1580156119d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f69190613f05565b92506000876001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5c9190613f05565b604051631d3965af60e11b81526001600160a01b038a81166004830152919250600091841690633a72cb5e90602401602060405180830381865afa158015611aa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611acc9190613f05565b9050818110611ade5760009350611aeb565b611ae88183613fb6565b93505b50505091939590929450565b6060806000600560009054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b4f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b779190810190614231565b9150506000805b8251811015611c41576000838281518110611b9b57611b9b6140d9565b6020026020010151604001519050806001600160a01b0316639b19251a886040518263ffffffff1660e01b8152600401611be491906001600160a01b0391909116815260200190565b602060405180830381865afa158015611c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c259190614325565b15611c385782611c3481614342565b9350505b50600101611b7e565b506000816001600160401b03811115611c5c57611c5c6137b1565b604051908082528060200260200182016040528015611c85578160200160208202803683370190505b5090506000826001600160401b03811115611ca257611ca26137b1565b604051908082528060200260200182016040528015611d1757816020015b611d046040518060a001604052806060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b815260200190600190039081611cc05790505b5090506000805b8551811015611e3d576000868281518110611d3b57611d3b6140d9565b6020026020010151604001519050806001600160a01b0316639b19251a8b6040518263ffffffff1660e01b8152600401611d8491906001600160a01b0391909116815260200190565b602060405180830381865afa158015611da1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc59190614325565b15611e345781858481518110611ddd57611ddd6140d9565b602002602001018181525050868281518110611dfb57611dfb6140d9565b6020026020010151848481518110611e1557611e156140d9565b60200260200101819052508280611e2b90614342565b93505050611e3d565b50600101611d1e565b509197909650945050505050565b606080606080600080600560009054906101000a90046001600160a01b03166001600160a01b0316634ae26ea16040518163ffffffff1660e01b8152600401600060405180830381865afa158015611ea7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ecf9190810190614231565b91509150600080611edf83612ec7565b949993985096509294509092505050565b6005546040516310c51ddf60e11b8152821515600482015260609182918291829160009182916001600160a01b039091169063218a3bbe90602401610b25565b60055460405163f348960d60e01b81526001600160a01b03838116600483015260609283928392839260009283929091169063f348960d90602401610b25565b60606000805b8451811015612035576000866001600160a01b0316638e8f294b878481518110611fa257611fa26140d9565b60200260200101516040518263ffffffff1660e01b8152600401611fd591906001600160a01b0391909116815260200190565b6040805180830381865afa158015611ff1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201591906142f7565b509050801561202c578261202881614342565b9350505b50600101611f76565b506000816001600160401b03811115612050576120506137b1565b60405190808252806020026020018201604052801561208957816020015b612076613319565b81526020019060019003908161206e5790505b509050600080876001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f19190613ee8565b905060005b8751811015612be1576000808a6001600160a01b0316638e8f294b8b8581518110612123576121236140d9565b60200260200101516040518263ffffffff1660e01b815260040161215691906001600160a01b0391909116815260200190565b6040805180830381865afa158015612172573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219691906142f7565b91509150816121a6575050612bd9565b6121ae613319565b60008b85815181106121c2576121c26140d9565b6020908102919091018101516001600160a01b0381168085526040805163a6afed9560e01b81529051929450909263a6afed959260048084019382900301816000875af1158015612217573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223b9190613f05565b50806001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229e9190613ee8565b6001600160a01b0316602083018190526122b7816130c4565b84604001856060018290528290525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612305573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612329919061435b565b60ff1660808401526040516370a0823160e01b81526001600160a01b038d811660048301528216906370a0823190602401602060405180830381865afa158015612377573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239b9190613f05565b8360a0018181525050816001600160a01b031663ae9d70b06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124069190613f05565b8360c0018181525050816001600160a01b031663f8f9da286040518163ffffffff1660e01b8152600401602060405180830381865afa15801561244d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124719190613f05565b8360e0018181525050816001600160a01b0316633b1d21a26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124dc9190613f05565b83610180018181525050816001600160a01b03166373acee986040518163ffffffff1660e01b8152600401602060405180830381865afa158015612524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125489190613f05565b83610120018181525050816001600160a01b0316639826394b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612590573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b49190613f05565b826001600160a01b03166361feacff6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126169190613f05565b836001600160a01b0316638f840ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612654573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126789190613f05565b6126829190613f6a565b61268c9190613f6a565b8361012001518461018001516126a29190613f6a565b6126ac9190613fb6565b610100840152604051633af9e66960e01b81526001600160a01b038d81166004830152831690633af9e66990602401602060405180830381865afa1580156126f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271c9190613f05565b6101408401526040516305eff7ef60e21b81526001600160a01b038d811660048301528316906317bfdfbc90602401602060405180830381865afa158015612768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278c9190613f05565b61016084015260405163929fe9a160e01b81526001600160a01b038d8116600483015283811660248301528f169063929fe9a190604401602060405180830381865afa1580156127e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128049190614325565b15156101a08401526040805163bd6d894d60e01b815290516001600160a01b0384169163bd6d894d9160048083019260209291908290030181865afa158015612851573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128759190613f05565b6101c084015260208301516040516315d5220f60e31b81526001600160a01b0391821660048201529088169063aea9107890602401602060405180830381865afa1580156128c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128eb9190613f05565b6101e08401526001600160a01b038781166102008501819052602085015160405163addd509960e01b8152921660048301529063addd509990602401602060405180830381865afa925050508015612960575060408051601f3d908101601f1916820190925261295d91810190613ee8565b60015b15612975576001600160a01b03166102008401525b8383610220018181525050816001600160a01b031663173b99046040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e29190613f05565b83610240018181525050816001600160a01b0316638d02d9a16040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4e9190613f05565b83610260018181525050816001600160a01b031663c3bf11cd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aba9190613f05565b610280840152604051636d154ea560e01b81526001600160a01b0383811660048301528f1690636d154ea590602401602060405180830381865afa158015612b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2a9190614325565b15156102a084015260405163731f0c2b60e01b81526001600160a01b0383811660048301528f169063731f0c2b90602401602060405180830381865afa158015612b78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9c9190614325565b15156102c0840152885183908a908a908110612bba57612bba6140d9565b60200260200101819052508780612bd090614342565b98505050505050505b6001016120f6565b5091979650505050505050565b60608060606000846001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612c33573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612c5b9190810190613e4f565b905080516001600160401b03811115612c7657612c766137b1565b604051908082528060200260200182016040528015612c9f578160200160208202803683370190505b50935080516001600160401b03811115612cbb57612cbb6137b1565b604051908082528060200260200182016040528015612ce4578160200160208202803683370190505b50925080516001600160401b03811115612d0057612d006137b1565b604051908082528060200260200182016040528015612d29578160200160208202803683370190505b50915060005b8151811015612ebe576000828281518110612d4c57612d4c6140d9565b60200260200101519050876001600160a01b0316816001600160a01b031614612eb55780868381518110612d8257612d826140d9565b6001600160a01b03928316602091820292909201015260405163940cd6f160e01b8152898216600482015282821660248201529088169063940cd6f190604401602060405180830381865afa158015612ddf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e039190613f05565b858381518110612e1557612e156140d9565b6020908102919091010152604051631c819e4360e01b81526001600160a01b0389811660048301528281166024830152881690631c819e4390604401602060405180830381865afa158015612e6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e929190614325565b848381518110612ea457612ea46140d9565b911515602092830291909101909101525b50600101612d2f565b50509250925092565b606080600083516001600160401b03811115612ee557612ee56137b1565b604051908082528060200260200182016040528015612f4a57816020015b612f376040518060a00160405280600081526020016000815260200160608152602001606081526020016000151581525090565b815260200190600190039081612f035790505b509050600084516001600160401b03811115612f6857612f686137b1565b604051908082528060200260200182016040528015612f91578160200160208202803683370190505b50905060005b85518110156130b957306001600160a01b03166359d2fea6878381518110612fc157612fc16140d9565b6020026020010151604001516040518263ffffffff1660e01b8152600401612ff891906001600160a01b0391909116815260200190565b6000604051808303816000875af192505050801561303857506040513d6000823e601f3d908101601f1916820160405261303591908101906143fd565b60015b613065576001828281518110613050576130506140d9565b911515602092830291909101909101526130b1565b6040518060a001604052808681526020018581526020018481526020018381526020018215158152508887815181106130a0576130a06140d9565b602002602001018190525050505050505b600101612f97565b509094909350915050565b6001600160a01b0381166000908152600360205260409020600101805460609182916130ef90613e15565b159050613235576001600160a01b038316600090815260036020526040902080546001820190829061312090613e15565b80601f016020809104026020016040519081016040528092919081815260200182805461314c90613e15565b80156131995780601f1061316e57610100808354040283529160200191613199565b820191906000526020600020905b81548152906001019060200180831161317c57829003601f168201915b505050505091508080546131ac90613e15565b80601f01602080910402602001604051908101604052809291908181526020018280546131d890613e15565b80156132255780601f106131fa57610100808354040283529160200191613225565b820191906000526020600020905b81548152906001019060200180831161320857829003601f168201915b5050505050905091509150915091565b60008390506000816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561327a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526132a291908101906144e5565b90506000826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156132e4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261330c91908101906144e5565b9196919550909350505050565b604051806102e0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600015158152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b60005b838110156134035781810151838201526020016133eb565b50506000910152565b600081518084526134248160208601602086016133e8565b601f01601f19169290920160200192915050565b602081526000610b9e602083018461340c565b6001600160a01b038116811461346057600080fd5b50565b6000806040838503121561347657600080fd5b82356134818161344b565b915060208301356134918161344b565b809150509250929050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561361d57888303603f19018552815180516001600160a01b031684526102e0818901516001600160a01b038116868b0152508782015181898701526135108287018261340c565b9150506060808301518683038288015261352a838261340c565b6080858101519089015260a0808601519089015260c0808601519089015260e08086015190890152610100808601519089015261012080860151908901526101408086015190890152610160808601519089015261018080860151908901526101a0808601511515908901526101c080860151908901526101e08086015190890152610200808601516001600160a01b03169089015261022080860151908901526102408086015190890152610260808601519089015261028080860151908901526102a0808601511515908901526102c0948501511515949097019390935250505093860193908601906001016134c5565b509098975050505050505050565b60006020828403121561363d57600080fd5b8135610b9e8161344b565b60008151808452602080850194506020840160005b838110156136825781516001600160a01b03168752958201959082019060010161365d565b509495945050505050565b60008151808452602080850194506020840160005b83811015613682578151875295820195908201906001016136a2565b60008151808452602080850194506020840160005b838110156136825781511515875295820195908201906001016136d3565b6080815260006137046080830187613648565b8281036020840152613716818761368d565b9050828103604084015261372a81866136be565b91505082606083015295945050505050565b60008060008060008060c0878903121561375557600080fd5b86356137608161344b565b955060208701356137708161344b565b945060408701356137808161344b565b959894975094956060810135955060808101359460a0909101359350915050565b80356137ac8161344b565b919050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b03811182821017156137e9576137e96137b1565b60405290565b604051601f8201601f191681016001600160401b0381118282101715613817576138176137b1565b604052919050565b60006001600160401b03821115613838576138386137b1565b50601f01601f191660200190565b600082601f83011261385757600080fd5b813561386a6138658261381f565b6137ef565b81815284602083860101111561387f57600080fd5b816020850160208301376000918101602001919091529392505050565b60006001600160401b038211156138b5576138b56137b1565b5060051b60200190565b600082601f8301126138d057600080fd5b813560206138e06138658361389c565b8083825260208201915060208460051b87010193508684111561390257600080fd5b602086015b8481101561392757803561391a8161344b565b8352918301918301613907565b509695505050505050565b600082601f83011261394357600080fd5b813560206139536138658361389c565b82815260059290921b8401810191818101908684111561397257600080fd5b8286015b848110156139275780356001600160401b038111156139955760008081fd5b6139a38986838b0101613846565b845250918301918301613976565b60008060008060008060008060006101208a8c0312156139d057600080fd5b6139d98a6137a1565b985060208a01356001600160401b03808211156139f557600080fd5b613a018d838e01613846565b995060408c0135915080821115613a1757600080fd5b613a238d838e01613846565b985060608c0135915080821115613a3957600080fd5b613a458d838e016138bf565b975060808c0135915080821115613a5b57600080fd5b613a678d838e01613932565b965060a08c0135915080821115613a7d57600080fd5b613a898d838e01613932565b955060c08c0135915080821115613a9f57600080fd5b613aab8d838e01613932565b945060e08c0135915080821115613ac157600080fd5b613acd8d838e01613932565b93506101008c0135915080821115613ae457600080fd5b50613af18c828d01613932565b9150509295985092959850929598565b600082825180855260208086019550808260051b84010181860160005b84811015613b8e57601f19868403018952815160a08151818652613b448287018261340c565b838801516001600160a01b03908116888a01526040808601519091169088015260608085015190880152608093840151939096019290925250509783019790830190600101613b1e565b5090979650505050505050565b60008282518085526020808601955060208260051b8401016020860160005b84811015613b8e57601f19868403018952613bd683835161340c565b98840198925090830190600101613bba565b60006080808352613bfc608084018861368d565b602084820381860152613c0f8289613b01565b9150604085830360408701528288518085528385019150838160051b860101848b0160005b83811015613ca557601f19888403018552815160a0815185528882015189860152878201518189870152613c6a82870182613648565b91505060608083015186830382880152613c848382613b9b565b938d01511515968d0196909652505094870194925090860190600101613c34565b505088810360608a0152613cb9818b6136be565b9d9c50505050505050505050505050565b85815284602082015260a060408201526000613ce960a0830186613648565b8281036060840152613cfb8186613b9b565b91505082151560808301529695505050505050565b604081526000613d236040830185613648565b8281036020840152613d35818561368d565b95945050505050565b606081526000613d516060830186613648565b8281036020840152613d63818661368d565b9050828103604084015261064b818561368d565b60a081526000613d8a60a0830188613648565b8281036020840152613d9c818861368d565b90508281036040840152613db081876136be565b60608401959095525050608001529392505050565b604081526000613dd8604083018561368d565b8281036020840152613d358185613b01565b801515811461346057600080fd5b600060208284031215613e0a57600080fd5b8135610b9e81613dea565b600181811c90821680613e2957607f821691505b602082108103613e4957634e487b7160e01b600052602260045260246000fd5b50919050565b60006020808385031215613e6257600080fd5b82516001600160401b03811115613e7857600080fd5b8301601f81018513613e8957600080fd5b8051613e976138658261389c565b81815260059190911b82018301908381019087831115613eb657600080fd5b928401925b82841015613edd578351613ece8161344b565b82529284019290840190613ebb565b979650505050505050565b600060208284031215613efa57600080fd5b8151610b9e8161344b565b600060208284031215613f1757600080fd5b5051919050565b60008060008060808587031215613f3457600080fd5b505082516020840151604085015160609095015191969095509092509050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561043857610438613f54565b808202811582820484141761043857610438613f54565b600082613fb157634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561043857610438613f54565b601f821115614015576000816000526020600020601f850160051c81016020861015613ff25750805b601f850160051c820191505b8181101561401157828155600101613ffe565b5050505b505050565b81516001600160401b03811115614033576140336137b1565b614047816140418454613e15565b84613fc9565b602080601f83116001811461407c57600084156140645750858301515b600019600386901b1c1916600185901b178555614011565b600085815260208120601f198616915b828110156140ab5788860151825594840194600190910190840161408c565b50858210156140c95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b600082601f83011261410057600080fd5b815161410e6138658261381f565b81815284602083860101111561412357600080fd5b6141348260208301602087016133e8565b949350505050565b600082601f83011261414d57600080fd5b8151602061415d6138658361389c565b82815260059290921b8401810191818101908684111561417c57600080fd5b8286015b848110156139275780516001600160401b03808211156141a05760008081fd5b9088019060a0828b03601f19018113156141ba5760008081fd5b6141c26137c7565b87840151838111156141d45760008081fd5b6141e28d8a838801016140ef565b82525060409250828401516141f68161344b565b818901526060848101516142098161344b565b9382019390935260808481015193820193909352920151908201528352918301918301614180565b6000806040838503121561424457600080fd5b82516001600160401b038082111561425b57600080fd5b818501915085601f83011261426f57600080fd5b8151602061427f6138658361389c565b82815260059290921b8401810191818101908984111561429e57600080fd5b948201945b838610156142bc578551825294820194908201906142a3565b918801519196509093505050808211156142d557600080fd5b506142e28582860161413c565b9150509250929050565b80516137ac81613dea565b6000806040838503121561430a57600080fd5b825161431581613dea565b6020939093015192949293505050565b60006020828403121561433757600080fd5b8151610b9e81613dea565b60006001820161435457614354613f54565b5060010190565b60006020828403121561436d57600080fd5b815160ff81168114610b9e57600080fd5b600082601f83011261438f57600080fd5b8151602061439f6138658361389c565b82815260059290921b840181019181810190868411156143be57600080fd5b8286015b848110156139275780516001600160401b038111156143e15760008081fd5b6143ef8986838b01016140ef565b8452509183019183016143c2565b600080600080600060a0868803121561441557600080fd5b85519450602080870151945060408701516001600160401b038082111561443b57600080fd5b818901915089601f83011261444f57600080fd5b815161445d6138658261389c565b81815260059190911b8301840190848101908c83111561447c57600080fd5b938501935b828510156144a35784516144948161344b565b82529385019390850190614481565b60608c015190985094505050808311156144bc57600080fd5b50506144ca8882890161437e565b9250506144d9608087016142ec565b90509295509295909350565b6000602082840312156144f757600080fd5b81516001600160401b0381111561450d57600080fd5b614134848285016140ef56fea2646970667358221220f0a13980ddfec3912a00add4529fd287eb3a29595ecef3f60ab7848c9e497d4a64736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "getBorrowCapsDataForAsset(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getBorrowCapsForAsset(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getPoolAssetsByUser(address,address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getPoolAssetsWithData(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.", + "params": { + "comptroller": "The Comptroller proxy contract of the Ionic pool." + }, + "returns": { + "_0": "An array of Ionic pool assets." + } + }, + "getPoolsByAccountWithData(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "getPoolsOIonicrWithData(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "getPublicPoolsByVerificationWithData(bool)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "getPublicPoolsWithData()": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "getSupplyCapsDataForPool(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getSupplyCapsForPool(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getWhitelistedPoolsByAccount(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getWhitelistedPoolsByAccountWithData(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "initialize(address,string,string,address[],string[],string[],string[],string[],string[])": { + "params": { + "_directory": "The PoolDirectory", + "_hardcodedAddresses": "Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`", + "_hardcodedNames": "Harcoded name for these tokens", + "_hardcodedSymbols": "Harcoded symbol for these tokens", + "_name": "Name for the nativeToken", + "_symbol": "Symbol for the nativeToken", + "_uniswapLPTokenDisplayNames": "Harcoded display names for underlying uniswap LpToken", + "_uniswapLPTokenNames": "Harcoded names for underlying uniswap LpToken", + "_uniswapLPTokenSymbols": "Harcoded symbols for underlying uniswap LpToken" + } + } + }, + "title": "PoolLens", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "directory()": { + "notice": "`PoolDirectory` contract object." + }, + "getBorrowCapsDataForAsset(address)": { + "notice": "returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows" + }, + "getBorrowCapsForAsset(address)": { + "notice": "returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset" + }, + "getPoolAssetsByUser(address,address)": { + "notice": "Returns arrays of PoolAsset for a specific user" + }, + "getPoolAssetsWithData(address)": { + "notice": "Returns the assets of the specified Ionic pool." + }, + "getPoolSummary(address)": { + "notice": "Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool." + }, + "getPoolsByAccountWithData(address)": { + "notice": "Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed." + }, + "getPoolsOIonicrWithData(address)": { + "notice": "Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed." + }, + "getPublicPoolsByVerificationWithData(bool)": { + "notice": "Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed." + }, + "getPublicPoolsWithData()": { + "notice": "Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed." + }, + "getSupplyCapsDataForPool(address)": { + "notice": "returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets" + }, + "getSupplyCapsForPool(address)": { + "notice": "returns the total supply cap for each asset in the pool" + }, + "getWhitelistedPoolsByAccount(address)": { + "notice": "Returns arrays of Ionic pool indexes and data with a whitelist containing `account`. Note that the whitelist does not have to be enforced." + }, + "getWhitelistedPoolsByAccountWithData(address)": { + "notice": "Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed." + }, + "initialize(address,string,string,address[],string[],string[],string[],string[],string[])": { + "notice": "Initialize the `PoolDirectory` contract object." + } + }, + "notice": "PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 14935, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "name", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 14937, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "symbol", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 14947, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "hardcoded", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_struct(TokenData)14942_storage)" + }, + { + "astId": 14958, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "uniswapData", + "offset": 0, + "slot": "4", + "type": "t_array(t_struct(UniswapData)14954_storage)dyn_storage" + }, + { + "astId": 14962, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "directory", + "offset": 0, + "slot": "5", + "type": "t_contract(PoolDirectory)14768" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(UniswapData)14954_storage)dyn_storage": { + "base": "t_struct(UniswapData)14954_storage", + "encoding": "dynamic_array", + "label": "struct PoolLens.UniswapData[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(PoolDirectory)14768": { + "encoding": "inplace", + "label": "contract PoolDirectory", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_struct(TokenData)14942_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct PoolLens.TokenData)", + "numberOfBytes": "32", + "value": "t_struct(TokenData)14942_storage" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(TokenData)14942_storage": { + "encoding": "inplace", + "label": "struct PoolLens.TokenData", + "members": [ + { + "astId": 14939, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "name", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 14941, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "symbol", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(UniswapData)14954_storage": { + "encoding": "inplace", + "label": "struct PoolLens.UniswapData", + "members": [ + { + "astId": 14949, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "name", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 14951, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "symbol", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 14953, + "contract": "contracts/PoolLens.sol:PoolLens", + "label": "displayName", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + } + ], + "numberOfBytes": "96" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/PoolLensSecondary.json b/packages/contracts/deployments/superseed/PoolLensSecondary.json new file mode 100644 index 0000000000..67531e856f --- /dev/null +++ b/packages/contracts/deployments/superseed/PoolLensSecondary.json @@ -0,0 +1,491 @@ +{ + "address": "0x5f0369AA93f36cA6a8B5ed7aAc47bf9e76086D03", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "directory", + "outputs": [ + { + "internalType": "contract PoolDirectory", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getFlywheelsToClaim", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "contract IonicComptroller[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[][]", + "name": "", + "type": "address[][]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenModify", + "type": "address" + } + ], + "name": "getMaxBorrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "contract ICErc20", + "name": "cTokenModify", + "type": "address" + } + ], + "name": "getMaxRedeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getPoolOwnership", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "cToken", + "type": "address" + }, + { + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "internalType": "bool", + "name": "adminHasRights", + "type": "bool" + }, + { + "internalType": "bool", + "name": "ionicAdminHasRights", + "type": "bool" + } + ], + "internalType": "struct PoolLensSecondary.CTokenOwnership[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller", + "name": "comptroller", + "type": "address" + } + ], + "name": "getRewardSpeedsByPool", + "outputs": [ + { + "internalType": "contract ICErc20[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[][]", + "name": "", + "type": "uint256[][]" + }, + { + "internalType": "uint256[][]", + "name": "", + "type": "uint256[][]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IonicComptroller[]", + "name": "comptrollers", + "type": "address[]" + } + ], + "name": "getRewardSpeedsByPools", + "outputs": [ + { + "internalType": "contract ICErc20[][]", + "name": "", + "type": "address[][]" + }, + { + "internalType": "address[][]", + "name": "", + "type": "address[][]" + }, + { + "internalType": "address[][]", + "name": "", + "type": "address[][]" + }, + { + "internalType": "uint256[][][]", + "name": "", + "type": "uint256[][][]" + }, + { + "internalType": "uint256[][][]", + "name": "", + "type": "uint256[][][]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "supplier", + "type": "address" + } + ], + "name": "getRewardsDistributorsBySupplier", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "contract IonicComptroller[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "address[][]", + "name": "", + "type": "address[][]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "contract IRewardsDistributor_PLS[]", + "name": "distributors", + "type": "address[]" + } + ], + "name": "getUnclaimedRewardsByDistributors", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "contract ICErc20[][]", + "name": "", + "type": "address[][]" + }, + { + "internalType": "uint256[2][][]", + "name": "", + "type": "uint256[2][][]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract PoolDirectory", + "name": "_directory", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x278450f337daede985d60a5e895255c178e347a5849de83aa0ce2a256905ad10", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x5f0369AA93f36cA6a8B5ed7aAc47bf9e76086D03", + "transactionIndex": 1, + "gasUsed": "2607416", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x10a2f247b9648aa39ef6d5297a1897680e7a504bc47f1ffc105d4849876e578b", + "transactionHash": "0x278450f337daede985d60a5e895255c178e347a5849de83aa0ce2a256905ad10", + "logs": [], + "blockNumber": 4135358, + "cumulativeGasUsed": "2662482", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"directory\",\"outputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getFlywheelsToClaim\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"contract IonicComptroller[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[][]\",\"name\":\"\",\"type\":\"address[][]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenModify\",\"type\":\"address\"}],\"name\":\"getMaxBorrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract ICErc20\",\"name\":\"cTokenModify\",\"type\":\"address\"}],\"name\":\"getMaxRedeem\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getPoolOwnership\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"adminHasRights\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"ionicAdminHasRights\",\"type\":\"bool\"}],\"internalType\":\"struct PoolLensSecondary.CTokenOwnership[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller\",\"name\":\"comptroller\",\"type\":\"address\"}],\"name\":\"getRewardSpeedsByPool\",\"outputs\":[{\"internalType\":\"contract ICErc20[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[][]\",\"name\":\"\",\"type\":\"uint256[][]\"},{\"internalType\":\"uint256[][]\",\"name\":\"\",\"type\":\"uint256[][]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IonicComptroller[]\",\"name\":\"comptrollers\",\"type\":\"address[]\"}],\"name\":\"getRewardSpeedsByPools\",\"outputs\":[{\"internalType\":\"contract ICErc20[][]\",\"name\":\"\",\"type\":\"address[][]\"},{\"internalType\":\"address[][]\",\"name\":\"\",\"type\":\"address[][]\"},{\"internalType\":\"address[][]\",\"name\":\"\",\"type\":\"address[][]\"},{\"internalType\":\"uint256[][][]\",\"name\":\"\",\"type\":\"uint256[][][]\"},{\"internalType\":\"uint256[][][]\",\"name\":\"\",\"type\":\"uint256[][][]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"supplier\",\"type\":\"address\"}],\"name\":\"getRewardsDistributorsBySupplier\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"contract IonicComptroller[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"address[][]\",\"name\":\"\",\"type\":\"address[][]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"contract IRewardsDistributor_PLS[]\",\"name\":\"distributors\",\"type\":\"address[]\"}],\"name\":\"getUnclaimedRewardsByDistributors\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"contract ICErc20[][]\",\"name\":\"\",\"type\":\"address[][]\"},{\"internalType\":\"uint256[2][][]\",\"name\":\"\",\"type\":\"uint256[2][][]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract PoolDirectory\",\"name\":\"_directory\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"David Lucid (https://github.com/davidlucid)\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"getFlywheelsToClaim(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getMaxBorrow(address,address)\":{\"params\":{\"account\":\"The account to determine liquidity for.\",\"cTokenModify\":\"The market to hypothetically borrow in.\"},\"returns\":{\"_0\":\"Maximum borrow amount.\"}},\"getMaxRedeem(address,address)\":{\"params\":{\"account\":\"The account to determine liquidity for.\",\"cTokenModify\":\"The market to hypothetically redeem in.\"},\"returns\":{\"_0\":\"Maximum redeem amount.\"}},\"getPoolOwnership(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\"},\"getRewardSpeedsByPool(address)\":{\"params\":{\"comptroller\":\"The Ionic pool Comptroller to check.\"}},\"getRewardSpeedsByPools(address[])\":{\"params\":{\"comptrollers\":\"The Ionic pool Comptrollers to check.\"}},\"getRewardsDistributorsBySupplier(address)\":{\"details\":\"This function is not designed to be called in a transaction: it is too gas-intensive.\"},\"getUnclaimedRewardsByDistributors(address,address[])\":{\"params\":{\"distributors\":\"The `RewardsDistributor` contracts to check.\",\"holder\":\"The address to check.\"},\"returns\":{\"_0\":\"For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\"}}},\"title\":\"PoolLensSecondary\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"directory()\":{\"notice\":\"`PoolDirectory` contract object.\"},\"getFlywheelsToClaim(address)\":{\"notice\":\"The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\"},\"getMaxBorrow(address,address)\":{\"notice\":\"Determine the maximum borrow amount of a cToken.\"},\"getMaxRedeem(address,address)\":{\"notice\":\"Determine the maximum redeem amount of a cToken.\"},\"getPoolOwnership(address)\":{\"notice\":\"Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\"},\"getRewardSpeedsByPool(address)\":{\"notice\":\"Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\"},\"getRewardSpeedsByPools(address[])\":{\"notice\":\"For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\"},\"getRewardsDistributorsBySupplier(address)\":{\"notice\":\"Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\"},\"getUnclaimedRewardsByDistributors(address,address[])\":{\"notice\":\"Returns all unclaimed rewards accrued by the `holder` on `distributors`.\"},\"initialize(address)\":{\"notice\":\"Constructor to set the `PoolDirectory` contract object.\"}},\"notice\":\"PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/PoolLensSecondary.sol\":\"PoolLensSecondary\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/PoolDirectory.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { BasePriceOracle } from \\\"./oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./compound/Unitroller.sol\\\";\\nimport \\\"./ionic/SafeOwnableUpgradeable.sol\\\";\\nimport \\\"./ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title PoolDirectory\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\\n */\\ncontract PoolDirectory is SafeOwnableUpgradeable {\\n /**\\n * @dev Initializes a deployer whitelist if desired.\\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\\n */\\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\\n __SafeOwnable_init(msg.sender);\\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\\n }\\n\\n /**\\n * @dev Struct for a Ionic interest rate pool.\\n */\\n struct Pool {\\n string name;\\n address creator;\\n address comptroller;\\n uint256 blockPosted;\\n uint256 timestampPosted;\\n }\\n\\n /**\\n * @dev Array of Ionic interest rate pools.\\n */\\n Pool[] public pools;\\n\\n /**\\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\\n */\\n mapping(address => uint256[]) private _poolsByAccount;\\n\\n /**\\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\\n */\\n mapping(address => bool) public poolExists;\\n\\n /**\\n * @dev Emitted when a new Ionic pool is added to the directory.\\n */\\n event PoolRegistered(uint256 index, Pool pool);\\n\\n /**\\n * @dev Booleans indicating if the deployer whitelist is enforced.\\n */\\n bool public enforceDeployerWhitelist;\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\\n */\\n mapping(address => bool) public deployerWhitelist;\\n\\n /**\\n * @dev Controls if the deployer whitelist is to be enforced.\\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\\n */\\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\\n enforceDeployerWhitelist = enforce;\\n }\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\\n * @param deployers Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\\n require(deployers.length > 0, \\\"No deployers supplied.\\\");\\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\\n }\\n\\n /**\\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\\n * @param name The name of the pool.\\n * @param comptroller The pool's Comptroller proxy contract address.\\n * @return The index of the registered Ionic pool.\\n */\\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\\n require(!poolExists[comptroller], \\\"Pool already exists in the directory.\\\");\\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \\\"Sender is not on deployer whitelist.\\\");\\n require(bytes(name).length <= 100, \\\"No pool name supplied.\\\");\\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\\n pools.push(pool);\\n _poolsByAccount[msg.sender].push(pools.length - 1);\\n poolExists[comptroller] = true;\\n emit PoolRegistered(pools.length - 1, pool);\\n return pools.length - 1;\\n }\\n\\n function _deprecatePool(address comptroller) external onlyOwner {\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller == comptroller) {\\n _deprecatePool(i);\\n break;\\n }\\n }\\n }\\n\\n function _deprecatePool(uint256 index) public onlyOwner {\\n Pool storage ionicPool = pools[index];\\n\\n require(ionicPool.comptroller != address(0), \\\"pool already deprecated\\\");\\n\\n // swap with the last pool of the creator and delete\\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\\n for (uint256 i = 0; i < creatorPools.length; i++) {\\n if (creatorPools[i] == index) {\\n creatorPools[i] = creatorPools[creatorPools.length - 1];\\n creatorPools.pop();\\n break;\\n }\\n }\\n\\n // leave it to true to deny the re-registering of the same pool\\n poolExists[ionicPool.comptroller] = true;\\n\\n // nullify the storage\\n ionicPool.comptroller = address(0);\\n ionicPool.creator = address(0);\\n ionicPool.name = \\\"\\\";\\n ionicPool.blockPosted = 0;\\n ionicPool.timestampPosted = 0;\\n }\\n\\n /**\\n * @dev Deploys a new Ionic pool and adds to the directory.\\n * @param name The name of the pool.\\n * @param implementation The Comptroller implementation contract address.\\n * @param constructorData Encoded construction data for `Unitroller constructor()`\\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\\n * @param closeFactor The pool's close factor (scaled by 1e18).\\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\\n * @param priceOracle The pool's PriceOracle contract address.\\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\\n */\\n function deployPool(\\n string memory name,\\n address implementation,\\n bytes calldata constructorData,\\n bool enforceWhitelist,\\n uint256 closeFactor,\\n uint256 liquidationIncentive,\\n address priceOracle\\n ) external returns (uint256, address) {\\n // Input validation\\n require(implementation != address(0), \\\"No Comptroller implementation contract address specified.\\\");\\n require(priceOracle != address(0), \\\"No PriceOracle contract address specified.\\\");\\n\\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\\n address proxy = Create2Upgradeable.deploy(\\n 0,\\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\\n unitrollerCreationCode\\n );\\n\\n // Setup the pool\\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\\n // Set up the extensions\\n comptrollerProxy._upgrade();\\n\\n // Set pool parameters\\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \\\"Failed to set pool close factor.\\\");\\n require(\\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\\n \\\"Failed to set pool liquidation incentive.\\\"\\n );\\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \\\"Failed to set pool price oracle.\\\");\\n\\n // Whitelist\\n if (enforceWhitelist)\\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \\\"Failed to enforce supplier/borrower whitelist.\\\");\\n\\n // Make msg.sender the admin\\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \\\"Failed to set pending admin on Unitroller.\\\");\\n\\n // Register the pool with this PoolDirectory\\n return (_registerPool(name, proxy), proxy);\\n }\\n\\n /**\\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory activePools = new Pool[](count);\\n uint256[] memory poolIds = new uint256[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n poolIds[index] = i;\\n activePools[index] = pools[i];\\n index++;\\n }\\n }\\n\\n return (poolIds, activePools);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pools' data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getAllPools() public view returns (Pool[] memory) {\\n uint256 count = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) count++;\\n }\\n\\n Pool[] memory result = new Pool[](count);\\n\\n uint256 index = 0;\\n for (uint256 i = 0; i < pools.length; i++) {\\n if (pools[i].comptroller != address(0)) {\\n result[index++] = pools[i];\\n }\\n }\\n\\n return result;\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\\n if (enforceWhitelist) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all public Ionic pool indexes and data.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\\n if (!isUsing) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n poolsOfUser[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, poolsOfUser);\\n }\\n\\n /**\\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\\n */\\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\\n (, Pool[] memory activePools) = getActivePools();\\n\\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\\n indexes[i] = _poolsByAccount[account][i];\\n accountPools[i] = activePools[_poolsByAccount[account][i]];\\n }\\n\\n return (indexes, accountPools);\\n }\\n\\n /**\\n * @notice Modify existing Ionic pool name.\\n */\\n function setPoolName(uint256 index, string calldata name) external {\\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\\n require(\\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\\n \\\"!permission\\\"\\n );\\n pools[index].name = name;\\n }\\n\\n /**\\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\\n */\\n mapping(address => bool) public adminWhitelist;\\n\\n /**\\n * @dev used as salt for the creation of new pools\\n */\\n uint256 public poolsCounter;\\n\\n /**\\n * @dev Event emitted when the admin whitelist is updated.\\n */\\n event AdminWhitelistUpdated(address[] admins, bool status);\\n\\n /**\\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\\n * @param admins Array of Ethereum accounts to be whitelisted.\\n * @param status Whether to add or remove the accounts.\\n */\\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\\n require(admins.length > 0, \\\"No admins supplied.\\\");\\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\\n emit AdminWhitelistUpdated(admins, status);\\n }\\n\\n /**\\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\\n uint256 arrayLength = 0;\\n\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory publicPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.admin() returns (address admin) {\\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n publicPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, publicPools);\\n }\\n\\n /**\\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getVerifiedPoolsOfWhitelistedAccount(address account)\\n external\\n view\\n returns (uint256[] memory, Pool[] memory)\\n {\\n uint256 arrayLength = 0;\\n (, Pool[] memory activePools) = getActivePools();\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n arrayLength++;\\n }\\n\\n uint256[] memory indexes = new uint256[](arrayLength);\\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < activePools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\\n } catch {}\\n\\n indexes[index] = i;\\n accountWhitelistedPools[index] = activePools[i];\\n index++;\\n }\\n\\n return (indexes, accountWhitelistedPools);\\n }\\n}\\n\",\"keccak256\":\"0xd3d28cd044a0205a86f0c2d82021a36018ec4b0e95f72064c92bcad99f84f6c8\",\"license\":\"UNLICENSED\"},\"contracts/PoolLensSecondary.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\n\\nimport { IonicComptroller } from \\\"./compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20 } from \\\"./compound/CTokenInterfaces.sol\\\";\\nimport { IUniswapV2Pair } from \\\"./external/uniswap/IUniswapV2Pair.sol\\\";\\n\\nimport { PoolDirectory } from \\\"./PoolDirectory.sol\\\";\\n\\ninterface IRewardsDistributor_PLS {\\n function rewardToken() external view returns (address);\\n\\n function compSupplySpeeds(address) external view returns (uint256);\\n\\n function compBorrowSpeeds(address) external view returns (uint256);\\n\\n function compAccrued(address) external view returns (uint256);\\n\\n function flywheelPreSupplierAction(address cToken, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n}\\n\\n/**\\n * @title PoolLensSecondary\\n * @author David Lucid (https://github.com/davidlucid)\\n * @notice PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\\n */\\ncontract PoolLensSecondary is Initializable {\\n /**\\n * @notice Constructor to set the `PoolDirectory` contract object.\\n */\\n function initialize(PoolDirectory _directory) public initializer {\\n require(address(_directory) != address(0), \\\"PoolDirectory instance cannot be the zero address.\\\");\\n directory = _directory;\\n }\\n\\n /**\\n * @notice `PoolDirectory` contract object.\\n */\\n PoolDirectory public directory;\\n\\n /**\\n * @notice Struct for ownership over a CToken.\\n */\\n struct CTokenOwnership {\\n address cToken;\\n address admin;\\n bool adminHasRights;\\n bool ionicAdminHasRights;\\n }\\n\\n /**\\n * @notice Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\\n */\\n function getPoolOwnership(IonicComptroller comptroller)\\n external\\n view\\n returns (\\n address,\\n bool,\\n bool,\\n CTokenOwnership[] memory\\n )\\n {\\n // Get pool ownership\\n address comptrollerAdmin = comptroller.admin();\\n bool comptrollerAdminHasRights = comptroller.adminHasRights();\\n bool comptrollerIonicAdminHasRights = comptroller.ionicAdminHasRights();\\n\\n // Get cToken ownership\\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n\\n address cTokenAdmin;\\n try cToken.admin() returns (address _cTokenAdmin) {\\n cTokenAdmin = _cTokenAdmin;\\n } catch {\\n continue;\\n }\\n bool cTokenAdminHasRights = cToken.adminHasRights();\\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\\n\\n // If outlier, push to array\\n if (\\n cTokenAdmin != comptrollerAdmin ||\\n cTokenAdminHasRights != comptrollerAdminHasRights ||\\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\\n ) arrayLength++;\\n }\\n\\n CTokenOwnership[] memory outliers = new CTokenOwnership[](arrayLength);\\n uint256 arrayIndex = 0;\\n\\n for (uint256 i = 0; i < cTokens.length; i++) {\\n ICErc20 cToken = cTokens[i];\\n (bool isListed, ) = comptroller.markets(address(cToken));\\n if (!isListed) continue;\\n\\n address cTokenAdmin;\\n try cToken.admin() returns (address _cTokenAdmin) {\\n cTokenAdmin = _cTokenAdmin;\\n } catch {\\n continue;\\n }\\n bool cTokenAdminHasRights = cToken.adminHasRights();\\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\\n\\n // If outlier, push to array and increment array index\\n if (\\n cTokenAdmin != comptrollerAdmin ||\\n cTokenAdminHasRights != comptrollerAdminHasRights ||\\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\\n ) {\\n outliers[arrayIndex] = CTokenOwnership(\\n address(cToken),\\n cTokenAdmin,\\n cTokenAdminHasRights,\\n cTokenIonicAdminHasRights\\n );\\n arrayIndex++;\\n }\\n }\\n\\n return (comptrollerAdmin, comptrollerAdminHasRights, comptrollerIonicAdminHasRights, outliers);\\n }\\n\\n /**\\n * @notice Determine the maximum redeem amount of a cToken.\\n * @param cTokenModify The market to hypothetically redeem in.\\n * @param account The account to determine liquidity for.\\n * @return Maximum redeem amount.\\n */\\n function getMaxRedeem(address account, ICErc20 cTokenModify) external returns (uint256) {\\n return getMaxRedeemOrBorrow(account, cTokenModify, false);\\n }\\n\\n /**\\n * @notice Determine the maximum borrow amount of a cToken.\\n * @param cTokenModify The market to hypothetically borrow in.\\n * @param account The account to determine liquidity for.\\n * @return Maximum borrow amount.\\n */\\n function getMaxBorrow(address account, ICErc20 cTokenModify) external returns (uint256) {\\n return getMaxRedeemOrBorrow(account, cTokenModify, true);\\n }\\n\\n /**\\n * @dev Internal function to determine the maximum borrow/redeem amount of a cToken.\\n * @param cTokenModify The market to hypothetically borrow/redeem in.\\n * @param account The account to determine liquidity for.\\n * @return Maximum borrow/redeem amount.\\n */\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal returns (uint256) {\\n IonicComptroller comptroller = IonicComptroller(cTokenModify.comptroller());\\n return comptroller.getMaxRedeemOrBorrow(account, cTokenModify, isBorrow);\\n }\\n\\n /**\\n * @notice Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\\n * @param comptroller The Ionic pool Comptroller to check.\\n */\\n function getRewardSpeedsByPool(IonicComptroller comptroller)\\n public\\n view\\n returns (\\n ICErc20[] memory,\\n address[] memory,\\n address[] memory,\\n uint256[][] memory,\\n uint256[][] memory\\n )\\n {\\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\\n address[] memory distributors;\\n\\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\\n distributors = _distributors;\\n } catch {\\n distributors = new address[](0);\\n }\\n\\n address[] memory rewardTokens = new address[](distributors.length);\\n uint256[][] memory supplySpeeds = new uint256[][](allMarkets.length);\\n uint256[][] memory borrowSpeeds = new uint256[][](allMarkets.length);\\n\\n // Get reward tokens for each distributor\\n for (uint256 i = 0; i < distributors.length; i++) {\\n rewardTokens[i] = IRewardsDistributor_PLS(distributors[i]).rewardToken();\\n }\\n\\n // Get reward speeds for each market for each distributor\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n address cToken = address(allMarkets[i]);\\n supplySpeeds[i] = new uint256[](distributors.length);\\n borrowSpeeds[i] = new uint256[](distributors.length);\\n\\n for (uint256 j = 0; j < distributors.length; j++) {\\n IRewardsDistributor_PLS distributor = IRewardsDistributor_PLS(distributors[j]);\\n supplySpeeds[i][j] = distributor.compSupplySpeeds(cToken);\\n borrowSpeeds[i][j] = distributor.compBorrowSpeeds(cToken);\\n }\\n }\\n\\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\\n }\\n\\n /**\\n * @notice For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\\n * @param comptrollers The Ionic pool Comptrollers to check.\\n */\\n function getRewardSpeedsByPools(IonicComptroller[] memory comptrollers)\\n external\\n view\\n returns (\\n ICErc20[][] memory,\\n address[][] memory,\\n address[][] memory,\\n uint256[][][] memory,\\n uint256[][][] memory\\n )\\n {\\n ICErc20[][] memory allMarkets = new ICErc20[][](comptrollers.length);\\n address[][] memory distributors = new address[][](comptrollers.length);\\n address[][] memory rewardTokens = new address[][](comptrollers.length);\\n uint256[][][] memory supplySpeeds = new uint256[][][](comptrollers.length);\\n uint256[][][] memory borrowSpeeds = new uint256[][][](comptrollers.length);\\n for (uint256 i = 0; i < comptrollers.length; i++)\\n (allMarkets[i], distributors[i], rewardTokens[i], supplySpeeds[i], borrowSpeeds[i]) = getRewardSpeedsByPool(\\n comptrollers[i]\\n );\\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\\n }\\n\\n /**\\n * @notice Returns unaccrued rewards by `holder` from `cToken` on `distributor`.\\n * @param holder The address to check.\\n * @param distributor The RewardsDistributor to check.\\n * @param cToken The CToken to check.\\n * @return Unaccrued (unclaimed) supply-side rewards and unaccrued (unclaimed) borrow-side rewards.\\n */\\n function getUnaccruedRewards(\\n address holder,\\n IRewardsDistributor_PLS distributor,\\n ICErc20 cToken\\n ) internal returns (uint256, uint256) {\\n // Get unaccrued supply rewards\\n uint256 compAccruedPrior = distributor.compAccrued(holder);\\n distributor.flywheelPreSupplierAction(address(cToken), holder);\\n uint256 supplyRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\\n\\n // Get unaccrued borrow rewards\\n compAccruedPrior = distributor.compAccrued(holder);\\n distributor.flywheelPreBorrowerAction(address(cToken), holder);\\n uint256 borrowRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\\n\\n // Return both\\n return (supplyRewardsUnaccrued, borrowRewardsUnaccrued);\\n }\\n\\n /**\\n * @notice Returns all unclaimed rewards accrued by the `holder` on `distributors`.\\n * @param holder The address to check.\\n * @param distributors The `RewardsDistributor` contracts to check.\\n * @return For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\\n */\\n function getUnclaimedRewardsByDistributors(address holder, IRewardsDistributor_PLS[] memory distributors)\\n external\\n returns (\\n address[] memory,\\n uint256[] memory,\\n ICErc20[][] memory,\\n uint256[2][][] memory,\\n uint256[] memory\\n )\\n {\\n address[] memory rewardTokens = new address[](distributors.length);\\n uint256[] memory compUnclaimedTotal = new uint256[](distributors.length);\\n ICErc20[][] memory allMarkets = new ICErc20[][](distributors.length);\\n uint256[2][][] memory rewardsUnaccrued = new uint256[2][][](distributors.length);\\n uint256[] memory distributorFunds = new uint256[](distributors.length);\\n\\n for (uint256 i = 0; i < distributors.length; i++) {\\n IRewardsDistributor_PLS distributor = distributors[i];\\n rewardTokens[i] = distributor.rewardToken();\\n allMarkets[i] = distributor.getAllMarkets();\\n rewardsUnaccrued[i] = new uint256[2][](allMarkets[i].length);\\n for (uint256 j = 0; j < allMarkets[i].length; j++)\\n (rewardsUnaccrued[i][j][0], rewardsUnaccrued[i][j][1]) = getUnaccruedRewards(\\n holder,\\n distributor,\\n allMarkets[i][j]\\n );\\n compUnclaimedTotal[i] = distributor.compAccrued(holder);\\n distributorFunds[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(distributor));\\n }\\n\\n return (rewardTokens, compUnclaimedTotal, allMarkets, rewardsUnaccrued, distributorFunds);\\n }\\n\\n /**\\n * @notice Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getRewardsDistributorsBySupplier(address supplier)\\n external\\n view\\n returns (\\n uint256[] memory,\\n IonicComptroller[] memory,\\n address[][] memory\\n )\\n {\\n // Get array length\\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n uint256 arrayLength = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n try IonicComptroller(pools[i].comptroller).suppliers(supplier) returns (bool isSupplier) {\\n if (isSupplier) arrayLength++;\\n } catch {}\\n }\\n\\n // Build array\\n uint256[] memory indexes = new uint256[](arrayLength);\\n IonicComptroller[] memory comptrollers = new IonicComptroller[](arrayLength);\\n address[][] memory distributors = new address[][](arrayLength);\\n uint256 index = 0;\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n\\n try comptroller.suppliers(supplier) returns (bool isSupplier) {\\n if (isSupplier) {\\n indexes[index] = i;\\n comptrollers[index] = comptroller;\\n\\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\\n distributors[index] = _distributors;\\n } catch {}\\n\\n index++;\\n }\\n } catch {}\\n }\\n\\n // Return distributors\\n return (indexes, comptrollers, distributors);\\n }\\n\\n /**\\n * @notice The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\\n */\\n function getFlywheelsToClaim(address user)\\n external\\n view\\n returns (\\n uint256[] memory,\\n IonicComptroller[] memory,\\n address[][] memory\\n )\\n {\\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\\n\\n IonicComptroller[] memory comptrollers = new IonicComptroller[](pools.length);\\n address[][] memory distributors = new address[][](pools.length);\\n\\n for (uint256 i = 0; i < pools.length; i++) {\\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\\n comptrollers[i] = comptroller;\\n distributors[i] = flywheelsWithRewardsForPoolUser(user, _distributors);\\n } catch {}\\n }\\n\\n return (poolIds, comptrollers, distributors);\\n }\\n\\n function flywheelsWithRewardsForPoolUser(address user, address[] memory _distributors)\\n internal\\n view\\n returns (address[] memory)\\n {\\n address[] memory distributors = new address[](_distributors.length);\\n for (uint256 j = 0; j < _distributors.length; j++) {\\n if (IRewardsDistributor_PLS(_distributors[j]).compAccrued(user) > 0) {\\n distributors[j] = _distributors[j];\\n }\\n }\\n\\n return distributors;\\n }\\n}\\n\",\"keccak256\":\"0xeff31ed17e66ef06ddd6353350ddfb16f8d9e22d7638ac518b0e5c156d979e87\",\"license\":\"UNLICENSED\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/CarefulMath.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Careful Math\\n * @author Compound\\n * @notice Derived from OpenZeppelin's SafeMath library\\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\\n */\\ncontract CarefulMath {\\n /**\\n * @dev Possible error codes that we can return\\n */\\n enum MathError {\\n NO_ERROR,\\n DIVISION_BY_ZERO,\\n INTEGER_OVERFLOW,\\n INTEGER_UNDERFLOW\\n }\\n\\n /**\\n * @dev Multiplies two numbers, returns an error on overflow.\\n */\\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (a == 0) {\\n return (MathError.NO_ERROR, 0);\\n }\\n\\n uint256 c;\\n unchecked {\\n c = a * b;\\n }\\n\\n if (c / a != b) {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n } else {\\n return (MathError.NO_ERROR, c);\\n }\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b == 0) {\\n return (MathError.DIVISION_BY_ZERO, 0);\\n }\\n\\n return (MathError.NO_ERROR, a / b);\\n }\\n\\n /**\\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n if (b <= a) {\\n return (MathError.NO_ERROR, a - b);\\n } else {\\n return (MathError.INTEGER_UNDERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev Adds two numbers, returns an error on overflow.\\n */\\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\\n uint256 c;\\n unchecked {\\n c = a + b;\\n }\\n\\n if (c >= a) {\\n return (MathError.NO_ERROR, c);\\n } else {\\n return (MathError.INTEGER_OVERFLOW, 0);\\n }\\n }\\n\\n /**\\n * @dev add a and b and then subtract c\\n */\\n function addThenSubUInt(\\n uint256 a,\\n uint256 b,\\n uint256 c\\n ) internal pure returns (MathError, uint256) {\\n (MathError err0, uint256 sum) = addUInt(a, b);\\n\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, 0);\\n }\\n\\n return subUInt(sum, c);\\n }\\n}\\n\",\"keccak256\":\"0x7425598d767521ba25277a7f95273c4705721aef0d7f2cd855cb6a61de709a7c\",\"license\":\"UNLICENSED\"},\"contracts/compound/Comptroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { ComptrollerErrorReporter } from \\\"./ErrorReporter.sol\\\";\\nimport { Exponential } from \\\"./Exponential.sol\\\";\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { Unitroller } from \\\"./Unitroller.sol\\\";\\nimport { IFeeDistributor } from \\\"./IFeeDistributor.sol\\\";\\nimport { IIonicFlywheel } from \\\"../ionic/strategies/flywheel/IIonicFlywheel.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \\\"./ComptrollerInterface.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\n/**\\n * @title Compound's Comptroller Contract\\n * @author Compound\\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\\n */\\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /// @notice Emitted when an admin supports a market\\n event MarketListed(ICErc20 cToken);\\n\\n /// @notice Emitted when an account enters a market\\n event MarketEntered(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when an account exits a market\\n event MarketExited(ICErc20 cToken, address account);\\n\\n /// @notice Emitted when close factor is changed by admin\\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\\n\\n /// @notice Emitted when a collateral factor is changed by admin\\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\\n\\n /// @notice Emitted when liquidation incentive is changed by admin\\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\\n\\n /// @notice Emitted when price oracle is changed\\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\\n\\n /// @notice Emitted when the whitelist enforcement is changed\\n event WhitelistEnforcementChanged(bool enforce);\\n\\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\\n event AddedRewardsDistributor(address rewardsDistributor);\\n\\n // closeFactorMantissa must be strictly greater than this value\\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\\n\\n // closeFactorMantissa must not exceed this value\\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // No collateralFactorMantissa may exceed this value\\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\\n\\n // liquidationIncentiveMantissa must be no less than this value\\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\\n\\n // liquidationIncentiveMantissa must be no greater than this value\\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\\n\\n modifier isAuthorized() {\\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \\\"not authorized\\\");\\n _;\\n }\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\\n return ComptrollerBase.effectiveSupplyCaps(cToken);\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(\\n address cToken\\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\\n return ComptrollerBase.effectiveBorrowCaps(cToken);\\n }\\n\\n /*** Assets You Are In ***/\\n\\n /**\\n * @notice Returns the assets an account has entered\\n * @param account The address of the account to pull assets for\\n * @return A dynamic list with the assets the account has entered\\n */\\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\\n ICErc20[] memory assetsIn = accountAssets[account];\\n\\n return assetsIn;\\n }\\n\\n /**\\n * @notice Returns whether the given account is entered in the given asset\\n * @param account The address of the account to check\\n * @param cToken The cToken to check\\n * @return True if the account is in the asset, otherwise false.\\n */\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\\n return markets[address(cToken)].accountMembership[account];\\n }\\n\\n /**\\n * @notice Add assets to be included in account liquidity calculation\\n * @param cTokens The list of addresses of the cToken markets to be enabled\\n * @return Success indicator for whether each corresponding market was entered\\n */\\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\\n uint256 len = cTokens.length;\\n\\n uint256[] memory results = new uint256[](len);\\n for (uint256 i = 0; i < len; i++) {\\n ICErc20 cToken = ICErc20(cTokens[i]);\\n\\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\\n }\\n\\n return results;\\n }\\n\\n /**\\n * @notice Add the market to the borrower's \\\"assets in\\\" for liquidity calculations\\n * @param cToken The market to enter\\n * @param borrower The address of the account to modify\\n * @return Success indicator for whether the market was entered\\n */\\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\\n Market storage marketToJoin = markets[address(cToken)];\\n\\n if (!marketToJoin.isListed) {\\n // market is not listed, cannot join\\n return Error.MARKET_NOT_LISTED;\\n }\\n\\n if (marketToJoin.accountMembership[borrower] == true) {\\n // already joined\\n return Error.NO_ERROR;\\n }\\n\\n // survived the gauntlet, add to list\\n // NOTE: we store these somewhat redundantly as a significant optimization\\n // this avoids having to iterate through the list for the most common use cases\\n // that is, only when we need to perform liquidity checks\\n // and not whenever we want to check if an account is in a particular market\\n marketToJoin.accountMembership[borrower] = true;\\n accountAssets[borrower].push(cToken);\\n\\n // Add to allBorrowers\\n if (!borrowers[borrower]) {\\n allBorrowers.push(borrower);\\n borrowers[borrower] = true;\\n borrowerIndexes[borrower] = allBorrowers.length - 1;\\n }\\n\\n emit MarketEntered(cToken, borrower);\\n\\n return Error.NO_ERROR;\\n }\\n\\n /**\\n * @notice Removes asset from sender's account liquidity calculation\\n * @dev Sender must not have an outstanding borrow balance in the asset,\\n * or be providing necessary collateral for an outstanding borrow.\\n * @param cTokenAddress The address of the asset to be removed\\n * @return Whether or not the account successfully exited the market\\n */\\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\\n // TODO\\n require(markets[cTokenAddress].isListed, \\\"!Comptroller:exitMarket\\\");\\n\\n ICErc20 cToken = ICErc20(cTokenAddress);\\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\\n require(oErr == 0, \\\"!exitMarket\\\"); // semi-opaque error code\\n\\n /* Fail if the sender has a borrow balance */\\n if (amountOwed != 0) {\\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\\n }\\n\\n /* Fail if the sender is not permitted to redeem all of their tokens */\\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\\n if (allowed != 0) {\\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\\n }\\n\\n Market storage marketToExit = markets[cTokenAddress];\\n\\n /* Return true if the sender is not already \\u2018in\\u2019 the market */\\n if (!marketToExit.accountMembership[msg.sender]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Set cToken account membership to false */\\n delete marketToExit.accountMembership[msg.sender];\\n\\n /* Delete cToken from the account\\u2019s list of assets */\\n // load into memory for faster iteration\\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\\n uint256 len = userAssetList.length;\\n uint256 assetIndex = len;\\n for (uint256 i = 0; i < len; i++) {\\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\\n assetIndex = i;\\n break;\\n }\\n }\\n\\n // We *must* have found the asset in the list or our redundant data structure is broken\\n assert(assetIndex < len);\\n\\n // copy last item in list to location of item to be removed, reduce length by 1\\n ICErc20[] storage storedList = accountAssets[msg.sender];\\n storedList[assetIndex] = storedList[storedList.length - 1];\\n storedList.pop();\\n\\n // If the user has exited all markets, remove them from the `allBorrowers` array\\n if (storedList.length == 0) {\\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\\n allBorrowers.pop(); // Reduce length by 1\\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\\n }\\n\\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Policy Hooks ***/\\n\\n /**\\n * @notice Checks if the account should be allowed to mint tokens in the given market\\n * @param cTokenAddress The market to verify the mint against\\n * @param minter The account which would get the minted tokens\\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!mintGuardianPaused[cTokenAddress], \\\"!mint:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cTokenAddress].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure minter is whitelisted\\n if (enforceWhitelist && !whitelist[minter]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\\n\\n // Supply cap of 0 corresponds to unlimited supplying\\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\\n uint256 nonWhitelistedTotalSupply;\\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\\n\\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \\\"!supply cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cTokenAddress, minter);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to redeem tokens in the given market\\n * @param cToken The market to verify the redeem against\\n * @param redeemer The account which would redeem the tokens\\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreSupplierAction(cToken, redeemer);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function redeemAllowedInternal(\\n address cToken,\\n address redeemer,\\n uint256 redeemTokens\\n ) internal view returns (uint256) {\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\\n if (!markets[cToken].accountMembership[redeemer]) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n redeemer,\\n ICErc20(cToken),\\n redeemTokens,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Validates mint and reverts on rejection. May emit logs.\\n * @param cToken Asset being minted\\n * @param minter The address minting the tokens\\n * @param actualMintAmount The amount of the underlying asset being minted\\n * @param mintTokens The number of tokens being minted\\n */\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\\n // Add minter to suppliers mapping\\n suppliers[minter] = true;\\n }\\n\\n /**\\n * @notice Validates redeem and reverts on rejection. May emit logs.\\n * @param cToken Asset being redeemed\\n * @param redeemer The address redeeming the tokens\\n * @param redeemAmount The amount of the underlying asset being redeemed\\n * @param redeemTokens The number of tokens being redeemed\\n */\\n function redeemVerify(\\n address cToken,\\n address redeemer,\\n uint256 redeemAmount,\\n uint256 redeemTokens\\n ) external override {\\n require(markets[msg.sender].isListed, \\\"!market\\\");\\n\\n // Require tokens is zero or amount is also zero\\n if (redeemTokens == 0 && redeemAmount > 0) {\\n revert(\\\"!zero\\\");\\n }\\n }\\n\\n function getMaxRedeemOrBorrow(\\n address account,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) external view override returns (uint256) {\\n address cToken = address(cTokenModify);\\n // Accrue interest\\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\\n\\n // Get account liquidity\\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n account,\\n isBorrow ? cTokenModify : ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n require(err == Error.NO_ERROR, \\\"!liquidity\\\");\\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\\n\\n // Get max borrow/redeem\\n uint256 maxBorrowOrRedeemAmount;\\n\\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\\n // Max redeem = balance of underlying if not used as collateral\\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n } else {\\n // Avoid \\\"stack too deep\\\" error by separating this logic\\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\\n\\n // Redeem only: max out at underlying balance\\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\\n }\\n\\n // Get max borrow or redeem considering cToken liquidity\\n uint256 cTokenLiquidity = cTokenModify.getCash();\\n\\n // Return the minimum of the two maximums\\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\\n }\\n\\n /**\\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \\\"stack too deep\\\" errors.\\n */\\n function _getMaxRedeemOrBorrow(\\n uint256 liquidity,\\n ICErc20 cTokenModify,\\n bool isBorrow\\n ) internal view returns (uint256) {\\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\\n\\n // Get the normalized price of the asset\\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\\n require(conversionFactor > 0, \\\"!oracle\\\");\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n if (!isBorrow) {\\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\\n }\\n\\n // Get max borrow or redeem considering excess account liquidity\\n return (liquidity * 1e18) / conversionFactor;\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken The market to verify the borrow against\\n * @param borrower The account which would borrow the asset\\n * @param borrowAmount The amount of underlying the account would borrow\\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!borrowGuardianPaused[cToken], \\\"!borrow:paused\\\");\\n\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n if (!markets[cToken].accountMembership[borrower]) {\\n // only cTokens may call borrowAllowed if borrower not in market\\n require(msg.sender == cToken, \\\"!ctoken\\\");\\n\\n // attempt to add borrower to the market\\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n // it should be impossible to break the important invariant\\n assert(markets[cToken].accountMembership[borrower]);\\n }\\n\\n // Make sure oracle price is available\\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\\n return uint256(Error.PRICE_ERROR);\\n }\\n\\n // Make sure borrower is whitelisted\\n if (enforceWhitelist && !whitelist[borrower]) {\\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\\n }\\n\\n uint256 borrowCap = effectiveBorrowCaps(cToken);\\n\\n // Borrow cap of 0 corresponds to unlimited borrowing\\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\\n uint256 nonWhitelistedTotalBorrows;\\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\\n\\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \\\"!borrow:cap\\\");\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n // Perform a hypothetical liquidity check to guard against shortfall\\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\\n if (err != uint256(Error.NO_ERROR)) {\\n return err;\\n }\\n if (shortfall > 0) {\\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\\n * @param cToken Asset whose underlying is being borrowed\\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\\n */\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\\n // Check if min borrow exists\\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\\n\\n if (minBorrowEth > 0) {\\n // Get new underlying borrow balance of account for this cToken\\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\\n Exp({ mantissa: oraclePriceMantissa }),\\n accountBorrowsNew\\n );\\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\\n\\n // Check against min borrow\\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\\n }\\n\\n // Return no error\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to repay a borrow in the given market\\n * @param cToken The market to verify the repay against\\n * @param payer The account which would repay the asset\\n * @param borrower The account which would borrowed the asset\\n * @param repayAmount The amount of the underlying asset the account would repay\\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure market is listed\\n if (!markets[cToken].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreBorrowerAction(cToken, borrower);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the liquidation should be allowed to occur\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param repayAmount The amount of underlying being repaid\\n */\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external override returns (uint256) {\\n // Make sure markets are listed\\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Get borrowers' underlying borrow balance\\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\\n\\n /* allow accounts to be liquidated if the market is deprecated */\\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\\n require(borrowBalance >= repayAmount, \\\"!borrow>repay\\\");\\n } else {\\n /* The borrower must have shortfall in order to be liquidateable */\\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\\n borrower,\\n ICErc20(address(0)),\\n 0,\\n 0,\\n 0\\n );\\n if (err != Error.NO_ERROR) {\\n return uint256(err);\\n }\\n\\n if (shortfall == 0) {\\n return uint256(Error.INSUFFICIENT_SHORTFALL);\\n }\\n\\n /* The liquidator may not repay more than what is allowed by the closeFactor */\\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\\n if (repayAmount > maxClose) {\\n return uint256(Error.TOO_MUCH_REPAY);\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the seizing of assets should be allowed to occur\\n * @param cTokenCollateral Asset which was used as collateral and will be seized\\n * @param cTokenBorrowed Asset which was borrowed by the borrower\\n * @param liquidator The address repaying the borrow and seizing the collateral\\n * @param borrower The address of the borrower\\n * @param seizeTokens The number of collateral tokens to seize\\n */\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!seizeGuardianPaused, \\\"!seize:paused\\\");\\n\\n // Make sure markets are listed\\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\\n return uint256(Error.MARKET_NOT_LISTED);\\n }\\n\\n // Make sure cToken Comptrollers are identical\\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\\n return uint256(Error.COMPTROLLER_MISMATCH);\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Checks if the account should be allowed to transfer tokens in the given market\\n * @param cToken The market to verify the transfer against\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n * @param transferTokens The number of cTokens to transfer\\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\\n */\\n function transferAllowed(\\n address cToken,\\n address src,\\n address dst,\\n uint256 transferTokens\\n ) external override returns (uint256) {\\n // Pausing is a very serious situation - we revert to sound the alarms\\n require(!transferGuardianPaused, \\\"!transfer:paused\\\");\\n\\n // Currently the only consideration is whether or not\\n // the src is allowed to redeem this many tokens\\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\\n if (allowed != uint256(Error.NO_ERROR)) {\\n return allowed;\\n }\\n\\n // Keep the flywheel moving\\n flywheelPreTransferAction(cToken, src, dst);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /*** Flywheel Hooks ***/\\n\\n /**\\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\\n * @param cToken The relevant market\\n * @param supplier The minter/redeemer\\n */\\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\\n * @param cToken The relevant market\\n * @param borrower The borrower\\n */\\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\\n }\\n\\n /**\\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\\n * @param cToken The relevant market\\n * @param src The account which sources the tokens\\n * @param dst The account which receives the tokens\\n */\\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\\n }\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n /**\\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\\n */\\n struct AccountLiquidityLocalVars {\\n ICErc20 asset;\\n uint256 sumCollateral;\\n uint256 sumBorrowPlusEffects;\\n uint256 cTokenBalance;\\n uint256 borrowBalance;\\n uint256 exchangeRateMantissa;\\n uint256 oraclePriceMantissa;\\n Exp collateralFactor;\\n Exp exchangeRate;\\n Exp oraclePrice;\\n Exp tokensToDenom;\\n uint256 borrowCapForCollateral;\\n uint256 borrowedAssetPrice;\\n uint256 assetAsCollateralValueCap;\\n }\\n\\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code (semi-opaque),\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) public view returns (uint256, uint256, uint256, uint256) {\\n (\\n Error err,\\n uint256 collateralValue,\\n uint256 liquidity,\\n uint256 shortfall\\n ) = getHypotheticalAccountLiquidityInternal(\\n account,\\n ICErc20(cTokenModify),\\n redeemTokens,\\n borrowAmount,\\n repayAmount\\n );\\n return (uint256(err), collateralValue, liquidity, shortfall);\\n }\\n\\n /**\\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\\n * @param cTokenModify The market to hypothetically redeem/borrow in\\n * @param account The account to determine liquidity for\\n * @param redeemTokens The number of tokens to hypothetically redeem\\n * @param borrowAmount The amount of underlying to hypothetically borrow\\n * @return (possible error code,\\n hypothetical account collateral value,\\n hypothetical account liquidity in excess of collateral requirements,\\n * hypothetical account shortfall below collateral requirements)\\n */\\n function getHypotheticalAccountLiquidityInternal(\\n address account,\\n ICErc20 cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) internal view returns (Error, uint256, uint256, uint256) {\\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\\n\\n if (address(cTokenModify) != address(0)) {\\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\\n }\\n\\n // For each asset the account is in\\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\\n vars.asset = accountAssets[account][i];\\n\\n {\\n // Read the balances and exchange rate from the cToken\\n uint256 oErr;\\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\\n account\\n );\\n if (oErr != 0) {\\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\\n }\\n }\\n {\\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\\n\\n // Get the normalized price of the asset\\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\\n if (vars.oraclePriceMantissa == 0) {\\n return (Error.PRICE_ERROR, 0, 0, 0);\\n }\\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\\n\\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\\n }\\n {\\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\\n vars.asset,\\n cTokenModify,\\n redeemTokens > 0,\\n account\\n );\\n\\n // accumulate the collateral value to sumCollateral\\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\\n assetCollateralValue = vars.assetAsCollateralValueCap;\\n vars.sumCollateral += assetCollateralValue;\\n }\\n\\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n vars.borrowBalance,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // Calculate effects of interacting with cTokenModify\\n if (vars.asset == cTokenModify) {\\n // redeem effect\\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.tokensToDenom,\\n redeemTokens,\\n vars.sumBorrowPlusEffects\\n );\\n\\n // borrow effect\\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\\n vars.oraclePrice,\\n borrowAmount,\\n vars.sumBorrowPlusEffects\\n );\\n\\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\\n if (repayEffect >= vars.sumBorrowPlusEffects) {\\n vars.sumBorrowPlusEffects = 0;\\n } else {\\n vars.sumBorrowPlusEffects -= repayEffect;\\n }\\n }\\n }\\n\\n // These are safe, as the underflow condition is checked first\\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\\n } else {\\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\\n }\\n }\\n\\n /**\\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\\n * @param cTokenBorrowed The address of the borrowed cToken\\n * @param cTokenCollateral The address of the collateral cToken\\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\\n */\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 actualRepayAmount\\n ) external view override returns (uint256, uint256) {\\n /* Read oracle prices for borrowed and collateral markets */\\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\\n return (uint256(Error.PRICE_ERROR), 0);\\n }\\n\\n /*\\n * Get the exchange rate and calculate the number of collateral tokens to seize:\\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\\n * seizeTokens = seizeAmount / exchangeRate\\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\\n */\\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\\n uint256 seizeTokens;\\n Exp memory numerator;\\n Exp memory denominator;\\n Exp memory ratio;\\n\\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\\n\\n /*\\n * The liquidation penalty includes\\n * - the liquidator incentive\\n * - the protocol fees (Ionic admin fees)\\n * - the market fee\\n */\\n Exp memory totalPenaltyMantissa = add_(\\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\\n Exp({ mantissa: feeSeizeShareMantissa })\\n );\\n\\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\\n ratio = div_(numerator, denominator);\\n\\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\\n return (uint256(Error.NO_ERROR), seizeTokens);\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Add a RewardsDistributor contracts.\\n * @dev Admin function to add a RewardsDistributor contract\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _addRewardsDistributor(address distributor) external returns (uint256) {\\n require(hasAdminRights(), \\\"!admin\\\");\\n\\n // Check marker method\\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \\\"!isRewardsDistributor\\\");\\n\\n // Check for existing RewardsDistributor\\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \\\"!added\\\");\\n\\n // Add RewardsDistributor to array\\n rewardsDistributors.push(distributor);\\n emit AddedRewardsDistributor(distributor);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist enforcement for the comptroller\\n * @dev Admin function to set a new whitelist enforcement boolean\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\\n }\\n\\n // Check if `enforceWhitelist` already equals `enforce`\\n if (enforceWhitelist == enforce) {\\n return uint256(Error.NO_ERROR);\\n }\\n\\n // Set comptroller's `enforceWhitelist` to `enforce`\\n enforceWhitelist = enforce;\\n\\n // Emit WhitelistEnforcementChanged(bool enforce);\\n emit WhitelistEnforcementChanged(enforce);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the whitelist `statuses` for `suppliers`\\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\\n }\\n\\n // Set whitelist statuses for suppliers\\n for (uint256 i = 0; i < suppliers.length; i++) {\\n address supplier = suppliers[i];\\n\\n if (statuses[i]) {\\n // If not already whitelisted, add to whitelist\\n if (!whitelist[supplier]) {\\n whitelist[supplier] = true;\\n whitelistArray.push(supplier);\\n whitelistIndexes[supplier] = whitelistArray.length - 1;\\n }\\n } else {\\n // If whitelisted, remove from whitelist\\n if (whitelist[supplier]) {\\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\\n whitelistArray.pop(); // Reduce length by 1\\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\\n }\\n }\\n }\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets a new price oracle for the comptroller\\n * @dev Admin function to set a new price oracle\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\\n }\\n\\n // Track the old oracle for the comptroller\\n BasePriceOracle oldOracle = oracle;\\n\\n // Set comptroller's oracle to newOracle\\n oracle = newOracle;\\n\\n // Emit NewPriceOracle(oldOracle, newOracle)\\n emit NewPriceOracle(oldOracle, newOracle);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the closeFactor used when liquidating borrows\\n * @dev Admin function to set closeFactor\\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\\n }\\n\\n // Check limits\\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCloseFactorExp)) {\\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\\n }\\n\\n // Set pool close factor to new close factor, remember old value\\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\\n closeFactorMantissa = newCloseFactorMantissa;\\n\\n // Emit event\\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets the collateralFactor for a market\\n * @dev Admin function to set per-market collateralFactor\\n * @param cToken The market to set the factor on\\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\\n }\\n\\n // Verify market is listed\\n Market storage market = markets[address(cToken)];\\n if (!market.isListed) {\\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\\n }\\n\\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\\n\\n // Check collateral factor <= 0.9\\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\\n }\\n\\n // If collateral factor != 0, fail if price == 0\\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\\n }\\n\\n // Set market's collateral factor to new collateral factor, remember old value\\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\\n market.collateralFactorMantissa = newCollateralFactorMantissa;\\n\\n // Emit event with asset, old collateral factor, and new collateral factor\\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Sets liquidationIncentive\\n * @dev Admin function to set liquidationIncentive\\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\\n */\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\\n }\\n\\n // Check de-scaled min <= newLiquidationIncentive <= max\\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\\n }\\n\\n // Save current value for use in log\\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\\n\\n // Set liquidation incentive to new incentive\\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\\n\\n // Emit event with old incentive, new incentive\\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Add the market to the markets mapping and set it as listed\\n * @dev Admin function to set isListed and add support for the market\\n * @param cToken The address of the market (token) to list\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Is market already listed?\\n if (markets[address(cToken)].isListed) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // Check cToken.comptroller == this\\n require(address(cToken.comptroller()) == address(this), \\\"!comptroller\\\");\\n\\n // Make sure market is not already listed\\n address underlying = ICErc20(address(cToken)).underlying();\\n\\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\\n }\\n\\n // List market and emit event\\n Market storage market = markets[address(cToken)];\\n market.isListed = true;\\n market.collateralFactorMantissa = 0;\\n allMarkets.push(cToken);\\n cTokensByUnderlying[underlying] = cToken;\\n emit MarketListed(cToken);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\\n */\\n function _deployMarket(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256) {\\n // Check caller is admin\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\\n }\\n\\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\\n bool oldIonicAdminHasRights = ionicAdminHasRights;\\n ionicAdminHasRights = true;\\n\\n // Deploy via Ionic admin\\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\\n // Reset Ionic admin rights to the original value\\n ionicAdminHasRights = oldIonicAdminHasRights;\\n // Support market here in the Comptroller\\n uint256 err = _supportMarket(cToken);\\n\\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\\n\\n // Set collateral factor\\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\\n }\\n\\n function _becomeImplementation() external {\\n require(msg.sender == address(this), \\\"!self call\\\");\\n\\n if (!_notEnteredInitialized) {\\n _notEntered = true;\\n _notEnteredInitialized = true;\\n }\\n }\\n\\n /*** Helper Functions ***/\\n\\n /**\\n * @notice Returns true if the given cToken market has been deprecated\\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\\n * @param cToken The market to check if deprecated\\n */\\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\\n return\\n markets[address(cToken)].collateralFactorMantissa == 0 &&\\n borrowGuardianPaused[address(cToken)] == true &&\\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\\n }\\n\\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\\n return ComptrollerExtensionInterface(address(this));\\n }\\n\\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\\n uint8 fnsCount = 32;\\n\\n functionSelectors = new bytes4[](fnsCount);\\n\\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\\n functionSelectors[--fnsCount] = this._deployMarket.selector;\\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\\n functionSelectors[--fnsCount] = this.checkMembership.selector;\\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\\n functionSelectors[--fnsCount] = this.exitMarket.selector;\\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\\n functionSelectors[--fnsCount] = this.mintVerify.selector;\\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n }\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n /**\\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _beforeNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_beforeNonReentrant\\\");\\n require(_notEntered, \\\"!reentered\\\");\\n _notEntered = false;\\n }\\n\\n /**\\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\\n */\\n function _afterNonReentrant() external override {\\n require(markets[msg.sender].isListed, \\\"!Comptroller:_afterNonReentrant\\\");\\n _notEntered = true; // get a gas-refund post-Istanbul\\n }\\n}\\n\",\"keccak256\":\"0x99b5df813bb4a7619169842591460bd0a13dc2f544f683f4420741bc28079e8a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/ErrorReporter.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\ncontract ComptrollerErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n COMPTROLLER_MISMATCH,\\n INSUFFICIENT_SHORTFALL,\\n INSUFFICIENT_LIQUIDITY,\\n INVALID_CLOSE_FACTOR,\\n INVALID_COLLATERAL_FACTOR,\\n INVALID_LIQUIDATION_INCENTIVE,\\n MARKET_NOT_LISTED,\\n MARKET_ALREADY_LISTED,\\n MATH_ERROR,\\n NONZERO_BORROW_BALANCE,\\n PRICE_ERROR,\\n REJECTION,\\n SNAPSHOT_ERROR,\\n TOO_MANY_ASSETS,\\n TOO_MUCH_REPAY,\\n SUPPLIER_NOT_WHITELISTED,\\n BORROW_BELOW_MIN,\\n SUPPLY_ABOVE_MAX,\\n NONZERO_TOTAL_SUPPLY\\n }\\n\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\\n EXIT_MARKET_BALANCE_OWED,\\n EXIT_MARKET_REJECTION,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\\n SET_CLOSE_FACTOR_OWNER_CHECK,\\n SET_CLOSE_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_NO_EXISTS,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\\n SET_PRICE_ORACLE_OWNER_CHECK,\\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\\n SET_WHITELIST_STATUS_OWNER_CHECK,\\n SUPPORT_MARKET_EXISTS,\\n SUPPORT_MARKET_OWNER_CHECK,\\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\\n UNSUPPORT_MARKET_OWNER_CHECK,\\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\\n UNSUPPORT_MARKET_IN_USE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return uint256(err);\\n }\\n}\\n\\ncontract TokenErrorReporter {\\n enum Error {\\n NO_ERROR,\\n UNAUTHORIZED,\\n BAD_INPUT,\\n COMPTROLLER_REJECTION,\\n COMPTROLLER_CALCULATION_ERROR,\\n INTEREST_RATE_MODEL_ERROR,\\n INVALID_ACCOUNT_PAIR,\\n INVALID_CLOSE_AMOUNT_REQUESTED,\\n INVALID_COLLATERAL_FACTOR,\\n MATH_ERROR,\\n MARKET_NOT_FRESH,\\n MARKET_NOT_LISTED,\\n TOKEN_INSUFFICIENT_ALLOWANCE,\\n TOKEN_INSUFFICIENT_BALANCE,\\n TOKEN_INSUFFICIENT_CASH,\\n TOKEN_TRANSFER_IN_FAILED,\\n TOKEN_TRANSFER_OUT_FAILED,\\n UTILIZATION_ABOVE_MAX\\n }\\n\\n /*\\n * Note: FailureInfo (but not Error) is kept in alphabetical order\\n * This is because FailureInfo grows significantly faster, and\\n * the order of Error has some meaning, while the order of FailureInfo\\n * is entirely arbitrary.\\n */\\n enum FailureInfo {\\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n BORROW_ACCRUE_INTEREST_FAILED,\\n BORROW_CASH_NOT_AVAILABLE,\\n BORROW_FRESHNESS_CHECK,\\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n BORROW_MARKET_NOT_LISTED,\\n BORROW_COMPTROLLER_REJECTION,\\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\\n LIQUIDATE_COMPTROLLER_REJECTION,\\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\\n LIQUIDATE_FRESHNESS_CHECK,\\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\\n LIQUIDATE_SEIZE_TOO_MUCH,\\n MINT_ACCRUE_INTEREST_FAILED,\\n MINT_COMPTROLLER_REJECTION,\\n MINT_EXCHANGE_CALCULATION_FAILED,\\n MINT_EXCHANGE_RATE_READ_FAILED,\\n MINT_FRESHNESS_CHECK,\\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n MINT_TRANSFER_IN_FAILED,\\n MINT_TRANSFER_IN_NOT_POSSIBLE,\\n NEW_UTILIZATION_RATE_ABOVE_MAX,\\n REDEEM_ACCRUE_INTEREST_FAILED,\\n REDEEM_COMPTROLLER_REJECTION,\\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\\n REDEEM_EXCHANGE_RATE_READ_FAILED,\\n REDEEM_FRESHNESS_CHECK,\\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\\n WITHDRAW_IONIC_FEES_VALIDATION,\\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\\n WITHDRAW_ADMIN_FEES_VALIDATION,\\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\\n REDUCE_RESERVES_ADMIN_CHECK,\\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\\n REDUCE_RESERVES_FRESH_CHECK,\\n REDUCE_RESERVES_VALIDATION,\\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_COMPTROLLER_REJECTION,\\n REPAY_BORROW_FRESHNESS_CHECK,\\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\\n SET_COLLATERAL_FACTOR_VALIDATION,\\n SET_COMPTROLLER_OWNER_CHECK,\\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\\n SET_PENDING_ADMIN_OWNER_CHECK,\\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\\n SET_ADMIN_FEE_ADMIN_CHECK,\\n SET_ADMIN_FEE_FRESH_CHECK,\\n SET_ADMIN_FEE_BOUNDS_CHECK,\\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\\n SET_IONIC_FEE_FRESH_CHECK,\\n SET_IONIC_FEE_BOUNDS_CHECK,\\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\\n SET_RESERVE_FACTOR_ADMIN_CHECK,\\n SET_RESERVE_FACTOR_FRESH_CHECK,\\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\\n TRANSFER_COMPTROLLER_REJECTION,\\n TRANSFER_NOT_ALLOWED,\\n TRANSFER_NOT_ENOUGH,\\n TRANSFER_TOO_MUCH,\\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\\n ADD_RESERVES_FRESH_CHECK,\\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\\n }\\n\\n /**\\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\\n **/\\n event Failure(uint256 error, uint256 info, uint256 detail);\\n\\n /**\\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\\n */\\n function fail(Error err, FailureInfo info) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), 0);\\n\\n return uint256(err);\\n }\\n\\n /**\\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\\n */\\n function failOpaque(\\n Error err,\\n FailureInfo info,\\n uint256 opaqueError\\n ) internal returns (uint256) {\\n emit Failure(uint256(err), uint256(info), opaqueError);\\n\\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\\n }\\n}\\n\",\"keccak256\":\"0xad342553cda4d7b7e40678c636a406bc2785be2117a29d9b1cb52e747726745e\",\"license\":\"UNLICENSED\"},\"contracts/compound/Exponential.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./CarefulMath.sol\\\";\\nimport \\\"./ExponentialNoError.sol\\\";\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract Exponential is CarefulMath, ExponentialNoError {\\n /**\\n * @dev Creates an exponential from numerator and denominator values.\\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\\n * or if `denom` is zero.\\n */\\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\\n }\\n\\n /**\\n * @dev Adds two exponentials, returning a new exponential.\\n */\\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Subtracts two exponentials, returning a new exponential.\\n */\\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\\n\\n return (error, Exp({ mantissa: result }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, returning a new Exp.\\n */\\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory product) = mulScalar(a, scalar);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(product));\\n }\\n\\n /**\\n * @dev Divide an Exp by a scalar, returning a new Exp.\\n */\\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, returning a new Exp.\\n */\\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\\n /*\\n We are doing this as:\\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\\n\\n How it works:\\n Exp = a / b;\\n Scalar = s;\\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\\n */\\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n return getExp(numerator, divisor.mantissa);\\n }\\n\\n /**\\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\\n */\\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\\n if (err != MathError.NO_ERROR) {\\n return (err, 0);\\n }\\n\\n return (MathError.NO_ERROR, truncate(fraction));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials, returning a new exponential.\\n */\\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\\n if (err0 != MathError.NO_ERROR) {\\n return (err0, Exp({ mantissa: 0 }));\\n }\\n\\n // We add half the scale before dividing so that we get rounding instead of truncation.\\n // See \\\"Listing 6\\\" and text above it at https://accu.org/index.php/journals/1717\\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\\n if (err1 != MathError.NO_ERROR) {\\n return (err1, Exp({ mantissa: 0 }));\\n }\\n\\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\\n assert(err2 == MathError.NO_ERROR);\\n\\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\\n }\\n\\n /**\\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\\n */\\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\\n }\\n\\n /**\\n * @dev Multiplies three exponentials, returning a new exponential.\\n */\\n function mulExp3(\\n Exp memory a,\\n Exp memory b,\\n Exp memory c\\n ) internal pure returns (MathError, Exp memory) {\\n (MathError err, Exp memory ab) = mulExp(a, b);\\n if (err != MathError.NO_ERROR) {\\n return (err, ab);\\n }\\n return mulExp(ab, c);\\n }\\n\\n /**\\n * @dev Divides two exponentials, returning a new exponential.\\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\\n */\\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\\n return getExp(a.mantissa, b.mantissa);\\n }\\n}\\n\",\"keccak256\":\"0xf1b6442cbde756ce56dc5507487b1769905147f390fdf88e1d59a66bc3e2161e\",\"license\":\"UNLICENSED\"},\"contracts/compound/ExponentialNoError.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Exponential module for storing fixed-precision decimals\\n * @author Compound\\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\\n * `Exp({mantissa: 5100000000000000000})`.\\n */\\ncontract ExponentialNoError {\\n uint256 constant expScale = 1e18;\\n uint256 constant doubleScale = 1e36;\\n uint256 constant halfExpScale = expScale / 2;\\n uint256 constant mantissaOne = expScale;\\n\\n struct Exp {\\n uint256 mantissa;\\n }\\n\\n struct Double {\\n uint256 mantissa;\\n }\\n\\n /**\\n * @dev Truncates the given exp to a whole number value.\\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\\n */\\n function truncate(Exp memory exp) internal pure returns (uint256) {\\n // Note: We are not using careful math here as we're performing a division that cannot fail\\n return exp.mantissa / expScale;\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\\n */\\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return truncate(product);\\n }\\n\\n /**\\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\\n */\\n function mul_ScalarTruncateAddUInt(\\n Exp memory a,\\n uint256 scalar,\\n uint256 addend\\n ) internal pure returns (uint256) {\\n Exp memory product = mul_(a, scalar);\\n return add_(truncate(product), addend);\\n }\\n\\n /**\\n * @dev Checks if first Exp is less than second Exp.\\n */\\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa < right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp <= right Exp.\\n */\\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa <= right.mantissa;\\n }\\n\\n /**\\n * @dev Checks if left Exp > right Exp.\\n */\\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\\n return left.mantissa > right.mantissa;\\n }\\n\\n /**\\n * @dev returns true if Exp is exactly zero\\n */\\n function isZeroExp(Exp memory value) internal pure returns (bool) {\\n return value.mantissa == 0;\\n }\\n\\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\\n require(n < 2**224, errorMessage);\\n return uint224(n);\\n }\\n\\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\\n require(n < 2**32, errorMessage);\\n return uint32(n);\\n }\\n\\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\\n }\\n\\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return add_(a, b, \\\"addition overflow\\\");\\n }\\n\\n function add_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, errorMessage);\\n return c;\\n }\\n\\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\\n }\\n\\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return sub_(a, b, \\\"subtraction underflow\\\");\\n }\\n\\n function sub_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\\n }\\n\\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / expScale;\\n }\\n\\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\\n }\\n\\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: mul_(a.mantissa, b) });\\n }\\n\\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return mul_(a, b.mantissa) / doubleScale;\\n }\\n\\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return mul_(a, b, \\\"multiplication overflow\\\");\\n }\\n\\n function mul_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n if (a == 0 || b == 0) {\\n return 0;\\n }\\n uint256 c = a * b;\\n require(c / a == b, errorMessage);\\n return c;\\n }\\n\\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\\n }\\n\\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\\n return Exp({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\\n return div_(mul_(a, expScale), b.mantissa);\\n }\\n\\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\\n }\\n\\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(a.mantissa, b) });\\n }\\n\\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\\n return div_(mul_(a, doubleScale), b.mantissa);\\n }\\n\\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\\n return div_(a, b, \\\"divide by zero\\\");\\n }\\n\\n function div_(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\\n }\\n}\\n\",\"keccak256\":\"0xec0df0038026b4e9c272de575121befd31d3a306fec5f157aaf1625fc08cfe69\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/compound/Unitroller.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./ErrorReporter.sol\\\";\\nimport \\\"./ComptrollerStorage.sol\\\";\\nimport \\\"./Comptroller.sol\\\";\\nimport { DiamondExtension, DiamondBase, LibDiamond } from \\\"../ionic/DiamondExtension.sol\\\";\\n\\n/**\\n * @title Unitroller\\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\\n * CTokens should reference this contract as their comptroller.\\n */\\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\\n /**\\n * @notice Event emitted when the admin rights are changed\\n */\\n event AdminRightsToggled(bool hasRights);\\n\\n /**\\n * @notice Emitted when pendingAdmin is changed\\n */\\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\\n\\n /**\\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\\n */\\n event NewAdmin(address oldAdmin, address newAdmin);\\n\\n constructor(address payable _ionicAdmin) {\\n admin = msg.sender;\\n ionicAdmin = _ionicAdmin;\\n }\\n\\n /*** Admin Functions ***/\\n\\n /**\\n * @notice Toggles admin rights.\\n * @param hasRights Boolean indicating if the admin is to have rights.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\\n }\\n\\n // Check that rights have not already been set to the desired value\\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\\n\\n adminHasRights = hasRights;\\n emit AdminRightsToggled(hasRights);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\\n * @param newPendingAdmin New pending admin.\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\\n if (!hasAdminRights()) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\\n }\\n\\n address oldPendingAdmin = pendingAdmin;\\n pendingAdmin = newPendingAdmin;\\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n /**\\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\\n * @dev Admin function for pending admin to accept role and update admin\\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\\n */\\n function _acceptAdmin() public returns (uint256) {\\n // Check caller is pendingAdmin and pendingAdmin \\u2260 address(0)\\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\\n }\\n\\n // Save current values for inclusion in log\\n address oldAdmin = admin;\\n address oldPendingAdmin = pendingAdmin;\\n\\n admin = pendingAdmin;\\n pendingAdmin = address(0);\\n\\n emit NewAdmin(oldAdmin, admin);\\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\\n\\n return uint256(Error.NO_ERROR);\\n }\\n\\n function comptrollerImplementation() public view returns (address) {\\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\\\"_deployMarket(uint8,bytes,bytes,uint256)\\\"))));\\n }\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external {\\n require(msg.sender == address(this) || hasAdminRights(), \\\"!self || !admin\\\");\\n\\n address currentImplementation = comptrollerImplementation();\\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\\n currentImplementation\\n );\\n\\n _updateExtensions(latestComptrollerImplementation);\\n\\n if (currentImplementation != latestComptrollerImplementation) {\\n // reinitialize\\n _functionCall(address(this), abi.encodeWithSignature(\\\"_becomeImplementation()\\\"), \\\"!become impl\\\");\\n }\\n }\\n\\n function _functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.call(data);\\n\\n if (!success) {\\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 return returndata;\\n }\\n\\n function _updateExtensions(address currentComptroller) internal {\\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\\n address[] memory currentExtensions = LibDiamond.listExtensions();\\n\\n // removed the current (old) extensions\\n for (uint256 i = 0; i < currentExtensions.length; i++) {\\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\\n }\\n // add the new extensions\\n for (uint256 i = 0; i < latestExtensions.length; i++) {\\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\\n }\\n }\\n\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\\n require(hasAdminRights(), \\\"!unauthorized\\\");\\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\\n }\\n}\\n\",\"keccak256\":\"0xcea89eb6bccd6ab62b57e42d483fd3638a0296ec9aae45d21f80a521004cc9e8\",\"license\":\"UNLICENSED\"},\"contracts/external/uniswap/IUniswapV2Pair.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\ninterface IUniswapV2Pair {\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n function name() external pure returns (string memory);\\n\\n function symbol() external pure returns (string memory);\\n\\n function decimals() external pure returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 value\\n ) external returns (bool);\\n\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n function nonces(address owner) external view returns (uint256);\\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\\n event Swap(\\n address indexed sender,\\n uint256 amount0In,\\n uint256 amount1In,\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address indexed to\\n );\\n event Sync(uint112 reserve0, uint112 reserve1);\\n\\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\\n\\n function factory() external view returns (address);\\n\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n\\n function kLast() external view returns (uint256);\\n\\n function mint(address to) external returns (uint256 liquidity);\\n\\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\\n\\n function swap(\\n uint256 amount0Out,\\n uint256 amount1Out,\\n address to,\\n bytes calldata data\\n ) external;\\n\\n function skim(address to) external;\\n\\n function sync() external;\\n\\n function initialize(address, address) external;\\n}\\n\",\"keccak256\":\"0xc30635313c081ea723c128678f4d45c48aac88080d91578e8c4374774d26cba2\",\"license\":\"GPL-3.0-only\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/ionic/strategies/flywheel/IIonicFlywheel.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity ^0.8.10;\\n\\nimport { ERC20 } from \\\"solmate/tokens/ERC20.sol\\\";\\n\\ninterface IIonicFlywheel {\\n function isRewardsDistributor() external returns (bool);\\n\\n function isFlywheel() external returns (bool);\\n\\n function flywheelPreSupplierAction(address market, address supplier) external;\\n\\n function flywheelPreBorrowerAction(address market, address borrower) external;\\n\\n function flywheelPreTransferAction(address market, address src, address dst) external;\\n\\n function compAccrued(address user) external view returns (uint256);\\n\\n function addMarketForRewards(ERC20 strategy) external;\\n\\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\\n}\\n\",\"keccak256\":\"0xb24009cac18b0f9b6d12884169ab4461ec04027110a768091077dc5c648e934c\",\"license\":\"AGPL-3.0-only\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\\n * `CREATE2` can be used to compute in advance the address where a smart\\n * contract will be deployed, which allows for interesting new mechanisms known\\n * as 'counterfactual interactions'.\\n *\\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\\n * information.\\n */\\nlibrary Create2Upgradeable {\\n /**\\n * @dev Deploys a contract using `CREATE2`. The address where the contract\\n * will be deployed can be known in advance via {computeAddress}.\\n *\\n * The bytecode for a contract can be obtained from Solidity with\\n * `type(contractName).creationCode`.\\n *\\n * Requirements:\\n *\\n * - `bytecode` must not be empty.\\n * - `salt` must have not been used for `bytecode` already.\\n * - the factory must have a balance of at least `amount`.\\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\\n */\\n function deploy(\\n uint256 amount,\\n bytes32 salt,\\n bytes memory bytecode\\n ) internal returns (address addr) {\\n require(address(this).balance >= amount, \\\"Create2: insufficient balance\\\");\\n require(bytecode.length != 0, \\\"Create2: bytecode length is zero\\\");\\n /// @solidity memory-safe-assembly\\n assembly {\\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\\n }\\n require(addr != address(0), \\\"Create2: Failed on deploy\\\");\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\\n * `bytecodeHash` or `salt` will result in a new destination address.\\n */\\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\\n return computeAddress(salt, bytecodeHash, address(this));\\n }\\n\\n /**\\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\\n */\\n function computeAddress(\\n bytes32 salt,\\n bytes32 bytecodeHash,\\n address deployer\\n ) internal pure returns (address addr) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40) // Get free memory pointer\\n\\n // | | \\u2193 ptr ... \\u2193 ptr + 0x0B (start) ... \\u2193 ptr + 0x20 ... \\u2193 ptr + 0x40 ... |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\\n // | salt | BBBBBBBBBBBBB...BB |\\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\\n // | 0xFF | FF |\\n // |-------------------|---------------------------------------------------------------------------|\\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\\n // | keccak(start, 85) | \\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191\\u2191 |\\n\\n mstore(add(ptr, 0x40), bytecodeHash)\\n mstore(add(ptr, 0x20), salt)\\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\\n mstore8(start, 0xff)\\n addr := keccak256(start, 85)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd4f2e4c252119ec161cc4de7fc6631b0dd840c46e85bf1fc771252924957d5ab\",\"license\":\"MIT\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"},\"solmate/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0xcdfd8db76b2a3415620e4d18cc5545f3d50de792dbf2c3dd5adb40cbe6f94b10\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50612e30806100206000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806397f35ff01161006657806397f35ff014610148578063998e2d4a1461016b578063c41c2f241461018d578063c4d66de8146101be578063d24eaf13146101d357600080fd5b80631ec18ec0146100a3578063338038fa146100c95780633fc5fab5146100ed578063641290421461011157806384b3403d14610124575b600080fd5b6100b66100b13660046122b2565b6101e6565b6040519081526020015b60405180910390f35b6100dc6100d736600461237c565b6101fd565b6040516100c09594939291906124ff565b6101006100fb3660046125f9565b610792565b6040516100c09594939291906127d8565b6100b661011f3660046122b2565b610a09565b610137610132366004612845565b610a17565b6040516100c0959493929190612869565b61015b610156366004612845565b610f15565b6040516100c094939291906128ca565b61017e610179366004612845565b611609565b6040516100c09392919061295f565b6000546101a6906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100c0565b6101d16101cc366004612845565b61182f565b005b61017e6101e1366004612845565b6119d1565b60006101f483836001611da0565b90505b92915050565b6060806060806060600086516001600160401b03811115610220576102206122eb565b604051908082528060200260200182016040528015610249578160200160208202803683370190505b509050600087516001600160401b03811115610267576102676122eb565b604051908082528060200260200182016040528015610290578160200160208202803683370190505b509050600088516001600160401b038111156102ae576102ae6122eb565b6040519080825280602002602001820160405280156102e157816020015b60608152602001906001900390816102cc5790505b509050600089516001600160401b038111156102ff576102ff6122eb565b60405190808252806020026020018201604052801561033257816020015b606081526020019060019003908161031d5790505b50905060008a516001600160401b03811115610350576103506122eb565b604051908082528060200260200182016040528015610379578160200160208202803683370190505b50905060005b8b5181101561077e5760008c828151811061039c5761039c6129c6565b60200260200101519050806001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040891906129ec565b87838151811061041a5761041a6129c6565b60200260200101906001600160a01b031690816001600160a01b031681525050806001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610478573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104a09190810190612a09565b8583815181106104b2576104b26129c6565b60200260200101819052508482815181106104cf576104cf6129c6565b6020026020010151516001600160401b038111156104ef576104ef6122eb565b60405190808252806020026020018201604052801561052857816020015b61051561227c565b81526020019060019003908161050d5790505b5084838151811061053b5761053b6129c6565b602002602001018190525060005b85838151811061055b5761055b6129c6565b602002602001015151811015610647576105a88f83888681518110610582576105826129c6565b6020026020010151848151811061059b5761059b6129c6565b6020026020010151611e8c565b8685815181106105ba576105ba6129c6565b602002602001015183815181106105d3576105d36129c6565b60200260200101516000600281106105ed576105ed6129c6565b60200201878681518110610603576106036129c6565b6020026020010151848151811061061c5761061c6129c6565b6020026020010151600160028110610636576106366129c6565b602002019190915252600101610549565b5060405163331faf7160e21b81526001600160a01b038f8116600483015282169063cc7ebdc490602401602060405180830381865afa15801561068e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b29190612a97565b8683815181106106c4576106c46129c6565b6020026020010181815250508682815181106106e2576106e26129c6565b60209081029190910101516040516370a0823160e01b81526001600160a01b038381166004830152909116906370a0823190602401602060405180830381865afa158015610734573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107589190612a97565b83838151811061076a5761076a6129c6565b60209081029190910101525060010161037f565b50939b929a50909850965090945092505050565b6060806060806060600086516001600160401b038111156107b5576107b56122eb565b6040519080825280602002602001820160405280156107e857816020015b60608152602001906001900390816107d35790505b509050600087516001600160401b03811115610806576108066122eb565b60405190808252806020026020018201604052801561083957816020015b60608152602001906001900390816108245790505b509050600088516001600160401b03811115610857576108576122eb565b60405190808252806020026020018201604052801561088a57816020015b60608152602001906001900390816108755790505b509050600089516001600160401b038111156108a8576108a86122eb565b6040519080825280602002602001820160405280156108db57816020015b60608152602001906001900390816108c65790505b50905060008a516001600160401b038111156108f9576108f96122eb565b60405190808252806020026020018201604052801561092c57816020015b60608152602001906001900390816109175790505b50905060005b8b518110156109f65761095d8c8281518110610950576109506129c6565b6020026020010151610a17565b8a868151811061096f5761096f6129c6565b602002602001018a8781518110610988576109886129c6565b602002602001018a88815181106109a1576109a16129c6565b602002602001018a89815181106109ba576109ba6129c6565b602002602001018a8a815181106109d3576109d36129c6565b602090810291909101019490945293909252929091529190915252600101610932565b50939a9299509097509550909350915050565b60006101f483836000611da0565b60608060608060606000866001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610a5f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a879190810190612a09565b90506060876001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015610aea57506040513d6000823e601f3d908101601f19168201604052610ae79190810190612ab0565b60015b610b035750604080516000815260208101909152610b06565b90505b600081516001600160401b03811115610b2157610b216122eb565b604051908082528060200260200182016040528015610b4a578160200160208202803683370190505b509050600083516001600160401b03811115610b6857610b686122eb565b604051908082528060200260200182016040528015610b9b57816020015b6060815260200190600190039081610b865790505b509050600084516001600160401b03811115610bb957610bb96122eb565b604051908082528060200260200182016040528015610bec57816020015b6060815260200190600190039081610bd75790505b50905060005b8451811015610ca857848181518110610c0d57610c0d6129c6565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7691906129ec565b848281518110610c8857610c886129c6565b6001600160a01b0390921660209283029190910190910152600101610bf2565b5060005b85518110156109f6576000868281518110610cc957610cc96129c6565b6020026020010151905085516001600160401b03811115610cec57610cec6122eb565b604051908082528060200260200182016040528015610d15578160200160208202803683370190505b50848381518110610d2857610d286129c6565b602002602001018190525085516001600160401b03811115610d4c57610d4c6122eb565b604051908082528060200260200182016040528015610d75578160200160208202803683370190505b50838381518110610d8857610d886129c6565b602002602001018190525060005b8651811015610f0b576000878281518110610db357610db36129c6565b6020908102919091010151604051636aa875b560e01b81526001600160a01b03858116600483015291925090821690636aa875b590602401602060405180830381865afa158015610e08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2c9190612a97565b868581518110610e3e57610e3e6129c6565b60200260200101518381518110610e5757610e576129c6565b60209081029190910101526040516303d290cf60e61b81526001600160a01b03848116600483015282169063f4a433c090602401602060405180830381865afa158015610ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecc9190612a97565b858581518110610ede57610ede6129c6565b60200260200101518381518110610ef757610ef76129c6565b602090810291909101015250600101610d96565b5050600101610cac565b600080600060606000856001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8091906129ec565b90506000866001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe69190612b4e565b90506000876001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104c9190612b4e565b90506000886001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561108e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110b69190810190612a09565b90506000805b82518110156112ed5760008382815181106110d9576110d96129c6565b6020908102919091010151604051638e8f294b60e01b81526001600160a01b0380831660048301529192506000918e1690638e8f294b906024016040805180830381865afa15801561112f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111539190612b69565b509050806111625750506112e5565b6000826001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156111be575060408051601f3d908101601f191682019092526111bb918101906129ec565b60015b6111ca575050506112e5565b90506000836001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112309190612b4e565b90506000846001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190612b4e565b90508a6001600160a01b0316836001600160a01b03161415806112bd575089151582151514155b806112cc575088151581151514155b156112df57866112db81612bab565b9750505b50505050505b6001016110bc565b506000816001600160401b03811115611308576113086122eb565b60405190808252806020026020018201604052801561135a57816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816113265790505b5090506000805b84518110156115f457600085828151811061137e5761137e6129c6565b6020026020010151905060008e6001600160a01b0316638e8f294b836040518263ffffffff1660e01b81526004016113c591906001600160a01b0391909116815260200190565b6040805180830381865afa1580156113e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114059190612b69565b509050806114145750506115ec565b6000826001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611470575060408051601f3d908101601f1916820190925261146d918101906129ec565b60015b61147c575050506115ec565b90506000836001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e29190612b4e565b90506000846001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115489190612b4e565b90508c6001600160a01b0316836001600160a01b031614158061156f57508b151582151514155b8061157e57508a151581151514155b156115e6576040518060800160405280866001600160a01b03168152602001846001600160a01b0316815260200183151581526020018215158152508888815181106115cc576115cc6129c6565b602002602001018190525086806115e290612bab565b9750505b50505050505b600101611361565b50959b949a5092985091965091945050505050565b6060806060600080600060029054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261168c9190810190612d2c565b91509150600081516001600160401b038111156116ab576116ab6122eb565b6040519080825280602002602001820160405280156116d4578160200160208202803683370190505b509050600082516001600160401b038111156116f2576116f26122eb565b60405190808252806020026020018201604052801561172557816020015b60608152602001906001900390816117105790505b50905060005b835181101561181f576000848281518110611748576117486129c6565b6020026020010151604001519050806001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156117b557506040513d6000823e601f3d908101601f191682016040526117b29190810190612ab0565b60015b1561181657818584815181106117cd576117cd6129c6565b60200260200101906001600160a01b031690816001600160a01b0316815250506117f78b8261213a565b848481518110611809576118096129c6565b6020026020010181905250505b5060010161172b565b5092979096509194509092505050565b600054610100900460ff161580801561184f5750600054600160ff909116105b806118695750303b158015611869575060005460ff166001145b6118d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156118f4576000805461ff0019166101001790555b6001600160a01b0382166119655760405162461bcd60e51b815260206004820152603260248201527f506f6f6c4469726563746f727920696e7374616e63652063616e6e6f74206265604482015271103a3432903d32b9379030b2323932b9b99760711b60648201526084016118c8565b6000805462010000600160b01b031916620100006001600160a01b0385160217905580156119cd576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b606080606060008060029054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611a2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611a529190810190612d2c565b9150506000805b8251811015611b1657828181518110611a7457611a746129c6565b6020026020010151604001516001600160a01b03166316dc15fe886040518263ffffffff1660e01b8152600401611aba91906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015611af3575060408051601f3d908101601f19168201909252611af091810190612b4e565b60015b15611b0e578015611b0c5782611b0881612bab565b9350505b505b600101611a59565b506000816001600160401b03811115611b3157611b316122eb565b604051908082528060200260200182016040528015611b5a578160200160208202803683370190505b5090506000826001600160401b03811115611b7757611b776122eb565b604051908082528060200260200182016040528015611ba0578160200160208202803683370190505b5090506000836001600160401b03811115611bbd57611bbd6122eb565b604051908082528060200260200182016040528015611bf057816020015b6060815260200190600190039081611bdb5790505b5090506000805b8651811015611d90576000878281518110611c1457611c146129c6565b6020026020010151604001519050806001600160a01b03166316dc15fe8d6040518263ffffffff1660e01b8152600401611c5d91906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015611c96575060408051601f3d908101601f19168201909252611c9391810190612b4e565b60015b15611d87578015611d855782878581518110611cb457611cb46129c6565b60200260200101818152505081868581518110611cd357611cd36129c6565b60200260200101906001600160a01b031690816001600160a01b031681525050816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015611d5257506040513d6000823e601f3d908101601f19168201604052611d4f9190810190612ab0565b60015b15611d775780868681518110611d6a57611d6a6129c6565b6020026020010181905250505b83611d8181612bab565b9450505b505b50600101611bf7565b5092999198509650945050505050565b600080836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0591906129ec565b604051630cbb414760e11b81526001600160a01b0387811660048301528681166024830152851515604483015291925090821690631976828e90606401602060405180830381865afa158015611e5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e839190612a97565b95945050505050565b60405163331faf7160e21b81526001600160a01b038481166004830152600091829182919086169063cc7ebdc490602401602060405180830381865afa158015611eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611efe9190612a97565b60405162e48b0f60e51b81526001600160a01b038681166004830152888116602483015291925090861690631c9161e090604401600060405180830381600087803b158015611f4c57600080fd5b505af1158015611f60573d6000803e3d6000fd5b505060405163331faf7160e21b81526001600160a01b0389811660048301526000935084925088169063cc7ebdc490602401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd39190612a97565b611fdd9190612de7565b60405163331faf7160e21b81526001600160a01b0389811660048301529192509087169063cc7ebdc490602401602060405180830381865afa158015612027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204b9190612a97565b604051631cdc2c5d60e31b81526001600160a01b03878116600483015289811660248301529193509087169063e6e162e890604401600060405180830381600087803b15801561209a57600080fd5b505af11580156120ae573d6000803e3d6000fd5b505060405163331faf7160e21b81526001600160a01b038a811660048301526000935085925089169063cc7ebdc490602401602060405180830381865afa1580156120fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121219190612a97565b61212b9190612de7565b91989197509095505050505050565b6060600082516001600160401b03811115612157576121576122eb565b604051908082528060200260200182016040528015612180578160200160208202803683370190505b50905060005b83518110156122745760008482815181106121a3576121a36129c6565b602090810291909101015160405163331faf7160e21b81526001600160a01b0388811660048301529091169063cc7ebdc490602401602060405180830381865afa1580156121f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122199190612a97565b111561226c57838181518110612231576122316129c6565b602002602001015182828151811061224b5761224b6129c6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600101612186565b509392505050565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b03811681146122af57600080fd5b50565b600080604083850312156122c557600080fd5b82356122d08161229a565b915060208301356122e08161229a565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715612323576123236122eb565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612351576123516122eb565b604052919050565b60006001600160401b03821115612372576123726122eb565b5060051b60200190565b6000806040838503121561238f57600080fd5b823561239a8161229a565b91506020838101356001600160401b038111156123b657600080fd5b8401601f810186136123c757600080fd5b80356123da6123d582612359565b612329565b81815260059190911b820183019083810190888311156123f957600080fd5b928401925b828410156124205783356124118161229a565b825292840192908401906123fe565b80955050505050509250929050565b60008151808452602080850194506020840160005b838110156124695781516001600160a01b031687529582019590820190600101612444565b509495945050505050565b60008151808452602080850194506020840160005b8381101561246957815187529582019590820190600101612489565b60008282518085526020808601955060208260051b8401016020860160005b848110156124f257601f198684030189526124e083835161242f565b988401989250908301906001016124c4565b5090979650505050505050565b60a08152600061251260a083018861242f565b6020838203818501526125258289612474565b91506040848303604086015261253b83896124a5565b925084830360608601528287518085528385019150838160051b860101848a0160005b838110156125d457878303601f1901855281518051808552908801908885019060005b818110156125bf5783518360005b60028110156125ac5782518252918d0191908d019060010161258f565b505050928a019291890191600101612581565b5050958801959350509086019060010161255e565b505087810360808901526125e8818a612474565b9d9c50505050505050505050505050565b6000602080838503121561260c57600080fd5b82356001600160401b0381111561262257600080fd5b8301601f8101851361263357600080fd5b80356126416123d582612359565b81815260059190911b8201830190838101908783111561266057600080fd5b928401925b828410156126875783356126788161229a565b82529284019290840190612665565b979650505050505050565b600082825180855260208086019550808260051b8401018186016000805b8581101561270c57868403601f19018a52825180518086529086019086860190845b818110156126f75783516001600160a01b0316835292880192918801916001016126d2565b50509a86019a945050918401916001016126b0565b509198975050505050505050565b600082825180855260208086019550808260051b8401018186016000805b8581101561270c57868403601f19018a52825180518086529086019086860190845b818110156127765783518352928801929188019160010161275a565b50509a86019a94505091840191600101612738565b60008282518085526020808601955060208260051b8401016020860160005b848110156124f257601f198684030189526127c683835161271a565b988401989250908301906001016127aa565b60a0815260006127eb60a08301886124a5565b82810360208401526127fd8188612692565b905082810360408401526128118187612692565b90508281036060840152612825818661278b565b90508281036080840152612839818561278b565b98975050505050505050565b60006020828403121561285757600080fd5b81356128628161229a565b9392505050565b60a08152600061287c60a083018861242f565b828103602084015261288e818861242f565b905082810360408401526128a2818761242f565b905082810360608401526128b6818661271a565b90508281036080840152612839818561271a565b6000608080830160018060a01b038089168552602088151560208701526040881515604088015260606080606089015284895180875260a08a01915060208b01965060005b8181101561294c5787518051881684528681015188168785015285810151151586850152840151151584840152968501969188019160010161290f565b50909d9c50505050505050505050505050565b6060815260006129726060830186612474565b82810360208481019190915285518083528682019282019060005b818110156129b25784516001600160a01b03168352938301939183019160010161298d565b505084810360408601526128398187612692565b634e487b7160e01b600052603260045260246000fd5b80516129e78161229a565b919050565b6000602082840312156129fe57600080fd5b81516128628161229a565b60006020808385031215612a1c57600080fd5b82516001600160401b03811115612a3257600080fd5b8301601f81018513612a4357600080fd5b8051612a516123d582612359565b81815260059190911b82018301908381019087831115612a7057600080fd5b928401925b82841015612687578351612a888161229a565b82529284019290840190612a75565b600060208284031215612aa957600080fd5b5051919050565b60006020808385031215612ac357600080fd5b82516001600160401b03811115612ad957600080fd5b8301601f81018513612aea57600080fd5b8051612af86123d582612359565b81815260059190911b82018301908381019087831115612b1757600080fd5b928401925b82841015612687578351612b2f8161229a565b82529284019290840190612b1c565b805180151581146129e757600080fd5b600060208284031215612b6057600080fd5b6101f482612b3e565b60008060408385031215612b7c57600080fd5b612b8583612b3e565b9150602083015190509250929050565b634e487b7160e01b600052601160045260246000fd5b600060018201612bbd57612bbd612b95565b5060010190565b6000601f83601f840112612bd757600080fd5b82516020612be76123d583612359565b82815260059290921b85018101918181019087841115612c0657600080fd5b8287015b84811015612d205780516001600160401b0380821115612c2a5760008081fd5b9089019060a0601f19838d038101821315612c455760008081fd5b612c4d612301565b8885015184811115612c5f5760008081fd5b8501603f81018f13612c715760008081fd5b8981015185811115612c8557612c856122eb565b612c948b858f84011601612329565b9550808652604093508f84828401011115612caf5760008081fd5b60005b81811015612ccd578281018501518782018d01528b01612cb2565b5060009086018b015250838152612ce58583016129dc565b8982015260609350612cf88486016129dc565b9181019190915260808481015193820193909352920151908201528352918301918301612c0a565b50979650505050505050565b60008060408385031215612d3f57600080fd5b82516001600160401b0380821115612d5657600080fd5b818501915085601f830112612d6a57600080fd5b81516020612d7a6123d583612359565b82815260059290921b84018101918181019089841115612d9957600080fd5b948201945b83861015612db757855182529482019490820190612d9e565b91880151919650909350505080821115612dd057600080fd5b50612ddd85828601612bc4565b9150509250929050565b818103818111156101f7576101f7612b9556fea26469706673582212206bef02802407d09b599635818d8b4c1b2166778897a27119aba3e9cbe103fd6464736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806397f35ff01161006657806397f35ff014610148578063998e2d4a1461016b578063c41c2f241461018d578063c4d66de8146101be578063d24eaf13146101d357600080fd5b80631ec18ec0146100a3578063338038fa146100c95780633fc5fab5146100ed578063641290421461011157806384b3403d14610124575b600080fd5b6100b66100b13660046122b2565b6101e6565b6040519081526020015b60405180910390f35b6100dc6100d736600461237c565b6101fd565b6040516100c09594939291906124ff565b6101006100fb3660046125f9565b610792565b6040516100c09594939291906127d8565b6100b661011f3660046122b2565b610a09565b610137610132366004612845565b610a17565b6040516100c0959493929190612869565b61015b610156366004612845565b610f15565b6040516100c094939291906128ca565b61017e610179366004612845565b611609565b6040516100c09392919061295f565b6000546101a6906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100c0565b6101d16101cc366004612845565b61182f565b005b61017e6101e1366004612845565b6119d1565b60006101f483836001611da0565b90505b92915050565b6060806060806060600086516001600160401b03811115610220576102206122eb565b604051908082528060200260200182016040528015610249578160200160208202803683370190505b509050600087516001600160401b03811115610267576102676122eb565b604051908082528060200260200182016040528015610290578160200160208202803683370190505b509050600088516001600160401b038111156102ae576102ae6122eb565b6040519080825280602002602001820160405280156102e157816020015b60608152602001906001900390816102cc5790505b509050600089516001600160401b038111156102ff576102ff6122eb565b60405190808252806020026020018201604052801561033257816020015b606081526020019060019003908161031d5790505b50905060008a516001600160401b03811115610350576103506122eb565b604051908082528060200260200182016040528015610379578160200160208202803683370190505b50905060005b8b5181101561077e5760008c828151811061039c5761039c6129c6565b60200260200101519050806001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040891906129ec565b87838151811061041a5761041a6129c6565b60200260200101906001600160a01b031690816001600160a01b031681525050806001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610478573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104a09190810190612a09565b8583815181106104b2576104b26129c6565b60200260200101819052508482815181106104cf576104cf6129c6565b6020026020010151516001600160401b038111156104ef576104ef6122eb565b60405190808252806020026020018201604052801561052857816020015b61051561227c565b81526020019060019003908161050d5790505b5084838151811061053b5761053b6129c6565b602002602001018190525060005b85838151811061055b5761055b6129c6565b602002602001015151811015610647576105a88f83888681518110610582576105826129c6565b6020026020010151848151811061059b5761059b6129c6565b6020026020010151611e8c565b8685815181106105ba576105ba6129c6565b602002602001015183815181106105d3576105d36129c6565b60200260200101516000600281106105ed576105ed6129c6565b60200201878681518110610603576106036129c6565b6020026020010151848151811061061c5761061c6129c6565b6020026020010151600160028110610636576106366129c6565b602002019190915252600101610549565b5060405163331faf7160e21b81526001600160a01b038f8116600483015282169063cc7ebdc490602401602060405180830381865afa15801561068e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b29190612a97565b8683815181106106c4576106c46129c6565b6020026020010181815250508682815181106106e2576106e26129c6565b60209081029190910101516040516370a0823160e01b81526001600160a01b038381166004830152909116906370a0823190602401602060405180830381865afa158015610734573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107589190612a97565b83838151811061076a5761076a6129c6565b60209081029190910101525060010161037f565b50939b929a50909850965090945092505050565b6060806060806060600086516001600160401b038111156107b5576107b56122eb565b6040519080825280602002602001820160405280156107e857816020015b60608152602001906001900390816107d35790505b509050600087516001600160401b03811115610806576108066122eb565b60405190808252806020026020018201604052801561083957816020015b60608152602001906001900390816108245790505b509050600088516001600160401b03811115610857576108576122eb565b60405190808252806020026020018201604052801561088a57816020015b60608152602001906001900390816108755790505b509050600089516001600160401b038111156108a8576108a86122eb565b6040519080825280602002602001820160405280156108db57816020015b60608152602001906001900390816108c65790505b50905060008a516001600160401b038111156108f9576108f96122eb565b60405190808252806020026020018201604052801561092c57816020015b60608152602001906001900390816109175790505b50905060005b8b518110156109f65761095d8c8281518110610950576109506129c6565b6020026020010151610a17565b8a868151811061096f5761096f6129c6565b602002602001018a8781518110610988576109886129c6565b602002602001018a88815181106109a1576109a16129c6565b602002602001018a89815181106109ba576109ba6129c6565b602002602001018a8a815181106109d3576109d36129c6565b602090810291909101019490945293909252929091529190915252600101610932565b50939a9299509097509550909350915050565b60006101f483836000611da0565b60608060608060606000866001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610a5f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a879190810190612a09565b90506060876001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015610aea57506040513d6000823e601f3d908101601f19168201604052610ae79190810190612ab0565b60015b610b035750604080516000815260208101909152610b06565b90505b600081516001600160401b03811115610b2157610b216122eb565b604051908082528060200260200182016040528015610b4a578160200160208202803683370190505b509050600083516001600160401b03811115610b6857610b686122eb565b604051908082528060200260200182016040528015610b9b57816020015b6060815260200190600190039081610b865790505b509050600084516001600160401b03811115610bb957610bb96122eb565b604051908082528060200260200182016040528015610bec57816020015b6060815260200190600190039081610bd75790505b50905060005b8451811015610ca857848181518110610c0d57610c0d6129c6565b60200260200101516001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7691906129ec565b848281518110610c8857610c886129c6565b6001600160a01b0390921660209283029190910190910152600101610bf2565b5060005b85518110156109f6576000868281518110610cc957610cc96129c6565b6020026020010151905085516001600160401b03811115610cec57610cec6122eb565b604051908082528060200260200182016040528015610d15578160200160208202803683370190505b50848381518110610d2857610d286129c6565b602002602001018190525085516001600160401b03811115610d4c57610d4c6122eb565b604051908082528060200260200182016040528015610d75578160200160208202803683370190505b50838381518110610d8857610d886129c6565b602002602001018190525060005b8651811015610f0b576000878281518110610db357610db36129c6565b6020908102919091010151604051636aa875b560e01b81526001600160a01b03858116600483015291925090821690636aa875b590602401602060405180830381865afa158015610e08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2c9190612a97565b868581518110610e3e57610e3e6129c6565b60200260200101518381518110610e5757610e576129c6565b60209081029190910101526040516303d290cf60e61b81526001600160a01b03848116600483015282169063f4a433c090602401602060405180830381865afa158015610ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecc9190612a97565b858581518110610ede57610ede6129c6565b60200260200101518381518110610ef757610ef76129c6565b602090810291909101015250600101610d96565b5050600101610cac565b600080600060606000856001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8091906129ec565b90506000866001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe69190612b4e565b90506000876001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104c9190612b4e565b90506000886001600160a01b031663b0772d0b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561108e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110b69190810190612a09565b90506000805b82518110156112ed5760008382815181106110d9576110d96129c6565b6020908102919091010151604051638e8f294b60e01b81526001600160a01b0380831660048301529192506000918e1690638e8f294b906024016040805180830381865afa15801561112f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111539190612b69565b509050806111625750506112e5565b6000826001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156111be575060408051601f3d908101601f191682019092526111bb918101906129ec565b60015b6111ca575050506112e5565b90506000836001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112309190612b4e565b90506000846001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611272573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112969190612b4e565b90508a6001600160a01b0316836001600160a01b03161415806112bd575089151582151514155b806112cc575088151581151514155b156112df57866112db81612bab565b9750505b50505050505b6001016110bc565b506000816001600160401b03811115611308576113086122eb565b60405190808252806020026020018201604052801561135a57816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816113265790505b5090506000805b84518110156115f457600085828151811061137e5761137e6129c6565b6020026020010151905060008e6001600160a01b0316638e8f294b836040518263ffffffff1660e01b81526004016113c591906001600160a01b0391909116815260200190565b6040805180830381865afa1580156113e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114059190612b69565b509050806114145750506115ec565b6000826001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611470575060408051601f3d908101601f1916820190925261146d918101906129ec565b60015b61147c575050506115ec565b90506000836001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e29190612b4e565b90506000846001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611524573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115489190612b4e565b90508c6001600160a01b0316836001600160a01b031614158061156f57508b151582151514155b8061157e57508a151581151514155b156115e6576040518060800160405280866001600160a01b03168152602001846001600160a01b0316815260200183151581526020018215158152508888815181106115cc576115cc6129c6565b602002602001018190525086806115e290612bab565b9750505b50505050505b600101611361565b50959b949a5092985091965091945050505050565b6060806060600080600060029054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261168c9190810190612d2c565b91509150600081516001600160401b038111156116ab576116ab6122eb565b6040519080825280602002602001820160405280156116d4578160200160208202803683370190505b509050600082516001600160401b038111156116f2576116f26122eb565b60405190808252806020026020018201604052801561172557816020015b60608152602001906001900390816117105790505b50905060005b835181101561181f576000848281518110611748576117486129c6565b6020026020010151604001519050806001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156117b557506040513d6000823e601f3d908101601f191682016040526117b29190810190612ab0565b60015b1561181657818584815181106117cd576117cd6129c6565b60200260200101906001600160a01b031690816001600160a01b0316815250506117f78b8261213a565b848481518110611809576118096129c6565b6020026020010181905250505b5060010161172b565b5092979096509194509092505050565b600054610100900460ff161580801561184f5750600054600160ff909116105b806118695750303b158015611869575060005460ff166001145b6118d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156118f4576000805461ff0019166101001790555b6001600160a01b0382166119655760405162461bcd60e51b815260206004820152603260248201527f506f6f6c4469726563746f727920696e7374616e63652063616e6e6f74206265604482015271103a3432903d32b9379030b2323932b9b99760711b60648201526084016118c8565b6000805462010000600160b01b031916620100006001600160a01b0385160217905580156119cd576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b606080606060008060029054906101000a90046001600160a01b03166001600160a01b0316638ec083546040518163ffffffff1660e01b8152600401600060405180830381865afa158015611a2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611a529190810190612d2c565b9150506000805b8251811015611b1657828181518110611a7457611a746129c6565b6020026020010151604001516001600160a01b03166316dc15fe886040518263ffffffff1660e01b8152600401611aba91906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015611af3575060408051601f3d908101601f19168201909252611af091810190612b4e565b60015b15611b0e578015611b0c5782611b0881612bab565b9350505b505b600101611a59565b506000816001600160401b03811115611b3157611b316122eb565b604051908082528060200260200182016040528015611b5a578160200160208202803683370190505b5090506000826001600160401b03811115611b7757611b776122eb565b604051908082528060200260200182016040528015611ba0578160200160208202803683370190505b5090506000836001600160401b03811115611bbd57611bbd6122eb565b604051908082528060200260200182016040528015611bf057816020015b6060815260200190600190039081611bdb5790505b5090506000805b8651811015611d90576000878281518110611c1457611c146129c6565b6020026020010151604001519050806001600160a01b03166316dc15fe8d6040518263ffffffff1660e01b8152600401611c5d91906001600160a01b0391909116815260200190565b602060405180830381865afa925050508015611c96575060408051601f3d908101601f19168201909252611c9391810190612b4e565b60015b15611d87578015611d855782878581518110611cb457611cb46129c6565b60200260200101818152505081868581518110611cd357611cd36129c6565b60200260200101906001600160a01b031690816001600160a01b031681525050816001600160a01b0316633605b51b6040518163ffffffff1660e01b8152600401600060405180830381865afa925050508015611d5257506040513d6000823e601f3d908101601f19168201604052611d4f9190810190612ab0565b60015b15611d775780868681518110611d6a57611d6a6129c6565b6020026020010181905250505b83611d8181612bab565b9450505b505b50600101611bf7565b5092999198509650945050505050565b600080836001600160a01b0316635fe3b5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0591906129ec565b604051630cbb414760e11b81526001600160a01b0387811660048301528681166024830152851515604483015291925090821690631976828e90606401602060405180830381865afa158015611e5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e839190612a97565b95945050505050565b60405163331faf7160e21b81526001600160a01b038481166004830152600091829182919086169063cc7ebdc490602401602060405180830381865afa158015611eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611efe9190612a97565b60405162e48b0f60e51b81526001600160a01b038681166004830152888116602483015291925090861690631c9161e090604401600060405180830381600087803b158015611f4c57600080fd5b505af1158015611f60573d6000803e3d6000fd5b505060405163331faf7160e21b81526001600160a01b0389811660048301526000935084925088169063cc7ebdc490602401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd39190612a97565b611fdd9190612de7565b60405163331faf7160e21b81526001600160a01b0389811660048301529192509087169063cc7ebdc490602401602060405180830381865afa158015612027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204b9190612a97565b604051631cdc2c5d60e31b81526001600160a01b03878116600483015289811660248301529193509087169063e6e162e890604401600060405180830381600087803b15801561209a57600080fd5b505af11580156120ae573d6000803e3d6000fd5b505060405163331faf7160e21b81526001600160a01b038a811660048301526000935085925089169063cc7ebdc490602401602060405180830381865afa1580156120fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121219190612a97565b61212b9190612de7565b91989197509095505050505050565b6060600082516001600160401b03811115612157576121576122eb565b604051908082528060200260200182016040528015612180578160200160208202803683370190505b50905060005b83518110156122745760008482815181106121a3576121a36129c6565b602090810291909101015160405163331faf7160e21b81526001600160a01b0388811660048301529091169063cc7ebdc490602401602060405180830381865afa1580156121f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122199190612a97565b111561226c57838181518110612231576122316129c6565b602002602001015182828151811061224b5761224b6129c6565b60200260200101906001600160a01b031690816001600160a01b0316815250505b600101612186565b509392505050565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b03811681146122af57600080fd5b50565b600080604083850312156122c557600080fd5b82356122d08161229a565b915060208301356122e08161229a565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715612323576123236122eb565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612351576123516122eb565b604052919050565b60006001600160401b03821115612372576123726122eb565b5060051b60200190565b6000806040838503121561238f57600080fd5b823561239a8161229a565b91506020838101356001600160401b038111156123b657600080fd5b8401601f810186136123c757600080fd5b80356123da6123d582612359565b612329565b81815260059190911b820183019083810190888311156123f957600080fd5b928401925b828410156124205783356124118161229a565b825292840192908401906123fe565b80955050505050509250929050565b60008151808452602080850194506020840160005b838110156124695781516001600160a01b031687529582019590820190600101612444565b509495945050505050565b60008151808452602080850194506020840160005b8381101561246957815187529582019590820190600101612489565b60008282518085526020808601955060208260051b8401016020860160005b848110156124f257601f198684030189526124e083835161242f565b988401989250908301906001016124c4565b5090979650505050505050565b60a08152600061251260a083018861242f565b6020838203818501526125258289612474565b91506040848303604086015261253b83896124a5565b925084830360608601528287518085528385019150838160051b860101848a0160005b838110156125d457878303601f1901855281518051808552908801908885019060005b818110156125bf5783518360005b60028110156125ac5782518252918d0191908d019060010161258f565b505050928a019291890191600101612581565b5050958801959350509086019060010161255e565b505087810360808901526125e8818a612474565b9d9c50505050505050505050505050565b6000602080838503121561260c57600080fd5b82356001600160401b0381111561262257600080fd5b8301601f8101851361263357600080fd5b80356126416123d582612359565b81815260059190911b8201830190838101908783111561266057600080fd5b928401925b828410156126875783356126788161229a565b82529284019290840190612665565b979650505050505050565b600082825180855260208086019550808260051b8401018186016000805b8581101561270c57868403601f19018a52825180518086529086019086860190845b818110156126f75783516001600160a01b0316835292880192918801916001016126d2565b50509a86019a945050918401916001016126b0565b509198975050505050505050565b600082825180855260208086019550808260051b8401018186016000805b8581101561270c57868403601f19018a52825180518086529086019086860190845b818110156127765783518352928801929188019160010161275a565b50509a86019a94505091840191600101612738565b60008282518085526020808601955060208260051b8401016020860160005b848110156124f257601f198684030189526127c683835161271a565b988401989250908301906001016127aa565b60a0815260006127eb60a08301886124a5565b82810360208401526127fd8188612692565b905082810360408401526128118187612692565b90508281036060840152612825818661278b565b90508281036080840152612839818561278b565b98975050505050505050565b60006020828403121561285757600080fd5b81356128628161229a565b9392505050565b60a08152600061287c60a083018861242f565b828103602084015261288e818861242f565b905082810360408401526128a2818761242f565b905082810360608401526128b6818661271a565b90508281036080840152612839818561271a565b6000608080830160018060a01b038089168552602088151560208701526040881515604088015260606080606089015284895180875260a08a01915060208b01965060005b8181101561294c5787518051881684528681015188168785015285810151151586850152840151151584840152968501969188019160010161290f565b50909d9c50505050505050505050505050565b6060815260006129726060830186612474565b82810360208481019190915285518083528682019282019060005b818110156129b25784516001600160a01b03168352938301939183019160010161298d565b505084810360408601526128398187612692565b634e487b7160e01b600052603260045260246000fd5b80516129e78161229a565b919050565b6000602082840312156129fe57600080fd5b81516128628161229a565b60006020808385031215612a1c57600080fd5b82516001600160401b03811115612a3257600080fd5b8301601f81018513612a4357600080fd5b8051612a516123d582612359565b81815260059190911b82018301908381019087831115612a7057600080fd5b928401925b82841015612687578351612a888161229a565b82529284019290840190612a75565b600060208284031215612aa957600080fd5b5051919050565b60006020808385031215612ac357600080fd5b82516001600160401b03811115612ad957600080fd5b8301601f81018513612aea57600080fd5b8051612af86123d582612359565b81815260059190911b82018301908381019087831115612b1757600080fd5b928401925b82841015612687578351612b2f8161229a565b82529284019290840190612b1c565b805180151581146129e757600080fd5b600060208284031215612b6057600080fd5b6101f482612b3e565b60008060408385031215612b7c57600080fd5b612b8583612b3e565b9150602083015190509250929050565b634e487b7160e01b600052601160045260246000fd5b600060018201612bbd57612bbd612b95565b5060010190565b6000601f83601f840112612bd757600080fd5b82516020612be76123d583612359565b82815260059290921b85018101918181019087841115612c0657600080fd5b8287015b84811015612d205780516001600160401b0380821115612c2a5760008081fd5b9089019060a0601f19838d038101821315612c455760008081fd5b612c4d612301565b8885015184811115612c5f5760008081fd5b8501603f81018f13612c715760008081fd5b8981015185811115612c8557612c856122eb565b612c948b858f84011601612329565b9550808652604093508f84828401011115612caf5760008081fd5b60005b81811015612ccd578281018501518782018d01528b01612cb2565b5060009086018b015250838152612ce58583016129dc565b8982015260609350612cf88486016129dc565b9181019190915260808481015193820193909352920151908201528352918301918301612c0a565b50979650505050505050565b60008060408385031215612d3f57600080fd5b82516001600160401b0380821115612d5657600080fd5b818501915085601f830112612d6a57600080fd5b81516020612d7a6123d583612359565b82815260059290921b84018101918181019089841115612d9957600080fd5b948201945b83861015612db757855182529482019490820190612d9e565b91880151919650909350505080821115612dd057600080fd5b50612ddd85828601612bc4565b9150509250929050565b818103818111156101f7576101f7612b9556fea26469706673582212206bef02802407d09b599635818d8b4c1b2166778897a27119aba3e9cbe103fd6464736f6c63430008160033", + "devdoc": { + "author": "David Lucid (https://github.com/davidlucid)", + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "getFlywheelsToClaim(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getMaxBorrow(address,address)": { + "params": { + "account": "The account to determine liquidity for.", + "cTokenModify": "The market to hypothetically borrow in." + }, + "returns": { + "_0": "Maximum borrow amount." + } + }, + "getMaxRedeem(address,address)": { + "params": { + "account": "The account to determine liquidity for.", + "cTokenModify": "The market to hypothetically redeem in." + }, + "returns": { + "_0": "Maximum redeem amount." + } + }, + "getPoolOwnership(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive. Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state." + }, + "getRewardSpeedsByPool(address)": { + "params": { + "comptroller": "The Ionic pool Comptroller to check." + } + }, + "getRewardSpeedsByPools(address[])": { + "params": { + "comptrollers": "The Ionic pool Comptrollers to check." + } + }, + "getRewardsDistributorsBySupplier(address)": { + "details": "This function is not designed to be called in a transaction: it is too gas-intensive." + }, + "getUnclaimedRewardsByDistributors(address,address[])": { + "params": { + "distributors": "The `RewardsDistributor` contracts to check.", + "holder": "The address to check." + }, + "returns": { + "_0": "For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor." + } + } + }, + "title": "PoolLensSecondary", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "directory()": { + "notice": "`PoolDirectory` contract object." + }, + "getFlywheelsToClaim(address)": { + "notice": "The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim" + }, + "getMaxBorrow(address,address)": { + "notice": "Determine the maximum borrow amount of a cToken." + }, + "getMaxRedeem(address,address)": { + "notice": "Determine the maximum redeem amount of a cToken." + }, + "getPoolOwnership(address)": { + "notice": "Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties." + }, + "getRewardSpeedsByPool(address)": { + "notice": "Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds." + }, + "getRewardSpeedsByPools(address[])": { + "notice": "For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds." + }, + "getRewardsDistributorsBySupplier(address)": { + "notice": "Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`." + }, + "getUnclaimedRewardsByDistributors(address,address[])": { + "notice": "Returns all unclaimed rewards accrued by the `holder` on `distributors`." + }, + "initialize(address)": { + "notice": "Constructor to set the `PoolDirectory` contract object." + } + }, + "notice": "PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/PoolLensSecondary.sol:PoolLensSecondary", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/PoolLensSecondary.sol:PoolLensSecondary", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 16900, + "contract": "contracts/PoolLensSecondary.sol:PoolLensSecondary", + "label": "directory", + "offset": 2, + "slot": "0", + "type": "t_contract(PoolDirectory)14768" + } + ], + "types": { + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(PoolDirectory)14768": { + "encoding": "inplace", + "label": "contract PoolDirectory", + "numberOfBytes": "20" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/SimplePriceOracle.json b/packages/contracts/deployments/superseed/SimplePriceOracle.json new file mode 100644 index 0000000000..0bbe0221bb --- /dev/null +++ b/packages/contracts/deployments/superseed/SimplePriceOracle.json @@ -0,0 +1,547 @@ +{ + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "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": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousPriceMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "requestedPriceMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPriceMantissa", + "type": "uint256" + } + ], + "name": "PricePosted", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "assetPrices", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underlying", + "type": "address" + } + ], + "name": "price", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setDirectPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPriceMantissa", + "type": "uint256" + } + ], + "name": "setUnderlyingPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "transactionIndex": 1, + "gasUsed": "772074", + "logsBloom": "0x00000000000000000000000800000000400000000000000000800000000200000000000000000000000010100000000004000000100000000000000000000000000000000000000000000000000002000001000000004000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000000000000080000000000000c00000000000000000000000000000000400000000000000000000000000000000000000000020000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24", + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000d8d2d1195a548fe2ff69c31c4c90e54b263771c7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + } + ], + "blockNumber": 4135331, + "cumulativeGasUsed": "815940", + "status": 1, + "byzantium": true + }, + "args": [ + "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x8129fc1c" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "execute": { + "methodName": "initialize", + "args": [] + }, + "implementation": "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/SimplePriceOracle_Implementation.json b/packages/contracts/deployments/superseed/SimplePriceOracle_Implementation.json new file mode 100644 index 0000000000..55157a0ddc --- /dev/null +++ b/packages/contracts/deployments/superseed/SimplePriceOracle_Implementation.json @@ -0,0 +1,469 @@ +{ + "address": "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPendingOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "NewPendingOwner", + "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": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousPriceMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "requestedPriceMantissa", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPriceMantissa", + "type": "uint256" + } + ], + "name": "PricePosted", + "type": "event" + }, + { + "inputs": [], + "name": "_acceptOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPendingOwner", + "type": "address" + } + ], + "name": "_setPendingOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "assetPrices", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underlying", + "type": "address" + } + ], + "name": "price", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setDirectPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICErc20", + "name": "cToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "underlyingPriceMantissa", + "type": "uint256" + } + ], + "name": "setUnderlyingPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x882fb581a41d40aae82af2c659871a2503f8ea42812fe75b0f6eb9d48487127b", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7", + "transactionIndex": 1, + "gasUsed": "788039", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x1d6916c17a1822a4d2b934d46bf91855e5cee288acd01447fcf1ea7e7beb588c", + "transactionHash": "0x882fb581a41d40aae82af2c659871a2503f8ea42812fe75b0f6eb9d48487127b", + "logs": [], + "blockNumber": 4135328, + "cumulativeGasUsed": "840293", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"NewPendingOwner\",\"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\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousPriceMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requestedPriceMantissa\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newPriceMantissa\",\"type\":\"uint256\"}],\"name\":\"PricePosted\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_acceptOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"_setPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"assetPrices\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"underlying\",\"type\":\"address\"}],\"name\":\"price\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_price\",\"type\":\"uint256\"}],\"name\":\"setDirectPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICErc20\",\"name\":\"cToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"underlyingPriceMantissa\",\"type\":\"uint256\"}],\"name\":\"setUnderlyingPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"_acceptOwner()\":{\"details\":\"Owner function for pending owner to accept role and update owner\"},\"_setPendingOwner(address)\":{\"details\":\"Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\",\"params\":{\"newPendingOwner\":\"New pending owner.\"}},\"getUnderlyingPrice(address)\":{\"params\":{\"cToken\":\"The cToken to get the underlying price of\"},\"returns\":{\"_0\":\"The underlying asset price mantissa (scaled by 1e18). Zero means the price is unavailable.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"price(address)\":{\"params\":{\"underlying\":\"The underlying asset to get the price of.\"},\"returns\":{\"_0\":\"The underlying asset price in ETH as a mantissa (scaled by 1e18). Zero means the price is unavailable.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"events\":{\"NewOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is accepted, which means owner is updated\"},\"NewPendingOwner(address,address)\":{\"notice\":\"Emitted when pendingOwner is changed\"}},\"kind\":\"user\",\"methods\":{\"_acceptOwner()\":{\"notice\":\"Accepts transfer of owner rights. msg.sender must be pendingOwner\"},\"_setPendingOwner(address)\":{\"notice\":\"Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\"},\"getUnderlyingPrice(address)\":{\"notice\":\"Get the underlying price of a cToken asset\"},\"pendingOwner()\":{\"notice\":\"Pending owner of this contract\"},\"price(address)\":{\"notice\":\"Get the price of an underlying asset.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/default/SimplePriceOracle.sol\":\"SimplePriceOracle\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb94eac067c85cd79a4195c0a1f4a878e9827329045c12475a0199f1ae17b9700\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x636eab608b4563c01e88042aba9330e6fe69af2c567fe1adf4d85731974ac81d\",\"license\":\"MIT\"},\"adrastia-periphery/rates/IHistoricalRates.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\nimport \\\"./RateLibrary.sol\\\";\\n\\n/**\\n * @title IHistoricalRates\\n * @notice An interface that defines a contract that stores historical rates.\\n */\\ninterface IHistoricalRates {\\n /// @notice Gets an rate for a token at a specific index.\\n /// @param token The address of the token to get the rates for.\\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\\n /// index contains the oldest rate (uses reverse chronological ordering).\\n /// @return rate The rate for the token at the specified index.\\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the latest rates for a token.\\n /// @param token The address of the token to get the rates for.\\n /// @param amount The number of rates to get.\\n /// @param offset The index of the first rate to get (default: 0).\\n /// @param increment The increment between rates to get (default: 1).\\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\\n function getRates(\\n address token,\\n uint256 amount,\\n uint256 offset,\\n uint256 increment\\n ) external view returns (RateLibrary.Rate[] memory);\\n\\n /// @notice Gets the number of rates for a token.\\n /// @param token The address of the token to get the number of rates for.\\n /// @return count The number of rates for the token.\\n function getRatesCount(address token) external view returns (uint256);\\n\\n /// @notice Gets the capacity of rates for a token.\\n /// @param token The address of the token to get the capacity of rates for.\\n /// @return capacity The capacity of rates for the token.\\n function getRatesCapacity(address token) external view returns (uint256);\\n\\n /// @notice Sets the capacity of rates for a token.\\n /// @param token The address of the token to set the capacity of rates for.\\n /// @param amount The new capacity of rates for the token.\\n function setRatesCapacity(address token, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0x2754968c368df628f1ed00c2016b1a73f0f9b44f29e48d405887ad108723b3af\",\"license\":\"MIT\"},\"adrastia-periphery/rates/RateLibrary.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0 <0.9.0;\\n\\npragma experimental ABIEncoderV2;\\n\\nlibrary RateLibrary {\\n struct Rate {\\n uint64 target;\\n uint64 current;\\n uint32 timestamp;\\n }\\n}\\n\",\"keccak256\":\"0x397b79cf9f183afa76db3c8d10cffb408e31ba154900f671a7e93c071bacbff4\",\"license\":\"MIT\"},\"contracts/adrastia/PrudentiaLib.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nlibrary PrudentiaLib {\\n struct PrudentiaConfig {\\n address controller; // Adrastia Prudentia controller address\\n uint8 offset; // Offset for delayed rate activation\\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\\n }\\n}\\n\",\"keccak256\":\"0x8cc50f1a5dab30e0c205b0bba5f58c18eda9ebf01c661895c8f40678b86bf31f\",\"license\":\"UNLICENSED\"},\"contracts/compound/CTokenInterfaces.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller } from \\\"./ComptrollerInterface.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { ComptrollerV3Storage } from \\\"./ComptrollerStorage.sol\\\";\\nimport { AddressesProvider } from \\\"../ionic/AddressesProvider.sol\\\";\\n\\nabstract contract CTokenAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n}\\n\\nabstract contract CErc20Storage is CTokenAdminStorage {\\n /**\\n * @dev Guard variable for re-entrancy checks\\n */\\n bool internal _notEntered;\\n\\n /**\\n * @notice EIP-20 token name for this token\\n */\\n string public name;\\n\\n /**\\n * @notice EIP-20 token symbol for this token\\n */\\n string public symbol;\\n\\n /**\\n * @notice EIP-20 token decimals for this token\\n */\\n uint8 public decimals;\\n\\n /*\\n * Maximum borrow rate that can ever be applied (.0005% / block)\\n */\\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\\n\\n /*\\n * Maximum fraction of interest that can be set aside for reserves + fees\\n */\\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\\n\\n /**\\n * @notice Contract which oversees inter-cToken operations\\n */\\n IonicComptroller public comptroller;\\n\\n /**\\n * @notice Model which tells what the current interest rate should be\\n */\\n InterestRateModel public interestRateModel;\\n\\n /*\\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\\n */\\n uint256 internal initialExchangeRateMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for admin fees\\n */\\n uint256 public adminFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for Ionic fees\\n */\\n uint256 public ionicFeeMantissa;\\n\\n /**\\n * @notice Fraction of interest currently set aside for reserves\\n */\\n uint256 public reserveFactorMantissa;\\n\\n /**\\n * @notice Block number that interest was last accrued at\\n */\\n uint256 public accrualBlockNumber;\\n\\n /**\\n * @notice Accumulator of the total earned interest rate since the opening of the market\\n */\\n uint256 public borrowIndex;\\n\\n /**\\n * @notice Total amount of outstanding borrows of the underlying in this market\\n */\\n uint256 public totalBorrows;\\n\\n /**\\n * @notice Total amount of reserves of the underlying held in this market\\n */\\n uint256 public totalReserves;\\n\\n /**\\n * @notice Total amount of admin fees of the underlying held in this market\\n */\\n uint256 public totalAdminFees;\\n\\n /**\\n * @notice Total amount of Ionic fees of the underlying held in this market\\n */\\n uint256 public totalIonicFees;\\n\\n /**\\n * @notice Total number of tokens in circulation\\n */\\n uint256 public totalSupply;\\n\\n /*\\n * Official record of token balances for each account\\n */\\n mapping(address => uint256) internal accountTokens;\\n\\n /*\\n * Approved token transfer amounts on behalf of others\\n */\\n mapping(address => mapping(address => uint256)) internal transferAllowances;\\n\\n /**\\n * @notice Container for borrow balance information\\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\\n */\\n struct BorrowSnapshot {\\n uint256 principal;\\n uint256 interestIndex;\\n }\\n\\n /*\\n * Mapping of account addresses to outstanding borrow balances\\n */\\n mapping(address => BorrowSnapshot) internal accountBorrows;\\n\\n /*\\n * Share of seized collateral that is added to reserves\\n */\\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\\n\\n /*\\n * Share of seized collateral taken as fees\\n */\\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\\n\\n /**\\n * @notice Underlying asset for this CToken\\n */\\n address public underlying;\\n\\n /**\\n * @notice Addresses Provider\\n */\\n AddressesProvider public ap;\\n}\\n\\nabstract contract CTokenBaseEvents {\\n /* ERC20 */\\n\\n /**\\n * @notice EIP20 Transfer event\\n */\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /*** Admin Events ***/\\n\\n /**\\n * @notice Event emitted when interestRateModel is changed\\n */\\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\\n\\n /**\\n * @notice Event emitted when the reserve factor is changed\\n */\\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\\n\\n /**\\n * @notice Event emitted when the admin fee is changed\\n */\\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\\n\\n /**\\n * @notice Event emitted when the Ionic fee is changed\\n */\\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\\n\\n /**\\n * @notice EIP20 Approval event\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /**\\n * @notice Event emitted when interest is accrued\\n */\\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\\n}\\n\\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\\n event Flash(address receiver, uint256 amount);\\n}\\n\\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\\n /*** Market Events ***/\\n\\n /**\\n * @notice Event emitted when tokens are minted\\n */\\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\\n\\n /**\\n * @notice Event emitted when tokens are redeemed\\n */\\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\\n\\n /**\\n * @notice Event emitted when underlying is borrowed\\n */\\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is repaid\\n */\\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\\n\\n /**\\n * @notice Event emitted when a borrow is liquidated\\n */\\n event LiquidateBorrow(\\n address liquidator,\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral,\\n uint256 seizeTokens\\n );\\n\\n /**\\n * @notice Event emitted when the reserves are added\\n */\\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\\n\\n /**\\n * @notice Event emitted when the reserves are reduced\\n */\\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\\n}\\n\\ninterface CTokenFirstExtensionInterface {\\n /*** User Interface ***/\\n\\n function transfer(address dst, uint256 amount) external returns (bool);\\n\\n function transferFrom(\\n address src,\\n address dst,\\n uint256 amount\\n ) external returns (bool);\\n\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n function balanceOf(address owner) external view returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\\n\\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\\n\\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\\n\\n function getAccountSnapshot(address account)\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256\\n );\\n\\n function borrowRatePerBlock() external view returns (uint256);\\n\\n function supplyRatePerBlock() external view returns (uint256);\\n\\n function exchangeRateCurrent() external view returns (uint256);\\n\\n function accrueInterest() external returns (uint256);\\n\\n function totalBorrowsCurrent() external view returns (uint256);\\n\\n function borrowBalanceCurrent(address account) external view returns (uint256);\\n\\n function getTotalUnderlyingSupplied() external view returns (uint256);\\n\\n function balanceOfUnderlying(address owner) external view returns (uint256);\\n\\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\\n\\n function flash(uint256 amount, bytes calldata data) external;\\n\\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\\n\\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\\n\\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface CTokenSecondExtensionInterface {\\n function mint(uint256 mintAmount) external returns (uint256);\\n\\n function redeem(uint256 redeemTokens) external returns (uint256);\\n\\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\\n\\n function borrow(uint256 borrowAmount) external returns (uint256);\\n\\n function repayBorrow(uint256 repayAmount) external returns (uint256);\\n\\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\\n\\n function liquidateBorrow(\\n address borrower,\\n uint256 repayAmount,\\n address cTokenCollateral\\n ) external returns (uint256);\\n\\n function getCash() external view returns (uint256);\\n\\n function seize(\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n /*** Admin Functions ***/\\n\\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\\n\\n function selfTransferOut(address to, uint256 amount) external;\\n\\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\\n}\\n\\ninterface CDelegatorInterface {\\n function implementation() external view returns (address);\\n\\n /**\\n * @notice Called by the admin to update the implementation of the delegator\\n * @param implementation_ The address of the new implementation for delegation\\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\\n */\\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\\n\\n /**\\n * @dev upgrades the implementation if necessary\\n */\\n function _upgrade() external;\\n}\\n\\ninterface CDelegateInterface {\\n /**\\n * @notice Called by the delegator on a delegate to initialize it for duty\\n * @dev Should revert if any issues arise which make it unfit for delegation\\n * @param data The encoded bytes data for any initialization\\n */\\n function _becomeImplementation(bytes calldata data) external;\\n\\n function delegateType() external pure returns (uint8);\\n\\n function contractType() external pure returns (string memory);\\n}\\n\\nabstract contract CErc20AdminBase is CErc20Storage {\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\\n return\\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\\n }\\n}\\n\\nabstract contract CErc20FirstExtensionBase is\\n CErc20AdminBase,\\n CTokenFirstExtensionEvents,\\n CTokenFirstExtensionInterface\\n{}\\n\\nabstract contract CTokenSecondExtensionBase is\\n CErc20AdminBase,\\n CTokenSecondExtensionEvents,\\n CTokenSecondExtensionInterface,\\n CDelegateInterface\\n{}\\n\\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\\n\\ninterface CErc20StorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function comptroller() external view returns (IonicComptroller);\\n\\n function name() external view returns (string memory);\\n\\n function symbol() external view returns (string memory);\\n\\n function decimals() external view returns (uint8);\\n\\n function totalSupply() external view returns (uint256);\\n\\n function adminFeeMantissa() external view returns (uint256);\\n\\n function ionicFeeMantissa() external view returns (uint256);\\n\\n function reserveFactorMantissa() external view returns (uint256);\\n\\n function protocolSeizeShareMantissa() external view returns (uint256);\\n\\n function feeSeizeShareMantissa() external view returns (uint256);\\n\\n function totalReserves() external view returns (uint256);\\n\\n function totalAdminFees() external view returns (uint256);\\n\\n function totalIonicFees() external view returns (uint256);\\n\\n function totalBorrows() external view returns (uint256);\\n\\n function accrualBlockNumber() external view returns (uint256);\\n\\n function underlying() external view returns (address);\\n\\n function borrowIndex() external view returns (uint256);\\n\\n function interestRateModel() external view returns (address);\\n}\\n\\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\\n function plugin() external view returns (address);\\n}\\n\\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\\n function approve(address, address) external;\\n}\\n\\ninterface ICErc20 is\\n CErc20StorageInterface,\\n CTokenSecondExtensionInterface,\\n CTokenFirstExtensionInterface,\\n CDelegatorInterface,\\n CDelegateInterface\\n{}\\n\\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\\n function _updatePlugin(address _plugin) external;\\n}\\n\\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\\n\",\"keccak256\":\"0x7cc75051a5fa860b9ee93d0ba1ac0608921f02308aeff786ce8bbd8d8a70489a\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { BasePriceOracle } from \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { DiamondExtension } from \\\"../ionic/DiamondExtension.sol\\\";\\nimport { ComptrollerV4Storage } from \\\"../compound/ComptrollerStorage.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\nimport { IHistoricalRates } from \\\"adrastia-periphery/rates/IHistoricalRates.sol\\\";\\n\\ninterface ComptrollerInterface {\\n function isDeprecated(ICErc20 cToken) external view returns (bool);\\n\\n function _becomeImplementation() external;\\n\\n function _deployMarket(\\n uint8 delegateType,\\n bytes memory constructorData,\\n bytes calldata becomeImplData,\\n uint256 collateralFactorMantissa\\n ) external returns (uint256);\\n\\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\\n\\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\\n\\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\\n\\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\\n\\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\\n\\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\\n\\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\\n\\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\\n\\n function _addRewardsDistributor(address distributor) external returns (uint256);\\n\\n function getHypotheticalAccountLiquidity(\\n address account,\\n address cTokenModify,\\n uint256 redeemTokens,\\n uint256 borrowAmount,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256, uint256, uint256);\\n\\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\\n\\n /*** Assets You Are In ***/\\n\\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\\n\\n function exitMarket(address cToken) external returns (uint256);\\n\\n /*** Policy Hooks ***/\\n\\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\\n\\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\\n\\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\\n\\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\\n\\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\\n\\n function repayBorrowAllowed(\\n address cToken,\\n address payer,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function liquidateBorrowAllowed(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n address liquidator,\\n address borrower,\\n uint256 repayAmount\\n ) external returns (uint256);\\n\\n function seizeAllowed(\\n address cTokenCollateral,\\n address cTokenBorrowed,\\n address liquidator,\\n address borrower,\\n uint256 seizeTokens\\n ) external returns (uint256);\\n\\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\\n\\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\\n\\n /*** Liquidity/Liquidation Calculations ***/\\n\\n function getAccountLiquidity(\\n address account\\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\\n\\n function liquidateCalculateSeizeTokens(\\n address cTokenBorrowed,\\n address cTokenCollateral,\\n uint256 repayAmount\\n ) external view returns (uint256, uint256);\\n\\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\\n\\n function _beforeNonReentrant() external;\\n\\n function _afterNonReentrant() external;\\n\\n /*** New supply and borrow cap view functions ***/\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\\n}\\n\\ninterface ComptrollerStorageInterface {\\n function admin() external view returns (address);\\n\\n function adminHasRights() external view returns (bool);\\n\\n function ionicAdmin() external view returns (address);\\n\\n function ionicAdminHasRights() external view returns (bool);\\n\\n function pendingAdmin() external view returns (address);\\n\\n function oracle() external view returns (BasePriceOracle);\\n\\n function pauseGuardian() external view returns (address);\\n\\n function closeFactorMantissa() external view returns (uint256);\\n\\n function liquidationIncentiveMantissa() external view returns (uint256);\\n\\n function isUserOfPool(address user) external view returns (bool);\\n\\n function whitelist(address account) external view returns (bool);\\n\\n function enforceWhitelist() external view returns (bool);\\n\\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\\n\\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\\n\\n function suppliers(address account) external view returns (bool);\\n\\n function cTokensByUnderlying(address) external view returns (address);\\n\\n /**\\n * Gets the supply cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\\n * `effectiveSupplyCaps` to get the correct supply cap.\\n * @param cToken The address of the cToken.\\n * @return The supply cap in the units of the underlying asset.\\n */\\n function supplyCaps(address cToken) external view returns (uint256);\\n\\n /**\\n * Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\\n * `effectiveBorrowCaps` to get the correct borrow cap.\\n * @param cToken The address of the cToken.\\n * @return The borrow cap in the units of the underlying asset.\\n */\\n function borrowCaps(address cToken) external view returns (uint256);\\n\\n function markets(address cToken) external view returns (bool, uint256);\\n\\n function accountAssets(address, uint256) external view returns (address);\\n\\n function borrowGuardianPaused(address cToken) external view returns (bool);\\n\\n function mintGuardianPaused(address cToken) external view returns (bool);\\n\\n function rewardsDistributors(uint256) external view returns (address);\\n}\\n\\ninterface SFSRegister {\\n function register(address _recipient) external returns (uint256 tokenId);\\n}\\n\\ninterface ComptrollerExtensionInterface {\\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\\n\\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\\n\\n function getAllMarkets() external view returns (ICErc20[] memory);\\n\\n function getAllBorrowers() external view returns (address[] memory);\\n\\n function getAllBorrowersCount() external view returns (uint256);\\n\\n function getPaginatedBorrowers(\\n uint256 page,\\n uint256 pageSize\\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\\n\\n function getRewardsDistributors() external view returns (address[] memory);\\n\\n function getAccruingFlywheels() external view returns (address[] memory);\\n\\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\\n\\n function _setBorrowCapForCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBorrowCapForCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function _blacklistBorrowingAgainstCollateral(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n bool blacklisted\\n ) external;\\n\\n function _blacklistBorrowingAgainstCollateralWhitelist(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account,\\n bool whitelisted\\n ) external;\\n\\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\\n address cTokenBorrow,\\n address cTokenCollateral,\\n address account\\n ) external view returns (bool);\\n\\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\\n\\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\\n\\n function _removeFlywheel(address flywheelAddress) external returns (bool);\\n\\n function getWhitelist() external view returns (address[] memory);\\n\\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\\n\\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\\n\\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\\n\\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\\n\\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\\n\\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\\n\\n function _setTransferPaused(bool state) external returns (bool);\\n\\n function _setSeizePaused(bool state) external returns (bool);\\n\\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\\n\\n function getAssetAsCollateralValueCap(\\n ICErc20 collateral,\\n ICErc20 cTokenModify,\\n bool redeeming,\\n address account\\n ) external view returns (uint256);\\n\\n function registerInSFS() external returns (uint256);\\n}\\n\\ninterface ComptrollerPrudentiaCapsExtInterface {\\n /**\\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\\n * @return The config.\\n */\\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\\n * @return The config.\\n */\\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\\n * @param newConfig The new config.\\n */\\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n\\n /**\\n * @notice Sets the Adrastia Prudentia supply cap config.\\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\\n * @param newConfig The new config.\\n */\\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\\n}\\n\\ninterface UnitrollerInterface {\\n function comptrollerImplementation() external view returns (address);\\n\\n function _upgrade() external;\\n\\n function _acceptAdmin() external returns (uint256);\\n\\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\\n\\n function _toggleAdminRights(bool hasRights) external returns (uint256);\\n}\\n\\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\\n\\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\\n\\ninterface IonicComptroller is\\n ComptrollerInterface,\\n ComptrollerExtensionInterface,\\n UnitrollerInterface,\\n ComptrollerStorageInterface\\n{\\n\\n}\\n\\nabstract contract ComptrollerBase is ComptrollerV4Storage {\\n /// @notice Indicator that this is a Comptroller contract (for inspection)\\n bool public constant isComptroller = true;\\n\\n /**\\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the supply cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the supply cap from Adrastia Prudentia\\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n supplyCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n supplyCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local supply cap\\n\\n // Get the supply cap from the local supply cap\\n supplyCap = supplyCaps[cToken];\\n }\\n }\\n\\n /**\\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\\n * @param cToken The address of the cToken.\\n */\\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\\n\\n // Check if we're using Adrastia Prudentia for the borrow cap\\n if (capConfig.controller != address(0)) {\\n // We have a controller, so we're using Adrastia Prudentia\\n\\n address underlyingToken = ICErc20(cToken).underlying();\\n\\n // Get the borrow cap from Adrastia Prudentia\\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\\n\\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\\n // must scale the supply cap to get the correct amount\\n\\n int256 scaleByDecimals = 18;\\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\\\"decimals()\\\"));\\n if (success && data.length == 32) {\\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\\n }\\n\\n scaleByDecimals += capConfig.decimalShift;\\n\\n if (scaleByDecimals >= 0) {\\n // We're scaling up, so we need to multiply\\n borrowCap *= 10 ** uint256(scaleByDecimals);\\n } else {\\n // We're scaling down, so we need to divide\\n borrowCap /= 10 ** uint256(-scaleByDecimals);\\n }\\n } else {\\n // We don't have a controller, so we're using the local borrow cap\\n borrowCap = borrowCaps[cToken];\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7632af3b32bc1fccd14255b6885e74c4d5ac8de5f00fb8ed67186810d286424f\",\"license\":\"UNLICENSED\"},\"contracts/compound/ComptrollerStorage.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IFeeDistributor.sol\\\";\\nimport \\\"../oracles/BasePriceOracle.sol\\\";\\nimport { ICErc20 } from \\\"./CTokenInterfaces.sol\\\";\\nimport { PrudentiaLib } from \\\"../adrastia/PrudentiaLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract UnitrollerAdminStorage {\\n /*\\n * Administrator for Ionic\\n */\\n address payable public ionicAdmin;\\n\\n /**\\n * @notice Administrator for this contract\\n */\\n address public admin;\\n\\n /**\\n * @notice Pending administrator for this contract\\n */\\n address public pendingAdmin;\\n\\n /**\\n * @notice Whether or not the Ionic admin has admin rights\\n */\\n bool public ionicAdminHasRights = true;\\n\\n /**\\n * @notice Whether or not the admin has admin rights\\n */\\n bool public adminHasRights = true;\\n\\n /**\\n * @notice Returns a boolean indicating if the sender has admin rights\\n */\\n function hasAdminRights() internal view returns (bool) {\\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\\n }\\n}\\n\\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\\n /**\\n * @notice Oracle which gives the price of any given asset\\n */\\n BasePriceOracle public oracle;\\n\\n /**\\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\\n */\\n uint256 public closeFactorMantissa;\\n\\n /**\\n * @notice Multiplier representing the discount on collateral that a liquidator receives\\n */\\n uint256 public liquidationIncentiveMantissa;\\n\\n /*\\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\\n */\\n uint256 internal maxAssets;\\n\\n /**\\n * @notice Per-account mapping of \\\"assets you are in\\\", capped by maxAssets\\n */\\n mapping(address => ICErc20[]) public accountAssets;\\n}\\n\\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\\n struct Market {\\n // Whether or not this market is listed\\n bool isListed;\\n // Multiplier representing the most one can borrow against their collateral in this market.\\n // For instance, 0.9 to allow borrowing 90% of collateral value.\\n // Must be between 0 and 1, and stored as a mantissa.\\n uint256 collateralFactorMantissa;\\n // Per-market mapping of \\\"accounts in this asset\\\"\\n mapping(address => bool) accountMembership;\\n }\\n\\n /**\\n * @notice Official mapping of cTokens -> Market metadata\\n * @dev Used e.g. to determine if a market is supported\\n */\\n mapping(address => Market) public markets;\\n\\n /// @notice A list of all markets\\n ICErc20[] public allMarkets;\\n\\n /**\\n * @dev Maps borrowers to booleans indicating if they have entered any markets\\n */\\n mapping(address => bool) internal borrowers;\\n\\n /// @notice A list of all borrowers who have entered markets\\n address[] public allBorrowers;\\n\\n // Indexes of borrower account addresses in the `allBorrowers` array\\n mapping(address => uint256) internal borrowerIndexes;\\n\\n /**\\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\\n */\\n mapping(address => bool) public suppliers;\\n\\n /// @notice All cTokens addresses mapped by their underlying token addresses\\n mapping(address => ICErc20) public cTokensByUnderlying;\\n\\n /// @notice Whether or not the supplier whitelist is enforced\\n bool public enforceWhitelist;\\n\\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\\n mapping(address => bool) public whitelist;\\n\\n /// @notice An array of all whitelisted accounts\\n address[] public whitelistArray;\\n\\n // Indexes of account addresses in the `whitelistArray` array\\n mapping(address => uint256) internal whitelistIndexes;\\n\\n /**\\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\\n * Actions which allow users to remove their own assets cannot be paused.\\n * Liquidation / seizing / transfer can only be paused globally, not by market.\\n */\\n address public pauseGuardian;\\n bool public _mintGuardianPaused;\\n bool public _borrowGuardianPaused;\\n bool public transferGuardianPaused;\\n bool public seizeGuardianPaused;\\n mapping(address => bool) public mintGuardianPaused;\\n mapping(address => bool) public borrowGuardianPaused;\\n}\\n\\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\\n address public borrowCapGuardian;\\n\\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\\n mapping(address => uint256) public borrowCaps;\\n\\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\\n mapping(address => uint256) public supplyCaps;\\n\\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\\n address[] public rewardsDistributors;\\n\\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\\n bool internal _notEntered;\\n\\n /// @dev Whether or not _notEntered has been initialized\\n bool internal _notEnteredInitialized;\\n\\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\\n address[] public nonAccruingRewardsDistributors;\\n\\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\\n\\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => mapping(address => EnumerableSet.AddressSet))\\n internal borrowingAgainstCollateralBlacklistWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\\n\\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\\n}\\n\\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\\n /// @dev Adrastia Prudentia config for controlling borrow caps.\\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\\n\\n /// @dev Adrastia Prudentia config for controlling supply caps.\\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\\n}\\n\",\"keccak256\":\"0xa4a8110e666a93c1228c914f1414131e0f3b93385826bb72f6f93d429e514286\",\"license\":\"UNLICENSED\"},\"contracts/compound/IFeeDistributor.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../ionic/AuthoritiesRegistry.sol\\\";\\n\\ninterface IFeeDistributor {\\n function minBorrowEth() external view returns (uint256);\\n\\n function maxUtilizationRate() external view returns (uint256);\\n\\n function interestFeeRate() external view returns (uint256);\\n\\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\\n\\n function latestCErc20Delegate(uint8 delegateType)\\n external\\n view\\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\\n\\n function latestPluginImplementation(address oldImplementation) external view returns (address);\\n\\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\\n\\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\\n\\n function deployCErc20(\\n uint8 delegateType,\\n bytes calldata constructorData,\\n bytes calldata becomeImplData\\n ) external returns (address);\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n\\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\\n\\n fallback() external payable;\\n\\n receive() external payable;\\n}\\n\",\"keccak256\":\"0xa822e2942e6a88851968d5f3bda48709713c84d556031a1dd3db5dfd06121d3e\",\"license\":\"UNLICENSED\"},\"contracts/compound/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @title Compound's InterestRateModel Interface\\n * @author Compound\\n */\\nabstract contract InterestRateModel {\\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\\n bool public constant isInterestRateModel = true;\\n\\n /**\\n * @notice Calculates the current borrow interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getBorrowRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves\\n ) public view virtual returns (uint256);\\n\\n /**\\n * @notice Calculates the current supply interest rate per block\\n * @param cash The total amount of cash the market has\\n * @param borrows The total amount of borrows the market has outstanding\\n * @param reserves The total amount of reserves the market has\\n * @param reserveFactorMantissa The current reserve factor the market has\\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\\n */\\n function getSupplyRate(\\n uint256 cash,\\n uint256 borrows,\\n uint256 reserves,\\n uint256 reserveFactorMantissa\\n ) public view virtual returns (uint256);\\n}\\n\",\"keccak256\":\"0x587a54b49d48df2cd91583eac93ddde4e2849f79d0441f179bf835e9dffe24e9\",\"license\":\"UNLICENSED\"},\"contracts/ionic/AddressesProvider.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\n/**\\n * @title AddressesProvider\\n * @notice The Addresses Provider serves as a central storage of system internal and external\\n * contract addresses that change between deploys and across chains\\n * @author Veliko Minkov \\n */\\ncontract AddressesProvider is SafeOwnableUpgradeable {\\n mapping(string => address) private _addresses;\\n mapping(address => Contract) public plugins;\\n mapping(address => Contract) public flywheelRewards;\\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\\n JarvisPool[] public jarvisPoolsConfig;\\n CurveSwapPool[] public curveSwapPoolsConfig;\\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\\n\\n /// @dev Initializer to set the admin that can set and change contracts addresses\\n function initialize(address owner) public initializer {\\n __SafeOwnable_init(owner);\\n }\\n\\n /**\\n * @dev The contract address and a string that uniquely identifies the contract's interface\\n */\\n struct Contract {\\n address addr;\\n string contractInterface;\\n }\\n\\n struct RedemptionStrategy {\\n address addr;\\n string contractInterface;\\n address outputToken;\\n }\\n\\n struct FundingStrategy {\\n address addr;\\n string contractInterface;\\n address inputToken;\\n }\\n\\n struct JarvisPool {\\n address syntheticToken;\\n address collateralToken;\\n address liquidityPool;\\n uint256 expirationTime;\\n }\\n\\n struct CurveSwapPool {\\n address poolAddress;\\n address[] coins;\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the flywheel for the reward token\\n * @param rewardToken the reward token address\\n * @param flywheelRewardsModule the flywheel rewards module address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFlywheelRewards(\\n address rewardToken,\\n address flywheelRewardsModule,\\n string calldata contractInterface\\n ) public onlyOwner {\\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\\n * @param asset the asset address\\n * @param plugin the ERC4626 plugin address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setPlugin(\\n address asset,\\n address plugin,\\n string calldata contractInterface\\n ) public onlyOwner {\\n plugins[asset] = Contract(plugin, contractInterface);\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\\n * @param asset the asset address\\n * @param strategy redemption strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setRedemptionStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address outputToken\\n ) public onlyOwner {\\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\\n }\\n\\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\\n return redemptionStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev sets the address and contract interface ID of the funding strategy for the asset\\n * @param asset the asset address\\n * @param strategy funding strategy address\\n * @param contractInterface a string that uniquely identifies the contract's interface\\n */\\n function setFundingStrategy(\\n address asset,\\n address strategy,\\n string calldata contractInterface,\\n address inputToken\\n ) public onlyOwner {\\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\\n }\\n\\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\\n return fundingStrategiesConfig[asset];\\n }\\n\\n /**\\n * @dev configures the Jarvis pool of a Jarvis synthetic token\\n * @param syntheticToken the synthetic token address\\n * @param collateralToken the collateral token address\\n * @param liquidityPool the liquidity pool address\\n * @param expirationTime the operation expiration time\\n */\\n function setJarvisPool(\\n address syntheticToken,\\n address collateralToken,\\n address liquidityPool,\\n uint256 expirationTime\\n ) public onlyOwner {\\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\\n }\\n\\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\\n }\\n\\n /**\\n * @dev Sets an address for an id replacing the address saved in the addresses map\\n * @param id The id\\n * @param newAddress The address to set\\n */\\n function setAddress(string calldata id, address newAddress) external onlyOwner {\\n _addresses[id] = newAddress;\\n }\\n\\n /**\\n * @dev Returns an address by id\\n * @return The address\\n */\\n function getAddress(string calldata id) public view returns (address) {\\n return _addresses[id];\\n }\\n\\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\\n return curveSwapPoolsConfig;\\n }\\n\\n function getJarvisPools() public view returns (JarvisPool[] memory) {\\n return jarvisPoolsConfig;\\n }\\n\\n function setBalancerPoolForTokens(\\n address inputToken,\\n address outputToken,\\n address pool\\n ) external onlyOwner {\\n balancerPoolForTokens[inputToken][outputToken] = pool;\\n }\\n\\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\\n return balancerPoolForTokens[inputToken][outputToken];\\n }\\n}\\n\",\"keccak256\":\"0xf48e9e8b2150408c1c6b68dd957226c342ba47396da792fdaa0922f539a7e163\",\"license\":\"AGPL-3.0-only\"},\"contracts/ionic/AuthoritiesRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { PoolRolesAuthority } from \\\"../ionic/PoolRolesAuthority.sol\\\";\\nimport { SafeOwnableUpgradeable } from \\\"../ionic/SafeOwnableUpgradeable.sol\\\";\\nimport { IonicComptroller } from \\\"../compound/ComptrollerInterface.sol\\\";\\n\\nimport { TransparentUpgradeableProxy } from \\\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\\\";\\n\\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\\n PoolRolesAuthority public poolAuthLogic;\\n address public leveredPositionsFactory;\\n bool public noAuthRequired;\\n\\n function initialize(address _leveredPositionsFactory) public initializer {\\n __SafeOwnable_init(msg.sender);\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n }\\n\\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\\n leveredPositionsFactory = _leveredPositionsFactory;\\n poolAuthLogic = new PoolRolesAuthority();\\n // for Neon the auth is not required\\n noAuthRequired = block.chainid == 245022934;\\n }\\n\\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\\n require(address(poolsAuthorities[pool]) == address(0), \\\"already created\\\");\\n\\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \\\"\\\");\\n auth = PoolRolesAuthority(address(proxy));\\n auth.initialize(address(this));\\n poolsAuthorities[pool] = auth;\\n\\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\\n // sets the registry owner as the auth owner\\n reconfigureAuthority(pool);\\n }\\n\\n function reconfigureAuthority(address poolAddress) public {\\n IonicComptroller pool = IonicComptroller(poolAddress);\\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\\n\\n if (msg.sender != poolAddress || address(auth) != address(0)) {\\n require(address(auth) != address(0), \\\"no such authority\\\");\\n require(msg.sender == owner() || msg.sender == poolAddress, \\\"not owner or pool\\\");\\n\\n auth.configureRegistryCapabilities();\\n auth.configurePoolSupplierCapabilities(pool);\\n auth.configurePoolBorrowerCapabilities(pool);\\n // everyone can be a liquidator\\n auth.configureOpenPoolLiquidatorCapabilities(pool);\\n auth.configureLeveredPositionCapabilities(pool);\\n\\n if (auth.owner() != owner()) {\\n auth.setOwner(owner());\\n }\\n }\\n }\\n\\n function canCall(\\n address pool,\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool) {\\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\\n if (address(authorityForPool) == address(0)) {\\n return noAuthRequired;\\n } else {\\n // allow only if an auth exists and it allows the action\\n return authorityForPool.canCall(user, target, functionSig);\\n }\\n }\\n\\n function setUserRole(\\n address pool,\\n address user,\\n uint8 role,\\n bool enabled\\n ) external {\\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\\n\\n require(address(poolAuth) != address(0), \\\"auth does not exist\\\");\\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \\\"not owner or factory\\\");\\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \\\"only lev pos role\\\");\\n\\n poolAuth.setUserRole(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x98fc1f8a735b5759fc7524e3065ae322703d2771e7ec429e1cc9b60a4b1028dd\",\"license\":\"UNLICENSED\"},\"contracts/ionic/DiamondExtension.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\n/**\\n * @notice a base contract for logic extensions that use the diamond pattern storage\\n * to map the functions when looking up the extension contract to delegate to.\\n */\\nabstract contract DiamondExtension {\\n /**\\n * @return a list of all the function selectors that this logic extension exposes\\n */\\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\\n}\\n\\n// When no function exists for function called\\nerror FunctionNotFound(bytes4 _functionSelector);\\n\\n// When no extension exists for function called\\nerror ExtensionNotFound(bytes4 _functionSelector);\\n\\n// When the function is already added\\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\\n\\nabstract contract DiamondBase {\\n /**\\n * @dev register a logic extension\\n * @param extensionToAdd the extension whose functions are to be added\\n * @param extensionToReplace the extension whose functions are to be removed/replaced\\n */\\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\\n\\n function _listExtensions() public view returns (address[] memory) {\\n return LibDiamond.listExtensions();\\n }\\n\\n fallback() external {\\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\\n // Execute external function from extension using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the extension\\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n}\\n\\n/**\\n * @notice a library to use in a contract, whose logic is extended with diamond extension\\n */\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\\\"diamond.extensions.diamond.storage\\\");\\n\\n struct Function {\\n address extension;\\n bytes4 selector;\\n }\\n\\n struct LogicStorage {\\n Function[] functions;\\n address[] extensions;\\n }\\n\\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\\n return getExtensionForSelector(msgSig, diamondStorage());\\n }\\n\\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function listExtensions() internal view returns (address[] memory) {\\n return diamondStorage().extensions;\\n }\\n\\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\\n if (address(extensionToReplace) != address(0)) {\\n removeExtension(extensionToReplace);\\n }\\n addExtension(extensionToAdd);\\n }\\n\\n function removeExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n // remove all functions of the extension to replace\\n removeExtensionFunctions(extension);\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n if (ds.extensions[i] == address(extension)) {\\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\\n ds.extensions.pop();\\n }\\n }\\n }\\n\\n function addExtension(DiamondExtension extension) internal {\\n LogicStorage storage ds = diamondStorage();\\n for (uint8 i = 0; i < ds.extensions.length; i++) {\\n require(ds.extensions[i] != address(extension), \\\"extension already added\\\");\\n }\\n addExtensionFunctions(extension);\\n ds.extensions.push(address(extension));\\n }\\n\\n function removeExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\\n bytes4 selectorToRemove = fnsToRemove[i];\\n // must never fail\\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\\n // swap with the last element in the selectorAtIndex array and remove the last element\\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\\n ds.functions.pop();\\n }\\n }\\n\\n function addExtensionFunctions(DiamondExtension extension) internal {\\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\\n LogicStorage storage ds = diamondStorage();\\n uint16 functionsCount = uint16(ds.functions.length);\\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\\n bytes4 selector = fnsToAdd[functionsIndex];\\n address oldImplementation = getExtensionForSelector(selector, ds);\\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\\n ds.functions.push(Function(address(extension), selector));\\n functionsCount++;\\n }\\n }\\n\\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\\n uint256 fnsLen = ds.functions.length;\\n for (uint256 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\\n }\\n\\n return address(0);\\n }\\n\\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\\n uint16 fnsLen = uint16(ds.functions.length);\\n for (uint16 i = 0; i < fnsLen; i++) {\\n if (ds.functions[i].selector == selector) return i;\\n }\\n\\n return type(uint16).max;\\n }\\n}\\n\",\"keccak256\":\"0x6d33291928e3c255f0276fa465dcc5ea88d74a6562241a39ad2e52ae8abaf7bc\",\"license\":\"UNLICENSED\"},\"contracts/ionic/PoolRolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IonicComptroller, ComptrollerInterface } from \\\"../compound/ComptrollerInterface.sol\\\";\\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \\\"../compound/CTokenInterfaces.sol\\\";\\n\\nimport { RolesAuthority, Authority } from \\\"solmate/auth/authorities/RolesAuthority.sol\\\";\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\\\";\\n\\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\\n constructor() RolesAuthority(address(0), Authority(address(0))) {\\n _disableInitializers();\\n }\\n\\n function initialize(address _owner) public initializer {\\n owner = _owner;\\n authority = this;\\n }\\n\\n // up to 256 roles\\n uint8 public constant REGISTRY_ROLE = 0;\\n uint8 public constant SUPPLIER_ROLE = 1;\\n uint8 public constant BORROWER_ROLE = 2;\\n uint8 public constant LIQUIDATOR_ROLE = 3;\\n uint8 public constant LEVERED_POSITION_ROLE = 4;\\n\\n function configureRegistryCapabilities() external requiresAuth {\\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\\n true\\n );\\n setRoleCapability(\\n REGISTRY_ROLE,\\n address(this),\\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\\n true\\n );\\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\\n }\\n\\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, true);\\n }\\n\\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolSupplierCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\\n }\\n }\\n }\\n\\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\\n }\\n\\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\\n uint8 fnsCount = 6;\\n selectors = new bytes4[](fnsCount);\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\\n\\n require(fnsCount == 0, \\\"use the correct array length\\\");\\n return selectors;\\n }\\n\\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n bytes4[] memory selectors = getSupplierMarketSelectors();\\n for (uint256 j = 0; j < selectors.length; j++) {\\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\\n }\\n }\\n }\\n\\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, true);\\n }\\n\\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n _setPublicPoolBorrowerCapabilities(pool, false);\\n }\\n\\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\\n }\\n }\\n\\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\\n // borrowers have the SUPPLIER_ROLE capabilities by default\\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n\\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\\n // TODO this leaves redeeming open for everyone\\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n }\\n }\\n\\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\\n ICErc20[] memory allMarkets = pool.getAllMarkets();\\n for (uint256 i = 0; i < allMarkets.length; i++) {\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\\n\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1ec824166a7b4b1e67384a25d231d3acab89ef90ff43ff380cbf1715410d9851\",\"license\":\"UNLICENSED\"},\"contracts/ionic/SafeOwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\\\";\\n\\n/**\\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\\n * that will shift the other.\\n */\\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\\n /**\\n * @notice Pending owner of this contract\\n */\\n address public pendingOwner;\\n\\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\\n __Ownable_init();\\n _transferOwnership(owner_);\\n }\\n\\n struct AddressSlot {\\n address value;\\n }\\n\\n modifier onlyOwnerOrAdmin() {\\n bool isOwner = owner() == _msgSender();\\n if (!isOwner) {\\n address admin = _getProxyAdmin();\\n bool isAdmin = admin == _msgSender();\\n require(isAdmin, \\\"Ownable: caller is neither the owner nor the admin\\\");\\n }\\n _;\\n }\\n\\n /**\\n * @notice Emitted when pendingOwner is changed\\n */\\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\\n\\n /**\\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\\n */\\n event NewOwner(address oldOwner, address newOwner);\\n\\n /**\\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\\n * @param newPendingOwner New pending owner.\\n */\\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\\n // Save current value, if any, for inclusion in log\\n address oldPendingOwner = pendingOwner;\\n\\n // Store pendingOwner with value newPendingOwner\\n pendingOwner = newPendingOwner;\\n\\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\\n * @dev Owner function for pending owner to accept role and update owner\\n */\\n function _acceptOwner() public {\\n // Check caller is pendingOwner and pendingOwner \\u2260 address(0)\\n require(msg.sender == pendingOwner, \\\"not the pending owner\\\");\\n\\n // Save current values for inclusion in log\\n address oldOwner = owner();\\n address oldPendingOwner = pendingOwner;\\n\\n // Store owner with value pendingOwner\\n _transferOwnership(pendingOwner);\\n\\n // Clear the pending value\\n pendingOwner = address(0);\\n\\n emit NewOwner(oldOwner, pendingOwner);\\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\\n }\\n\\n function renounceOwnership() public override onlyOwner {\\n // do not remove this overriding fn\\n revert(\\\"not used anymore\\\");\\n }\\n\\n function transferOwnership(address newOwner) public override onlyOwner {\\n emit NewPendingOwner(pendingOwner, newOwner);\\n pendingOwner = newOwner;\\n }\\n\\n function _getProxyAdmin() internal view returns (address admin) {\\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n AddressSlot storage adminSlot;\\n assembly {\\n adminSlot.slot := _ADMIN_SLOT\\n }\\n admin = adminSlot.value;\\n }\\n}\\n\",\"keccak256\":\"0x73f50a022ee86874b63ebd7e418b5948ef2913e32cb80024fe3cd4f17be7f2a5\",\"license\":\"UNLICENSED\"},\"contracts/oracles/BasePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../compound/CTokenInterfaces.sol\\\";\\n\\n/**\\n * @title BasePriceOracle\\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\\n * @dev Implements the `PriceOracle` interface.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface BasePriceOracle {\\n /**\\n * @notice Get the price of an underlying asset.\\n * @param underlying The underlying asset to get the price of.\\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function price(address underlying) external view returns (uint256);\\n\\n /**\\n * @notice Get the underlying price of a cToken asset\\n * @param cToken The cToken to get the underlying price of\\n * @return The underlying asset price mantissa (scaled by 1e18).\\n * Zero means the price is unavailable.\\n */\\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xed2a27a8dc71a4280c0ef19d3165ff237d8066ae782e750b071bb39d12e73404\",\"license\":\"UNLICENSED\"},\"contracts/oracles/default/SimplePriceOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"../BasePriceOracle.sol\\\";\\nimport { ERC20Upgradeable } from \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\\\";\\nimport \\\"../../ionic/SafeOwnableUpgradeable.sol\\\";\\n\\ncontract SimplePriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\\n mapping(address => uint256) prices;\\n event PricePosted(\\n address asset,\\n uint256 previousPriceMantissa,\\n uint256 requestedPriceMantissa,\\n uint256 newPriceMantissa\\n );\\n\\n function initialize() public initializer {\\n __SafeOwnable_init(msg.sender);\\n }\\n\\n function getUnderlyingPrice(ICErc20 cToken) public view override returns (uint256) {\\n if (compareStrings(cToken.symbol(), \\\"cETH\\\")) {\\n return 1e18;\\n } else {\\n address underlying = ICErc20(address(cToken)).underlying();\\n uint256 oraclePrice = prices[underlying];\\n\\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\\n return\\n underlyingDecimals <= 18\\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\\n }\\n }\\n\\n function setUnderlyingPrice(ICErc20 cToken, uint256 underlyingPriceMantissa) public onlyOwner {\\n address asset = ICErc20(address(cToken)).underlying();\\n emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);\\n prices[asset] = underlyingPriceMantissa;\\n }\\n\\n function setDirectPrice(address asset, uint256 _price) public onlyOwner {\\n emit PricePosted(asset, prices[asset], _price, _price);\\n prices[asset] = _price;\\n }\\n\\n function price(address underlying) external view returns (uint256) {\\n return prices[address(underlying)];\\n }\\n\\n // v1 price oracle interface for use as backing of proxy\\n function assetPrices(address asset) external view returns (uint256) {\\n return prices[asset];\\n }\\n\\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\\n }\\n}\\n\",\"keccak256\":\"0xdbcea6c06314c3deffcf383629f85507d16bd7995798787ffe220fe215ca8c41\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x6c2b54ec184943843041ab77f61988b5060f6f03acbfe92cdc125f95f00891da\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\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\":\"0x17aff86be546601617585e91fd98aad74cf39f1be65d8eb6f93b7f3c30181275\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0a3b4afc301241e2629ad192fa02e0f8626e3cf38ab6f45342bfd7afbde16ee0\",\"license\":\"MIT\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/auth/Auth.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\nabstract contract Auth {\\n event OwnerUpdated(address indexed user, address indexed newOwner);\\n\\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\\n\\n address public owner;\\n\\n Authority public authority;\\n\\n constructor(address _owner, Authority _authority) {\\n owner = _owner;\\n authority = _authority;\\n\\n emit OwnerUpdated(msg.sender, _owner);\\n emit AuthorityUpdated(msg.sender, _authority);\\n }\\n\\n modifier requiresAuth() virtual {\\n require(isAuthorized(msg.sender, msg.sig), \\\"UNAUTHORIZED\\\");\\n\\n _;\\n }\\n\\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\\n\\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\\n }\\n\\n function setAuthority(Authority newAuthority) public virtual {\\n // We check if the caller is the owner first because we want to ensure they can\\n // always swap out the authority even if it's reverting or using up a lot of gas.\\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\\n\\n authority = newAuthority;\\n\\n emit AuthorityUpdated(msg.sender, newAuthority);\\n }\\n\\n function setOwner(address newOwner) public virtual requiresAuth {\\n owner = newOwner;\\n\\n emit OwnerUpdated(msg.sender, newOwner);\\n }\\n}\\n\\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\\ninterface Authority {\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd5cf8213a40d727af89c93dd359ad68984c123c1a1a93fc9ad7ba62b3436fb75\",\"license\":\"AGPL-3.0-only\"},\"solmate/auth/authorities/RolesAuthority.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport {Auth, Authority} from \\\"../Auth.sol\\\";\\n\\n/// @notice Role based Authority that supports up to 256 roles.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\\ncontract RolesAuthority is Auth, Authority {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\\n\\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE/USER STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n mapping(address => bytes32) public getUserRoles;\\n\\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\\n\\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\\n\\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\\n }\\n\\n function doesRoleHaveCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig\\n ) public view virtual returns (bool) {\\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n AUTHORIZATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function canCall(\\n address user,\\n address target,\\n bytes4 functionSig\\n ) public view virtual override returns (bool) {\\n return\\n isCapabilityPublic[target][functionSig] ||\\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ROLE CAPABILITY CONFIGURATION LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setPublicCapability(\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n isCapabilityPublic[target][functionSig] = enabled;\\n\\n emit PublicCapabilityUpdated(target, functionSig, enabled);\\n }\\n\\n function setRoleCapability(\\n uint8 role,\\n address target,\\n bytes4 functionSig,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\\n } else {\\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\\n }\\n\\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n USER ROLE ASSIGNMENT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function setUserRole(\\n address user,\\n uint8 role,\\n bool enabled\\n ) public virtual requiresAuth {\\n if (enabled) {\\n getUserRoles[user] |= bytes32(1 << role);\\n } else {\\n getUserRoles[user] &= ~bytes32(1 << role);\\n }\\n\\n emit UserRoleUpdated(user, role, enabled);\\n }\\n}\\n\",\"keccak256\":\"0x278247a2c5b0accb60af8d3749e34ab5d4436ee4f35a8fff301aaa25ab690762\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610d4a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b14610140578063aea91078146100e1578063e30c397814610165578063f2fde38b14610178578063fc4d33f91461018b578063fc57d4df1461019357600080fd5b806309a8acb0146100b9578063127ffda0146100ce5780635e9a523c146100e15780636e96dfd71461011d578063715018a6146101305780638129fc1c14610138575b600080fd5b6100cc6100c73660046109e4565b6101a6565b005b6100cc6100dc3660046109e4565b610229565b61010a6100ef366004610a10565b6001600160a01b031660009081526066602052604090205490565b6040519081526020015b60405180910390f35b6100cc61012b366004610a10565b610312565b6100cc61037c565b6100cc6103c4565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610114565b60655461014d906001600160a01b031681565b6100cc610186366004610a10565b6104d6565b6100cc610547565b61010a6101a1366004610a10565b61065b565b6101ae610839565b6001600160a01b038216600081815260666020908152604091829020548251938452908301528101829052606081018290527fdd71a1d19fcba687442a1d5c58578f1e409af71a79d10fd95a4d66efd8fa9ae79060800160405180910390a16001600160a01b03909116600090815260666020526040902055565b610231610839565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102959190610a34565b6001600160a01b038116600081815260666020908152604091829020548251938452908301528101849052606081018490529091507fdd71a1d19fcba687442a1d5c58578f1e409af71a79d10fd95a4d66efd8fa9ae79060800160405180910390a16001600160a01b031660009081526066602052604090205550565b61031a610839565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b610384610839565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064015b60405180910390fd5b600054610100900460ff16158080156103e45750600054600160ff909116105b806103fe5750303b1580156103fe575060005460ff166001145b6104615760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103bb565b6000805460ff191660011790558015610484576000805461ff0019166101001790555b61048d33610895565b80156104d3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6104de610839565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b031633146105995760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b60448201526064016103bb565b60006105ad6033546001600160a01b031690565b6065549091506001600160a01b03166105c5816108c9565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101610370565b60006106e8826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561069e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106c69190810190610a8b565b604051806040016040528060048152602001630c68aa8960e31b81525061091b565b156106fc5750670de0b6b3a7640000919050565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107609190610a34565b6001600160a01b038116600081815260666020908152604080832054815163313ce56760e01b815291519596509492939263313ce567926004808401939192918290030181865afa1580156107b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107dd9190610b38565b60ff1690506012811115610810576107f6601282610b71565b61080190600a610c68565b61080b9083610c74565b610830565b61081b816012610b71565b61082690600a610c68565b6108309083610c96565b95945050505050565b6033546001600160a01b031633146108935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103bb565b565b600054610100900460ff166108bc5760405162461bcd60e51b81526004016103bb90610cad565b6108c4610975565b6104d3815b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008160405160200161092e9190610cf8565b60405160208183030381529060405280519060200120836040516020016109559190610cf8565b604051602081830303815290604052805190602001201490505b92915050565b600054610100900460ff1661099c5760405162461bcd60e51b81526004016103bb90610cad565b610893600054610100900460ff166109c65760405162461bcd60e51b81526004016103bb90610cad565b610893336108c9565b6001600160a01b03811681146104d357600080fd5b600080604083850312156109f757600080fd5b8235610a02816109cf565b946020939093013593505050565b600060208284031215610a2257600080fd5b8135610a2d816109cf565b9392505050565b600060208284031215610a4657600080fd5b8151610a2d816109cf565b634e487b7160e01b600052604160045260246000fd5b60005b83811015610a82578181015183820152602001610a6a565b50506000910152565b600060208284031215610a9d57600080fd5b815167ffffffffffffffff80821115610ab557600080fd5b818401915084601f830112610ac957600080fd5b815181811115610adb57610adb610a51565b604051601f8201601f19908116603f01168101908382118183101715610b0357610b03610a51565b81604052828152876020848701011115610b1c57600080fd5b610b2d836020830160208801610a67565b979650505050505050565b600060208284031215610b4a57600080fd5b815160ff81168114610a2d57600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561096f5761096f610b5b565b600181815b80851115610bbf578160001904821115610ba557610ba5610b5b565b80851615610bb257918102915b93841c9390800290610b89565b509250929050565b600082610bd65750600161096f565b81610be35750600061096f565b8160018114610bf95760028114610c0357610c1f565b600191505061096f565b60ff841115610c1457610c14610b5b565b50506001821b61096f565b5060208310610133831016604e8410600b8410161715610c42575081810a61096f565b610c4c8383610b84565b8060001904821115610c6057610c60610b5b565b029392505050565b6000610a2d8383610bc7565b600082610c9157634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761096f5761096f610b5b565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251610d0a818460208701610a67565b919091019291505056fea2646970667358221220dd496347511ec8296f7ef10fd462cf201e7a79d1ea87cde4389b92aeafcd2c5764736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b14610140578063aea91078146100e1578063e30c397814610165578063f2fde38b14610178578063fc4d33f91461018b578063fc57d4df1461019357600080fd5b806309a8acb0146100b9578063127ffda0146100ce5780635e9a523c146100e15780636e96dfd71461011d578063715018a6146101305780638129fc1c14610138575b600080fd5b6100cc6100c73660046109e4565b6101a6565b005b6100cc6100dc3660046109e4565b610229565b61010a6100ef366004610a10565b6001600160a01b031660009081526066602052604090205490565b6040519081526020015b60405180910390f35b6100cc61012b366004610a10565b610312565b6100cc61037c565b6100cc6103c4565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610114565b60655461014d906001600160a01b031681565b6100cc610186366004610a10565b6104d6565b6100cc610547565b61010a6101a1366004610a10565b61065b565b6101ae610839565b6001600160a01b038216600081815260666020908152604091829020548251938452908301528101829052606081018290527fdd71a1d19fcba687442a1d5c58578f1e409af71a79d10fd95a4d66efd8fa9ae79060800160405180910390a16001600160a01b03909116600090815260666020526040902055565b610231610839565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102959190610a34565b6001600160a01b038116600081815260666020908152604091829020548251938452908301528101849052606081018490529091507fdd71a1d19fcba687442a1d5c58578f1e409af71a79d10fd95a4d66efd8fa9ae79060800160405180910390a16001600160a01b031660009081526066602052604090205550565b61031a610839565b606580546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b91015b60405180910390a15050565b610384610839565b60405162461bcd60e51b815260206004820152601060248201526f6e6f74207573656420616e796d6f726560801b60448201526064015b60405180910390fd5b600054610100900460ff16158080156103e45750600054600160ff909116105b806103fe5750303b1580156103fe575060005460ff166001145b6104615760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103bb565b6000805460ff191660011790558015610484576000805461ff0019166101001790555b61048d33610895565b80156104d3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6104de610839565b606554604080516001600160a01b03928316815291831660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b910160405180910390a1606580546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b031633146105995760405162461bcd60e51b81526020600482015260156024820152743737ba103a3432903832b73234b7339037bbb732b960591b60448201526064016103bb565b60006105ad6033546001600160a01b031690565b6065549091506001600160a01b03166105c5816108c9565b606580546001600160a01b0319169055604080516001600160a01b0384168152600060208201527f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364910160405180910390a1606554604080516001600160a01b03808516825290921660208301527fb3d55174552271a4f1aaf36b72f50381e892171636b3fb5447fe00e995e7a37b9101610370565b60006106e8826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561069e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106c69190810190610a8b565b604051806040016040528060048152602001630c68aa8960e31b81525061091b565b156106fc5750670de0b6b3a7640000919050565b6000826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107609190610a34565b6001600160a01b038116600081815260666020908152604080832054815163313ce56760e01b815291519596509492939263313ce567926004808401939192918290030181865afa1580156107b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107dd9190610b38565b60ff1690506012811115610810576107f6601282610b71565b61080190600a610c68565b61080b9083610c74565b610830565b61081b816012610b71565b61082690600a610c68565b6108309083610c96565b95945050505050565b6033546001600160a01b031633146108935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103bb565b565b600054610100900460ff166108bc5760405162461bcd60e51b81526004016103bb90610cad565b6108c4610975565b6104d3815b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008160405160200161092e9190610cf8565b60405160208183030381529060405280519060200120836040516020016109559190610cf8565b604051602081830303815290604052805190602001201490505b92915050565b600054610100900460ff1661099c5760405162461bcd60e51b81526004016103bb90610cad565b610893600054610100900460ff166109c65760405162461bcd60e51b81526004016103bb90610cad565b610893336108c9565b6001600160a01b03811681146104d357600080fd5b600080604083850312156109f757600080fd5b8235610a02816109cf565b946020939093013593505050565b600060208284031215610a2257600080fd5b8135610a2d816109cf565b9392505050565b600060208284031215610a4657600080fd5b8151610a2d816109cf565b634e487b7160e01b600052604160045260246000fd5b60005b83811015610a82578181015183820152602001610a6a565b50506000910152565b600060208284031215610a9d57600080fd5b815167ffffffffffffffff80821115610ab557600080fd5b818401915084601f830112610ac957600080fd5b815181811115610adb57610adb610a51565b604051601f8201601f19908116603f01168101908382118183101715610b0357610b03610a51565b81604052828152876020848701011115610b1c57600080fd5b610b2d836020830160208801610a67565b979650505050505050565b600060208284031215610b4a57600080fd5b815160ff81168114610a2d57600080fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561096f5761096f610b5b565b600181815b80851115610bbf578160001904821115610ba557610ba5610b5b565b80851615610bb257918102915b93841c9390800290610b89565b509250929050565b600082610bd65750600161096f565b81610be35750600061096f565b8160018114610bf95760028114610c0357610c1f565b600191505061096f565b60ff841115610c1457610c14610b5b565b50506001821b61096f565b5060208310610133831016604e8410600b8410161715610c42575081810a61096f565b610c4c8383610b84565b8060001904821115610c6057610c60610b5b565b029392505050565b6000610a2d8383610bc7565b600082610c9157634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761096f5761096f610b5b565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251610d0a818460208701610a67565b919091019291505056fea2646970667358221220dd496347511ec8296f7ef10fd462cf201e7a79d1ea87cde4389b92aeafcd2c5764736f6c63430008160033", + "devdoc": { + "events": { + "Initialized(uint8)": { + "details": "Triggered when the contract has been initialized or reinitialized." + } + }, + "kind": "dev", + "methods": { + "_acceptOwner()": { + "details": "Owner function for pending owner to accept role and update owner" + }, + "_setPendingOwner(address)": { + "details": "Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.", + "params": { + "newPendingOwner": "New pending owner." + } + }, + "getUnderlyingPrice(address)": { + "params": { + "cToken": "The cToken to get the underlying price of" + }, + "returns": { + "_0": "The underlying asset price mantissa (scaled by 1e18). Zero means the price is unavailable." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "price(address)": { + "params": { + "underlying": "The underlying asset to get the price of." + }, + "returns": { + "_0": "The underlying asset price in ETH as a mantissa (scaled by 1e18). Zero means the price is unavailable." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "NewOwner(address,address)": { + "notice": "Emitted when pendingOwner is accepted, which means owner is updated" + }, + "NewPendingOwner(address,address)": { + "notice": "Emitted when pendingOwner is changed" + } + }, + "kind": "user", + "methods": { + "_acceptOwner()": { + "notice": "Accepts transfer of owner rights. msg.sender must be pendingOwner" + }, + "_setPendingOwner(address)": { + "notice": "Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer." + }, + "getUnderlyingPrice(address)": { + "notice": "Get the underlying price of a cToken asset" + }, + "pendingOwner()": { + "notice": "Pending owner of this contract" + }, + "price(address)": { + "notice": "Get the price of an underlying asset." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 184207, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 184210, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 186558, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 183831, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 183951, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 54261, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "pendingOwner", + "offset": 0, + "slot": "101", + "type": "t_address" + }, + { + "astId": 87786, + "contract": "contracts/oracles/default/SimplePriceOracle.sol:SimplePriceOracle", + "label": "prices", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "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_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/SimplePriceOracle_Proxy.json b/packages/contracts/deployments/superseed/SimplePriceOracle_Proxy.json new file mode 100644 index 0000000000..ec41b4b2be --- /dev/null +++ b/packages/contracts/deployments/superseed/SimplePriceOracle_Proxy.json @@ -0,0 +1,275 @@ +{ + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "transactionIndex": 1, + "gasUsed": "772074", + "logsBloom": "0x00000000000000000000000800000000400000000000000000800000000200000000000000000000000010100000000004000000100000000000000000000000000000000000000000000000000002000001000000004000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000000000000080000000000000c00000000000000000000000000000000400000000000000000000000000000000000000000020000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24", + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000d8d2d1195a548fe2ff69c31c4c90e54b263771c7" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7", + "0x0000000000000000000000001155b614971f16758c92c4890ed338c9e3ede6b7" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + }, + { + "transactionIndex": 1, + "blockNumber": 4135331, + "transactionHash": "0xf89d2496cd58c977d15af52c3a096edfe6d1b1df7e6827bbced6fa667cee8e5b", + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c21db52cca974df3dc019c92e52e522ce57156", + "logIndex": 4, + "blockHash": "0x4aaa99d0f29b3e62f125d9f8ecc1217fb9e2b48022bca525475ead1fdbf4df24" + } + ], + "blockNumber": 4135331, + "cumulativeGasUsed": "815940", + "status": 1, + "byzantium": true + }, + "args": [ + "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7", + "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156", + "0x8129fc1c" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/UniswapV3LiquidatorFunder.json b/packages/contracts/deployments/superseed/UniswapV3LiquidatorFunder.json new file mode 100644 index 0000000000..eac00b9226 --- /dev/null +++ b/packages/contracts/deployments/superseed/UniswapV3LiquidatorFunder.json @@ -0,0 +1,167 @@ +{ + "address": "0x1D89E5ba287E67AC0046D2218Be5fE1382cE47b4", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "strategyData", + "type": "bytes" + } + ], + "name": "convert", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "strategyData", + "type": "bytes" + } + ], + "name": "estimateInputAmount", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "strategyData", + "type": "bytes" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "outputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xcbda28745a5037ba7b76cffdb5506fd99a5b124e32eb78498c59dabf0f45d40f", + "receipt": { + "to": null, + "from": "0x1155b614971f16758C92c4890eD338C9e3ede6b7", + "contractAddress": "0x1D89E5ba287E67AC0046D2218Be5fE1382cE47b4", + "transactionIndex": 1, + "gasUsed": "381373", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2bc5c183145d8cf35a620dc7dc9043198a7c030bc044e7476cb93147644706a3", + "transactionHash": "0xcbda28745a5037ba7b76cffdb5506fd99a5b124e32eb78498c59dabf0f45d40f", + "logs": [], + "blockNumber": 4135351, + "cumulativeGasUsed": "425251", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4516d6f7efae8f060f60e63dbb0131ce", + "metadata": "{\"compiler\":{\"version\":\"0.8.22+commit.4fc1097e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputAmount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"strategyData\",\"type\":\"bytes\"}],\"name\":\"convert\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"outputAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"outputAmount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"strategyData\",\"type\":\"bytes\"}],\"name\":\"estimateInputAmount\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"inputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"inputAmount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"strategyData\",\"type\":\"bytes\"}],\"name\":\"redeem\",\"outputs\":[{\"internalType\":\"contract IERC20Upgradeable\",\"name\":\"outputToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"outputAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"estimateInputAmount(uint256,bytes)\":{\"details\":\"Estimates the needed input amount of the input token for the conversion to return the desired output amount.\",\"params\":{\"outputAmount\":\"the desired output amount\",\"strategyData\":\"the input token\"}},\"redeem(address,uint256,bytes)\":{\"details\":\"Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\",\"params\":{\"inputAmount\":\"input amount\",\"inputToken\":\"Address of the token\",\"strategyData\":\"context specific data like input token, pool address and tx expiratio period\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/liquidators/UniswapV3LiquidatorFunder.sol\":\"UniswapV3LiquidatorFunder\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/external/uniswap/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// From Uniswap3 Core\\n\\n// Updated to Solidity 0.8 by Midas Capital:\\n// * Rewrite unary negation of denominator, which is a uint\\n// * Wrapped function bodies with \\\"unchecked {}\\\" so as to not add any extra gas costs\\n\\npragma solidity ^0.8.0;\\n\\n/// @title Contains 512-bit math functions\\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\\n/// @dev Handles \\\"phantom overflow\\\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\\nlibrary FullMath {\\n /// @notice Calculates floor(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\\n function mulDiv(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = a * b\\n // Compute the product mod 2**256 and mod 2**256 - 1\\n // then use the Chinese Remainder Theorem to reconstruct\\n // the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2**256 + prod0\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(a, b, not(0))\\n prod0 := mul(a, b)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division\\n if (prod1 == 0) {\\n require(denominator > 0);\\n assembly {\\n result := div(prod0, denominator)\\n }\\n return result;\\n }\\n\\n // Make sure the result is less than 2**256.\\n // Also prevents denominator == 0\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0]\\n // Compute remainder using mulmod\\n uint256 remainder;\\n assembly {\\n remainder := mulmod(a, b, denominator)\\n }\\n // Subtract 256 bit number from 512 bit number\\n assembly {\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator\\n // Compute largest power of two divisor of denominator.\\n // Always >= 1.\\n uint256 twos = denominator & (~denominator + 1);\\n\\n // Divide denominator by power of two\\n assembly {\\n denominator := div(denominator, twos)\\n }\\n\\n // Divide [prod1 prod0] by the factors of two\\n assembly {\\n prod0 := div(prod0, twos)\\n }\\n // Shift in bits from prod1 into prod0. For this we need\\n // to flip `twos` such that it is 2**256 / twos.\\n // If twos is zero, then it becomes one\\n assembly {\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2**256\\n // Now that denominator is an odd number, it has an inverse\\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\\n // Compute the inverse by starting with a seed that is correct\\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\\n uint256 inv = (3 * denominator) ^ 2;\\n // Now use Newton-Raphson iteration to improve the precision.\\n // Thanks to Hensel's lifting lemma, this also works in modular\\n // arithmetic, doubling the correct bits in each step.\\n inv *= 2 - denominator * inv; // inverse mod 2**8\\n inv *= 2 - denominator * inv; // inverse mod 2**16\\n inv *= 2 - denominator * inv; // inverse mod 2**32\\n inv *= 2 - denominator * inv; // inverse mod 2**64\\n inv *= 2 - denominator * inv; // inverse mod 2**128\\n inv *= 2 - denominator * inv; // inverse mod 2**256\\n\\n // Because the division is now exact we can divide by multiplying\\n // with the modular inverse of denominator. This will give us the\\n // correct result modulo 2**256. Since the precoditions guarantee\\n // that the outcome is less than 2**256, this is the final result.\\n // We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inv;\\n return result;\\n }\\n }\\n\\n /// @notice Calculates ceil(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n function mulDivRoundingUp(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf42bdded6dc8044ea0321c72dcf05e2c422122beed96889c478326907ed51d16\",\"license\":\"MIT\"},\"contracts/external/uniswap/IUniswapV3Factory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title The interface for the Uniswap V3 Factory\\n/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees\\ninterface IUniswapV3Factory {\\n /// @notice Emitted when the owner of the factory is changed\\n /// @param oldOwner The owner before the owner was changed\\n /// @param newOwner The owner after the owner was changed\\n event OwnerChanged(address indexed oldOwner, address indexed newOwner);\\n\\n /// @notice Emitted when a pool is created\\n /// @param token0 The first token of the pool by address sort order\\n /// @param token1 The second token of the pool by address sort order\\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\\n /// @param tickSpacing The minimum number of ticks between initialized ticks\\n /// @param pool The address of the created pool\\n event PoolCreated(\\n address indexed token0,\\n address indexed token1,\\n uint24 indexed fee,\\n int24 tickSpacing,\\n address pool\\n );\\n\\n /// @notice Emitted when a new fee amount is enabled for pool creation via the factory\\n /// @param fee The enabled fee, denominated in hundredths of a bip\\n /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee\\n event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);\\n\\n /// @notice Returns the current owner of the factory\\n /// @dev Can be changed by the current owner via setOwner\\n /// @return The address of the factory owner\\n function owner() external view returns (address);\\n\\n /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled\\n /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context\\n /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee\\n /// @return The tick spacing\\n function feeAmountTickSpacing(uint24 fee) external view returns (int24);\\n\\n /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\\n /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\\n /// @param tokenA The contract address of either token0 or token1\\n /// @param tokenB The contract address of the other token\\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\\n /// @return pool The pool address\\n function getPool(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) external view returns (address pool);\\n\\n /// @notice Creates a pool for the given two tokens and fee\\n /// @param tokenA One of the two tokens in the desired pool\\n /// @param tokenB The other of the two tokens in the desired pool\\n /// @param fee The desired fee for the pool\\n /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\\n /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\\n /// are invalid.\\n /// @return pool The address of the newly created pool\\n function createPool(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) external returns (address pool);\\n\\n /// @notice Updates the owner of the factory\\n /// @dev Must be called by the current owner\\n /// @param _owner The new owner of the factory\\n function setOwner(address _owner) external;\\n\\n /// @notice Enables a fee amount with the given tickSpacing\\n /// @dev Fee amounts may never be removed once enabled\\n /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)\\n /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount\\n function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\\n}\\n\",\"keccak256\":\"0x94c0f98bad3dc5b39706fbe5704b3a31d6399177fb72abc906f5ffa64c2562c2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IUniswapV3PoolActions.sol\\\";\\n\\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\\n function token0() external view returns (address);\\n\\n function token1() external view returns (address);\\n\\n function fee() external view returns (uint24);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n\\n function liquidity() external view returns (uint128);\\n\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\\n\\n function observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 liquidityCumulative,\\n bool initialized\\n );\\n\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n function ticks(int24 tick)\\n external\\n view\\n returns (\\n uint128 liquidityGross,\\n int128 liquidityNet,\\n uint256 feeGrowthOutside0X128,\\n uint256 feeGrowthOutside1X128,\\n int56 tickCumulativeOutside,\\n uint160 secondsPerLiquidityOutsideX128,\\n uint32 secondsOutside,\\n bool initialized\\n );\\n\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n\\n function positions(bytes32 key)\\n external\\n view\\n returns (\\n uint128 _liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n}\\n\",\"keccak256\":\"0x815e94e8e575e572117cf045489c699e2e0cb56b7d2dd1a9adb1b0b1f8ac25e1\",\"license\":\"GPL-3.0-only\"},\"contracts/external/uniswap/IUniswapV3PoolActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissionless pool actions\\n/// @notice Contains pool methods that can be called by anyone\\ninterface IUniswapV3PoolActions {\\n /// @notice Sets the initial price for the pool\\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\\n function initialize(uint160 sqrtPriceX96) external;\\n\\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\\n /// @param recipient The address for which the liquidity will be created\\n /// @param tickLower The lower tick of the position in which to add liquidity\\n /// @param tickUpper The upper tick of the position in which to add liquidity\\n /// @param amount The amount of liquidity to mint\\n /// @param data Any data that should be passed through to the callback\\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\\n function mint(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount,\\n bytes calldata data\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Collects tokens owed to a position\\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\\n /// @param recipient The address which should receive the fees collected\\n /// @param tickLower The lower tick of the position for which to collect fees\\n /// @param tickUpper The upper tick of the position for which to collect fees\\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(\\n address recipient,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n\\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\\n /// @dev Fees must be collected separately via a call to #collect\\n /// @param tickLower The lower tick of the position for which to burn liquidity\\n /// @param tickUpper The upper tick of the position for which to burn liquidity\\n /// @param amount How much liquidity to burn\\n /// @return amount0 The amount of token0 sent to the recipient\\n /// @return amount1 The amount of token1 sent to the recipient\\n function burn(\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 amount\\n ) external returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Swap token0 for token1, or token1 for token0\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\\n /// @param recipient The address to receive the output of the swap\\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\\n /// @param data Any data to be passed through to the callback\\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\\n /// @param recipient The address which will receive the token0 and token1 amounts\\n /// @param amount0 The amount of token0 to send\\n /// @param amount1 The amount of token1 to send\\n /// @param data Any data to be passed through to the callback\\n function flash(\\n address recipient,\\n uint256 amount0,\\n uint256 amount1,\\n bytes calldata data\\n ) external;\\n\\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\\n /// the input observationCardinalityNext.\\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\\n}\\n\",\"keccak256\":\"0x01e66a0dca41f6e36bc20da4f66ff0e47b6b09ee9dcf59ce272a6e15a6c91a19\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3PoolImmutables.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that never changes\\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\\ninterface IUniswapV3PoolImmutables {\\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\\n /// @return The contract address\\n function factory() external view returns (address);\\n\\n /// @notice The first of the two tokens of the pool, sorted by address\\n /// @return The token contract address\\n function token0() external view returns (address);\\n\\n /// @notice The second of the two tokens of the pool, sorted by address\\n /// @return The token contract address\\n function token1() external view returns (address);\\n\\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\\n /// @return The fee\\n function fee() external view returns (uint24);\\n\\n /// @notice The pool tick spacing\\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\\n /// This value is an int24 to avoid casting even though it is always positive.\\n /// @return The tick spacing\\n function tickSpacing() external view returns (int24);\\n\\n /// @notice The maximum amount of position liquidity that can use any tick in the range\\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\\n /// @return The max amount of liquidity per tick\\n function maxLiquidityPerTick() external view returns (uint128);\\n}\\n\",\"keccak256\":\"0xb2fb3532ff4b51c3aeedfbd85161048e9423d91e4e9c15a4784dbfd9431156ae\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IUniswapV3SwapCallback.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Callback for IUniswapV3PoolActions#swap\\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\\ninterface IUniswapV3SwapCallback {\\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\\n function uniswapV3SwapCallback(\\n int256 amount0Delta,\\n int256 amount1Delta,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x3f485fb1a44e8fbeadefb5da07d66edab3cfe809f0ac4074b1e54e3eb3c4cf69\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/IV3SwapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport './IUniswapV3SwapCallback.sol';\\n\\n/// @title Router token swapping functionality\\n/// @notice Functions for swapping tokens via Uniswap V3\\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\\n struct ExactInputSingleParams {\\n address tokenIn;\\n address tokenOut;\\n uint24 fee;\\n address recipient;\\n uint256 amountIn;\\n uint256 amountOutMinimum;\\n uint160 sqrtPriceLimitX96;\\n }\\n\\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\\n /// @return amountOut The amount of the received token\\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\\n\\n struct ExactInputParams {\\n bytes path;\\n address recipient;\\n uint256 amountIn;\\n uint256 amountOutMinimum;\\n }\\n\\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\\n /// @return amountOut The amount of the received token\\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\\n\\n struct ExactOutputSingleParams {\\n address tokenIn;\\n address tokenOut;\\n uint24 fee;\\n address recipient;\\n uint256 amountOut;\\n uint256 amountInMaximum;\\n uint160 sqrtPriceLimitX96;\\n }\\n\\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\\n /// that may remain in the router after the swap.\\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\\n /// @return amountIn The amount of the input token\\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\\n\\n struct ExactOutputParams {\\n bytes path;\\n address recipient;\\n uint256 amountOut;\\n uint256 amountInMaximum;\\n }\\n\\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\\n /// that may remain in the router after the swap.\\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\\n /// @return amountIn The amount of the input token\\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xe95fc9d2ee5575049d60bcd0927866fee6f01398456929833541c0c7ca3ed8f5\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\n// From Uniswap3 Core\\n\\n// Updated to Solidity 0.8 by Midas Capital:\\n// * Cast MAX_TICK to int256 before casting to uint\\n// * Wrapped function bodies with \\\"unchecked {}\\\" so as to not add any extra gas costs\\n\\npragma solidity ^0.8.0;\\n\\n/// @title Math library for computing sqrt prices from ticks and vice versa\\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\\n/// prices between 2**-128 and 2**128\\nlibrary TickMath {\\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\\n int24 internal constant MIN_TICK = -887272;\\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\\n int24 internal constant MAX_TICK = -MIN_TICK;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\\n /// @dev Throws if |tick| > max tick\\n /// @param tick The input tick for the above formula\\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\\n /// at the given tick\\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\\n unchecked {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(int256(MAX_TICK)), \\\"T\\\");\\n\\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\\n\\n if (tick > 0) ratio = type(uint256).max / ratio;\\n\\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\\n }\\n }\\n\\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\\n /// ever return.\\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\\n unchecked {\\n // second inequality must be < because the price can never reach the price at the max tick\\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, \\\"R\\\");\\n uint256 ratio = uint256(sqrtPriceX96) << 32;\\n\\n uint256 r = ratio;\\n uint256 msb = 0;\\n\\n assembly {\\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(5, gt(r, 0xFFFFFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(4, gt(r, 0xFFFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(3, gt(r, 0xFF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(2, gt(r, 0xF))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := shl(1, gt(r, 0x3))\\n msb := or(msb, f)\\n r := shr(f, r)\\n }\\n assembly {\\n let f := gt(r, 0x1)\\n msb := or(msb, f)\\n }\\n\\n if (msb >= 128) r = ratio >> (msb - 127);\\n else r = ratio << (127 - msb);\\n\\n int256 log_2 = (int256(msb) - 128) << 64;\\n\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(63, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(62, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(61, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(60, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(59, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(58, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(57, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(56, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(55, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(54, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(53, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(52, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(51, f))\\n r := shr(f, r)\\n }\\n assembly {\\n r := shr(127, mul(r, r))\\n let f := shr(128, r)\\n log_2 := or(log_2, shl(50, f))\\n }\\n\\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\\n\\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\\n\\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x432aca6b585c17a1130b0eb17a8f9ff1c3d1de49adbfea0e31b6d6c3c63c52a7\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"../IUniswapV3Factory.sol\\\";\\nimport \\\"./interfaces/IQuoter.sol\\\";\\nimport \\\"./UniswapV3Quoter.sol\\\";\\n\\ncontract Quoter is IQuoter, UniswapV3Quoter {\\n IUniswapV3Factory internal uniV3Factory; // TODO should it be immutable?\\n\\n constructor(address _uniV3Factory) {\\n uniV3Factory = IUniswapV3Factory(_uniV3Factory);\\n }\\n\\n // This should be equal to quoteExactInputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\\n // todo: add price limit\\n function estimateMaxSwapUniswapV3(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n uint24 _poolFee\\n ) public view override returns (uint256) {\\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\\n\\n return _estimateOutputSingle(_toToken, _fromToken, _amount, pool);\\n }\\n\\n // This should be equal to quoteExactOutputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\\n // todo: add price limit\\n function estimateMinSwapUniswapV3(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n uint24 _poolFee\\n ) public view override returns (uint256) {\\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\\n\\n return _estimateInputSingle(_fromToken, _toToken, _amount, pool);\\n }\\n\\n // todo: add price limit\\n function _estimateOutputSingle(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n address _pool\\n ) internal view returns (uint256 amountOut) {\\n bool zeroForOne = _fromToken > _toToken;\\n // todo: price limit?\\n (int256 amount0, int256 amount1) = quoteSwap(\\n _pool,\\n int256(_amount),\\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\\n zeroForOne\\n );\\n if (zeroForOne) amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\\n else amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\\n }\\n\\n // todo: add price limit\\n function _estimateInputSingle(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n address _pool\\n ) internal view returns (uint256 amountOut) {\\n bool zeroForOne = _fromToken < _toToken;\\n // todo: price limit?\\n (int256 amount0, int256 amount1) = quoteSwap(\\n _pool,\\n -int256(_amount),\\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\\n zeroForOne\\n );\\n if (zeroForOne) amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\\n else amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\\n }\\n\\n function doesPoolExist(address _token0, address _token1) external view returns (bool) {\\n // try 0.05%\\n address pool = uniV3Factory.getPool(_token0, _token1, 500);\\n if (pool != address(0)) return true;\\n\\n // try 0.3%\\n pool = uniV3Factory.getPool(_token0, _token1, 3000);\\n if (pool != address(0)) return true;\\n\\n // try 1%\\n pool = uniV3Factory.getPool(_token0, _token1, 10000);\\n if (pool != address(0)) return true;\\n else return false;\\n }\\n}\\n\",\"keccak256\":\"0xcfbc88a172c99b9d4ef5b1fa9f97513fe6f41565f87cb5d8070a1f938985d70c\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/UniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.7.6;\\n\\nimport \\\"./libraries/LowGasSafeMath.sol\\\";\\nimport \\\"./libraries/SafeCast.sol\\\";\\nimport \\\"./libraries/Tick.sol\\\";\\nimport \\\"./libraries/TickBitmap.sol\\\";\\n\\nimport \\\"../FullMath.sol\\\";\\nimport \\\"../TickMath.sol\\\";\\nimport \\\"./libraries/LiquidityMath.sol\\\";\\nimport \\\"./libraries/SqrtPriceMath.sol\\\";\\nimport \\\"./libraries/SwapMath.sol\\\";\\n\\nimport \\\"./interfaces/IUniswapV3Quoter.sol\\\";\\nimport \\\"../IUniswapV3Pool.sol\\\";\\nimport \\\"../IUniswapV3PoolImmutables.sol\\\";\\n\\ncontract UniswapV3Quoter {\\n using LowGasSafeMath for int256;\\n using SafeCast for uint256;\\n using Tick for mapping(int24 => Tick.Info);\\n\\n struct PoolState {\\n // the current price\\n uint160 sqrtPriceX96;\\n // the current tick\\n int24 tick;\\n // the tick spacing\\n int24 tickSpacing;\\n // the pool's fee\\n uint24 fee;\\n // the pool's liquidity\\n uint128 liquidity;\\n // whether the pool is locked\\n bool unlocked;\\n }\\n\\n // accumulated protocol fees in token0/token1 units\\n struct ProtocolFees {\\n uint128 token0;\\n uint128 token1;\\n }\\n\\n // the top level state of the swap, the results of which are recorded in storage at the end\\n struct SwapState {\\n // the amount remaining to be swapped in/out of the input/output asset\\n int256 amountSpecifiedRemaining;\\n // the amount already swapped out/in of the output/input asset\\n int256 amountCalculated;\\n // current sqrt(price)\\n uint160 sqrtPriceX96;\\n // the tick associated with the current price\\n int24 tick;\\n // the current liquidity in range\\n uint128 liquidity;\\n }\\n\\n struct StepComputations {\\n // the price at the beginning of the step\\n uint160 sqrtPriceStartX96;\\n // the next tick to swap to from the current tick in the swap direction\\n int24 tickNext;\\n // whether tickNext is initialized or not\\n bool initialized;\\n // sqrt(price) for the next tick (1/0)\\n uint160 sqrtPriceNextX96;\\n // how much is being swapped in in this step\\n uint256 amountIn;\\n // how much is being swapped out\\n uint256 amountOut;\\n // how much fee is being paid in\\n uint256 feeAmount;\\n }\\n\\n struct InitialState {\\n address poolAddress;\\n PoolState poolState;\\n uint256 feeGrowthGlobal0X128;\\n uint256 feeGrowthGlobal1X128;\\n }\\n\\n struct NextTickPassage {\\n int24 tick;\\n int24 tickSpacing;\\n }\\n\\n function fetchState(address _pool) internal view returns (PoolState memory poolState) {\\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\\n (uint160 sqrtPriceX96, int24 tick, , , , , bool unlocked) = pool.slot0(); // external call\\n uint128 liquidity = pool.liquidity(); // external call\\n int24 tickSpacing = IUniswapV3PoolImmutables(_pool).tickSpacing(); // external call\\n uint24 fee = IUniswapV3PoolImmutables(_pool).fee(); // external call\\n poolState = PoolState(sqrtPriceX96, tick, tickSpacing, fee, liquidity, unlocked);\\n }\\n\\n function setInitialState(\\n PoolState memory initialPoolState,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bool zeroForOne\\n )\\n internal\\n pure\\n returns (\\n SwapState memory state,\\n uint128 liquidity,\\n uint160 sqrtPriceX96\\n )\\n {\\n liquidity = initialPoolState.liquidity;\\n\\n sqrtPriceX96 = initialPoolState.sqrtPriceX96;\\n\\n require(\\n zeroForOne\\n ? sqrtPriceLimitX96 < initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO\\n : sqrtPriceLimitX96 > initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,\\n \\\"SPL\\\"\\n );\\n\\n state = SwapState({\\n amountSpecifiedRemaining: amountSpecified,\\n amountCalculated: 0,\\n sqrtPriceX96: initialPoolState.sqrtPriceX96,\\n tick: initialPoolState.tick,\\n liquidity: 0 // to be modified after initialization\\n });\\n }\\n\\n function getNextTickAndPrice(\\n int24 tickSpacing,\\n int24 currentTick,\\n IUniswapV3Pool pool,\\n bool zeroForOne\\n )\\n internal\\n view\\n returns (\\n int24 tickNext,\\n bool initialized,\\n uint160 sqrtPriceNextX96\\n )\\n {\\n int24 compressed = currentTick / tickSpacing;\\n if (!zeroForOne) compressed++;\\n if (currentTick < 0 && currentTick % tickSpacing != 0) compressed--; // round towards negative infinity\\n\\n uint256 selfResult = pool.tickBitmap(int16(compressed >> 8)); // external call\\n\\n (tickNext, initialized) = TickBitmap.nextInitializedTickWithinOneWord(\\n selfResult,\\n currentTick,\\n tickSpacing,\\n zeroForOne\\n );\\n\\n if (tickNext < TickMath.MIN_TICK) {\\n tickNext = TickMath.MIN_TICK;\\n } else if (tickNext > TickMath.MAX_TICK) {\\n tickNext = TickMath.MAX_TICK;\\n }\\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\\n }\\n\\n function processSwapWithinTick(\\n IUniswapV3Pool pool,\\n PoolState memory initialPoolState,\\n SwapState memory state,\\n uint160 firstSqrtPriceX96,\\n uint128 firstLiquidity,\\n uint160 sqrtPriceLimitX96,\\n bool zeroForOne,\\n bool exactAmount\\n )\\n internal\\n view\\n returns (\\n uint160 sqrtPriceNextX96,\\n uint160 finalSqrtPriceX96,\\n uint128 finalLiquidity\\n )\\n {\\n StepComputations memory step;\\n\\n step.sqrtPriceStartX96 = firstSqrtPriceX96;\\n\\n (step.tickNext, step.initialized, sqrtPriceNextX96) = getNextTickAndPrice(\\n initialPoolState.tickSpacing,\\n state.tick,\\n pool,\\n zeroForOne\\n );\\n\\n (finalSqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\\n firstSqrtPriceX96,\\n (zeroForOne ? sqrtPriceNextX96 < sqrtPriceLimitX96 : sqrtPriceNextX96 > sqrtPriceLimitX96)\\n ? sqrtPriceLimitX96\\n : sqrtPriceNextX96,\\n firstLiquidity,\\n state.amountSpecifiedRemaining,\\n initialPoolState.fee,\\n zeroForOne\\n );\\n\\n if (exactAmount) {\\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\\n } else {\\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\\n }\\n\\n if (finalSqrtPriceX96 == sqrtPriceNextX96) {\\n if (step.initialized) {\\n (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext);\\n if (zeroForOne) liquidityNet = -liquidityNet;\\n finalLiquidity = LiquidityMath.addDelta(firstLiquidity, liquidityNet);\\n }\\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\\n } else if (finalSqrtPriceX96 != step.sqrtPriceStartX96) {\\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\\n state.tick = TickMath.getTickAtSqrtRatio(finalSqrtPriceX96);\\n }\\n }\\n\\n function returnedAmount(\\n SwapState memory state,\\n int256 amountSpecified,\\n bool zeroForOne\\n ) internal pure returns (int256 amount0, int256 amount1) {\\n if (amountSpecified > 0) {\\n (amount0, amount1) = zeroForOne\\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\\n } else {\\n (amount0, amount1) = zeroForOne\\n ? (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining)\\n : (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated);\\n }\\n }\\n\\n function quoteSwap(\\n address poolAddress,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bool zeroForOne\\n ) internal view returns (int256 amount0, int256 amount1) {\\n bool exactAmount = amountSpecified > 0;\\n\\n PoolState memory initialPoolState = fetchState(poolAddress);\\n uint160 sqrtPriceNextX96;\\n\\n (SwapState memory state, uint128 liquidity, uint160 sqrtPriceX96) = setInitialState(\\n initialPoolState,\\n amountSpecified,\\n sqrtPriceLimitX96,\\n zeroForOne\\n );\\n\\n while (state.amountSpecifiedRemaining != 0 && sqrtPriceX96 != sqrtPriceLimitX96)\\n (sqrtPriceNextX96, sqrtPriceX96, liquidity) = processSwapWithinTick(\\n IUniswapV3Pool(poolAddress),\\n initialPoolState,\\n state,\\n sqrtPriceX96,\\n liquidity,\\n sqrtPriceLimitX96,\\n zeroForOne,\\n exactAmount\\n );\\n\\n (amount0, amount1) = returnedAmount(state, amountSpecified, zeroForOne);\\n }\\n}\\n\",\"keccak256\":\"0x04323a39bc058fccb502d2fb2ef9438560f4b8b06bc51d1a072c1b39b2006d45\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/interfaces/IQuoter.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity >=0.8.0 <0.9.0;\\n\\ninterface IQuoter {\\n function estimateMaxSwapUniswapV3(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n uint24 _poolFee\\n ) external view returns (uint256);\\n\\n function estimateMinSwapUniswapV3(\\n address _fromToken,\\n address _toToken,\\n uint256 _amount,\\n uint24 _poolFee\\n ) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4354205b233dc56b0809867666845265260cb4059554a4bd4f35b0360508fea0\",\"license\":\"BUSL-1.1\"},\"contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Quoter Interface\\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\\ninterface IUniswapV3Quoter {\\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee\\n /// @param amountIn The amount of the first token to swap\\n /// @return amountOut The amount of the last token that would be received\\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountIn The desired input amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountOut The amount of `tokenOut` that would be received\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\\n /// @param amountOut The amount of the last token to receive\\n /// @return amountIn The amount of first token required to be paid\\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\\n\\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\\n /// @param tokenIn The token being swapped in\\n /// @param tokenOut The token being swapped out\\n /// @param fee The fee of the token pool to consider for the pair\\n /// @param amountOut The desired output amount\\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xfebe8703ca93969f7314c5eefcd48125059abaa94182dac93ae202e761055d88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/external/uniswap/quoter/libraries/BitMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\n/// @title BitMath\\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\\nlibrary BitMath {\\n /// @notice Returns the index of the most significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\\n /// @param x the value for which to compute the most significant bit, must be greater than 0\\n /// @return r the index of the most significant bit\\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n if (x >= 0x100000000000000000000000000000000) {\\n x >>= 128;\\n r += 128;\\n }\\n if (x >= 0x10000000000000000) {\\n x >>= 64;\\n r += 64;\\n }\\n if (x >= 0x100000000) {\\n x >>= 32;\\n r += 32;\\n }\\n if (x >= 0x10000) {\\n x >>= 16;\\n r += 16;\\n }\\n if (x >= 0x100) {\\n x >>= 8;\\n r += 8;\\n }\\n if (x >= 0x10) {\\n x >>= 4;\\n r += 4;\\n }\\n if (x >= 0x4) {\\n x >>= 2;\\n r += 2;\\n }\\n if (x >= 0x2) r += 1;\\n }\\n\\n /// @notice Returns the index of the least significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\\n /// @param x the value for which to compute the least significant bit, must be greater than 0\\n /// @return r the index of the least significant bit\\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n r = 255;\\n if (x & type(uint128).max > 0) {\\n r -= 128;\\n } else {\\n x >>= 128;\\n }\\n if (x & type(uint64).max > 0) {\\n r -= 64;\\n } else {\\n x >>= 64;\\n }\\n if (x & type(uint32).max > 0) {\\n r -= 32;\\n } else {\\n x >>= 32;\\n }\\n if (x & type(uint16).max > 0) {\\n r -= 16;\\n } else {\\n x >>= 16;\\n }\\n if (x & type(uint8).max > 0) {\\n r -= 8;\\n } else {\\n x >>= 8;\\n }\\n if (x & 0xf > 0) {\\n r -= 4;\\n } else {\\n x >>= 4;\\n }\\n if (x & 0x3 > 0) {\\n r -= 2;\\n } else {\\n x >>= 2;\\n }\\n if (x & 0x1 > 0) r -= 1;\\n }\\n}\\n\",\"keccak256\":\"0x6565078afaf4a8bc4804a95da936fd5a66c4b0095eabd462da0620d5388b7326\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.0;\\n\\n/// @title FixedPoint96\\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\\n/// @dev Used in SqrtPriceMath.sol\\nlibrary FixedPoint96 {\\n uint8 internal constant RESOLUTION = 96;\\n uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96\\n}\\n\",\"keccak256\":\"0xd9c548394832b82a4c4221b5a323fe2986061b759637ad87b23430d43e8fefad\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/LiquidityMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\n/// @title Math library for liquidity\\nlibrary LiquidityMath {\\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\\n /// @param x The liquidity before change\\n /// @param y The delta by which liquidity should be changed\\n /// @return z The liquidity delta\\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\\n if (y < 0) {\\n require((z = x - uint128(-y)) < x, \\\"LS\\\");\\n } else {\\n require((z = x + uint128(y)) >= x, \\\"LA\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x07062c5e1b28cf94a3c995566bb9acc7f1f23f555e9765d6bba7629a71f7c30e\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/LowGasSafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.7.0;\\n\\n/// @title Optimized overflow and underflow safe math operations\\n/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost\\nlibrary LowGasSafeMath {\\n /// @notice Returns x + y, reverts if sum overflows uint256\\n /// @param x The augend\\n /// @param y The addend\\n /// @return z The sum of x and y\\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n require((z = x + y) >= x);\\n }\\n\\n /// @notice Returns x - y, reverts if underflows\\n /// @param x The minuend\\n /// @param y The subtrahend\\n /// @return z The difference of x and y\\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n require((z = x - y) <= x);\\n }\\n\\n /// @notice Returns x * y, reverts if overflows\\n /// @param x The multiplicand\\n /// @param y The multiplier\\n /// @return z The product of x and y\\n function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n require(x == 0 || (z = x * y) / x == y);\\n }\\n\\n /// @notice Returns x + y, reverts if overflows or underflows\\n /// @param x The augend\\n /// @param y The addend\\n /// @return z The sum of x and y\\n function add(int256 x, int256 y) internal pure returns (int256 z) {\\n require((z = x + y) >= x == (y >= 0));\\n }\\n\\n /// @notice Returns x - y, reverts if overflows or underflows\\n /// @param x The minuend\\n /// @param y The subtrahend\\n /// @return z The difference of x and y\\n function sub(int256 x, int256 y) internal pure returns (int256 z) {\\n require((z = x - y) <= x == (y >= 0));\\n }\\n}\\n\",\"keccak256\":\"0x43f569e74a7d31db8e077710734e3267de08f7ce6eb2618f153ea7338e1eb774\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\n/// @title Safe casting methods\\n/// @notice Contains methods for safely casting between types\\nlibrary SafeCast {\\n /// @notice Cast a uint256 to a uint160, revert on overflow\\n /// @param y The uint256 to be downcasted\\n /// @return z The downcasted integer, now type uint160\\n function toUint160(uint256 y) internal pure returns (uint160 z) {\\n require((z = uint160(y)) == y);\\n }\\n\\n /// @notice Cast a int256 to a int128, revert on overflow or underflow\\n /// @param y The int256 to be downcasted\\n /// @return z The downcasted integer, now type int128\\n function toInt128(int256 y) internal pure returns (int128 z) {\\n require((z = int128(y)) == y);\\n }\\n\\n /// @notice Cast a uint256 to a int256, revert on overflow\\n /// @param y The uint256 to be casted\\n /// @return z The casted integer, now type int256\\n function toInt256(uint256 y) internal pure returns (int256 z) {\\n require(y < 2**255);\\n z = int256(y);\\n }\\n}\\n\",\"keccak256\":\"0x9aeb9a4b82064c1e0cd82046e4f5a011f74485461676599f76de6ffb969a25a0\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/SqrtPriceMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\nimport \\\"./LowGasSafeMath.sol\\\";\\nimport \\\"./SafeCast.sol\\\";\\n\\nimport \\\"../../FullMath.sol\\\";\\nimport \\\"./UnsafeMath.sol\\\";\\nimport \\\"./FixedPoint96.sol\\\";\\nimport \\\"./BitMath.sol\\\";\\n\\n/// @title Functions based on Q64.96 sqrt price and liquidity\\n/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas\\nlibrary SqrtPriceMath {\\n using LowGasSafeMath for uint256;\\n using SafeCast for uint256;\\n\\n /// @notice Gets the next sqrt price given a delta of token0\\n /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least\\n /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the\\n /// price less in order to not send too much output.\\n /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),\\n /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).\\n /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta\\n /// @param liquidity The amount of usable liquidity\\n /// @param amount How much of token0 to add or remove from virtual reserves\\n /// @param add Whether to add or remove the amount of token0\\n /// @return The price after adding or removing amount, depending on add\\n function getNextSqrtPriceFromAmount0RoundingUp(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amount,\\n bool add\\n ) internal pure returns (uint160) {\\n // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price\\n if (amount == 0) return sqrtPX96;\\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\\n\\n bool overflow = false;\\n if (numerator1 != 0 && sqrtPX96 != 0)\\n overflow = uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(sqrtPX96)) >= 254;\\n\\n if (add) {\\n uint256 product;\\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\\n uint256 denominator = numerator1 + product;\\n if (denominator >= numerator1) {\\n // always fits in 160 bits\\n return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));\\n }\\n }\\n\\n return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));\\n } else {\\n uint256 product;\\n // if the product overflows, we know the denominator underflows\\n // in addition, we must check that the denominator does not underflow\\n require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);\\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\\n uint256 denominator = numerator1 - product;\\n return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();\\n }\\n }\\n\\n /// @notice Gets the next sqrt price given a delta of token1\\n /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least\\n /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the\\n /// price less in order to not send too much output.\\n /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity\\n /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta\\n /// @param liquidity The amount of usable liquidity\\n /// @param amount How much of token1 to add, or remove, from virtual reserves\\n /// @param add Whether to add, or remove, the amount of token1\\n /// @return The price after adding or removing `amount`\\n function getNextSqrtPriceFromAmount1RoundingDown(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amount,\\n bool add\\n ) internal pure returns (uint160) {\\n // if we're adding (subtracting), rounding down requires rounding the quotient down (up)\\n // in both cases, avoid a mulDiv for most inputs\\n if (add) {\\n uint256 quotient = (\\n amount <= type(uint160).max\\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\\n );\\n\\n return uint256(sqrtPX96).add(quotient).toUint160();\\n } else {\\n uint256 quotient = (\\n amount <= type(uint160).max\\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\\n );\\n\\n require(sqrtPX96 > quotient);\\n // always fits 160 bits\\n return uint160(sqrtPX96 - quotient);\\n }\\n }\\n\\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\\n /// @param liquidity The amount of usable liquidity\\n /// @param amountIn How much of token0, or token1, is being swapped in\\n /// @param zeroForOne Whether the amount in is token0 or token1\\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\\n function getNextSqrtPriceFromInput(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amountIn,\\n bool zeroForOne\\n ) internal pure returns (uint160 sqrtQX96) {\\n require(sqrtPX96 > 0);\\n require(liquidity > 0);\\n\\n // round to make sure that we don't pass the target price\\n return\\n zeroForOne\\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\\n }\\n\\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\\n /// @param sqrtPX96 The starting price before accounting for the output amount\\n /// @param liquidity The amount of usable liquidity\\n /// @param amountOut How much of token0, or token1, is being swapped out\\n /// @param zeroForOne Whether the amount out is token0 or token1\\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\\n function getNextSqrtPriceFromOutput(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amountOut,\\n bool zeroForOne\\n ) internal pure returns (uint160 sqrtQX96) {\\n require(sqrtPX96 > 0);\\n require(liquidity > 0);\\n\\n // round to make sure that we pass the target price\\n return\\n zeroForOne\\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\\n }\\n\\n /// @notice Gets the amount0 delta between two prices\\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\\n /// @param sqrtRatioAX96 A sqrt price\\n /// @param sqrtRatioBX96 Another sqrt price\\n /// @param liquidity The amount of usable liquidity\\n /// @param roundUp Whether to round the amount up or down\\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\\n function getAmount0Delta(\\n uint160 sqrtRatioAX96,\\n uint160 sqrtRatioBX96,\\n uint128 liquidity,\\n bool roundUp\\n ) internal pure returns (uint256 amount0) {\\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\\n\\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\\n require(sqrtRatioAX96 > 0);\\n\\n bool overflow = false;\\n if (numerator1 != 0 && numerator2 != 0)\\n overflow =\\n uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(numerator2)) >= 254;\\n\\n if (overflow) {\\n return\\n roundUp\\n ? FullMath.mulDivRoundingUp(\\n FullMath.mulDivRoundingUp(uint256(liquidity), numerator2, sqrtRatioBX96),\\n FixedPoint96.Q96,\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(\\n FullMath.mulDiv(uint256(liquidity), numerator2, sqrtRatioBX96),\\n FixedPoint96.Q96,\\n sqrtRatioAX96\\n );\\n } else {\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96)\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\n }\\n }\\n\\n /// @notice Gets the amount1 delta between two prices\\n /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))\\n /// @param sqrtRatioAX96 A sqrt price\\n /// @param sqrtRatioBX96 Another sqrt price\\n /// @param liquidity The amount of usable liquidity\\n /// @param roundUp Whether to round the amount up, or down\\n /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices\\n function getAmount1Delta(\\n uint160 sqrtRatioAX96,\\n uint160 sqrtRatioBX96,\\n uint128 liquidity,\\n bool roundUp\\n ) internal pure returns (uint256 amount1) {\\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\\n\\n return\\n roundUp\\n ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)\\n : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\\n }\\n\\n /// @notice Helper that gets signed token0 delta\\n /// @param sqrtRatioAX96 A sqrt price\\n /// @param sqrtRatioBX96 Another sqrt price\\n /// @param liquidity The change in liquidity for which to compute the amount0 delta\\n /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices\\n function getAmount0Delta(\\n uint160 sqrtRatioAX96,\\n uint160 sqrtRatioBX96,\\n int128 liquidity\\n ) internal pure returns (int256 amount0) {\\n return\\n liquidity < 0\\n ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\\n : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\\n }\\n\\n /// @notice Helper that gets signed token1 delta\\n /// @param sqrtRatioAX96 A sqrt price\\n /// @param sqrtRatioBX96 Another sqrt price\\n /// @param liquidity The change in liquidity for which to compute the amount1 delta\\n /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices\\n function getAmount1Delta(\\n uint160 sqrtRatioAX96,\\n uint160 sqrtRatioBX96,\\n int128 liquidity\\n ) internal pure returns (int256 amount1) {\\n return\\n liquidity < 0\\n ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\\n : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\\n }\\n}\\n\",\"keccak256\":\"0x34d6754b798385e60b1b7ca9a405d371ce4986f73b3d08ce906b47eff2eaca2a\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/SwapMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\nimport \\\"../../FullMath.sol\\\";\\nimport \\\"./SqrtPriceMath.sol\\\";\\n\\n/// @title Computes the result of a swap within ticks\\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\\nlibrary SwapMath {\\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\\n /// @param liquidity The usable liquidity\\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\\n /// @return feeAmount The amount of input that will be taken as a fee\\n function computeSwapStep(\\n uint160 sqrtRatioCurrentX96,\\n uint160 sqrtRatioTargetX96,\\n uint128 liquidity,\\n int256 amountRemaining,\\n uint24 feePips,\\n bool zeroForOne\\n )\\n internal\\n pure\\n returns (\\n uint160 sqrtRatioNextX96,\\n uint256 amountIn,\\n uint256 amountOut,\\n uint256 feeAmount\\n )\\n {\\n require(zeroForOne == sqrtRatioCurrentX96 >= sqrtRatioTargetX96, \\\"SPD\\\");\\n bool exactIn = amountRemaining >= 0;\\n\\n if (exactIn) {\\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\\n amountIn = zeroForOne\\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n amountRemainingLessFee,\\n zeroForOne\\n );\\n } else {\\n amountOut = zeroForOne\\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\\n\\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n uint256(-amountRemaining),\\n zeroForOne\\n );\\n }\\n\\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\\n\\n // get the input/output amounts\\n if (zeroForOne) {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\\n } else {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\\n }\\n\\n // cap the output amount to not exceed the remaining output amount\\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\\n amountOut = uint256(-amountRemaining);\\n }\\n\\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\\n // we didn't reach the target, so take the remainder of the maximum input as fee\\n feeAmount = uint256(amountRemaining) - amountIn;\\n } else {\\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf25585e84e48d80c4d3ee87d73e57f0f81ca0e81876e50a29653b235762b544e\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/Tick.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\nimport \\\"./LowGasSafeMath.sol\\\";\\nimport \\\"./SafeCast.sol\\\";\\n\\nimport \\\"../../TickMath.sol\\\";\\nimport \\\"./LiquidityMath.sol\\\";\\n\\n/// @title Tick\\n/// @notice Contains functions for managing tick processes and relevant calculations\\n\\n/// Ithil to modify it, since it does not have access to storage arrays\\nlibrary Tick {\\n using LowGasSafeMath for int256;\\n using SafeCast for int256;\\n\\n // info stored for each initialized individual tick\\n struct Info {\\n // the total position liquidity that references this tick\\n uint128 liquidityGross;\\n // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),\\n int128 liquidityNet;\\n // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)\\n // only has relative meaning, not absolute \\u2014 the value depends on when the tick is initialized\\n uint256 feeGrowthOutside0X128;\\n uint256 feeGrowthOutside1X128;\\n // the cumulative tick value on the other side of the tick\\n int56 tickCumulativeOutside;\\n // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)\\n // only has relative meaning, not absolute \\u2014 the value depends on when the tick is initialized\\n uint160 secondsPerLiquidityOutsideX128;\\n // the seconds spent on the other side of the tick (relative to the current tick)\\n // only has relative meaning, not absolute \\u2014 the value depends on when the tick is initialized\\n uint32 secondsOutside;\\n // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0\\n // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks\\n bool initialized;\\n }\\n\\n /// @notice Derives max liquidity per tick from given tick spacing\\n /// @dev Executed within the pool constructor\\n /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`\\n /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...\\n /// @return The max liquidity per tick\\n function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {\\n int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\\n int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\\n uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;\\n return type(uint128).max / numTicks;\\n }\\n\\n /// @notice Retrieves fee growth data\\n /// Ithil: only use it with lower = self[tickLower] and upper = self[tickUpper]\\n /// @param lower The info of the lower tick boundary of the position\\n /// @param upper The info of the upper tick boundary of the position\\n /// @param tickLower The lower tick boundary of the position\\n /// @param tickUpper The upper tick boundary of the position\\n /// @param tickCurrent The current tick\\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\\n /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries\\n /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries\\n function getFeeGrowthInside(\\n Tick.Info memory lower,\\n Tick.Info memory upper,\\n int24 tickLower,\\n int24 tickUpper,\\n int24 tickCurrent,\\n uint256 feeGrowthGlobal0X128,\\n uint256 feeGrowthGlobal1X128\\n ) internal pure returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\\n // calculate fee growth below\\n uint256 feeGrowthBelow0X128;\\n uint256 feeGrowthBelow1X128;\\n if (tickCurrent >= tickLower) {\\n feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;\\n feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;\\n } else {\\n feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;\\n feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;\\n }\\n\\n // calculate fee growth above\\n uint256 feeGrowthAbove0X128;\\n uint256 feeGrowthAbove1X128;\\n if (tickCurrent < tickUpper) {\\n feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;\\n feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;\\n } else {\\n feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;\\n feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;\\n }\\n\\n feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;\\n feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;\\n }\\n\\n /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa\\n /// Ithil: always use with info = self[tick]\\n /// @param info The info tick that will be updated\\n /// @param tick The tick that will be updated\\n /// @param tickCurrent The current tick\\n /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)\\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\\n /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool\\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\\n /// @param time The current block timestamp cast to a uint32\\n /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick\\n /// @param maxLiquidity The maximum liquidity allocation for a single tick\\n /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa\\n function update(\\n Tick.Info memory info,\\n int24 tick,\\n int24 tickCurrent,\\n int128 liquidityDelta,\\n uint256 feeGrowthGlobal0X128,\\n uint256 feeGrowthGlobal1X128,\\n uint160 secondsPerLiquidityCumulativeX128,\\n int56 tickCumulative,\\n uint32 time,\\n bool upper,\\n uint128 maxLiquidity\\n ) internal pure returns (bool flipped) {\\n uint128 liquidityGrossBefore = info.liquidityGross;\\n uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);\\n\\n require(liquidityGrossAfter <= maxLiquidity, \\\"LO\\\");\\n\\n flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);\\n\\n if (liquidityGrossBefore == 0) {\\n // by convention, we assume that all growth before a tick was initialized happened _below_ the tick\\n if (tick <= tickCurrent) {\\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;\\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;\\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;\\n info.tickCumulativeOutside = tickCumulative;\\n info.secondsOutside = time;\\n }\\n info.initialized = true;\\n }\\n\\n info.liquidityGross = liquidityGrossAfter;\\n\\n // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)\\n info.liquidityNet = upper\\n ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()\\n : int256(info.liquidityNet).add(liquidityDelta).toInt128();\\n }\\n\\n /// @notice Transitions to next tick as needed by price movement\\n /// @param info The result of the mapping containing all tick information for initialized ticks\\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\\n /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity\\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\\n /// @param time The current block.timestamp\\n /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)\\n function cross(\\n Tick.Info memory info,\\n uint256 feeGrowthGlobal0X128,\\n uint256 feeGrowthGlobal1X128,\\n uint160 secondsPerLiquidityCumulativeX128,\\n int56 tickCumulative,\\n uint32 time\\n ) internal pure returns (int128 liquidityNet) {\\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;\\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;\\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;\\n info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;\\n info.secondsOutside = time - info.secondsOutside;\\n liquidityNet = info.liquidityNet;\\n }\\n}\\n\",\"keccak256\":\"0x53d99c9e769a4d6fc8f96a4db7c772a83a92b1822484992b2667b1afeb4c471e\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/TickBitmap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\nimport \\\"./BitMath.sol\\\";\\n\\n/// @title Packed tick initialized state library\\n/// @notice Stores a packed mapping of tick index to its initialized state\\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\\nlibrary TickBitmap {\\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\\n /// @param tick The tick for which to compute the position\\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\\n /// @return bitPos The bit position in the word where the flag is stored\\n /// @dev simply divides @param tick by 256 with remainder: tick = wordPos * 256 + bitPos\\n function position(int24 tick) internal pure returns (int16 wordPos, uint8 bitPos) {\\n wordPos = int16(tick >> 8);\\n bitPos = uint8(int8(tick % 256));\\n }\\n\\n /// Written by Ithil\\n function computeWordPos(\\n int24 tick,\\n int24 tickSpacing,\\n bool lte\\n ) internal pure returns (int16 wordPos) {\\n int24 compressed = tick / tickSpacing;\\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\\n\\n (wordPos, ) = lte ? position(compressed) : position(compressed + 1);\\n }\\n\\n /// @notice Flips the initialized state for a given tick from false to true, or vice versa\\n /// @param selfResult The result of the mapping in which to flip the tick (Ithil modified)\\n /// @param tick The tick to flip\\n /// @param tickSpacing The spacing between usable ticks\\n function flipTick(\\n uint256 selfResult,\\n int24 tick,\\n int24 tickSpacing\\n ) internal pure {\\n require(tick % tickSpacing == 0); // ensure that the tick is spaced\\n (, uint8 bitPos) = position(tick / tickSpacing);\\n uint256 mask = 1 << bitPos;\\n selfResult ^= mask;\\n }\\n\\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\\n /// to the left (less than or equal to) or right (greater than) of the given tick\\n /// @param selfResult The result of the mapping in which to compute the next initialized tick (Ithil modified)\\n /// @param tick The starting tick\\n /// @param tickSpacing The spacing between usable ticks\\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\\n function nextInitializedTickWithinOneWord(\\n uint256 selfResult,\\n int24 tick,\\n int24 tickSpacing,\\n bool lte\\n ) internal pure returns (int24 next, bool initialized) {\\n int24 compressed = tick / tickSpacing;\\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\\n\\n if (lte) {\\n (, uint8 bitPos) = position(compressed);\\n // all the 1s at or to the right of the current bitPos\\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\\n uint256 masked = selfResult & mask;\\n\\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed - int24(uint24(bitPos) - uint24(BitMath.mostSignificantBit(masked)))) * tickSpacing\\n : (compressed - int24(uint24(bitPos))) * tickSpacing;\\n } else {\\n // start from the word of the next tick, since the current tick state doesn't matter\\n (, uint8 bitPos) = position(compressed + 1);\\n // all the 1s at or to the left of the bitPos\\n uint256 mask = ~((1 << bitPos) - 1);\\n uint256 masked = selfResult & mask;\\n\\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed + 1 + int24(uint24(BitMath.leastSignificantBit(masked) - bitPos))) * tickSpacing\\n : (compressed + 1 + int24(uint24(type(uint8).max - bitPos))) * tickSpacing;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0dd2a7751c58a90757ef0c4e2a8f438d32e22e3f09eb0697229b1205ebda06dd\",\"license\":\"MIT\"},\"contracts/external/uniswap/quoter/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.5.0;\\n\\n/// @title Math functions that do not check inputs or outputs\\n/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks\\nlibrary UnsafeMath {\\n /// @notice Returns ceil(x / y)\\n /// @dev division by 0 has unspecified behavior, and must be checked externally\\n /// @param x The dividend\\n /// @param y The divisor\\n /// @return z The quotient, ceil(x / y)\\n function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n z := add(div(x, y), gt(mod(x, y), 0))\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6630728b314eb1b184ce20a66bb9797539211e40a7159890a0990de28e0f7e66\",\"license\":\"MIT\"},\"contracts/liquidators/IFundsConversionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IFundsConversionStrategy is IRedemptionStrategy {\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\\n}\\n\",\"keccak256\":\"0xa8bb583271cf321f13f24304b0d03aa951d63aca61bcbbff22d2b44138240271\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/IRedemptionStrategy.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @title IRedemptionStrategy\\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\\n * @author David Lucid (https://github.com/davidlucid)\\n */\\ninterface IRedemptionStrategy {\\n /**\\n * @notice Redeems custom collateral `token` for an underlying token.\\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\\n * @return outputToken The underlying ERC20 token outputted.\\n * @return outputAmount The quantity of underlying tokens outputted.\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\\n\\n function name() external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x4cf72f79d325ed14f3c8d52e013a8d1f8bfe15b59553bbd9dff251761baf60dd\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/UniswapV3Liquidator.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { IRedemptionStrategy } from \\\"./IRedemptionStrategy.sol\\\";\\nimport { IV3SwapRouter } from \\\"../external/uniswap/IV3SwapRouter.sol\\\";\\n\\nimport { IERC20Upgradeable } from \\\"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ncontract UniswapV3Liquidator is IRedemptionStrategy {\\n /**\\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\\n * @param inputToken Address of the token\\n * @param inputAmount input amount\\n * @param strategyData context specific data like input token, pool address and tx expiratio period\\n */\\n function redeem(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\\n return _convert(inputToken, inputAmount, strategyData);\\n }\\n\\n function _convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\\n (, address _outputToken, uint24 fee, IV3SwapRouter swapRouter, ) = abi.decode(\\n strategyData,\\n (address, address, uint24, IV3SwapRouter, address)\\n );\\n outputToken = IERC20Upgradeable(_outputToken);\\n\\n inputToken.approve(address(swapRouter), inputAmount);\\n\\n outputAmount = swapRouter.exactInputSingle(\\n IV3SwapRouter.ExactInputSingleParams(\\n address(inputToken),\\n _outputToken,\\n fee,\\n address(this),\\n inputAmount,\\n 0,\\n 0\\n )\\n );\\n }\\n\\n function name() public pure virtual override returns (string memory) {\\n return \\\"UniswapV3Liquidator\\\";\\n }\\n}\\n\",\"keccak256\":\"0xca10c4271aab376d1bd2a01c448f8102e997832da138dd982fc23cbe89c88b91\",\"license\":\"UNLICENSED\"},\"contracts/liquidators/UniswapV3LiquidatorFunder.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity >=0.8.0;\\n\\nimport { FixedPointMathLib } from \\\"solmate/utils/FixedPointMathLib.sol\\\";\\nimport { IFundsConversionStrategy } from \\\"./IFundsConversionStrategy.sol\\\";\\nimport { IRedemptionStrategy } from \\\"./IRedemptionStrategy.sol\\\";\\nimport \\\"./UniswapV3Liquidator.sol\\\";\\n\\nimport { Quoter } from \\\"../external/uniswap/quoter/Quoter.sol\\\";\\n\\ncontract UniswapV3LiquidatorFunder is UniswapV3Liquidator, IFundsConversionStrategy {\\n using FixedPointMathLib for uint256;\\n\\n function convert(\\n IERC20Upgradeable inputToken,\\n uint256 inputAmount,\\n bytes memory strategyData\\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\\n return _convert(inputToken, inputAmount, strategyData);\\n }\\n\\n /**\\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\\n * @param outputAmount the desired output amount\\n * @param strategyData the input token\\n */\\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\\n external\\n view\\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\\n {\\n (address _inputToken, address _outputToken, uint24 fee, , Quoter quoter) = abi.decode(\\n strategyData,\\n (address, address, uint24, IV3SwapRouter, Quoter)\\n );\\n\\n inputAmount = quoter.estimateMinSwapUniswapV3(_inputToken, _outputToken, outputAmount, fee);\\n inputToken = IERC20Upgradeable(_inputToken);\\n }\\n\\n function name() public pure override(UniswapV3Liquidator, IRedemptionStrategy) returns (string memory) {\\n return \\\"UniswapV3LiquidatorFunder\\\";\\n }\\n}\\n\",\"keccak256\":\"0xf251b80dd8b16f0d8eeb90dd033f4fca4666c9c7931546f870ece6b6d4b900ff\",\"license\":\"UNLICENSED\"},\"openzeppelin-contracts-upgradeable/contracts/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\"},\"solmate/utils/FixedPointMathLib.sol\":{\"content\":\"// SPDX-License-Identifier: AGPL-3.0-only\\npragma solidity >=0.8.0;\\n\\n/// @notice Arithmetic library with operations for fixed-point numbers.\\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\\nlibrary FixedPointMathLib {\\n /*//////////////////////////////////////////////////////////////\\n SIMPLIFIED FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\\n\\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\\n }\\n\\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\\n }\\n\\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\\n }\\n\\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n LOW LEVEL FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function mulDivDown(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // Divide z by the denominator.\\n z := div(z, denominator)\\n }\\n }\\n\\n function mulDivUp(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // First, divide z - 1 by the denominator and add 1.\\n // We allow z - 1 to underflow if z is 0, because we multiply the\\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\\n }\\n }\\n\\n function rpow(\\n uint256 x,\\n uint256 n,\\n uint256 scalar\\n ) internal pure returns (uint256 z) {\\n assembly {\\n switch x\\n case 0 {\\n switch n\\n case 0 {\\n // 0 ** 0 = 1\\n z := scalar\\n }\\n default {\\n // 0 ** n = 0\\n z := 0\\n }\\n }\\n default {\\n switch mod(n, 2)\\n case 0 {\\n // If n is even, store scalar in z for now.\\n z := scalar\\n }\\n default {\\n // If n is odd, store x in z for now.\\n z := x\\n }\\n\\n // Shifting right by 1 is like dividing by 2.\\n let half := shr(1, scalar)\\n\\n for {\\n // Shift n right by 1 before looping to halve it.\\n n := shr(1, n)\\n } n {\\n // Shift n right by 1 each iteration to halve it.\\n n := shr(1, n)\\n } {\\n // Revert immediately if x ** 2 would overflow.\\n // Equivalent to iszero(eq(div(xx, x), x)) here.\\n if shr(128, x) {\\n revert(0, 0)\\n }\\n\\n // Store x squared.\\n let xx := mul(x, x)\\n\\n // Round to the nearest number.\\n let xxRound := add(xx, half)\\n\\n // Revert if xx + half overflowed.\\n if lt(xxRound, xx) {\\n revert(0, 0)\\n }\\n\\n // Set x to scaled xxRound.\\n x := div(xxRound, scalar)\\n\\n // If n is even:\\n if mod(n, 2) {\\n // Compute z * x.\\n let zx := mul(z, x)\\n\\n // If z * x overflowed:\\n if iszero(eq(div(zx, x), z)) {\\n // Revert if x is non-zero.\\n if iszero(iszero(x)) {\\n revert(0, 0)\\n }\\n }\\n\\n // Round to the nearest number.\\n let zxRound := add(zx, half)\\n\\n // Revert if zx + half overflowed.\\n if lt(zxRound, zx) {\\n revert(0, 0)\\n }\\n\\n // Return properly scaled zxRound.\\n z := div(zxRound, scalar)\\n }\\n }\\n }\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n GENERAL NUMBER UTILITIES\\n //////////////////////////////////////////////////////////////*/\\n\\n function sqrt(uint256 x) internal pure returns (uint256 z) {\\n assembly {\\n let y := x // We start y at x, which will help us make our initial estimate.\\n\\n z := 181 // The \\\"correct\\\" value is 1, but this saves a multiplication later.\\n\\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\\n\\n // We check y >= 2^(k + 8) but shift right by k bits\\n // each branch to ensure that if x >= 256, then y >= 256.\\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\\n y := shr(128, y)\\n z := shl(64, z)\\n }\\n if iszero(lt(y, 0x1000000000000000000)) {\\n y := shr(64, y)\\n z := shl(32, z)\\n }\\n if iszero(lt(y, 0x10000000000)) {\\n y := shr(32, y)\\n z := shl(16, z)\\n }\\n if iszero(lt(y, 0x1000000)) {\\n y := shr(16, y)\\n z := shl(8, z)\\n }\\n\\n // Goal was to get z*z*y within a small factor of x. More iterations could\\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\\n\\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\\n\\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\\n\\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\\n\\n // There is no overflow risk here since y < 2^136 after the first branch above.\\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\\n\\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n\\n // If x+1 is a perfect square, the Babylonian method cycles between\\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\\n z := sub(z, lt(div(x, z), z))\\n }\\n }\\n\\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Mod x by y. Note this will return\\n // 0 instead of reverting if y is zero.\\n z := mod(x, y)\\n }\\n }\\n\\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\\n assembly {\\n // Divide x by y. Note this will return\\n // 0 instead of reverting if y is zero.\\n r := div(x, y)\\n }\\n }\\n\\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Add 1 to x * y if x % y > 0. Note this will\\n // return 0 instead of reverting if y is zero.\\n z := add(gt(mod(x, y), 0), div(x, y))\\n }\\n }\\n}\\n\",\"keccak256\":\"0xab8ca9afbb0f7412e1408d4f111b53cc00813bc752236638ad336050ea2188f8\",\"license\":\"AGPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506105f0806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806306fdde031461005157806310badf4e1461009957806330132996146100cb57806389eabf0214610099575b600080fd5b604080518082018252601981527f556e697377617056334c697175696461746f7246756e64657200000000000000602082015290516100909190610345565b60405180910390f35b6100ac6100a736600461044f565b6100de565b604080516001600160a01b039093168352602083019190915201610090565b6100ac6100d93660046104a8565b6100f8565b6000806100ec8585856101b6565b91509150935093915050565b600080600080600080868060200190518101906101159190610507565b6040516386ed50b160e01b81526001600160a01b0380871660048301528086166024830152604482018f905262ffffff8516606483015295995093975091955090935050908216906386ed50b190608401602060405180830381865afa158015610183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a79190610578565b93989397509295505050505050565b6000806000806000858060200190518101906101d29190610507565b5060405163095ea7b360e01b81526001600160a01b038083166004830152602482018d90529399508997509195509350908a16915063095ea7b3906044016020604051808303816000875af115801561022f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102539190610591565b506040805160e0810182526001600160a01b038a811682528581166020830190815262ffffff8681168486019081523060608601908152608086018e8152600060a0880181815260c0890191825298516304e45aaf60e01b815297518716600489015294518616602488015291519092166044860152905183166064850152516084840152925160a48301529151821660c4820152908216906304e45aaf9060e4016020604051808303816000875af1158015610314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103389190610578565b9350505050935093915050565b60006020808352835180602085015260005b8181101561037357858101830151858201604001528201610357565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146103a957600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126103d357600080fd5b813567ffffffffffffffff808211156103ee576103ee6103ac565b604051601f8301601f19908116603f01168101908282118183101715610416576104166103ac565b8160405283815286602085880101111561042f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060006060848603121561046457600080fd5b833561046f81610394565b925060208401359150604084013567ffffffffffffffff81111561049257600080fd5b61049e868287016103c2565b9150509250925092565b600080604083850312156104bb57600080fd5b82359150602083013567ffffffffffffffff8111156104d957600080fd5b6104e5858286016103c2565b9150509250929050565b805162ffffff8116811461050257600080fd5b919050565b600080600080600060a0868803121561051f57600080fd5b855161052a81610394565b602087015190955061053b81610394565b9350610549604087016104ef565b9250606086015161055981610394565b608087015190925061056a81610394565b809150509295509295909350565b60006020828403121561058a57600080fd5b5051919050565b6000602082840312156105a357600080fd5b815180151581146105b357600080fd5b939250505056fea26469706673582212207716a92ad1236e367da9c113a9a242d174933ce2c80dd5c13c7d7e6d17c3d27164736f6c63430008160033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806306fdde031461005157806310badf4e1461009957806330132996146100cb57806389eabf0214610099575b600080fd5b604080518082018252601981527f556e697377617056334c697175696461746f7246756e64657200000000000000602082015290516100909190610345565b60405180910390f35b6100ac6100a736600461044f565b6100de565b604080516001600160a01b039093168352602083019190915201610090565b6100ac6100d93660046104a8565b6100f8565b6000806100ec8585856101b6565b91509150935093915050565b600080600080600080868060200190518101906101159190610507565b6040516386ed50b160e01b81526001600160a01b0380871660048301528086166024830152604482018f905262ffffff8516606483015295995093975091955090935050908216906386ed50b190608401602060405180830381865afa158015610183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a79190610578565b93989397509295505050505050565b6000806000806000858060200190518101906101d29190610507565b5060405163095ea7b360e01b81526001600160a01b038083166004830152602482018d90529399508997509195509350908a16915063095ea7b3906044016020604051808303816000875af115801561022f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102539190610591565b506040805160e0810182526001600160a01b038a811682528581166020830190815262ffffff8681168486019081523060608601908152608086018e8152600060a0880181815260c0890191825298516304e45aaf60e01b815297518716600489015294518616602488015291519092166044860152905183166064850152516084840152925160a48301529151821660c4820152908216906304e45aaf9060e4016020604051808303816000875af1158015610314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103389190610578565b9350505050935093915050565b60006020808352835180602085015260005b8181101561037357858101830151858201604001528201610357565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146103a957600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126103d357600080fd5b813567ffffffffffffffff808211156103ee576103ee6103ac565b604051601f8301601f19908116603f01168101908282118183101715610416576104166103ac565b8160405283815286602085880101111561042f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060006060848603121561046457600080fd5b833561046f81610394565b925060208401359150604084013567ffffffffffffffff81111561049257600080fd5b61049e868287016103c2565b9150509250925092565b600080604083850312156104bb57600080fd5b82359150602083013567ffffffffffffffff8111156104d957600080fd5b6104e5858286016103c2565b9150509250929050565b805162ffffff8116811461050257600080fd5b919050565b600080600080600060a0868803121561051f57600080fd5b855161052a81610394565b602087015190955061053b81610394565b9350610549604087016104ef565b9250606086015161055981610394565b608087015190925061056a81610394565b809150509295509295909350565b60006020828403121561058a57600080fd5b5051919050565b6000602082840312156105a357600080fd5b815180151581146105b357600080fd5b939250505056fea26469706673582212207716a92ad1236e367da9c113a9a242d174933ce2c80dd5c13c7d7e6d17c3d27164736f6c63430008160033", + "devdoc": { + "kind": "dev", + "methods": { + "estimateInputAmount(uint256,bytes)": { + "details": "Estimates the needed input amount of the input token for the conversion to return the desired output amount.", + "params": { + "outputAmount": "the desired output amount", + "strategyData": "the input token" + } + }, + "redeem(address,uint256,bytes)": { + "details": "Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`", + "params": { + "inputAmount": "input amount", + "inputToken": "Address of the token", + "strategyData": "context specific data like input token, pool address and tx expiratio period" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/solcInputs/0e729d9c66e5b1bc1021561041d72a21.json b/packages/contracts/deployments/superseed/solcInputs/0e729d9c66e5b1bc1021561041d72a21.json new file mode 100644 index 0000000000..70cade21dc --- /dev/null +++ b/packages/contracts/deployments/superseed/solcInputs/0e729d9c66e5b1bc1021561041d72a21.json @@ -0,0 +1,588 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable2Step.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 \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.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/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "adrastia-periphery/rates/IHistoricalRates.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\nimport \"./RateLibrary.sol\";\n\n/**\n * @title IHistoricalRates\n * @notice An interface that defines a contract that stores historical rates.\n */\ninterface IHistoricalRates {\n /// @notice Gets an rate for a token at a specific index.\n /// @param token The address of the token to get the rates for.\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\n /// index contains the oldest rate (uses reverse chronological ordering).\n /// @return rate The rate for the token at the specified index.\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @param offset The index of the first rate to get (default: 0).\n /// @param increment The increment between rates to get (default: 1).\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the number of rates for a token.\n /// @param token The address of the token to get the number of rates for.\n /// @return count The number of rates for the token.\n function getRatesCount(address token) external view returns (uint256);\n\n /// @notice Gets the capacity of rates for a token.\n /// @param token The address of the token to get the capacity of rates for.\n /// @return capacity The capacity of rates for the token.\n function getRatesCapacity(address token) external view returns (uint256);\n\n /// @notice Sets the capacity of rates for a token.\n /// @param token The address of the token to set the capacity of rates for.\n /// @param amount The new capacity of rates for the token.\n function setRatesCapacity(address token, uint256 amount) external;\n}\n" + }, + "adrastia-periphery/rates/RateLibrary.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nlibrary RateLibrary {\n struct Rate {\n uint64 target;\n uint64 current;\n uint32 timestamp;\n }\n}\n" + }, + "contracts/adrastia/PrudentiaLib.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nlibrary PrudentiaLib {\n struct PrudentiaConfig {\n address controller; // Adrastia Prudentia controller address\n uint8 offset; // Offset for delayed rate activation\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\n }\n}\n" + }, + "contracts/compound/CarefulMath.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Careful Math\n * @author Compound\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint256 c;\n unchecked {\n c = a * b;\n }\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n uint256 c;\n unchecked {\n c = a + b;\n }\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(\n uint256 a,\n uint256 b,\n uint256 c\n ) internal pure returns (MathError, uint256) {\n (MathError err0, uint256 sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/compound/CErc20Delegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CToken.sol\";\n\n/**\n * @title Compound's CErc20Delegate Contract\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\n * @author Compound\n */\ncontract CErc20Delegate is CErc20 {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 3;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n */\n function _becomeImplementation(bytes memory) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 1;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20Delegate\";\n }\n}\n" + }, + "contracts/compound/CErc20Delegator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ComptrollerInterface.sol\";\nimport \"./InterestRateModel.sol\";\nimport \"../ionic/DiamondExtension.sol\";\nimport { CErc20DelegatorBase, CDelegateInterface } from \"./CTokenInterfaces.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\n/**\n * @title Compound's CErc20Delegator Contract\n * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Compound\n */\ncontract CErc20Delegator is CErc20DelegatorBase, DiamondBase {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param ionicAdmin_ The FeeDistributor contract address.\n * @param interestRateModel_ The address of the interest rate model\n * @param name_ ERC-20 name of this token\n * @param symbol_ ERC-20 symbol of this token\n */\n constructor(\n address underlying_,\n IonicComptroller comptroller_,\n address payable ionicAdmin_,\n InterestRateModel interestRateModel_,\n string memory name_,\n string memory symbol_,\n uint256 reserveFactorMantissa_,\n uint256 adminFeeMantissa_\n ) {\n require(msg.sender == ionicAdmin_, \"!admin\");\n uint8 decimals_ = EIP20Interface(underlying_).decimals();\n {\n ionicAdmin = ionicAdmin_;\n\n // Set initial exchange rate\n initialExchangeRateMantissa = 0.2e18;\n\n // Set the comptroller\n comptroller = comptroller_;\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = 1e18;\n\n // Set the interest rate model (depends on block number / borrow index)\n require(interestRateModel_.isInterestRateModel(), \"!notIrm\");\n interestRateModel = interestRateModel_;\n emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // Set reserve factor\n // Check newReserveFactor ≤ maxReserveFactor\n require(\n reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!rf:set\"\n );\n reserveFactorMantissa = reserveFactorMantissa_;\n emit NewReserveFactor(0, reserveFactorMantissa_);\n\n // Set admin fee\n // Sanitize adminFeeMantissa_\n if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n require(\n reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!adminFee:set\"\n );\n adminFeeMantissa = adminFeeMantissa_;\n emit NewAdminFee(0, adminFeeMantissa_);\n ionicFeeMantissa = newIonicFeeMantissa;\n emit NewIonicFee(0, newIonicFeeMantissa);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n function implementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"delegateType()\"))));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {\n // Check admin rights\n require(hasAdminRights(), \"!admin\");\n\n // Set implementation\n _setImplementationInternal(implementation_, becomeImplementationData);\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self or admin\");\n\n (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature(\"delegateType()\"));\n require(success, \"no delegate type\");\n\n uint8 currentDelegateType = abi.decode(data, (uint8));\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)\n .latestCErc20Delegate(currentDelegateType);\n\n address currentDelegate = implementation();\n if (currentDelegate != latestCErc20Delegate) {\n _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);\n } else {\n // only update the extensions without reinitializing with becomeImplementationData\n _updateExtensions(currentDelegate);\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(msg.sender == address(ionicAdmin), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n /**\n * @dev Internal function to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {\n address delegateBefore = implementation();\n _updateExtensions(implementation_);\n\n _functionCall(\n address(this),\n abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),\n \"!become impl\"\n );\n\n emit NewImplementation(delegateBefore, implementation_);\n }\n\n function _updateExtensions(address newDelegate) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CErc20PluginDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\nimport \"./IERC4626.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\n/**\n * @title Rari's CErc20Plugin's Contract\n * @notice CToken which outsources token logic to a plugin\n * @author Joey Santoro\n *\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\n */\ncontract CErc20PluginDelegate is CErc20Delegate {\n event NewPluginImplementation(address oldImpl, address newImpl);\n\n /**\n * @notice Plugin address\n */\n IERC4626 public plugin;\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Delegate interface to become the implementation\n * @param data The encoded arguments for becoming\n */\n function _becomeImplementation(bytes memory data) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _becomeImplementation\");\n\n address _plugin = abi.decode(data, (address));\n\n if (_plugin == address(0) && address(plugin) != address(0)) {\n // if no new plugin address is given, use the latest implementation\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\n }\n\n if (_plugin != address(0) && _plugin != address(plugin)) {\n _updatePlugin(_plugin);\n }\n }\n\n /**\n * @notice Update the plugin implementation to a whitelisted implementation\n * @param _plugin The address of the plugin implementation to use\n */\n function _updatePlugin(address _plugin) public {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _updatePlugin\");\n\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\n\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\n }\n\n plugin = IERC4626(_plugin);\n\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\n\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\n if (amount != 0) {\n deposit(amount);\n }\n\n emit NewPluginImplementation(oldImplementation, _plugin);\n }\n\n /*** CToken Overrides ***/\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of the plugin in terms of the underlying\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view override returns (uint256) {\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\n }\n\n /**\n * @notice Transfer the underlying to the cToken and trigger a deposit\n * @param from Address to transfer funds from\n * @param amount Amount of underlying to transfer\n * @return The actual amount that is transferred\n */\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\n // Perform the EIP-20 transfer in\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \"send\");\n\n deposit(amount);\n return amount;\n }\n\n function deposit(uint256 amount) internal {\n plugin.deposit(amount, address(this));\n }\n\n /**\n * @notice Transfer the underlying from plugin to destination\n * @param to Address to transfer funds to\n * @param amount Amount of underlying to transfer\n */\n function doTransferOut(address to, uint256 amount) internal override {\n plugin.withdraw(amount, to, address(this));\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 2;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20PluginDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20PluginRewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20PluginDelegate.sol\";\n\ncontract CErc20PluginRewardsDelegate is CErc20PluginDelegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying && _token != address(plugin), \"!token\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 4;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20PluginRewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20RewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\n\ncontract CErc20RewardsDelegate is CErc20Delegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n \n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying, \"!underlying\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 3;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20RewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/Comptroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./Unitroller.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { IIonicFlywheel } from \"../ionic/strategies/flywheel/IIonicFlywheel.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\n */\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when an admin supports a market\n event MarketListed(ICErc20 cToken);\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(ICErc20 cToken, address account);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(ICErc20 cToken, address account);\n\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\n\n /// @notice Emitted when the whitelist enforcement is changed\n event WhitelistEnforcementChanged(bool enforce);\n\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\n event AddedRewardsDistributor(address rewardsDistributor);\n\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n // liquidationIncentiveMantissa must be no less than this value\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\n\n // liquidationIncentiveMantissa must be no greater than this value\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\n\n modifier isAuthorized() {\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \"not authorized\");\n _;\n }\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\n return ComptrollerBase.effectiveSupplyCaps(cToken);\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\n return ComptrollerBase.effectiveBorrowCaps(cToken);\n }\n\n /*** Assets You Are In ***/\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\n ICErc20[] memory assetsIn = accountAssets[account];\n\n return assetsIn;\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param cToken The cToken to check\n * @return True if the account is in the asset, otherwise false.\n */\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\n return markets[address(cToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param cTokens The list of addresses of the cToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\n uint256 len = cTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i = 0; i < len; i++) {\n ICErc20 cToken = ICErc20(cTokens[i]);\n\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param cToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\n Market storage marketToJoin = markets[address(cToken)];\n\n if (!marketToJoin.isListed) {\n // market is not listed, cannot join\n return Error.MARKET_NOT_LISTED;\n }\n\n if (marketToJoin.accountMembership[borrower] == true) {\n // already joined\n return Error.NO_ERROR;\n }\n\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(cToken);\n\n // Add to allBorrowers\n if (!borrowers[borrower]) {\n allBorrowers.push(borrower);\n borrowers[borrower] = true;\n borrowerIndexes[borrower] = allBorrowers.length - 1;\n }\n\n emit MarketEntered(cToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow.\n * @param cTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\n // TODO\n require(markets[cTokenAddress].isListed, \"!Comptroller:exitMarket\");\n\n ICErc20 cToken = ICErc20(cTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"!exitMarket\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[cTokenAddress];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set cToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete cToken from the account’s list of assets */\n // load into memory for faster iteration\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n ICErc20[] storage storedList = accountAssets[msg.sender];\n storedList[assetIndex] = storedList[storedList.length - 1];\n storedList.pop();\n\n // If the user has exited all markets, remove them from the `allBorrowers` array\n if (storedList.length == 0) {\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\n allBorrowers.pop(); // Reduce length by 1\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\n }\n\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Policy Hooks ***/\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param cTokenAddress The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintGuardianPaused[cTokenAddress], \"!mint:paused\");\n\n // Make sure market is listed\n if (!markets[cTokenAddress].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure minter is whitelisted\n if (enforceWhitelist && !whitelist[minter]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\n\n // Supply cap of 0 corresponds to unlimited supplying\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\n uint256 nonWhitelistedTotalSupply;\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\n\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \"!supply cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cTokenAddress, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param cToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n function redeemAllowedInternal(\n address cToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[cToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n ICErc20(cToken),\n redeemTokens,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint and reverts on rejection. May emit logs.\n * @param cToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n // Add minter to suppliers mapping\n suppliers[minter] = true;\n }\n\n /**\n * @notice Validates redeem and reverts on rejection. May emit logs.\n * @param cToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(\n address cToken,\n address redeemer,\n uint256 redeemAmount,\n uint256 redeemTokens\n ) external override {\n require(markets[msg.sender].isListed, \"!market\");\n\n // Require tokens is zero or amount is also zero\n if (redeemTokens == 0 && redeemAmount > 0) {\n revert(\"!zero\");\n }\n }\n\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) external view override returns (uint256) {\n address cToken = address(cTokenModify);\n // Accrue interest\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\n\n // Get account liquidity\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n isBorrow ? cTokenModify : ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n require(err == Error.NO_ERROR, \"!liquidity\");\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\n\n // Get max borrow/redeem\n uint256 maxBorrowOrRedeemAmount;\n\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\n // Max redeem = balance of underlying if not used as collateral\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\n } else {\n // Avoid \"stack too deep\" error by separating this logic\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\n\n // Redeem only: max out at underlying balance\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\n }\n\n // Get max borrow or redeem considering cToken liquidity\n uint256 cTokenLiquidity = cTokenModify.getCash();\n\n // Return the minimum of the two maximums\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\n }\n\n /**\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \"stack too deep\" errors.\n */\n function _getMaxRedeemOrBorrow(\n uint256 liquidity,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal view returns (uint256) {\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\n\n // Get the normalized price of the asset\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\n require(conversionFactor > 0, \"!oracle\");\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n if (!isBorrow) {\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\n }\n\n // Get max borrow or redeem considering excess account liquidity\n return (liquidity * 1e18) / conversionFactor;\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!borrowGuardianPaused[cToken], \"!borrow:paused\");\n\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n if (!markets[cToken].accountMembership[borrower]) {\n // only cTokens may call borrowAllowed if borrower not in market\n require(msg.sender == cToken, \"!ctoken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n // it should be impossible to break the important invariant\n assert(markets[cToken].accountMembership[borrower]);\n }\n\n // Make sure oracle price is available\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n // Make sure borrower is whitelisted\n if (enforceWhitelist && !whitelist[borrower]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 borrowCap = effectiveBorrowCaps(cToken);\n\n // Borrow cap of 0 corresponds to unlimited borrowing\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\n uint256 nonWhitelistedTotalBorrows;\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \"!borrow:cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n // Perform a hypothetical liquidity check to guard against shortfall\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\n if (err != uint256(Error.NO_ERROR)) {\n return err;\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken Asset whose underlying is being borrowed\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\n */\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\n // Check if min borrow exists\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\n\n if (minBorrowEth > 0) {\n // Get new underlying borrow balance of account for this cToken\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\n Exp({ mantissa: oraclePriceMantissa }),\n accountBorrowsNew\n );\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\n\n // Check against min borrow\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\n }\n\n // Return no error\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param cToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which would borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure markets are listed\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Get borrowers' underlying borrow balance\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\n\n /* allow accounts to be liquidated if the market is deprecated */\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\n require(borrowBalance >= repayAmount, \"!borrow>repay\");\n } else {\n /* The borrower must have shortfall in order to be liquidateable */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n /* The liquidator may not repay more than what is allowed by the closeFactor */\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\n if (repayAmount > maxClose) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!seizeGuardianPaused, \"!seize:paused\");\n\n // Make sure markets are listed\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure cToken Comptrollers are identical\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param cToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of cTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address cToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!transferGuardianPaused, \"!transfer:paused\");\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cToken, src, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Flywheel Hooks ***/\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\n * @param cToken The relevant market\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n */\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\n }\n\n /*** Liquidity/Liquidation Calculations ***/\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n ICErc20 asset;\n uint256 sumCollateral;\n uint256 sumBorrowPlusEffects;\n uint256 cTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n uint256 borrowCapForCollateral;\n uint256 borrowedAssetPrice;\n uint256 assetAsCollateralValueCap;\n }\n\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(\n account,\n ICErc20(cTokenModify),\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code,\n hypothetical account collateral value,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n ICErc20 cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) internal view returns (Error, uint256, uint256, uint256) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n\n if (address(cTokenModify) != address(0)) {\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n }\n\n // For each asset the account is in\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\n vars.asset = accountAssets[account][i];\n\n {\n // Read the balances and exchange rate from the cToken\n uint256 oErr;\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\n }\n }\n {\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\n if (vars.oraclePriceMantissa == 0) {\n return (Error.PRICE_ERROR, 0, 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n }\n {\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\n vars.asset,\n cTokenModify,\n redeemTokens > 0,\n account\n );\n\n // accumulate the collateral value to sumCollateral\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\n assetCollateralValue = vars.assetAsCollateralValueCap;\n vars.sumCollateral += assetCollateralValue;\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with cTokenModify\n if (vars.asset == cTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\n if (repayEffect >= vars.sumBorrowPlusEffects) {\n vars.sumBorrowPlusEffects = 0;\n } else {\n vars.sumBorrowPlusEffects -= repayEffect;\n }\n }\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\n * @param cTokenBorrowed The address of the borrowed cToken\n * @param cTokenCollateral The address of the collateral cToken\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 actualRepayAmount\n ) external view override returns (uint256, uint256) {\n /* Read oracle prices for borrowed and collateral markets */\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\n uint256 seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\n\n /*\n * The liquidation penalty includes\n * - the liquidator incentive\n * - the protocol fees (Ionic admin fees)\n * - the market fee\n */\n Exp memory totalPenaltyMantissa = add_(\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\n Exp({ mantissa: feeSeizeShareMantissa })\n );\n\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n return (uint256(Error.NO_ERROR), seizeTokens);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Add a RewardsDistributor contracts.\n * @dev Admin function to add a RewardsDistributor contract\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addRewardsDistributor(address distributor) external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n\n // Check marker method\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \"!isRewardsDistributor\");\n\n // Check for existing RewardsDistributor\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \"!added\");\n\n // Add RewardsDistributor to array\n rewardsDistributors.push(distributor);\n emit AddedRewardsDistributor(distributor);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist enforcement for the comptroller\n * @dev Admin function to set a new whitelist enforcement boolean\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\n }\n\n // Check if `enforceWhitelist` already equals `enforce`\n if (enforceWhitelist == enforce) {\n return uint256(Error.NO_ERROR);\n }\n\n // Set comptroller's `enforceWhitelist` to `enforce`\n enforceWhitelist = enforce;\n\n // Emit WhitelistEnforcementChanged(bool enforce);\n emit WhitelistEnforcementChanged(enforce);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist `statuses` for `suppliers`\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\n }\n\n // Set whitelist statuses for suppliers\n for (uint256 i = 0; i < suppliers.length; i++) {\n address supplier = suppliers[i];\n\n if (statuses[i]) {\n // If not already whitelisted, add to whitelist\n if (!whitelist[supplier]) {\n whitelist[supplier] = true;\n whitelistArray.push(supplier);\n whitelistIndexes[supplier] = whitelistArray.length - 1;\n }\n } else {\n // If whitelisted, remove from whitelist\n if (whitelist[supplier]) {\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\n whitelistArray.pop(); // Reduce length by 1\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\n }\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Admin function to set a new price oracle\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\n }\n\n // Track the old oracle for the comptroller\n BasePriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Admin function to set closeFactor\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\n }\n\n // Check limits\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n if (lessThanExp(highLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n // Set pool close factor to new close factor, remember old value\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n\n // Emit event\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Admin function to set per-market collateralFactor\n * @param cToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\n }\n\n // Verify market is listed\n Market storage market = markets[address(cToken)];\n if (!market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\n }\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n // Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Admin function to set liquidationIncentive\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\n }\n\n // Check de-scaled min <= newLiquidationIncentive <= max\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Admin function to set isListed and add support for the market\n * @param cToken The address of the market (token) to list\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Is market already listed?\n if (markets[address(cToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // Check cToken.comptroller == this\n require(address(cToken.comptroller()) == address(this), \"!comptroller\");\n\n // Make sure market is not already listed\n address underlying = ICErc20(address(cToken)).underlying();\n\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // List market and emit event\n Market storage market = markets[address(cToken)];\n market.isListed = true;\n market.collateralFactorMantissa = 0;\n allMarkets.push(cToken);\n cTokensByUnderlying[underlying] = cToken;\n emit MarketListed(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _deployMarket(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\n bool oldIonicAdminHasRights = ionicAdminHasRights;\n ionicAdminHasRights = true;\n\n // Deploy via Ionic admin\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\n // Reset Ionic admin rights to the original value\n ionicAdminHasRights = oldIonicAdminHasRights;\n // Support market here in the Comptroller\n uint256 err = _supportMarket(cToken);\n\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\n\n // Set collateral factor\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\n }\n\n function _becomeImplementation() external {\n require(msg.sender == address(this), \"!self call\");\n\n if (!_notEnteredInitialized) {\n _notEntered = true;\n _notEnteredInitialized = true;\n }\n }\n\n /*** Helper Functions ***/\n\n /**\n * @notice Returns true if the given cToken market has been deprecated\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\n * @param cToken The market to check if deprecated\n */\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\n return\n markets[address(cToken)].collateralFactorMantissa == 0 &&\n borrowGuardianPaused[address(cToken)] == true &&\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\n }\n\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\n return ComptrollerExtensionInterface(address(this));\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 32;\n\n functionSelectors = new bytes4[](fnsCount);\n\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\n functionSelectors[--fnsCount] = this._deployMarket.selector;\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\n functionSelectors[--fnsCount] = this.checkMembership.selector;\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\n functionSelectors[--fnsCount] = this.exitMarket.selector;\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\n functionSelectors[--fnsCount] = this.mintVerify.selector;\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n /**\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _beforeNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_beforeNonReentrant\");\n require(_notEntered, \"!reentered\");\n _notEntered = false;\n }\n\n /**\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _afterNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_afterNonReentrant\");\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n}\n" + }, + "contracts/compound/ComptrollerFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ComptrollerFirstExtension is\n DiamondExtension,\n ComptrollerBase,\n ComptrollerExtensionInterface,\n ComptrollerErrorReporter\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when supply cap for a cToken is changed\n event NewSupplyCap(ICErc20 indexed cToken, uint256 newSupplyCap);\n\n /// @notice Emitted when borrow cap for a cToken is changed\n event NewBorrowCap(ICErc20 indexed cToken, uint256 newBorrowCap);\n\n /// @notice Emitted when borrow cap guardian is changed\n event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused globally\n event ActionPaused(string action, bool pauseState);\n\n /// @notice Emitted when an action is paused on a market\n event MarketActionPaused(ICErc20 cToken, string action, bool pauseState);\n\n /// @notice Emitted when an admin unsupports a market\n event MarketUnlisted(ICErc20 cToken);\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 33;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector;\n functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector;\n functionSelectors[--fnsCount] = this._setMarketBorrowCaps.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._supplyCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._borrowCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapGuardian.selector;\n functionSelectors[--fnsCount] = this._setPauseGuardian.selector;\n functionSelectors[--fnsCount] = this._setMintPaused.selector;\n functionSelectors[--fnsCount] = this._setBorrowPaused.selector;\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this._unsupportMarket.selector;\n functionSelectors[--fnsCount] = this.getAllMarkets.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowers.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowersCount.selector;\n functionSelectors[--fnsCount] = this.getPaginatedBorrowers.selector;\n functionSelectors[--fnsCount] = this.getWhitelist.selector;\n functionSelectors[--fnsCount] = this.getRewardsDistributors.selector;\n functionSelectors[--fnsCount] = this.isUserOfPool.selector;\n functionSelectors[--fnsCount] = this.getAccruingFlywheels.selector;\n functionSelectors[--fnsCount] = this._removeFlywheel.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateral.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateral.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapForCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBlacklistBorrowingAgainstCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isSupplyCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector;\n functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /**\n * @notice Returns true if the accruing flyhwheel was found and replaced\n * @dev Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\n * @param flywheelAddress The address of the flywheel to add to the non-accruing\n */\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n require(flywheelAddress != nonAccruingRewardsDistributors[i], \"!alreadyadded\");\n }\n\n // add it to the non-accruing\n nonAccruingRewardsDistributors.push(flywheelAddress);\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256) {\n if (address(collateral) == address(cTokenModify) && !redeeming) {\n // the collateral asset counts as 0 liquidity when borrowed\n return 0;\n }\n\n uint256 assetAsCollateralValueCap = type(uint256).max;\n if (address(cTokenModify) != address(0)) {\n // if the borrowed asset is blacklisted against this collateral & account is not whitelisted\n if (\n borrowingAgainstCollateralBlacklist[address(cTokenModify)][address(collateral)] &&\n !borrowingAgainstCollateralBlacklistWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n assetAsCollateralValueCap = 0;\n } else {\n // for each user the value of this kind of collateral is capped regardless of the amount borrowed\n // denominated in the borrowed asset\n uint256 borrowCapForCollateral = borrowCapForCollateral[address(cTokenModify)][address(collateral)];\n // check if set to any value & account is not whitelisted\n if (\n borrowCapForCollateral != 0 &&\n !borrowCapForCollateralWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n // this asset usage as collateral is capped at the native value of the borrow cap\n assetAsCollateralValueCap = (borrowCapForCollateral * borrowedAssetPrice) / 1e18;\n }\n }\n }\n\n uint256 supplyCap = effectiveSupplyCaps(address(collateral));\n\n // if there is any supply cap, don't allow donations to the market/plugin to go around it\n if (supplyCap > 0 && !supplyCapWhitelist[address(collateral)].contains(account)) {\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateral);\n uint256 supplyCapValue = (supplyCap * collateralAssetPrice) / 1e18;\n supplyCapValue = (supplyCapValue * markets[address(collateral)].collateralFactorMantissa) / 1e18;\n if (supplyCapValue < assetAsCollateralValueCap) assetAsCollateralValueCap = supplyCapValue;\n }\n\n return assetAsCollateralValueCap;\n }\n\n /**\n * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\n * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\n * @param cTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\n */\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n supplyCaps[address(cTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(cTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\n * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\n * @param cTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\n */\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n borrowCaps[address(cTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Admin function to change the Borrow Cap Guardian\n * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian\n */\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external {\n require(msg.sender == admin, \"!admin\");\n\n // Save current value for inclusion in log\n address oldBorrowCapGuardian = borrowCapGuardian;\n\n // Store borrowCapGuardian with value newBorrowCapGuardian\n borrowCapGuardian = newBorrowCapGuardian;\n\n // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)\n emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(address newPauseGuardian) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);\n }\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setMintPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n mintGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Mint\", state);\n return state;\n }\n\n function _setBorrowPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n borrowGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Borrow\", state);\n return state;\n }\n\n function _setTransferPaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n transferGuardianPaused = state;\n emit ActionPaused(\"Transfer\", state);\n return state;\n }\n\n function _setSeizePaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n seizeGuardianPaused = state;\n emit ActionPaused(\"Seize\", state);\n return state;\n }\n\n /**\n * @notice Removed a market from the markets mapping and sets it as unlisted\n * @dev Admin function unset isListed and collateralFactorMantissa and unadd support for the market\n * @param cToken The address of the market (token) to unlist\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _unsupportMarket(ICErc20 cToken) external returns (uint256) {\n // Check admin rights\n if (!hasAdminRights()) return fail(Error.UNAUTHORIZED, FailureInfo.UNSUPPORT_MARKET_OWNER_CHECK);\n\n // Check if market is already unlisted\n if (!markets[address(cToken)].isListed)\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNSUPPORT_MARKET_DOES_NOT_EXIST);\n\n // Check if market is in use\n if (cToken.totalSupply() > 0) return fail(Error.NONZERO_TOTAL_SUPPLY, FailureInfo.UNSUPPORT_MARKET_IN_USE);\n\n // Unlist market\n delete markets[address(cToken)];\n\n /* Delete cToken from allMarkets */\n // load into memory for faster iteration\n ICErc20[] memory _allMarkets = allMarkets;\n uint256 len = _allMarkets.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (_allMarkets[i] == cToken) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n allMarkets[assetIndex] = allMarkets[allMarkets.length - 1];\n allMarkets.pop();\n\n cTokensByUnderlying[ICErc20(address(cToken)).underlying()] = ICErc20(address(0));\n emit MarketUnlisted(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) public {\n require(hasAdminRights(), \"!admin\");\n borrowCapForCollateral[cTokenBorrow][cTokenCollateral] = borrowCap;\n }\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n borrowingAgainstCollateralBlacklist[cTokenBorrow][cTokenCollateral] = blacklisted;\n }\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) supplyCapWhitelist[cToken].add(account);\n else supplyCapWhitelist[cToken].remove(account);\n }\n\n function isSupplyCapWhitelisted(address cToken, address account) public view returns (bool) {\n return supplyCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedSuppliersSupply(address cToken) public view returns (uint256 supplied) {\n address[] memory whitelistedSuppliers = supplyCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedSuppliers.length; i++) {\n supplied += ICErc20(cToken).balanceOfUnderlying(whitelistedSuppliers[i]);\n }\n }\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapWhitelist[cToken].add(account);\n else borrowCapWhitelist[cToken].remove(account);\n }\n\n function isBorrowCapWhitelisted(address cToken, address account) public view returns (bool) {\n return borrowCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedBorrowersBorrows(address cToken) public view returns (uint256 borrowed) {\n address[] memory whitelistedBorrowers = borrowCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedBorrowers.length; i++) {\n borrowed += ICErc20(cToken).borrowBalanceCurrent(whitelistedBorrowers[i]);\n }\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market.\n * @return The list of market addresses\n */\n function getAllMarkets() public view returns (ICErc20[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Return all of the borrowers\n * @dev The automatic getter may be used to access an individual borrower.\n * @return The list of borrower account addresses\n */\n function getAllBorrowers() public view returns (address[] memory) {\n return allBorrowers;\n }\n\n function getAllBorrowersCount() public view returns (uint256) {\n return allBorrowers.length;\n }\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) public view returns (uint256 _totalPages, address[] memory _pageOfBorrowers) {\n uint256 allBorrowersCount = allBorrowers.length;\n if (allBorrowersCount == 0) {\n return (0, new address[](0));\n }\n\n if (pageSize == 0) pageSize = 300;\n uint256 currentPageSize = pageSize;\n uint256 sizeOfPageFromRemainder = allBorrowersCount % pageSize;\n\n _totalPages = allBorrowersCount / pageSize;\n if (sizeOfPageFromRemainder > 0) {\n _totalPages++;\n if (page + 1 == _totalPages) {\n currentPageSize = sizeOfPageFromRemainder;\n }\n }\n\n if (page + 1 > _totalPages) {\n return (_totalPages, new address[](0));\n }\n\n uint256 offset = page * pageSize;\n _pageOfBorrowers = new address[](currentPageSize);\n for (uint256 i = 0; i < currentPageSize; i++) {\n _pageOfBorrowers[i] = allBorrowers[i + offset];\n }\n }\n\n /**\n * @notice Return all of the whitelist\n * @dev The automatic getter may be used to access an individual whitelist status.\n * @return The list of borrower account addresses\n */\n function getWhitelist() external view returns (address[] memory) {\n return whitelistArray;\n }\n\n /**\n * @notice Returns an array of all accruing and non-accruing flywheels\n */\n function getRewardsDistributors() external view returns (address[] memory) {\n address[] memory allFlywheels = new address[](rewardsDistributors.length + nonAccruingRewardsDistributors.length);\n\n uint8 i = 0;\n while (i < rewardsDistributors.length) {\n allFlywheels[i] = rewardsDistributors[i];\n i++;\n }\n uint8 j = 0;\n while (j < nonAccruingRewardsDistributors.length) {\n allFlywheels[i + j] = nonAccruingRewardsDistributors[j];\n j++;\n }\n\n return allFlywheels;\n }\n\n function getAccruingFlywheels() external view returns (address[] memory) {\n return rewardsDistributors;\n }\n\n /**\n * @dev Removes a flywheel from the accruing or non-accruing array\n * @param flywheelAddress The address of the flywheel to remove from the accruing or non-accruing array\n * @return true if the flywheel was found and removed\n */\n function _removeFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n // or remove it from the non-accruing\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n if (flywheelAddress == nonAccruingRewardsDistributors[i]) {\n nonAccruingRewardsDistributors[i] = nonAccruingRewardsDistributors[nonAccruingRewardsDistributors.length - 1];\n nonAccruingRewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function isUserOfPool(address user) external view returns (bool) {\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address marketAddress = address(allMarkets[i]);\n if (markets[marketAddress].accountMembership[user]) {\n return true;\n }\n }\n\n return false;\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n\n for (uint256 i = 0; i < allMarkets.length; i++) {\n allMarkets[i].registerInSFS();\n }\n\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/ComptrollerInterface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerV4Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\nimport { IHistoricalRates } from \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\ninterface ComptrollerInterface {\n function isDeprecated(ICErc20 cToken) external view returns (bool);\n\n function _becomeImplementation() external;\n\n function _deployMarket(\n uint8 delegateType,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\n\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\n\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _addRewardsDistributor(address distributor) external returns (uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) external view returns (uint256, uint256, uint256, uint256);\n\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cToken) external returns (uint256);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\n\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\n\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function getAccountLiquidity(\n address account\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\n\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 repayAmount\n ) external view returns (uint256, uint256);\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n function _beforeNonReentrant() external;\n\n function _afterNonReentrant() external;\n\n /*** New supply and borrow cap view functions ***/\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\n}\n\ninterface ComptrollerStorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function pendingAdmin() external view returns (address);\n\n function oracle() external view returns (BasePriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function enforceWhitelist() external view returns (bool);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function suppliers(address account) external view returns (bool);\n\n function cTokensByUnderlying(address) external view returns (address);\n\n /**\n * Gets the supply cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\n * `effectiveSupplyCaps` to get the correct supply cap.\n * @param cToken The address of the cToken.\n * @return The supply cap in the units of the underlying asset.\n */\n function supplyCaps(address cToken) external view returns (uint256);\n\n /**\n * Gets the borrow cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\n * `effectiveBorrowCaps` to get the correct borrow cap.\n * @param cToken The address of the cToken.\n * @return The borrow cap in the units of the underlying asset.\n */\n function borrowCaps(address cToken) external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function accountAssets(address, uint256) external view returns (address);\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function rewardsDistributors(uint256) external view returns (address);\n}\n\ninterface SFSRegister {\n function register(address _recipient) external returns (uint256 tokenId);\n}\n\ninterface ComptrollerExtensionInterface {\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function getAllBorrowersCount() external view returns (uint256);\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAccruingFlywheels() external view returns (address[] memory);\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) external;\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _removeFlywheel(address flywheelAddress) external returns (bool);\n\n function getWhitelist() external view returns (address[] memory);\n\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\n\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setTransferPaused(bool state) external returns (bool);\n\n function _setSeizePaused(bool state) external returns (bool);\n\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\n * @return The config.\n */\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\n * @return The config.\n */\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\n * @param newConfig The new config.\n */\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\n * @param newConfig The new config.\n */\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n}\n\ninterface UnitrollerInterface {\n function comptrollerImplementation() external view returns (address);\n\n function _upgrade() external;\n\n function _acceptAdmin() external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n\n function _toggleAdminRights(bool hasRights) external returns (uint256);\n}\n\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\n\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\n\ninterface IonicComptroller is\n ComptrollerInterface,\n ComptrollerExtensionInterface,\n UnitrollerInterface,\n ComptrollerStorageInterface\n{\n\n}\n\nabstract contract ComptrollerBase is ComptrollerV4Storage {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\n\n // Check if we're using Adrastia Prudentia for the supply cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the supply cap from Adrastia Prudentia\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n supplyCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n supplyCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local supply cap\n\n // Get the supply cap from the local supply cap\n supplyCap = supplyCaps[cToken];\n }\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\n\n // Check if we're using Adrastia Prudentia for the borrow cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the borrow cap from Adrastia Prudentia\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n borrowCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n borrowCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local borrow cap\n borrowCap = borrowCaps[cToken];\n }\n }\n}\n" + }, + "contracts/compound/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IFeeDistributor.sol\";\nimport \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract UnitrollerAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Whether or not the Ionic admin has admin rights\n */\n bool public ionicAdminHasRights = true;\n\n /**\n * @notice Whether or not the admin has admin rights\n */\n bool public adminHasRights = true;\n\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\n }\n}\n\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n BasePriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /*\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 internal maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => ICErc20[]) public accountAssets;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n struct Market {\n // Whether or not this market is listed\n bool isListed;\n // Multiplier representing the most one can borrow against their collateral in this market.\n // For instance, 0.9 to allow borrowing 90% of collateral value.\n // Must be between 0 and 1, and stored as a mantissa.\n uint256 collateralFactorMantissa;\n // Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n }\n\n /**\n * @notice Official mapping of cTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /// @notice A list of all markets\n ICErc20[] public allMarkets;\n\n /**\n * @dev Maps borrowers to booleans indicating if they have entered any markets\n */\n mapping(address => bool) internal borrowers;\n\n /// @notice A list of all borrowers who have entered markets\n address[] public allBorrowers;\n\n // Indexes of borrower account addresses in the `allBorrowers` array\n mapping(address => uint256) internal borrowerIndexes;\n\n /**\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\n */\n mapping(address => bool) public suppliers;\n\n /// @notice All cTokens addresses mapped by their underlying token addresses\n mapping(address => ICErc20) public cTokensByUnderlying;\n\n /// @notice Whether or not the supplier whitelist is enforced\n bool public enforceWhitelist;\n\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\n mapping(address => bool) public whitelist;\n\n /// @notice An array of all whitelisted accounts\n address[] public whitelistArray;\n\n // Indexes of account addresses in the `whitelistArray` array\n mapping(address => uint256) internal whitelistIndexes;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n * Actions which allow users to remove their own assets cannot be paused.\n * Liquidation / seizing / transfer can only be paused globally, not by market.\n */\n address public pauseGuardian;\n bool public _mintGuardianPaused;\n bool public _borrowGuardianPaused;\n bool public transferGuardianPaused;\n bool public seizeGuardianPaused;\n mapping(address => bool) public mintGuardianPaused;\n mapping(address => bool) public borrowGuardianPaused;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\n mapping(address => uint256) public borrowCaps;\n\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\n mapping(address => uint256) public supplyCaps;\n\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\n address[] public rewardsDistributors;\n\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\n bool internal _notEntered;\n\n /// @dev Whether or not _notEntered has been initialized\n bool internal _notEnteredInitialized;\n\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\n address[] public nonAccruingRewardsDistributors;\n\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\n\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => mapping(address => EnumerableSet.AddressSet))\n internal borrowingAgainstCollateralBlacklistWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @dev Adrastia Prudentia config for controlling borrow caps.\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\n\n /// @dev Adrastia Prudentia config for controlling supply caps.\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\n}\n" + }, + "contracts/compound/CToken.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { CTokenSecondExtensionBase, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { DiamondExtension, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\n/**\n * @title Compound's CErc20 Contract\n * @notice CTokens which wrap an EIP-20 underlying\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\n * @author Compound\n */\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n modifier isMinHFThresholdExceeded(address borrower) {\n PoolLens lens = PoolLens(ap.getAddress(\"PoolLens\"));\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\n require(msg.sender == address(liquidator), \"Health factor not low enough for non-permissioned liquidations\");\n _;\n } else {\n _;\n }\n }\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 13;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.mint.selector;\n functionSelectors[--fnsCount] = this.redeem.selector;\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\n functionSelectors[--fnsCount] = this.borrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\n functionSelectors[--fnsCount] = this.getCash.selector;\n functionSelectors[--fnsCount] = this.seize.selector;\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemInternal(redeemTokens);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemUnderlyingInternal(redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return borrowInternal(borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\n return err;\n }\n\n /**\n * @notice Get cash balance of this cToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view override returns (uint256) {\n return getCashInternal();\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another cToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n function selfTransferOut(address to, uint256 amount) external override {\n require(msg.sender == address(this), \"!self\");\n doTransferOut(to, amount);\n }\n\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\n require(msg.sender == address(this), \"!self\");\n return doTransferIn(from, amount);\n }\n\n /**\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\n }\n\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalIonicFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\n totalIonicFees = totalIonicFeesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(address(ionicAdmin), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces admin fees by transferring to admin\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalAdminFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n totalAdminFees = totalAdminFees - withdrawAmount;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view virtual returns (uint256) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\n \"TOKEN_TRANSFER_IN_FAILED\"\n );\n\n // Calculate the amount that was *actually* transferred\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address to, uint256 amount) internal virtual {\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\n \"TOKEN_TRANSFER_OUT_FAILED\"\n );\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n struct MintLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 mintTokens;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n uint256 actualMintAmount;\n }\n\n /**\n * @notice User supplies assets into the market and receives cTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\n /* Fail if mint not allowed */\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n // Check max supply\n // unused function\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n } */\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of cTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n // mintTokens is rounded down here - correct\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n require(vars.mathErr == MathError.NO_ERROR, \"MINT_EXCHANGE_CALCULATION_FAILED\");\n require(vars.mintTokens > 0, \"MINT_ZERO_CTOKENS_REJECTED\");\n\n /*\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\n\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, 0, redeemAmount);\n }\n\n struct RedeemLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 redeemTokens;\n uint256 redeemAmount;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n }\n\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\n res = (x * 1e18) / y;\n if (x % y != 0) res += 1;\n }\n\n /**\n * @notice User redeems cTokens in exchange for the underlying asset\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemFresh(\n address redeemer,\n uint256 redeemTokensIn,\n uint256 redeemAmountIn\n ) internal returns (uint256) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"!redeem tokens or amount\");\n\n RedeemLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n if (redeemTokensIn > 0) {\n // don't allow dust tokens/assets to be left after\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\n\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n } else {\n if (redeemAmountIn == type(uint256).max) {\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\n }\n\n // don't allow dust tokens/assets to be left after\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\n\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\n\n // don't allow dust tokens/assets to be left after\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashInternal() < vars.redeemAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the redeemer and the redeemAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(redeemer, vars.redeemAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\n\n /* We call the defense hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(msg.sender, borrowAmount);\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n }\n\n /**\n * @notice Users borrow assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\n /* Fail if borrow not allowed */\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\n }\n\n /* Fail gracefully if protocol has insufficient underlying cash */\n uint256 cashPrior = getCashInternal();\n\n if (cashPrior < borrowAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n uint256(vars.mathErr)\n );\n }\n\n // Check min borrow for this user for this asset\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the borrower and the borrowAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(borrower, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\n internal\n nonReentrant(false)\n returns (uint256, uint256)\n {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint256 repayAmount;\n uint256 borrowerIndex;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n uint256 actualRepayAmount;\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer the account paying off the borrow\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(\n address payer,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256, uint256) {\n /* Fail if repayBorrow not allowed */\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == type(uint256).max) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\");\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\");\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n ICErc20(cTokenCollateral).accrueInterest();\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal returns (uint256, uint256) {\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n cTokenCollateral,\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify cTokenCollateral market's block number equals current block number */\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == type(uint256).max) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n cTokenCollateral,\n actualRepayAmount\n );\n require(amountSeizeError == uint256(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint256 seizeError;\n if (cTokenCollateral == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"!seize\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n\n struct SeizeInternalLocalVars {\n MathError mathErr;\n uint256 borrowerTokensNew;\n uint256 liquidatorTokensNew;\n uint256 liquidatorSeizeTokens;\n uint256 protocolSeizeTokens;\n uint256 protocolSeizeAmount;\n uint256 exchangeRateMantissa;\n uint256 totalReservesNew;\n uint256 totalIonicFeeNew;\n uint256 totalSupplyNew;\n uint256 feeSeizeTokens;\n uint256 feeSeizeAmount;\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) internal returns (uint256) {\n /* Fail if seize not allowed */\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n SeizeInternalLocalVars memory vars;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\n }\n\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n vars.protocolSeizeAmount = mul_ScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n vars.protocolSeizeTokens\n );\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\n\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\n\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n totalReserves = vars.totalReservesNew;\n totalSupply = vars.totalSupplyNew;\n totalIonicFees = vars.totalIonicFeeNew;\n\n accountTokens[borrower] = vars.borrowerTokensNew;\n accountTokens[liquidator] = vars.liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n function asCTokenExtension() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\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 * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CTokenFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { IFlashLoanReceiver } from \"../ionic/IFlashLoanReceiver.sol\";\nimport { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { SFSRegister } from \"./ComptrollerInterface.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport { Multicall } from \"../utils/Multicall.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenFirstExtension is\n CTokenOracleProtected,\n CErc20FirstExtensionBase,\n TokenErrorReporter,\n Exponential,\n DiamondExtension,\n Multicall\n{\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 25;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.transfer.selector;\n functionSelectors[--fnsCount] = this.transferFrom.selector;\n functionSelectors[--fnsCount] = this.allowance.selector;\n functionSelectors[--fnsCount] = this.approve.selector;\n functionSelectors[--fnsCount] = this.balanceOf.selector;\n functionSelectors[--fnsCount] = this._setAdminFee.selector;\n functionSelectors[--fnsCount] = this._setInterestRateModel.selector;\n functionSelectors[--fnsCount] = this._setNameAndSymbol.selector;\n functionSelectors[--fnsCount] = this._setAddressesProvider.selector;\n functionSelectors[--fnsCount] = this._setReserveFactor.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.exchangeRateCurrent.selector;\n functionSelectors[--fnsCount] = this.accrueInterest.selector;\n functionSelectors[--fnsCount] = this.totalBorrowsCurrent.selector;\n functionSelectors[--fnsCount] = this.balanceOfUnderlying.selector;\n functionSelectors[--fnsCount] = this.multicall.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterDeposit.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterWithdraw.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlockAfterBorrow.selector;\n functionSelectors[--fnsCount] = this.getTotalUnderlyingSupplied.selector;\n functionSelectors[--fnsCount] = this.flash.selector;\n functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;\n functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getTotalUnderlyingSupplied() public view override returns (uint256) {\n // (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees))\n return asCToken().getCash() + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees);\n }\n\n /* ERC20 fns */\n /**\n * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {\n /* Fail if transfer not allowed */\n uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint256 startingAllowance = 0;\n if (spender == src) {\n startingAllowance = type(uint256).max;\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint256 allowanceNew;\n uint256 srcTokensNew;\n uint256 dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srcTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != type(uint256).max) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(\n address spender,\n uint256 amount\n ) public override isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n address src = msg.sender;\n transferAllowances[src][spender] = amount;\n emit Approval(src, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) public view override returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) public view override returns (uint256) {\n return accountTokens[owner];\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice updates the cToken ERC20 name and symbol\n * @dev Admin function to update the cToken ERC20 name and symbol\n * @param _name the new ERC20 token name to use\n * @param _symbol the new ERC20 token symbol to use\n */\n function _setNameAndSymbol(string calldata _name, string calldata _symbol) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n // Set ERC20 name and symbol\n name = _name;\n symbol = _symbol;\n }\n\n function _setAddressesProvider(address _ap) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n ap = AddressesProvider(_ap);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(\n uint256 newReserveFactorMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK);\n }\n\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa + adminFeeMantissa + ionicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint256 oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\n * @dev Admin function to accrue interest and set a new admin fee\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setAdminFee(\n uint256 newAdminFeeMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_ADMIN_FEE_FRESH_CHECK);\n }\n\n // Sanitize newAdminFeeMantissa\n if (newAdminFeeMantissa == type(uint256).max) newAdminFeeMantissa = adminFeeMantissa;\n\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n\n // Check reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa ≤ reserveFactorPlusFeesMaxMantissa\n if (reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK);\n }\n\n // If setting admin fee\n if (adminFeeMantissa != newAdminFeeMantissa) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_ADMIN_FEE_ADMIN_CHECK);\n }\n\n // Set admin fee\n uint256 oldAdminFeeMantissa = adminFeeMantissa;\n adminFeeMantissa = newAdminFeeMantissa;\n\n // Emit event\n emit NewAdminFee(oldAdminFeeMantissa, newAdminFeeMantissa);\n }\n\n // If setting Ionic fee\n if (ionicFeeMantissa != newIonicFeeMantissa) {\n // Set Ionic fee\n uint256 oldIonicFeeMantissa = ionicFeeMantissa;\n ionicFeeMantissa = newIonicFeeMantissa;\n\n // Emit event\n emit NewIonicFee(oldIonicFeeMantissa, newIonicFeeMantissa);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(\n InterestRateModel newInterestRateModel\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);\n }\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n require(newInterestRateModel.isInterestRateModel(), \"!notIrm\");\n\n InterestRateModel oldInterestRateModel = interestRateModel;\n interestRateModel = newInterestRateModel;\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this cToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getBorrowRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) public view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= borrowAmount, \"market cash not enough\");\n\n return\n interestRateModel.getBorrowRate(\n cash - borrowAmount,\n totalBorrows + borrowAmount,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this cToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash() + mintAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= withdrawAmount, \"market cash not enough\");\n return\n interestRateModel.getSupplyRate(\n cash - withdrawAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public view override returns (uint256) {\n if (block.number == accrualBlockNumber) {\n return\n _exchangeRateHypothetical(\n totalSupply,\n initialExchangeRateMantissa,\n asCToken().getCash(),\n totalBorrows,\n totalReserves,\n totalAdminFees,\n totalIonicFees\n );\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n\n return\n _exchangeRateHypothetical(\n accrual.totalSupply,\n initialExchangeRateMantissa,\n cashPrior,\n accrual.totalBorrows,\n accrual.totalReserves,\n accrual.totalAdminFees,\n accrual.totalIonicFees\n );\n }\n }\n\n function _exchangeRateHypothetical(\n uint256 _totalSupply,\n uint256 _initialExchangeRateMantissa,\n uint256 _totalCash,\n uint256 _totalBorrows,\n uint256 _totalReserves,\n uint256 _totalAdminFees,\n uint256 _totalIonicFees\n ) internal pure returns (uint256) {\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return _initialExchangeRateMantissa;\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees)) / totalSupply\n */\n uint256 cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(\n _totalCash,\n _totalBorrows,\n _totalReserves + _totalAdminFees + _totalIonicFees\n );\n require(mathErr == MathError.NO_ERROR, \"!addThenSubUInt overflow check failed\");\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n require(mathErr == MathError.NO_ERROR, \"!getExp overflow check failed\");\n\n return exchangeRate.mantissa;\n }\n }\n\n struct InterestAccrual {\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalSupply;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n uint256 interestAccumulated;\n }\n\n function _accrueInterestHypothetical(\n uint256 blockNumber,\n uint256 cashPrior\n ) internal view returns (InterestAccrual memory accrual) {\n uint256 totalFees = totalAdminFees + totalIonicFees;\n uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);\n if (borrowRateMantissa > borrowRateMaxMantissa) {\n if (cashPrior > totalFees) revert(\"!borrowRate\");\n else borrowRateMantissa = borrowRateMaxMantissa;\n }\n (MathError mathErr, uint256 blockDelta) = subUInt(blockNumber, accrualBlockNumber);\n require(mathErr == MathError.NO_ERROR, \"!blockDelta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * totalIonicFeesNew = interestAccumulated * ionicFee + totalIonicFees\n * totalAdminFeesNew = interestAccumulated * adminFee + totalAdminFees\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n accrual.accrualBlockNumber = blockNumber;\n accrual.totalSupply = totalSupply;\n Exp memory simpleInterestFactor = mul_(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n accrual.interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, totalBorrows);\n accrual.totalBorrows = accrual.interestAccumulated + totalBorrows;\n accrual.totalReserves = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n accrual.interestAccumulated,\n totalReserves\n );\n accrual.totalIonicFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: ionicFeeMantissa }),\n accrual.interestAccumulated,\n totalIonicFees\n );\n accrual.totalAdminFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: adminFeeMantissa }),\n accrual.interestAccumulated,\n totalAdminFees\n );\n accrual.borrowIndex = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndex, borrowIndex);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public override returns (uint256) {\n /* Remember the initial block number */\n uint256 currentBlockNumber = block.number;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumber == currentBlockNumber) {\n return uint256(Error.NO_ERROR);\n }\n\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(currentBlockNumber, cashPrior);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = accrual.borrowIndex;\n totalBorrows = accrual.totalBorrows;\n totalReserves = accrual.totalReserves;\n totalIonicFees = accrual.totalIonicFees;\n totalAdminFees = accrual.totalAdminFees;\n emit AccrueInterest(cashPrior, accrual.interestAccumulated, borrowIndex, totalBorrows);\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external view override returns (uint256) {\n if (accrualBlockNumber == block.number) {\n return totalBorrows;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n return accrual.totalBorrows;\n }\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {\n uint256 cTokenBalance = accountTokens[account];\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n\n borrowBalance = borrowBalanceCurrent(account);\n\n exchangeRateMantissa = exchangeRateCurrent();\n\n return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\n * @param account The address whose balance should be calculated after recalculating the borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) public view override returns (uint256) {\n uint256 _borrowIndex;\n if (accrualBlockNumber == block.number) {\n _borrowIndex = borrowIndex;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n _borrowIndex = accrual.borrowIndex;\n }\n\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint256 principalTimesIndex;\n uint256 result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return 0;\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, _borrowIndex);\n require(mathErr == MathError.NO_ERROR, \"!mulUInt overflow check failed\");\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n require(mathErr == MathError.NO_ERROR, \"!divUInt overflow check failed\");\n\n return result;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external view override returns (uint256) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint256 balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n require(mErr == MathError.NO_ERROR, \"!balance\");\n return balance;\n }\n\n function flash(uint256 amount, bytes calldata data) public override isAuthorized onlyOracleApprovedAllowEOA {\n accrueInterest();\n\n totalBorrows += amount;\n asCToken().selfTransferOut(msg.sender, amount);\n\n IFlashLoanReceiver(msg.sender).receiveFlashLoan(underlying, amount, data);\n\n asCToken().selfTransferIn(msg.sender, amount);\n totalBorrows -= amount;\n\n emit Flash(msg.sender, amount);\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\n }\n\n function asCToken() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n function multicall(\n bytes[] calldata data\n ) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {\n return Multicall.multicall(data);\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights() || msg.sender == address(comptroller), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/CTokenInterfaces.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\n\nabstract contract CTokenAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n}\n\nabstract contract CErc20Storage is CTokenAdminStorage {\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /*\n * Maximum borrow rate that can ever be applied (.0005% / block)\n */\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /*\n * Maximum fraction of interest that can be set aside for reserves + fees\n */\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\n\n /**\n * @notice Contract which oversees inter-cToken operations\n */\n IonicComptroller public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /*\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\n */\n uint256 internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for admin fees\n */\n uint256 public adminFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for Ionic fees\n */\n uint256 public ionicFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint256 public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint256 public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint256 public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint256 public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint256 public totalReserves;\n\n /**\n * @notice Total amount of admin fees of the underlying held in this market\n */\n uint256 public totalAdminFees;\n\n /**\n * @notice Total amount of Ionic fees of the underlying held in this market\n */\n uint256 public totalIonicFees;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint256 public totalSupply;\n\n /*\n * Official record of token balances for each account\n */\n mapping(address => uint256) internal accountTokens;\n\n /*\n * Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint256)) internal transferAllowances;\n\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint256 principal;\n uint256 interestIndex;\n }\n\n /*\n * Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /*\n * Share of seized collateral that is added to reserves\n */\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\n\n /*\n * Share of seized collateral taken as fees\n */\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\n\n /**\n * @notice Underlying asset for this CToken\n */\n address public underlying;\n\n /**\n * @notice Addresses Provider\n */\n AddressesProvider public ap;\n}\n\nabstract contract CTokenBaseEvents {\n /* ERC20 */\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the admin fee is changed\n */\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\n\n /**\n * @notice Event emitted when the Ionic fee is changed\n */\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\n}\n\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\n event Flash(address receiver, uint256 amount);\n}\n\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral,\n uint256 seizeTokens\n );\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\n}\n\ninterface CTokenFirstExtensionInterface {\n /*** User Interface ***/\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n /*** Admin Functions ***/\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\n\n function getAccountSnapshot(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256\n );\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function exchangeRateCurrent() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function totalBorrowsCurrent() external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external view returns (uint256);\n\n function getTotalUnderlyingSupplied() external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external view returns (uint256);\n\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n\n function flash(uint256 amount, bytes calldata data) external;\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface CTokenSecondExtensionInterface {\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n /*** Admin Functions ***/\n\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\n\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\n\n function selfTransferOut(address to, uint256 amount) external;\n\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\n}\n\ninterface CDelegatorInterface {\n function implementation() external view returns (address);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external;\n}\n\ninterface CDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes calldata data) external;\n\n function delegateType() external pure returns (uint8);\n\n function contractType() external pure returns (string memory);\n}\n\nabstract contract CErc20AdminBase is CErc20Storage {\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\n return\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\n }\n}\n\nabstract contract CErc20FirstExtensionBase is\n CErc20AdminBase,\n CTokenFirstExtensionEvents,\n CTokenFirstExtensionInterface\n{}\n\nabstract contract CTokenSecondExtensionBase is\n CErc20AdminBase,\n CTokenSecondExtensionEvents,\n CTokenSecondExtensionInterface,\n CDelegateInterface\n{}\n\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\n\ninterface CErc20StorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function comptroller() external view returns (IonicComptroller);\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function accrualBlockNumber() external view returns (uint256);\n\n function underlying() external view returns (address);\n\n function borrowIndex() external view returns (uint256);\n\n function interestRateModel() external view returns (address);\n}\n\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\n function plugin() external view returns (address);\n}\n\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\n function approve(address, address) external;\n}\n\ninterface ICErc20 is\n CErc20StorageInterface,\n CTokenSecondExtensionInterface,\n CTokenFirstExtensionInterface,\n CDelegatorInterface,\n CDelegateInterface\n{}\n\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\n function _updatePlugin(address _plugin) external;\n}\n\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\n" + }, + "contracts/compound/CTokenOracleProtected.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { CErc20Storage } from \"./CTokenInterfaces.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenOracleProtected is CErc20Storage {\n error InteractionNotAllowed();\n error CallerIsNotEOA();\n\n modifier onlyOracleApproved() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\n _;\n }\n\n modifier onlyOracleApprovedAllowEOA() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n oracle.validateBlacklistedAccountInteraction(msg.sender);\n if (tx.origin == msg.sender) {\n _;\n return;\n }\n\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\n _;\n }\n\n modifier onlyNotBlacklistedEOA() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n if (msg.sender != tx.origin) {\n revert CallerIsNotEOA();\n }\n oracle.validateBlacklistedAccountInteraction(msg.sender);\n _;\n }\n}\n" + }, + "contracts/compound/EIP20Interface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title ERC 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return uint256 The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance uint256 The balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success bool Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/compound/ErrorReporter.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n SUPPLIER_NOT_WHITELISTED,\n BORROW_BELOW_MIN,\n SUPPLY_ABOVE_MAX,\n NONZERO_TOTAL_SUPPLY\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\n SET_WHITELIST_STATUS_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n UNSUPPORT_MARKET_OWNER_CHECK,\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\n UNSUPPORT_MARKET_IN_USE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return uint256(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n UTILIZATION_ABOVE_MAX\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n NEW_UTILIZATION_RATE_ABOVE_MAX,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\n WITHDRAW_IONIC_FEES_VALIDATION,\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\n WITHDRAW_ADMIN_FEES_VALIDATION,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\n SET_ADMIN_FEE_ADMIN_CHECK,\n SET_ADMIN_FEE_FRESH_CHECK,\n SET_ADMIN_FEE_BOUNDS_CHECK,\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\n SET_IONIC_FEE_FRESH_CHECK,\n SET_IONIC_FEE_BOUNDS_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\n }\n}\n" + }, + "contracts/compound/Exponential.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(\n Exp memory a,\n Exp memory b,\n Exp memory c\n ) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/compound/ExponentialNoError.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint256 constant expScale = 1e18;\n uint256 constant doubleScale = 1e36;\n uint256 constant halfExpScale = expScale / 2;\n uint256 constant mantissaOne = expScale;\n\n struct Exp {\n uint256 mantissa;\n }\n\n struct Double {\n uint256 mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint256) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(\n Exp memory a,\n uint256 scalar,\n uint256 addend\n ) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2**224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2**32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint256 c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/compound/IERC4626.sol": { + "content": "pragma solidity >=0.8.0;\npragma experimental ABIEncoderV2;\n\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\ninterface IERC4626 is EIP20Interface {\n /*----------------------------------------------------------------\n Events\n ----------------------------------------------------------------*/\n\n event Deposit(address indexed from, address indexed to, uint256 value);\n\n event Withdraw(address indexed from, address indexed to, uint256 value);\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n /**\n @notice Deposit a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to deposit.\n @param to The address to receive shares corresponding to the deposit\n @return shares The shares in the vault credited to `to`\n */\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\n\n /**\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\n @param shareAmount The amount of vault shares to mint.\n @param to The address to receive shares corresponding to the mint.\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\n */\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\n\n /**\n @notice Withdraw a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to withdraw.\n @param to The address to receive underlying corresponding to the withdrawal.\n @param from The address to burn shares from corresponding to the withdrawal.\n @return shares The shares in the vault burned from sender\n */\n function withdraw(\n uint256 underlyingAmount,\n address to,\n address from\n ) external returns (uint256 shares);\n\n /**\n @notice Redeem a specific amount of shares for underlying tokens.\n @param shareAmount The amount of shares to redeem.\n @param to The address to receive underlying corresponding to the redemption.\n @param from The address to burn shares from corresponding to the redemption.\n @return value The underlying amount transferred to `to`.\n */\n function redeem(\n uint256 shareAmount,\n address to,\n address from\n ) external returns (uint256 value);\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n /** \n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n @return the address of the asset\n */\n function asset() external view returns (address);\n\n /** \n @notice Returns a user's Vault balance in underlying tokens.\n @param user The user to get the underlying balance of.\n @return balance The user's Vault balance in underlying tokens.\n */\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\n\n /** \n @notice Calculates the total amount of underlying tokens the Vault manages.\n @return The total amount of underlying tokens the Vault manages.\n */\n function totalAssets() external view returns (uint256);\n\n /** \n @notice Returns the value in underlying terms of one vault token. \n */\n function exchangeRate() external view returns (uint256);\n\n /**\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\n */\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\n @param shareAmount the amount of shares from a mint call.\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\n */\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n\n /**\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\n */\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\n @param shareAmount the amount of shares from a redeem call.\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\n */\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n}\n" + }, + "contracts/compound/IFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../ionic/AuthoritiesRegistry.sol\";\n\ninterface IFeeDistributor {\n function minBorrowEth() external view returns (uint256);\n\n function maxUtilizationRate() external view returns (uint256);\n\n function interestFeeRate() external view returns (uint256);\n\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\n\n function latestCErc20Delegate(uint8 delegateType)\n external\n view\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\n\n function latestPluginImplementation(address oldImplementation) external view returns (address);\n\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\n\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address);\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\n\n fallback() external payable;\n\n receive() external payable;\n}\n" + }, + "contracts/compound/InterestRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's InterestRateModel Interface\n * @author Compound\n */\nabstract contract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual returns (uint256);\n}\n" + }, + "contracts/compound/JumpRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Compound's JumpRateModel Contract\n * @author Compound\n */\ncontract JumpRateModel is InterestRateModel {\n event NewInterestParams(\n uint256 baseRatePerBlock,\n uint256 multiplierPerBlock,\n uint256 jumpMultiplierPerBlock,\n uint256 kink\n );\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint256 public blocksPerYear;\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint256 public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint256 public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint256 public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint256 public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param _blocksPerYear The approximate number of blocks per year\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(\n uint256 _blocksPerYear,\n uint256 baseRatePerYear,\n uint256 multiplierPerYear,\n uint256 jumpMultiplierPerYear,\n uint256 kink_\n ) {\n blocksPerYear = _blocksPerYear;\n baseRatePerBlock = baseRatePerYear / blocksPerYear;\n multiplierPerBlock = multiplierPerYear / blocksPerYear;\n jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return (borrows * 1e18) / (cash + borrows - reserves);\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n uint256 util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return ((util * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n } else {\n uint256 normalRate = ((kink * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n uint256 excessUtil = util - kink;\n return ((excessUtil * jumpMultiplierPerBlock) / 1e18) + normalRate;\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\n }\n}\n" + }, + "contracts/compound/Unitroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ErrorReporter.sol\";\nimport \"./ComptrollerStorage.sol\";\nimport \"./Comptroller.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\n\n/**\n * @title Unitroller\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\n * CTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\n /**\n * @notice Event emitted when the admin rights are changed\n */\n event AdminRightsToggled(bool hasRights);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address payable _ionicAdmin) {\n admin = msg.sender;\n ionicAdmin = _ionicAdmin;\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Toggles admin rights.\n * @param hasRights Boolean indicating if the admin is to have rights.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\n }\n\n // Check that rights have not already been set to the desired value\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\n\n adminHasRights = hasRights;\n emit AdminRightsToggled(hasRights);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = newPendingAdmin;\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n function comptrollerImplementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"_deployMarket(uint8,bytes,bytes,uint256)\"))));\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n\n address currentImplementation = comptrollerImplementation();\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\n currentImplementation\n );\n\n _updateExtensions(latestComptrollerImplementation);\n\n if (currentImplementation != latestComptrollerImplementation) {\n // reinitialize\n _functionCall(address(this), abi.encodeWithSignature(\"_becomeImplementation()\"), \"!become impl\");\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function _updateExtensions(address currentComptroller) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(hasAdminRights(), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/external/aerodrome/IAerodromeRouter.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.10;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20_Router {\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(address from, address to, uint256 amount) external returns (bool);\n}\n\ninterface IWETH is IERC20_Router {\n function deposit() external payable;\n\n function withdraw(uint256) external;\n}\n\ninterface IRouter_Aerodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n address factory;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientAmountAOptimal();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidAmountInForETHDeposit();\n error InvalidTokenInForETHDeposit();\n error InvalidPath();\n error InvalidRouteA();\n error InvalidRouteB();\n error OnlyWETH();\n error PoolDoesNotExist();\n error PoolFactoryDoesNotExist();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of FactoryRegistry.sol\n function factoryRegistry() external view returns (address);\n\n /// @notice Address of Protocol PoolFactory.sol\n function defaultFactory() external view returns (address);\n\n /// @notice Address of Voter.sol\n function voter() external view returns (address);\n\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\n function weth() external view returns (IWETH);\n\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\n function ETHER() external view returns (address);\n\n /// @dev Struct containing information necessary to zap in and out of pools\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable Stable or volatile pool\n /// @param factory factory of pool\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\n struct Zap {\n address tokenA;\n address tokenB;\n bool stable;\n address factory;\n uint256 amountOutMinA;\n uint256 amountOutMinB;\n uint256 amountAMin;\n uint256 amountBMin;\n }\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\n /// Reverts if _factory is not approved by the FactoryRegistry\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of factory which created the pool\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n // **** SWAP ****\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap one token for another without slippage protection\n /// @return amounts Array of amounts to swap per route\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function UNSAFE_swapExactTokensForTokens(\n uint256[] memory amounts,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n // **** SWAP (supporting fee-on-transfer tokens) ****\n\n /// @notice Swap one token for another supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable;\n\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the initial swap.\n /// Additional slippage may be required when adding liquidity as the\n /// price of the token may have changed.\n /// @param tokenIn Token you are zapping in from (i.e. input token).\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param zapInPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @param to Address you wish to mint liquidity to.\n /// @param stake Auto-stake liquidity in corresponding gauge.\n /// @return liquidity Amount of LP tokens created from zapping in.\n function zapIn(\n address tokenIn,\n uint256 amountInA,\n uint256 amountInB,\n Zap calldata zapInPool,\n Route[] calldata routesA,\n Route[] calldata routesB,\n address to,\n bool stake\n ) external payable returns (uint256 liquidity);\n\n /// @notice Zap out a pool (B, C) into A.\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the removal of liquidity.\n /// Additional slippage may be required on the swap as the\n /// price of the token may have changed.\n /// @param tokenOut Token you are zapping out to (i.e. output token).\n /// @param liquidity Amount of liquidity you wish to remove.\n /// @param zapOutPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n function zapOut(\n address tokenOut,\n uint256 liquidity,\n Zap calldata zapOutPool,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external;\n\n /// @notice Used to generate params required for zapping in.\n /// Zap in => remove liquidity then swap.\n /// Apply slippage to expected swap values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap in from.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\n function generateZapInParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountInA,\n uint256 amountInB,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used to generate params required for zapping out.\n /// Zap out => swap then add liquidity.\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap out of.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\n function generateZapOutParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\n /// @dev Returns stable liquidity ratio of B to (A + B).\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\n /// Therefore you should deposit more of token A than B.\n /// @param tokenA tokenA of stable pool you are zapping into.\n /// @param tokenB tokenB of stable pool you are zapping into.\n /// @param factory Factory that created stable pool.\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\n function quoteStableLiquidityRatio(\n address tokenA,\n address tokenB,\n address factory\n ) external view returns (uint256 ratio);\n}\n" + }, + "contracts/external/aerodrome/IAerodromeSwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.10;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via CL\ninterface ISwapRouter_Aerodrome {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/algebra/IAlgebraSwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IAlgebraPoolActions#swap\n/// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraSwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call\n function algebraSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/algebra/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport \"./IAlgebraSwapCallback.sol\";\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Algebra\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-periphery\ninterface IAlgebraSwapRouter is IAlgebraSwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Unlike standard swaps, handles transferring from user before the actual swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingleSupportingFeeOnTransferTokens(ExactInputSingleParams calldata params)\n external\n returns (uint256 amountOut);\n}\n" + }, + "contracts/external/balancer/IBalancerPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\n\ninterface IBalancerPool {\n function getFinalTokens() external view returns (address[] memory);\n\n function getNormalizedWeight(address token) external view returns (uint256);\n\n function getNormalizedWeights() external view returns (uint256[] memory);\n\n function getSwapFee() external view returns (uint256);\n\n function getNumTokens() external view returns (uint256);\n\n function getBalance(address token) external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;\n\n function swapExactAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n address tokenOut,\n uint256 minAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter);\n\n function swapExactAmountOut(\n address tokenIn,\n uint256 maxAmountIn,\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountIn, uint256 spotPriceAfter);\n\n function joinswapExternAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n uint256 minPoolAmountOut\n ) external returns (uint256 poolAmountOut);\n\n function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;\n\n function exitswapExternAmountOut(\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPoolAmountIn\n ) external returns (uint256 poolAmountIn);\n}\n" + }, + "contracts/external/balancer/IBalancerVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IAsset {}\n\nenum UserBalanceOpKind {\n DEPOSIT_INTERNAL,\n WITHDRAW_INTERNAL,\n TRANSFER_INTERNAL,\n TRANSFER_EXTERNAL\n}\n\nenum SwapKind {\n GIVEN_IN,\n GIVEN_OUT\n}\n\nenum ExitKind {\n EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,\n EXACT_BPT_IN_FOR_TOKENS_OUT,\n BPT_IN_FOR_EXACT_TOKENS_OUT,\n MANAGEMENT_FEE_TOKENS_OUT\n}\n\nstruct UserBalanceOp {\n UserBalanceOpKind kind;\n IAsset asset;\n uint256 amount;\n address sender;\n address payable recipient;\n}\nstruct FundManagement {\n address sender;\n bool fromInternalBalance;\n address payable recipient;\n bool toInternalBalance;\n}\n\nstruct SingleSwap {\n bytes32 poolId;\n SwapKind kind;\n IAsset assetIn;\n IAsset assetOut;\n uint256 amount;\n bytes userData;\n}\n\nstruct ExitPoolRequest {\n IERC20Upgradeable[] assets;\n uint256[] minAmountsOut;\n bytes userData;\n bool toInternalBalance;\n}\n\ninterface IBalancerVault {\n function swap(\n SingleSwap memory singleSwap,\n FundManagement memory funds,\n uint256 limit,\n uint256 deadline\n ) external returns (uint256 amountCalculated);\n\n function manageUserBalance(UserBalanceOp[] memory ops) external payable;\n\n function getPoolTokens(bytes32 poolId)\n external\n view\n returns (\n IERC20Upgradeable[] memory tokens,\n uint256[] memory balances,\n uint256 lastChangeBlock\n );\n\n function exitPool(\n bytes32 poolId,\n address sender,\n address payable recipient,\n ExitPoolRequest memory request\n ) external;\n}\n" + }, + "contracts/external/compound/IComptroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./IPriceOracle.sol\";\nimport \"./ICToken.sol\";\nimport \"./IUnitroller.sol\";\nimport \"./IRewardsDistributor.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n */\ninterface IComptroller {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function oracle() external view returns (IPriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function getAssetsIn(address account) external view returns (ICToken[] memory);\n\n function checkMembership(address account, ICToken cToken) external view returns (bool);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n )\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function getAccountLiquidity(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _become(IUnitroller unitroller) external;\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAllMarkets() external view returns (ICToken[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function suppliers(address account) external view returns (bool);\n\n function supplyCaps(address cToken) external view returns (uint256);\n\n function borrowCaps(address cToken) external view returns (uint256);\n\n function enforceWhitelist() external view returns (bool);\n\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cTokenAddress) external returns (uint256);\n\n function autoImplementation() external view returns (bool);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\n\n function _deployMarket(\n bool isCEther,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getMaxRedeemOrBorrow(\n address account,\n ICToken cTokenModify,\n bool isBorrow\n ) external view returns (uint256);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function isDeprecated(ICToken cToken) external view returns (bool);\n\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n}\n" + }, + "contracts/external/compound/ICToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's CToken Contract\n * @notice Abstract base for CTokens\n * @author Compound\n */\ninterface ICToken {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function symbol() external view returns (string memory);\n\n function comptroller() external view returns (address);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function isCToken() external view returns (bool);\n\n function isCEther() external view returns (bool);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function totalBorrowsCurrent() external returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external returns (uint256);\n\n function exchangeRateCurrent() external returns (uint256);\n\n function exchangeRateStored() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n}\n" + }, + "contracts/external/compound/IPriceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\ninterface IPriceOracle {\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\n}\n" + }, + "contracts/external/compound/IRewardsDistributor.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\n/**\n * @title RewardsDistributor\n * @author Compound\n */\ninterface IRewardsDistributor {\n /// @dev The token to reward (i.e., COMP)\n function rewardToken() external view returns (address);\n\n /// @notice The portion of compRate that each market currently receives\n function compSupplySpeeds(address) external view returns (uint256);\n\n /// @notice The portion of compRate that each market currently receives\n function compBorrowSpeeds(address) external view returns (uint256);\n\n /// @notice The COMP accrued but not yet transferred to each user\n function compAccrued(address) external view returns (uint256);\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n /**\n * @notice Returns an array of all markets.\n */\n function getAllMarkets() external view returns (ICToken[] memory);\n}\n" + }, + "contracts/external/compound/IUnitroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * CTokens should reference this contract as their comptroller.\n */\ninterface IUnitroller {\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n}\n" + }, + "contracts/external/curve/ICurvePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ICurvePool is IERC20Upgradeable {\n function get_virtual_price() external view returns (uint256);\n\n function remove_liquidity_one_coin(\n uint256 _token_amount,\n int128 i,\n uint256 min_amount\n ) external;\n\n function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);\n\n function add_liquidity(uint256[2] calldata _amounts, uint256 _min_mint_amount) external returns (uint256);\n\n function exchange(\n int128 i,\n int128 j,\n uint256 dx,\n uint256 min_dy\n ) external returns (uint256);\n\n function get_dy(\n int128 i,\n int128 j,\n uint256 _dx\n ) external view returns (uint256);\n\n function coins(uint256 index) external view returns (address);\n\n function lp_token() external view returns (address);\n}\n" + }, + "contracts/external/curve/ICurveV2Pool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurvePool } from \"./ICurvePool.sol\";\n\ninterface ICurveV2Pool is ICurvePool {\n function price_oracle() external view returns (uint256);\n\n function lp_price() external view returns (uint256);\n\n function coins(uint256 arg0) external view returns (address);\n}\n" + }, + "contracts/external/hypernative/interfaces/IHypernativeOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IHypernativeOracle {\n function register(address account, bool isStrictMode) external;\n function validateForbiddenAccountInteraction(address sender) external view;\n function validateForbiddenContextInteraction(address origin, address sender) external view;\n function validateBlacklistedAccountInteraction(address sender) external;\n}" + }, + "contracts/external/jarvis/ISynthereumDeployment.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./ISynthereumFinder.sol\";\n\n/**\n * @title Interface that a pool MUST have in order to be included in the deployer\n */\ninterface ISynthereumDeployment {\n /**\n * @notice Get Synthereum finder of the pool/self-minting derivative\n * @return finder Returns finder contract\n */\n function synthereumFinder() external view returns (ISynthereumFinder finder);\n\n /**\n * @notice Get Synthereum version\n * @return poolVersion Returns the version of this pool/self-minting derivative\n */\n function version() external view returns (uint8 poolVersion);\n\n /**\n * @notice Get the collateral token of this pool/self-minting derivative\n * @return collateralCurrency The ERC20 collateral token\n */\n function collateralToken() external view returns (IERC20Upgradeable collateralCurrency);\n\n /**\n * @notice Get the synthetic token associated to this pool/self-minting derivative\n * @return syntheticCurrency The ERC20 synthetic token\n */\n function syntheticToken() external view returns (IERC20Upgradeable syntheticCurrency);\n\n /**\n * @notice Get the synthetic token symbol associated to this pool/self-minting derivative\n * @return symbol The ERC20 synthetic token symbol\n */\n function syntheticTokenSymbol() external view returns (string memory symbol);\n}\n" + }, + "contracts/external/jarvis/ISynthereumFinder.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\n/**\n * @title Provides addresses of the contracts implementing certain interfaces.\n */\ninterface ISynthereumFinder {\n /**\n * @notice Updates the address of the contract that implements `interfaceName`.\n * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.\n * @param implementationAddress address of the deployed contract that implements the interface.\n */\n function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;\n\n /**\n * @notice Gets the address of the contract that implements the given `interfaceName`.\n * @param interfaceName queried interface.\n * @return implementationAddress Address of the deployed contract that implements the interface.\n */\n function getImplementationAddress(bytes32 interfaceName) external view returns (address);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPool.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumLiquidityPoolGeneral.sol\";\n\n//import {\n//IEmergencyShutdown\n//} from '../../../common/interfaces/IEmergencyShutdown.sol';\n//import {ISynthereumLiquidityPoolGeneral} from './ILiquidityPoolGeneral.sol';\n//import {ISynthereumLiquidityPoolStorage} from './ILiquidityPoolStorage.sol';\n//import {ITypology} from '../../../common/interfaces/ITypology.sol';\n\n/**\n * @title Token Issuer Contract Interface\n */\n//ITypology,\n//IEmergencyShutdown,\ninterface ISynthereumLiquidityPool is ISynthereumLiquidityPoolGeneral {\n struct MintParams {\n // Minimum amount of synthetic tokens that a user wants to mint using collateral (anti-slippage)\n uint256 minNumTokens;\n // Amount of collateral that a user wants to spend for minting\n uint256 collateralAmount;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send synthetic tokens minted\n address recipient;\n }\n\n struct RedeemParams {\n // Amount of synthetic tokens that user wants to use for redeeming\n uint256 numTokens;\n // Minimium amount of collateral that user wants to redeem (anti-slippage)\n uint256 minCollateral;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send collateral tokens redeemed\n address recipient;\n }\n\n // struct ExchangeParams {\n // // Destination pool\n // ISynthereumLiquidityPoolGeneral destPool;\n // // Amount of source synthetic tokens that user wants to use for exchanging\n // uint256 numTokens;\n // // Minimum Amount of destination synthetic tokens that user wants to receive (anti-slippage)\n // uint256 minDestNumTokens;\n // // Expiration time of the transaction\n // uint256 expiration;\n // // Address to which send synthetic tokens exchanged\n // address recipient;\n // }\n\n /**\n * @notice Mint synthetic tokens using fixed amount of collateral\n * @notice This calculate the price using on chain price feed\n * @notice User must approve collateral transfer for the mint request to succeed\n * @param mintParams Input parameters for minting (see MintParams struct)\n * @return syntheticTokensMinted Amount of synthetic tokens minted by a user\n * @return feePaid Amount of collateral paid by the user as fee\n */\n function mint(MintParams calldata mintParams) external returns (uint256 syntheticTokensMinted, uint256 feePaid);\n\n /**\n * @notice Redeem amount of collateral using fixed number of synthetic token\n * @notice This calculate the price using on chain price feed\n * @notice User must approve synthetic token transfer for the redeem request to succeed\n * @param redeemParams Input parameters for redeeming (see RedeemParams struct)\n * @return collateralRedeemed Amount of collateral redeem by user\n * @return feePaid Amount of collateral paid by user as fee\n */\n function redeem(RedeemParams calldata redeemParams) external returns (uint256 collateralRedeemed, uint256 feePaid);\n\n // /**\n // * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool\n // * @notice This calculate the price using on chain price feed\n // * @notice User must approve synthetic token transfer for the redeem request to succeed\n // * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct)\n // * @return destNumTokensMinted Amount of collateral redeem by user\n // * @return feePaid Amount of collateral paid by user as fee\n // */\n // function exchange(ExchangeParams calldata exchangeParams)\n // external\n // returns (uint256 destNumTokensMinted, uint256 feePaid);\n\n /**\n * @notice Withdraw unused deposited collateral by the LP\n * @notice Only a sender with LP role can call this function\n * @param collateralAmount Collateral to be withdrawn\n * @return remainingLiquidity Remaining unused collateral in the pool\n */\n function withdrawLiquidity(uint256 collateralAmount) external returns (uint256 remainingLiquidity);\n\n /**\n * @notice Increase collaterallization of Lp position\n * @notice Only a sender with LP role can call this function\n * @param collateralToTransfer Collateral to be transferred before increase collateral in the position\n * @param collateralToIncrease Collateral to be added to the position\n * @return newTotalCollateral New total collateral amount\n */\n function increaseCollateral(uint256 collateralToTransfer, uint256 collateralToIncrease)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Decrease collaterallization of Lp position\n * @notice Check that final poosition is not undercollateralized\n * @notice Only a sender with LP role can call this function\n * @param collateralToDecrease Collateral to decreased from the position\n * @param collateralToWithdraw Collateral to be transferred to the LP\n * @return newTotalCollateral New total collateral amount\n */\n function decreaseCollateral(uint256 collateralToDecrease, uint256 collateralToWithdraw)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Withdraw fees gained by the sender\n * @return feeClaimed Amount of fee claimed\n */\n function claimFee() external returns (uint256 feeClaimed);\n\n /**\n * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized\n * @notice Revert if position is not undercollateralized\n * @param numSynthTokens Number of synthetic tokens that user wants to liquidate\n * @return synthTokensLiquidated Amount of synthetic tokens liquidated\n * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated\n * @return rewardAmount Amount of received collateral as reward for the liquidation\n */\n function liquidate(uint256 numSynthTokens)\n external\n returns (\n uint256 synthTokensLiquidated,\n uint256 collateralReceived,\n uint256 rewardAmount\n );\n\n /**\n * @notice Redeem tokens after emergency shutdown\n * @return synthTokensSettled Amount of synthetic tokens liquidated\n * @return collateralSettled Amount of collateral withdrawn after emergency shutdown\n */\n function settleEmergencyShutdown() external returns (uint256 synthTokensSettled, uint256 collateralSettled);\n\n // /**\n // * @notice Update the fee percentage, recipients and recipient proportions\n // * @notice Only the maintainer can call this function\n // * @param _feeData Fee info (percentage + recipients + weigths)\n // */\n // function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData)\n // external;\n\n /**\n * @notice Update the fee percentage\n * @notice Only the maintainer can call this function\n * @param _feePercentage The new fee percentage\n */\n function setFeePercentage(uint256 _feePercentage) external;\n\n /**\n * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive\n * @notice Only the maintainer can call this function\n * @param feeRecipients An array of the addresses of recipients that will receive generated fees\n * @param feeProportions An array of the proportions of fees generated each recipient will receive\n */\n function setFeeRecipients(address[] calldata feeRecipients, uint32[] calldata feeProportions) external;\n\n /**\n * @notice Update the overcollateralization percentage\n * @notice Only the maintainer can call this function\n * @param _overCollateralization Overcollateralization percentage\n */\n function setOverCollateralization(uint256 _overCollateralization) external;\n\n /**\n * @notice Update the liquidation reward percentage\n * @notice Only the maintainer can call this function\n * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator\n */\n function setLiquidationReward(uint256 _liquidationReward) external;\n\n /**\n * @notice Returns fee percentage set by the maintainer\n * @return Fee percentage\n */\n function feePercentage() external view returns (uint256);\n\n /**\n * @notice Returns fee recipients info\n * @return Addresses, weigths and total of weigths\n */\n function feeRecipientsInfo()\n external\n view\n returns (\n address[] memory,\n uint32[] memory,\n uint256\n );\n\n /**\n * @notice Returns total number of synthetic tokens generated by this pool\n * @return Number of synthetic tokens\n */\n function totalSyntheticTokens() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP)\n * @return Total collateral amount\n */\n function totalCollateralAmount() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of fees to be withdrawn\n * @return Total fee amount\n */\n function totalFeeAmount() external view returns (uint256);\n\n /**\n * @notice Returns the user's fee to be withdrawn\n * @param user User's address\n * @return User's fee\n */\n function userFee(address user) external view returns (uint256);\n\n /**\n * @notice Returns the percentage of overcollateralization to which a liquidation can triggered\n * @return Percentage of overcollateralization\n */\n function collateralRequirement() external view returns (uint256);\n\n /**\n * @notice Returns the percentage of reward for correct liquidation by a liquidator\n * @return Percentage of reward\n */\n function liquidationReward() external view returns (uint256);\n\n /**\n * @notice Returns the price of the pair at the moment of the shutdown\n * @return Price of the pair\n */\n function emergencyShutdownPrice() external view returns (uint256);\n\n /**\n * @notice Returns the timestamp (unix time) at the moment of the shutdown\n * @return Timestamp\n */\n function emergencyShutdownTimestamp() external view returns (uint256);\n\n /**\n * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price\n * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized))\n */\n function collateralCoverage() external returns (bool, uint256);\n\n /**\n * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param inputCollateral Input collateral amount to be exchanged\n * @return synthTokensReceived Synthetic tokens will be minted\n * @return feePaid Collateral fee will be paid\n */\n function getMintTradeInfo(uint256 inputCollateral)\n external\n view\n returns (uint256 synthTokensReceived, uint256 feePaid);\n\n /**\n * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param syntheticTokens Amount of synthetic tokens to be exchanged\n * @return collateralAmountReceived Collateral amount will be received by the user\n * @return feePaid Collateral fee will be paid\n */\n function getRedeemTradeInfo(uint256 syntheticTokens)\n external\n view\n returns (uint256 collateralAmountReceived, uint256 feePaid);\n\n // /**\n // * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n // * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n // * @param syntheticTokens Amount of synthetic tokens to be exchanged\n // * @param destinationPool Pool in which mint the destination synthetic token\n // * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool\n // * @return feePaid Collateral fee will be paid\n // */\n // function getExchangeTradeInfo(\n // uint256 syntheticTokens,\n // ISynthereumLiquidityPoolGeneral destinationPool\n // )\n // external\n // view\n // returns (uint256 destSyntheticTokensReceived, uint256 feePaid);\n /**\n * @notice Shutdown the pool or self-minting-derivative in case of emergency\n * @notice Only Synthereum manager contract can call this function\n * @return timestamp Timestamp of emergency shutdown transaction\n * @return price Price of the pair at the moment of shutdown execution\n */\n function emergencyShutdown() external returns (uint256 timestamp, uint256 price);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPoolGeneral.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumDeployment.sol\";\n\ninterface ISynthereumLiquidityPoolGeneral is\n ISynthereumDeployment\n //,\n //ISynthereumLiquidityPoolInteraction\n{}\n" + }, + "contracts/external/pyth/IExpressRelay.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelay {\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\n // This will return true if and only if it's being called while executing the auction winner(s) call.\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\n // @param permissionId The id that represents the action being gated\n // @return permissioned True if the permission is allowed, false otherwise\n function isPermissioned(\n address protocolFeeReceiver,\n bytes calldata permissionId\n ) external view returns (bool permissioned);\n}\n" + }, + "contracts/external/pyth/IExpressRelayFeeReceiver.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelayFeeReceiver {\n // Receive the proceeds of an auction.\n // @param permissionKey The permission key where the auction was conducted on.\n function receiveAuctionProceedings(\n bytes calldata permissionKey\n ) external payable;\n}\n" + }, + "contracts/external/redstone/IRedstoneOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IRedstoneOracle {\n function priceOf(address asset) external view returns (uint256);\n\n function priceOfETH() external view returns (uint256);\n\n function getDataFeedIdForAsset(address asset) external view returns (bytes32);\n\n function getDataFeedIds() external view returns (bytes32[] memory dataFeedIds);\n}\n" + }, + "contracts/external/solidly/IPair.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nstruct Observation {\n uint256 timestamp;\n uint256 reserve0Cumulative;\n uint256 reserve1Cumulative;\n}\n\ninterface IPair {\n function observations(uint256 index) external pure returns (Observation memory);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function metadata()\n external\n view\n returns (\n uint256 dec0,\n uint256 dec1,\n uint256 r0,\n uint256 r1,\n bool st,\n address t0,\n address t1\n );\n\n function claimFees() external returns (uint256, uint256);\n\n function tokens() external returns (address, address);\n\n function stable() external view returns (bool);\n\n function observationLength() external view returns (uint256);\n\n function lastObservation() external view returns (Observation memory);\n\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\n\n function currentCumulativePrices()\n external\n view\n returns (\n uint256 reserve0Cumulative,\n uint256 reserve1Cumulative,\n uint256 blockTimestamp\n );\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\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 function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function sync() external;\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function getReserves()\n external\n view\n returns (\n uint256 _reserve0,\n uint256 _reserve1,\n uint256 _blockTimestampLast\n );\n\n function getAmountOut(uint256, address) external view returns (uint256);\n}\n" + }, + "contracts/external/solidly/IRouter.sol": { + "content": "pragma solidity >=0.8.0;\n\ninterface IRouter {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n function isPair(address pair) external view returns (bool);\n\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n function pairFor(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (address pair);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function swapExactTokensForTokensSimple(\n uint256 amountIn,\n uint256 amountOutMin,\n address tokenFrom,\n address tokenTo,\n bool stable,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n )\n external\n view\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n}\n" + }, + "contracts/external/uniswap/FullMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Rewrite unary negation of denominator, which is a uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = a * b\n // Compute the product mod 2**256 and mod 2**256 - 1\n // then use the Chinese Remainder Theorem to reconstruct\n // the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2**256 + prod0\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(a, b, not(0))\n prod0 := mul(a, b)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division\n if (prod1 == 0) {\n require(denominator > 0);\n assembly {\n result := div(prod0, denominator)\n }\n return result;\n }\n\n // Make sure the result is less than 2**256.\n // Also prevents denominator == 0\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0]\n // Compute remainder using mulmod\n uint256 remainder;\n assembly {\n remainder := mulmod(a, b, denominator)\n }\n // Subtract 256 bit number from 512 bit number\n assembly {\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator\n // Compute largest power of two divisor of denominator.\n // Always >= 1.\n uint256 twos = denominator & (~denominator + 1);\n\n // Divide denominator by power of two\n assembly {\n denominator := div(denominator, twos)\n }\n\n // Divide [prod1 prod0] by the factors of two\n assembly {\n prod0 := div(prod0, twos)\n }\n // Shift in bits from prod1 into prod0. For this we need\n // to flip `twos` such that it is 2**256 / twos.\n // If twos is zero, then it becomes one\n assembly {\n twos := add(div(sub(0, twos), twos), 1)\n }\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2**256\n // Now that denominator is an odd number, it has an inverse\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n // Compute the inverse by starting with a seed that is correct\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\n uint256 inv = (3 * denominator) ^ 2;\n // Now use Newton-Raphson iteration to improve the precision.\n // Thanks to Hensel's lifting lemma, this also works in modular\n // arithmetic, doubling the correct bits in each step.\n inv *= 2 - denominator * inv; // inverse mod 2**8\n inv *= 2 - denominator * inv; // inverse mod 2**16\n inv *= 2 - denominator * inv; // inverse mod 2**32\n inv *= 2 - denominator * inv; // inverse mod 2**64\n inv *= 2 - denominator * inv; // inverse mod 2**128\n inv *= 2 - denominator * inv; // inverse mod 2**256\n\n // Because the division is now exact we can divide by multiplying\n // with the modular inverse of denominator. This will give us the\n // correct result modulo 2**256. Since the precoditions guarantee\n // that the outcome is less than 2**256, this is the final result.\n // We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inv;\n return result;\n }\n }\n\n /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n function mulDivRoundingUp(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n result = mulDiv(a, b, denominator);\n if (mulmod(a, b, denominator) > 0) {\n require(result < type(uint256).max);\n result++;\n }\n }\n }\n}\n" + }, + "contracts/external/uniswap/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n function exactInput(ExactInputParams calldata params) external returns (uint256 amountOut);\n\n function exactOutputSingle(ExactOutputSingleParams calldata params) external returns (uint256 amountIn);\n\n function exactOutput(ExactOutputParams calldata params) external returns (uint256 amountIn);\n\n function factory() external returns (address);\n\n function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Pair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title The interface for the Uniswap V3 Factory\n/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees\ninterface IUniswapV3Factory {\n /// @notice Emitted when the owner of the factory is changed\n /// @param oldOwner The owner before the owner was changed\n /// @param newOwner The owner after the owner was changed\n event OwnerChanged(address indexed oldOwner, address indexed newOwner);\n\n /// @notice Emitted when a pool is created\n /// @param token0 The first token of the pool by address sort order\n /// @param token1 The second token of the pool by address sort order\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks\n /// @param pool The address of the created pool\n event PoolCreated(\n address indexed token0,\n address indexed token1,\n uint24 indexed fee,\n int24 tickSpacing,\n address pool\n );\n\n /// @notice Emitted when a new fee amount is enabled for pool creation via the factory\n /// @param fee The enabled fee, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee\n event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);\n\n /// @notice Returns the current owner of the factory\n /// @dev Can be changed by the current owner via setOwner\n /// @return The address of the factory owner\n function owner() external view returns (address);\n\n /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled\n /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context\n /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee\n /// @return The tick spacing\n function feeAmountTickSpacing(uint24 fee) external view returns (int24);\n\n /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\n /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\n /// @param tokenA The contract address of either token0 or token1\n /// @param tokenB The contract address of the other token\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @return pool The pool address\n function getPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external view returns (address pool);\n\n /// @notice Creates a pool for the given two tokens and fee\n /// @param tokenA One of the two tokens in the desired pool\n /// @param tokenB The other of the two tokens in the desired pool\n /// @param fee The desired fee for the pool\n /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\n /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\n /// are invalid.\n /// @return pool The address of the newly created pool\n function createPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external returns (address pool);\n\n /// @notice Updates the owner of the factory\n /// @dev Must be called by the current owner\n /// @param _owner The new owner of the factory\n function setOwner(address _owner) external;\n\n /// @notice Enables a fee amount with the given tickSpacing\n /// @dev Fee amounts may never be removed once enabled\n /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)\n /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount\n function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3FlashCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#flash\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\ninterface IUniswapV3FlashCallback {\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\n function uniswapV3FlashCallback(\n uint256 fee0,\n uint256 fee1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV3PoolActions.sol\";\n\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function fee() external view returns (uint24);\n\n function slot0()\n external\n view\n returns (\n uint160 sqrtPriceX96,\n int24 tick,\n uint16 observationIndex,\n uint16 observationCardinality,\n uint16 observationCardinalityNext,\n uint8 feeProtocol,\n bool unlocked\n );\n\n function liquidity() external view returns (uint128);\n\n function observe(uint32[] calldata secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\n\n function observations(uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 liquidityCumulative,\n bool initialized\n );\n\n function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityGross,\n int128 liquidityNet,\n uint256 feeGrowthOutside0X128,\n uint256 feeGrowthOutside1X128,\n int56 tickCumulativeOutside,\n uint160 secondsPerLiquidityOutsideX128,\n uint32 secondsOutside,\n bool initialized\n );\n\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n\n function positions(bytes32 key)\n external\n view\n returns (\n uint128 _liquidity,\n uint256 feeGrowthInside0LastX128,\n uint256 feeGrowthInside1LastX128,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n /// @notice Sets the initial price for the pool\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n function initialize(uint160 sqrtPriceX96) external;\n\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n /// @param recipient The address for which the liquidity will be created\n /// @param tickLower The lower tick of the position in which to add liquidity\n /// @param tickUpper The upper tick of the position in which to add liquidity\n /// @param amount The amount of liquidity to mint\n /// @param data Any data that should be passed through to the callback\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n function mint(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount,\n bytes calldata data\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Collects tokens owed to a position\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n /// @param recipient The address which should receive the fees collected\n /// @param tickLower The lower tick of the position for which to collect fees\n /// @param tickUpper The upper tick of the position for which to collect fees\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n /// @return amount0 The amount of fees collected in token0\n /// @return amount1 The amount of fees collected in token1\n function collect(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n /// @dev Fees must be collected separately via a call to #collect\n /// @param tickLower The lower tick of the position for which to burn liquidity\n /// @param tickUpper The upper tick of the position for which to burn liquidity\n /// @param amount How much liquidity to burn\n /// @return amount0 The amount of token0 sent to the recipient\n /// @return amount1 The amount of token1 sent to the recipient\n function burn(\n int24 tickLower,\n int24 tickUpper,\n uint128 amount\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Swap token0 for token1, or token1 for token0\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n /// @param recipient The address to receive the output of the swap\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n /// @param data Any data to be passed through to the callback\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n /// @param recipient The address which will receive the token0 and token1 amounts\n /// @param amount0 The amount of token0 to send\n /// @param amount1 The amount of token1 to send\n /// @param data Any data to be passed through to the callback\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n /// the input observationCardinalityNext.\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolImmutables.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n /// @return The contract address\n function factory() external view returns (address);\n\n /// @notice The first of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token0() external view returns (address);\n\n /// @notice The second of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token1() external view returns (address);\n\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n /// @return The fee\n function fee() external view returns (uint24);\n\n /// @notice The pool tick spacing\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n /// This value is an int24 to avoid casting even though it is always positive.\n /// @return The tick spacing\n function tickSpacing() external view returns (int24);\n\n /// @notice The maximum amount of position liquidity that can use any tick in the range\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n /// @return The max amount of liquidity per tick\n function maxLiquidityPerTick() external view returns (uint128);\n}\n" + }, + "contracts/external/uniswap/IUniswapV3SwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IV3SwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport './IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IQuoter.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IQuoter {\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Quoter Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IUniswapV3Quoter {\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee\n /// @param amountIn The amount of the first token to swap\n /// @return amountOut The amount of the last token that would be received\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\n\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountIn The desired input amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountOut The amount of `tokenOut` that would be received\n function quoteExactInputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountIn,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountOut);\n\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n /// @param amountOut The amount of the last token to receive\n /// @return amountIn The amount of first token required to be paid\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\n\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountOut The desired output amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n function quoteExactOutputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountOut,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/BitMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title BitMath\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\nlibrary BitMath {\n /// @notice Returns the index of the most significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\n /// @param x the value for which to compute the most significant bit, must be greater than 0\n /// @return r the index of the most significant bit\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n if (x >= 0x100000000000000000000000000000000) {\n x >>= 128;\n r += 128;\n }\n if (x >= 0x10000000000000000) {\n x >>= 64;\n r += 64;\n }\n if (x >= 0x100000000) {\n x >>= 32;\n r += 32;\n }\n if (x >= 0x10000) {\n x >>= 16;\n r += 16;\n }\n if (x >= 0x100) {\n x >>= 8;\n r += 8;\n }\n if (x >= 0x10) {\n x >>= 4;\n r += 4;\n }\n if (x >= 0x4) {\n x >>= 2;\n r += 2;\n }\n if (x >= 0x2) r += 1;\n }\n\n /// @notice Returns the index of the least significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\n /// @param x the value for which to compute the least significant bit, must be greater than 0\n /// @return r the index of the least significant bit\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n r = 255;\n if (x & type(uint128).max > 0) {\n r -= 128;\n } else {\n x >>= 128;\n }\n if (x & type(uint64).max > 0) {\n r -= 64;\n } else {\n x >>= 64;\n }\n if (x & type(uint32).max > 0) {\n r -= 32;\n } else {\n x >>= 32;\n }\n if (x & type(uint16).max > 0) {\n r -= 16;\n } else {\n x >>= 16;\n }\n if (x & type(uint8).max > 0) {\n r -= 8;\n } else {\n x >>= 8;\n }\n if (x & 0xf > 0) {\n r -= 4;\n } else {\n x >>= 4;\n }\n if (x & 0x3 > 0) {\n r -= 2;\n } else {\n x >>= 2;\n }\n if (x & 0x1 > 0) r -= 1;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/FixedPoint96.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n uint8 internal constant RESOLUTION = 96;\n uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LiquidityMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math library for liquidity\nlibrary LiquidityMath {\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n /// @param x The liquidity before change\n /// @param y The delta by which liquidity should be changed\n /// @return z The liquidity delta\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\n if (y < 0) {\n require((z = x - uint128(-y)) < x, \"LS\");\n } else {\n require((z = x + uint128(y)) >= x, \"LA\");\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LowGasSafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\n/// @title Optimized overflow and underflow safe math operations\n/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost\nlibrary LowGasSafeMath {\n /// @notice Returns x + y, reverts if sum overflows uint256\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x);\n }\n\n /// @notice Returns x - y, reverts if underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x);\n }\n\n /// @notice Returns x * y, reverts if overflows\n /// @param x The multiplicand\n /// @param y The multiplier\n /// @return z The product of x and y\n function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require(x == 0 || (z = x * y) / x == y);\n }\n\n /// @notice Returns x + y, reverts if overflows or underflows\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x + y) >= x == (y >= 0));\n }\n\n /// @notice Returns x - y, reverts if overflows or underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x - y) <= x == (y >= 0));\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Safe casting methods\n/// @notice Contains methods for safely casting between types\nlibrary SafeCast {\n /// @notice Cast a uint256 to a uint160, revert on overflow\n /// @param y The uint256 to be downcasted\n /// @return z The downcasted integer, now type uint160\n function toUint160(uint256 y) internal pure returns (uint160 z) {\n require((z = uint160(y)) == y);\n }\n\n /// @notice Cast a int256 to a int128, revert on overflow or underflow\n /// @param y The int256 to be downcasted\n /// @return z The downcasted integer, now type int128\n function toInt128(int256 y) internal pure returns (int128 z) {\n require((z = int128(y)) == y);\n }\n\n /// @notice Cast a uint256 to a int256, revert on overflow\n /// @param y The uint256 to be casted\n /// @return z The casted integer, now type int256\n function toInt256(uint256 y) internal pure returns (int256 z) {\n require(y < 2**255);\n z = int256(y);\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SqrtPriceMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../FullMath.sol\";\nimport \"./UnsafeMath.sol\";\nimport \"./FixedPoint96.sol\";\nimport \"./BitMath.sol\";\n\n/// @title Functions based on Q64.96 sqrt price and liquidity\n/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas\nlibrary SqrtPriceMath {\n using LowGasSafeMath for uint256;\n using SafeCast for uint256;\n\n /// @notice Gets the next sqrt price given a delta of token0\n /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the\n /// price less in order to not send too much output.\n /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),\n /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).\n /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token0 to add or remove from virtual reserves\n /// @param add Whether to add or remove the amount of token0\n /// @return The price after adding or removing amount, depending on add\n function getNextSqrtPriceFromAmount0RoundingUp(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price\n if (amount == 0) return sqrtPX96;\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n\n bool overflow = false;\n if (numerator1 != 0 && sqrtPX96 != 0)\n overflow = uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(sqrtPX96)) >= 254;\n\n if (add) {\n uint256 product;\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 + product;\n if (denominator >= numerator1) {\n // always fits in 160 bits\n return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));\n }\n }\n\n return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));\n } else {\n uint256 product;\n // if the product overflows, we know the denominator underflows\n // in addition, we must check that the denominator does not underflow\n require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 - product;\n return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();\n }\n }\n\n /// @notice Gets the next sqrt price given a delta of token1\n /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the\n /// price less in order to not send too much output.\n /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity\n /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token1 to add, or remove, from virtual reserves\n /// @param add Whether to add, or remove, the amount of token1\n /// @return The price after adding or removing `amount`\n function getNextSqrtPriceFromAmount1RoundingDown(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // if we're adding (subtracting), rounding down requires rounding the quotient down (up)\n // in both cases, avoid a mulDiv for most inputs\n if (add) {\n uint256 quotient = (\n amount <= type(uint160).max\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\n );\n\n return uint256(sqrtPX96).add(quotient).toUint160();\n } else {\n uint256 quotient = (\n amount <= type(uint160).max\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\n );\n\n require(sqrtPX96 > quotient);\n // always fits 160 bits\n return uint160(sqrtPX96 - quotient);\n }\n }\n\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountIn How much of token0, or token1, is being swapped in\n /// @param zeroForOne Whether the amount in is token0 or token1\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\n function getNextSqrtPriceFromInput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountIn,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we don't pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\n }\n\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\n /// @param sqrtPX96 The starting price before accounting for the output amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountOut How much of token0, or token1, is being swapped out\n /// @param zeroForOne Whether the amount out is token0 or token1\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\n function getNextSqrtPriceFromOutput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountOut,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\n }\n\n /// @notice Gets the amount0 delta between two prices\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up or down\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount0) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\n require(sqrtRatioAX96 > 0);\n\n bool overflow = false;\n if (numerator1 != 0 && numerator2 != 0)\n overflow =\n uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(numerator2)) >= 254;\n\n if (overflow) {\n return\n roundUp\n ? FullMath.mulDivRoundingUp(\n FullMath.mulDivRoundingUp(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n )\n : FullMath.mulDiv(\n FullMath.mulDiv(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n );\n } else {\n return\n roundUp\n ? UnsafeMath.divRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96)\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\n }\n }\n\n /// @notice Gets the amount1 delta between two prices\n /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up, or down\n /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return\n roundUp\n ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)\n : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n }\n\n /// @notice Helper that gets signed token0 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount0 delta\n /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount0) {\n return\n liquidity < 0\n ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n\n /// @notice Helper that gets signed token1 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount1 delta\n /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount1) {\n return\n liquidity < 0\n ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SwapMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"../../FullMath.sol\";\nimport \"./SqrtPriceMath.sol\";\n\n/// @title Computes the result of a swap within ticks\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\nlibrary SwapMath {\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\n /// @param liquidity The usable liquidity\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\n /// @return feeAmount The amount of input that will be taken as a fee\n function computeSwapStep(\n uint160 sqrtRatioCurrentX96,\n uint160 sqrtRatioTargetX96,\n uint128 liquidity,\n int256 amountRemaining,\n uint24 feePips,\n bool zeroForOne\n )\n internal\n pure\n returns (\n uint160 sqrtRatioNextX96,\n uint256 amountIn,\n uint256 amountOut,\n uint256 feeAmount\n )\n {\n require(zeroForOne == sqrtRatioCurrentX96 >= sqrtRatioTargetX96, \"SPD\");\n bool exactIn = amountRemaining >= 0;\n\n if (exactIn) {\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\n amountIn = zeroForOne\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\n sqrtRatioCurrentX96,\n liquidity,\n amountRemainingLessFee,\n zeroForOne\n );\n } else {\n amountOut = zeroForOne\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\n\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\n sqrtRatioCurrentX96,\n liquidity,\n uint256(-amountRemaining),\n zeroForOne\n );\n }\n\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\n\n // get the input/output amounts\n if (zeroForOne) {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\n } else {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\n }\n\n // cap the output amount to not exceed the remaining output amount\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\n amountOut = uint256(-amountRemaining);\n }\n\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\n // we didn't reach the target, so take the remainder of the maximum input as fee\n feeAmount = uint256(amountRemaining) - amountIn;\n } else {\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/Tick.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../TickMath.sol\";\nimport \"./LiquidityMath.sol\";\n\n/// @title Tick\n/// @notice Contains functions for managing tick processes and relevant calculations\n\n/// Ithil to modify it, since it does not have access to storage arrays\nlibrary Tick {\n using LowGasSafeMath for int256;\n using SafeCast for int256;\n\n // info stored for each initialized individual tick\n struct Info {\n // the total position liquidity that references this tick\n uint128 liquidityGross;\n // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),\n int128 liquidityNet;\n // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint256 feeGrowthOutside0X128;\n uint256 feeGrowthOutside1X128;\n // the cumulative tick value on the other side of the tick\n int56 tickCumulativeOutside;\n // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint160 secondsPerLiquidityOutsideX128;\n // the seconds spent on the other side of the tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint32 secondsOutside;\n // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0\n // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks\n bool initialized;\n }\n\n /// @notice Derives max liquidity per tick from given tick spacing\n /// @dev Executed within the pool constructor\n /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`\n /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...\n /// @return The max liquidity per tick\n function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {\n int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\n int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\n uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;\n return type(uint128).max / numTicks;\n }\n\n /// @notice Retrieves fee growth data\n /// Ithil: only use it with lower = self[tickLower] and upper = self[tickUpper]\n /// @param lower The info of the lower tick boundary of the position\n /// @param upper The info of the upper tick boundary of the position\n /// @param tickLower The lower tick boundary of the position\n /// @param tickUpper The upper tick boundary of the position\n /// @param tickCurrent The current tick\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries\n /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries\n function getFeeGrowthInside(\n Tick.Info memory lower,\n Tick.Info memory upper,\n int24 tickLower,\n int24 tickUpper,\n int24 tickCurrent,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128\n ) internal pure returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n // calculate fee growth below\n uint256 feeGrowthBelow0X128;\n uint256 feeGrowthBelow1X128;\n if (tickCurrent >= tickLower) {\n feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;\n } else {\n feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;\n }\n\n // calculate fee growth above\n uint256 feeGrowthAbove0X128;\n uint256 feeGrowthAbove1X128;\n if (tickCurrent < tickUpper) {\n feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;\n } else {\n feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;\n }\n\n feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;\n feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;\n }\n\n /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa\n /// Ithil: always use with info = self[tick]\n /// @param info The info tick that will be updated\n /// @param tick The tick that will be updated\n /// @param tickCurrent The current tick\n /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block timestamp cast to a uint32\n /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick\n /// @param maxLiquidity The maximum liquidity allocation for a single tick\n /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa\n function update(\n Tick.Info memory info,\n int24 tick,\n int24 tickCurrent,\n int128 liquidityDelta,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time,\n bool upper,\n uint128 maxLiquidity\n ) internal pure returns (bool flipped) {\n uint128 liquidityGrossBefore = info.liquidityGross;\n uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);\n\n require(liquidityGrossAfter <= maxLiquidity, \"LO\");\n\n flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);\n\n if (liquidityGrossBefore == 0) {\n // by convention, we assume that all growth before a tick was initialized happened _below_ the tick\n if (tick <= tickCurrent) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;\n info.tickCumulativeOutside = tickCumulative;\n info.secondsOutside = time;\n }\n info.initialized = true;\n }\n\n info.liquidityGross = liquidityGrossAfter;\n\n // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)\n info.liquidityNet = upper\n ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()\n : int256(info.liquidityNet).add(liquidityDelta).toInt128();\n }\n\n /// @notice Transitions to next tick as needed by price movement\n /// @param info The result of the mapping containing all tick information for initialized ticks\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block.timestamp\n /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)\n function cross(\n Tick.Info memory info,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time\n ) internal pure returns (int128 liquidityNet) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;\n info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;\n info.secondsOutside = time - info.secondsOutside;\n liquidityNet = info.liquidityNet;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/TickBitmap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./BitMath.sol\";\n\n/// @title Packed tick initialized state library\n/// @notice Stores a packed mapping of tick index to its initialized state\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\nlibrary TickBitmap {\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\n /// @param tick The tick for which to compute the position\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\n /// @return bitPos The bit position in the word where the flag is stored\n /// @dev simply divides @param tick by 256 with remainder: tick = wordPos * 256 + bitPos\n function position(int24 tick) internal pure returns (int16 wordPos, uint8 bitPos) {\n wordPos = int16(tick >> 8);\n bitPos = uint8(int8(tick % 256));\n }\n\n /// Written by Ithil\n function computeWordPos(\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int16 wordPos) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n (wordPos, ) = lte ? position(compressed) : position(compressed + 1);\n }\n\n /// @notice Flips the initialized state for a given tick from false to true, or vice versa\n /// @param selfResult The result of the mapping in which to flip the tick (Ithil modified)\n /// @param tick The tick to flip\n /// @param tickSpacing The spacing between usable ticks\n function flipTick(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing\n ) internal pure {\n require(tick % tickSpacing == 0); // ensure that the tick is spaced\n (, uint8 bitPos) = position(tick / tickSpacing);\n uint256 mask = 1 << bitPos;\n selfResult ^= mask;\n }\n\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\n /// to the left (less than or equal to) or right (greater than) of the given tick\n /// @param selfResult The result of the mapping in which to compute the next initialized tick (Ithil modified)\n /// @param tick The starting tick\n /// @param tickSpacing The spacing between usable ticks\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\n function nextInitializedTickWithinOneWord(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int24 next, bool initialized) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n if (lte) {\n (, uint8 bitPos) = position(compressed);\n // all the 1s at or to the right of the current bitPos\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed - int24(uint24(bitPos) - uint24(BitMath.mostSignificantBit(masked)))) * tickSpacing\n : (compressed - int24(uint24(bitPos))) * tickSpacing;\n } else {\n // start from the word of the next tick, since the current tick state doesn't matter\n (, uint8 bitPos) = position(compressed + 1);\n // all the 1s at or to the left of the bitPos\n uint256 mask = ~((1 << bitPos) - 1);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed + 1 + int24(uint24(BitMath.leastSignificantBit(masked) - bitPos))) * tickSpacing\n : (compressed + 1 + int24(uint24(type(uint8).max - bitPos))) * tickSpacing;\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/UnsafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math functions that do not check inputs or outputs\n/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks\nlibrary UnsafeMath {\n /// @notice Returns ceil(x / y)\n /// @dev division by 0 has unspecified behavior, and must be checked externally\n /// @param x The dividend\n /// @param y The divisor\n /// @return z The quotient, ceil(x / y)\n function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n z := add(div(x, y), gt(mod(x, y), 0))\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../IUniswapV3Factory.sol\";\nimport \"./interfaces/IQuoter.sol\";\nimport \"./UniswapV3Quoter.sol\";\n\ncontract Quoter is IQuoter, UniswapV3Quoter {\n IUniswapV3Factory internal uniV3Factory; // TODO should it be immutable?\n\n constructor(address _uniV3Factory) {\n uniV3Factory = IUniswapV3Factory(_uniV3Factory);\n }\n\n // This should be equal to quoteExactInputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateOutputSingle(_toToken, _fromToken, _amount, pool);\n }\n\n // This should be equal to quoteExactOutputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateInputSingle(_fromToken, _toToken, _amount, pool);\n }\n\n // todo: add price limit\n function _estimateOutputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken > _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n else amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n }\n\n // todo: add price limit\n function _estimateInputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken < _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n -int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n else amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n }\n\n function doesPoolExist(address _token0, address _token1) external view returns (bool) {\n // try 0.05%\n address pool = uniV3Factory.getPool(_token0, _token1, 500);\n if (pool != address(0)) return true;\n\n // try 0.3%\n pool = uniV3Factory.getPool(_token0, _token1, 3000);\n if (pool != address(0)) return true;\n\n // try 1%\n pool = uniV3Factory.getPool(_token0, _token1, 10000);\n if (pool != address(0)) return true;\n else return false;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/UniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.6;\n\nimport \"./libraries/LowGasSafeMath.sol\";\nimport \"./libraries/SafeCast.sol\";\nimport \"./libraries/Tick.sol\";\nimport \"./libraries/TickBitmap.sol\";\n\nimport \"../FullMath.sol\";\nimport \"../TickMath.sol\";\nimport \"./libraries/LiquidityMath.sol\";\nimport \"./libraries/SqrtPriceMath.sol\";\nimport \"./libraries/SwapMath.sol\";\n\nimport \"./interfaces/IUniswapV3Quoter.sol\";\nimport \"../IUniswapV3Pool.sol\";\nimport \"../IUniswapV3PoolImmutables.sol\";\n\ncontract UniswapV3Quoter {\n using LowGasSafeMath for int256;\n using SafeCast for uint256;\n using Tick for mapping(int24 => Tick.Info);\n\n struct PoolState {\n // the current price\n uint160 sqrtPriceX96;\n // the current tick\n int24 tick;\n // the tick spacing\n int24 tickSpacing;\n // the pool's fee\n uint24 fee;\n // the pool's liquidity\n uint128 liquidity;\n // whether the pool is locked\n bool unlocked;\n }\n\n // accumulated protocol fees in token0/token1 units\n struct ProtocolFees {\n uint128 token0;\n uint128 token1;\n }\n\n // the top level state of the swap, the results of which are recorded in storage at the end\n struct SwapState {\n // the amount remaining to be swapped in/out of the input/output asset\n int256 amountSpecifiedRemaining;\n // the amount already swapped out/in of the output/input asset\n int256 amountCalculated;\n // current sqrt(price)\n uint160 sqrtPriceX96;\n // the tick associated with the current price\n int24 tick;\n // the current liquidity in range\n uint128 liquidity;\n }\n\n struct StepComputations {\n // the price at the beginning of the step\n uint160 sqrtPriceStartX96;\n // the next tick to swap to from the current tick in the swap direction\n int24 tickNext;\n // whether tickNext is initialized or not\n bool initialized;\n // sqrt(price) for the next tick (1/0)\n uint160 sqrtPriceNextX96;\n // how much is being swapped in in this step\n uint256 amountIn;\n // how much is being swapped out\n uint256 amountOut;\n // how much fee is being paid in\n uint256 feeAmount;\n }\n\n struct InitialState {\n address poolAddress;\n PoolState poolState;\n uint256 feeGrowthGlobal0X128;\n uint256 feeGrowthGlobal1X128;\n }\n\n struct NextTickPassage {\n int24 tick;\n int24 tickSpacing;\n }\n\n function fetchState(address _pool) internal view returns (PoolState memory poolState) {\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\n (uint160 sqrtPriceX96, int24 tick, , , , , bool unlocked) = pool.slot0(); // external call\n uint128 liquidity = pool.liquidity(); // external call\n int24 tickSpacing = IUniswapV3PoolImmutables(_pool).tickSpacing(); // external call\n uint24 fee = IUniswapV3PoolImmutables(_pool).fee(); // external call\n poolState = PoolState(sqrtPriceX96, tick, tickSpacing, fee, liquidity, unlocked);\n }\n\n function setInitialState(\n PoolState memory initialPoolState,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n )\n internal\n pure\n returns (\n SwapState memory state,\n uint128 liquidity,\n uint160 sqrtPriceX96\n )\n {\n liquidity = initialPoolState.liquidity;\n\n sqrtPriceX96 = initialPoolState.sqrtPriceX96;\n\n require(\n zeroForOne\n ? sqrtPriceLimitX96 < initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO\n : sqrtPriceLimitX96 > initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,\n \"SPL\"\n );\n\n state = SwapState({\n amountSpecifiedRemaining: amountSpecified,\n amountCalculated: 0,\n sqrtPriceX96: initialPoolState.sqrtPriceX96,\n tick: initialPoolState.tick,\n liquidity: 0 // to be modified after initialization\n });\n }\n\n function getNextTickAndPrice(\n int24 tickSpacing,\n int24 currentTick,\n IUniswapV3Pool pool,\n bool zeroForOne\n )\n internal\n view\n returns (\n int24 tickNext,\n bool initialized,\n uint160 sqrtPriceNextX96\n )\n {\n int24 compressed = currentTick / tickSpacing;\n if (!zeroForOne) compressed++;\n if (currentTick < 0 && currentTick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n uint256 selfResult = pool.tickBitmap(int16(compressed >> 8)); // external call\n\n (tickNext, initialized) = TickBitmap.nextInitializedTickWithinOneWord(\n selfResult,\n currentTick,\n tickSpacing,\n zeroForOne\n );\n\n if (tickNext < TickMath.MIN_TICK) {\n tickNext = TickMath.MIN_TICK;\n } else if (tickNext > TickMath.MAX_TICK) {\n tickNext = TickMath.MAX_TICK;\n }\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\n }\n\n function processSwapWithinTick(\n IUniswapV3Pool pool,\n PoolState memory initialPoolState,\n SwapState memory state,\n uint160 firstSqrtPriceX96,\n uint128 firstLiquidity,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne,\n bool exactAmount\n )\n internal\n view\n returns (\n uint160 sqrtPriceNextX96,\n uint160 finalSqrtPriceX96,\n uint128 finalLiquidity\n )\n {\n StepComputations memory step;\n\n step.sqrtPriceStartX96 = firstSqrtPriceX96;\n\n (step.tickNext, step.initialized, sqrtPriceNextX96) = getNextTickAndPrice(\n initialPoolState.tickSpacing,\n state.tick,\n pool,\n zeroForOne\n );\n\n (finalSqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\n firstSqrtPriceX96,\n (zeroForOne ? sqrtPriceNextX96 < sqrtPriceLimitX96 : sqrtPriceNextX96 > sqrtPriceLimitX96)\n ? sqrtPriceLimitX96\n : sqrtPriceNextX96,\n firstLiquidity,\n state.amountSpecifiedRemaining,\n initialPoolState.fee,\n zeroForOne\n );\n\n if (exactAmount) {\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\n } else {\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\n }\n\n if (finalSqrtPriceX96 == sqrtPriceNextX96) {\n if (step.initialized) {\n (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext);\n if (zeroForOne) liquidityNet = -liquidityNet;\n finalLiquidity = LiquidityMath.addDelta(firstLiquidity, liquidityNet);\n }\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\n } else if (finalSqrtPriceX96 != step.sqrtPriceStartX96) {\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\n state.tick = TickMath.getTickAtSqrtRatio(finalSqrtPriceX96);\n }\n }\n\n function returnedAmount(\n SwapState memory state,\n int256 amountSpecified,\n bool zeroForOne\n ) internal pure returns (int256 amount0, int256 amount1) {\n if (amountSpecified > 0) {\n (amount0, amount1) = zeroForOne\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\n } else {\n (amount0, amount1) = zeroForOne\n ? (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining)\n : (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated);\n }\n }\n\n function quoteSwap(\n address poolAddress,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n ) internal view returns (int256 amount0, int256 amount1) {\n bool exactAmount = amountSpecified > 0;\n\n PoolState memory initialPoolState = fetchState(poolAddress);\n uint160 sqrtPriceNextX96;\n\n (SwapState memory state, uint128 liquidity, uint160 sqrtPriceX96) = setInitialState(\n initialPoolState,\n amountSpecified,\n sqrtPriceLimitX96,\n zeroForOne\n );\n\n while (state.amountSpecifiedRemaining != 0 && sqrtPriceX96 != sqrtPriceLimitX96)\n (sqrtPriceNextX96, sqrtPriceX96, liquidity) = processSwapWithinTick(\n IUniswapV3Pool(poolAddress),\n initialPoolState,\n state,\n sqrtPriceX96,\n liquidity,\n sqrtPriceLimitX96,\n zeroForOne,\n exactAmount\n );\n\n (amount0, amount1) = returnedAmount(state, amountSpecified, zeroForOne);\n }\n}\n" + }, + "contracts/external/uniswap/TickMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Cast MAX_TICK to int256 before casting to uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n int24 internal constant MIN_TICK = -887272;\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n int24 internal constant MAX_TICK = -MIN_TICK;\n\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\n /// @dev Throws if |tick| > max tick\n /// @param tick The input tick for the above formula\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n /// at the given tick\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n unchecked {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n if (tick > 0) ratio = type(uint256).max / ratio;\n\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n }\n }\n\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n /// ever return.\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n unchecked {\n // second inequality must be < because the price can never reach the price at the max tick\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, \"R\");\n uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n uint256 r = ratio;\n uint256 msb = 0;\n\n assembly {\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(5, gt(r, 0xFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(4, gt(r, 0xFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(3, gt(r, 0xFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(2, gt(r, 0xF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(1, gt(r, 0x3))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := gt(r, 0x1)\n msb := or(msb, f)\n }\n\n if (msb >= 128) r = ratio >> (msb - 127);\n else r = ratio << (127 - msb);\n\n int256 log_2 = (int256(msb) - 128) << 64;\n\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(63, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(62, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(61, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(60, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(59, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(58, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(57, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(56, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(55, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(54, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(53, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(52, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(51, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(50, f))\n }\n\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n }\n }\n}\n" + }, + "contracts/external/velodrome/IVelodromeRouter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRouter_Velodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidPath();\n error OnlyWETH();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of Velodrome v2 pool factory\n function factory() external view returns (address);\n\n /// @notice Address of Velodrome v2 pool implementation\n function poolImplementation() external view returns (address);\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n}\n" + }, + "contracts/FeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { CErc20Delegator } from \"./compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"./compound/CErc20PluginDelegate.sol\";\nimport { SafeOwnableUpgradeable } from \"./ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { DiamondExtension, DiamondBase } from \"./ionic/DiamondExtension.sol\";\nimport { AuthoritiesRegistry } from \"./ionic/AuthoritiesRegistry.sol\";\n\ncontract FeeDistributorStorage {\n struct CDelegateUpgradeData {\n address implementation;\n bytes becomeImplementationData;\n }\n\n /**\n * @notice Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n * @dev A value of 0 means unset whereas a negative value means 0.\n */\n mapping(address => int256) public customInterestFeeRates;\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n mapping(address => address) internal _latestComptrollerImplementation;\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n mapping(uint8 => CDelegateUpgradeData) internal _latestCErc20Delegate;\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n mapping(address => address) internal _latestPluginImplementation;\n\n mapping(address => DiamondExtension[]) public comptrollerExtensions;\n\n mapping(address => DiamondExtension[]) public cErc20DelegateExtensions;\n\n AuthoritiesRegistry public authoritiesRegistry;\n\n /**\n * @dev used as salt for the creation of new markets\n */\n uint256 public marketsCounter;\n\n /**\n * @dev Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n */\n uint256 public minBorrowEth;\n\n /**\n * @dev Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n * No longer used as of `Rari-Capital/compound-protocol` version `fuse-v1.1.0`.\n */\n uint256 public maxUtilizationRate;\n\n /**\n * @notice The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n uint256 public defaultInterestFeeRate;\n}\n\n/**\n * @title FeeDistributor\n * @author David Lucid (https://github.com/davidlucid)\n * @notice FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\n */\ncontract FeeDistributor is SafeOwnableUpgradeable, FeeDistributorStorage {\n using AddressUpgradeable for address;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Initializer that sets initial values of state variables.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function initialize(uint256 _defaultInterestFeeRate) public initializer {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n __SafeOwnable_init(msg.sender);\n defaultInterestFeeRate = _defaultInterestFeeRate;\n maxUtilizationRate = type(uint256).max;\n }\n\n function reinitialize(AuthoritiesRegistry _ar) public onlyOwnerOrAdmin {\n authoritiesRegistry = _ar;\n }\n\n /**\n * @dev Sets the default proportion of Ionic pool interest taken as a protocol fee.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setDefaultInterestFeeRate(uint256 _defaultInterestFeeRate) external onlyOwner {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n defaultInterestFeeRate = _defaultInterestFeeRate;\n }\n\n /**\n * @dev Withdraws accrued fees on interest.\n * @param erc20Contract The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\n */\n function _withdrawAssets(address erc20Contract) external {\n if (erc20Contract == address(0)) {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No balance available to withdraw.\");\n (bool success, ) = owner().call{ value: balance }(\"\");\n require(success, \"Failed to transfer ETH balance to msg.sender.\");\n } else {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 balance = token.balanceOf(address(this));\n require(balance > 0, \"No token balance available to withdraw.\");\n token.safeTransfer(owner(), balance);\n }\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param _minBorrowEth Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n * @param _maxUtilizationRate Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n */\n function _setPoolLimits(uint256 _minBorrowEth, uint256 _maxUtilizationRate) external onlyOwner {\n minBorrowEth = _minBorrowEth;\n maxUtilizationRate = _maxUtilizationRate;\n }\n\n function getMinBorrowEth(ICErc20 _ctoken) public view returns (uint256) {\n (, , uint256 borrowBalance, ) = _ctoken.getAccountSnapshot(_msgSender());\n if (borrowBalance == 0) return minBorrowEth;\n IonicComptroller comptroller = IonicComptroller(address(_ctoken.comptroller()));\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPriceEth = oracle.price(ICErc20(address(_ctoken)).underlying());\n uint256 underlyingDecimals = _ctoken.decimals();\n uint256 borrowBalanceEth = (underlyingPriceEth * borrowBalance) / 10**underlyingDecimals;\n if (borrowBalanceEth > minBorrowEth) {\n return 0;\n }\n return minBorrowEth - borrowBalanceEth;\n }\n\n /**\n * @dev Receives native fees.\n */\n receive() external payable {}\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes[] calldata data) external onlyOwner {\n require(targets.length > 0 && targets.length == data.length, \"Array lengths must be equal and greater than 0.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data[i]);\n }\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes calldata data) external onlyOwner {\n require(targets.length > 0, \"No target addresses specified.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data);\n }\n\n /**\n * @dev Deploys a CToken for an underlying ERC20\n * @param constructorData Encoded construction data for `CToken initialize()`\n */\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address) {\n // Make sure comptroller == msg.sender\n (address underlying, address comptroller) = abi.decode(constructorData[0:64], (address, address));\n require(comptroller == msg.sender, \"Comptroller is not sender.\");\n\n // Deploy CErc20Delegator using msg.sender, underlying, and block.number as a salt\n bytes32 salt = keccak256(abi.encodePacked(msg.sender, underlying, ++marketsCounter));\n\n bytes memory cErc20DelegatorCreationCode = abi.encodePacked(type(CErc20Delegator).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(0, salt, cErc20DelegatorCreationCode);\n\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n DiamondExtension delegateAsExtension = DiamondExtension(data.implementation);\n // register the first extension\n DiamondBase(proxy)._registerExtension(delegateAsExtension, DiamondExtension(address(0)));\n // derive and configure the other extensions\n DiamondExtension[] memory ctokenExts = cErc20DelegateExtensions[address(delegateAsExtension)];\n for (uint256 i = 0; i < ctokenExts.length; i++) {\n if (ctokenExts[i] == delegateAsExtension) continue;\n DiamondBase(proxy)._registerExtension(ctokenExts[i], DiamondExtension(address(0)));\n }\n CErc20PluginDelegate(address(proxy))._becomeImplementation(becomeImplData);\n\n return proxy;\n }\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n function latestComptrollerImplementation(address oldImplementation) external view returns (address) {\n return\n _latestComptrollerImplementation[oldImplementation] != address(0)\n ? _latestComptrollerImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest `Comptroller` upgrade implementation address.\n * @param oldImplementation The old `Comptroller` implementation address to upgrade from.\n * @param newImplementation Latest `Comptroller` implementation address.\n */\n function _setLatestComptrollerImplementation(address oldImplementation, address newImplementation)\n external\n onlyOwner\n {\n _latestComptrollerImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n function latestCErc20Delegate(uint8 delegateType) external view returns (address, bytes memory) {\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n bytes memory emptyBytes;\n return\n data.implementation != address(0)\n ? (data.implementation, data.becomeImplementationData)\n : (address(0), emptyBytes);\n }\n\n /**\n * @dev Sets the latest `CErc20Delegate` upgrade implementation address and data.\n * @param delegateType The old `CErc20Delegate` implementation address to upgrade from.\n * @param newImplementation Latest `CErc20Delegate` implementation address.\n * @param becomeImplementationData Data passed to the new implementation via `becomeImplementation` after upgrade.\n */\n function _setLatestCErc20Delegate(\n uint8 delegateType,\n address newImplementation,\n bytes calldata becomeImplementationData\n ) external onlyOwner {\n _latestCErc20Delegate[delegateType] = CDelegateUpgradeData(newImplementation, becomeImplementationData);\n }\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n function latestPluginImplementation(address oldImplementation) external view returns (address) {\n return\n _latestPluginImplementation[oldImplementation] != address(0)\n ? _latestPluginImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest plugin upgrade implementation address.\n * @param oldImplementation The old plugin implementation address to upgrade from.\n * @param newImplementation Latest plugin implementation address.\n */\n function _setLatestPluginImplementation(address oldImplementation, address newImplementation) external onlyOwner {\n _latestPluginImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\n * @param cDelegator the proxy address\n * @return if the plugin was upgraded or not\n */\n function _upgradePluginToLatestImplementation(address cDelegator) external onlyOwner returns (bool) {\n CErc20PluginDelegate market = CErc20PluginDelegate(cDelegator);\n\n address oldPluginAddress = address(market.plugin());\n market._updatePlugin(_latestPluginImplementation[oldPluginAddress]);\n address newPluginAddress = address(market.plugin());\n\n return newPluginAddress != oldPluginAddress;\n }\n\n /**\n * @notice Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function interestFeeRate() external view returns (uint256) {\n (bool success, bytes memory data) = msg.sender.staticcall(abi.encodeWithSignature(\"comptroller()\"));\n\n if (success && data.length == 32) {\n address comptroller = abi.decode(data, (address));\n int256 customRate = customInterestFeeRates[comptroller];\n if (customRate > 0) return uint256(customRate);\n if (customRate < 0) return 0;\n }\n\n return defaultInterestFeeRate;\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param comptroller The Unitroller (Comptroller proxy) address.\n * @param rate The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setCustomInterestFeeRate(address comptroller, int256 rate) external onlyOwner {\n require(rate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n customInterestFeeRates[comptroller] = rate;\n }\n\n function getComptrollerExtensions(address comptroller) external view returns (DiamondExtension[] memory) {\n return comptrollerExtensions[comptroller];\n }\n\n function _setComptrollerExtensions(address comptroller, DiamondExtension[] calldata extensions) external onlyOwner {\n comptrollerExtensions[comptroller] = extensions;\n }\n\n function _registerComptrollerExtension(\n address payable pool,\n DiamondExtension extensionToAdd,\n DiamondExtension extensionToReplace\n ) external onlyOwner {\n DiamondBase(pool)._registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (DiamondExtension[] memory) {\n return cErc20DelegateExtensions[cErc20Delegate];\n }\n\n function _setCErc20DelegateExtensions(address cErc20Delegate, DiamondExtension[] calldata extensions)\n external\n onlyOwner\n {\n cErc20DelegateExtensions[cErc20Delegate] = extensions;\n }\n\n function autoUpgradePool(IonicComptroller pool) external onlyOwner {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n // auto upgrade the pool\n pool._upgrade();\n\n for (uint8 i = 0; i < markets.length; i++) {\n // upgrade the market\n markets[i]._upgrade();\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n return authoritiesRegistry.canCall(pool, user, target, functionSig);\n }\n}\n" + }, + "contracts/ILiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\n\ninterface ILiquidator {\n /**\n * borrower The borrower's Ethereum address.\n * repayAmount The amount to repay to liquidate the unhealthy loan.\n * cErc20 The borrowed CErc20 contract to repay.\n * cTokenCollateral The cToken collateral contract to be liquidated.\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\n */\n struct LiquidateToTokensWithFlashSwapVars {\n address borrower;\n uint256 repayAmount;\n ICErc20 cErc20;\n ICErc20 cTokenCollateral;\n address flashSwapContract;\n uint256 minProfitAmount;\n IRedemptionStrategy[] redemptionStrategies;\n bytes[] strategyData;\n IFundsConversionStrategy[] debtFundingStrategies;\n bytes[] debtFundingStrategiesData;\n }\n\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256);\n\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n returns (uint256);\n\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\n\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external;\n\n function setExpressRelay(address _expressRelay) external;\n\n function setPoolLens(address _poolLens) external;\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\n}\n" + }, + "contracts/ionic/AddressesProvider.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title AddressesProvider\n * @notice The Addresses Provider serves as a central storage of system internal and external\n * contract addresses that change between deploys and across chains\n * @author Veliko Minkov \n */\ncontract AddressesProvider is SafeOwnableUpgradeable {\n mapping(string => address) private _addresses;\n mapping(address => Contract) public plugins;\n mapping(address => Contract) public flywheelRewards;\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\n JarvisPool[] public jarvisPoolsConfig;\n CurveSwapPool[] public curveSwapPoolsConfig;\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\n\n /// @dev Initializer to set the admin that can set and change contracts addresses\n function initialize(address owner) public initializer {\n __SafeOwnable_init(owner);\n }\n\n /**\n * @dev The contract address and a string that uniquely identifies the contract's interface\n */\n struct Contract {\n address addr;\n string contractInterface;\n }\n\n struct RedemptionStrategy {\n address addr;\n string contractInterface;\n address outputToken;\n }\n\n struct FundingStrategy {\n address addr;\n string contractInterface;\n address inputToken;\n }\n\n struct JarvisPool {\n address syntheticToken;\n address collateralToken;\n address liquidityPool;\n uint256 expirationTime;\n }\n\n struct CurveSwapPool {\n address poolAddress;\n address[] coins;\n }\n\n /**\n * @dev sets the address and contract interface ID of the flywheel for the reward token\n * @param rewardToken the reward token address\n * @param flywheelRewardsModule the flywheel rewards module address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFlywheelRewards(\n address rewardToken,\n address flywheelRewardsModule,\n string calldata contractInterface\n ) public onlyOwner {\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\n * @param asset the asset address\n * @param plugin the ERC4626 plugin address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setPlugin(\n address asset,\n address plugin,\n string calldata contractInterface\n ) public onlyOwner {\n plugins[asset] = Contract(plugin, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\n * @param asset the asset address\n * @param strategy redemption strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setRedemptionStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address outputToken\n ) public onlyOwner {\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\n }\n\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\n return redemptionStrategiesConfig[asset];\n }\n\n /**\n * @dev sets the address and contract interface ID of the funding strategy for the asset\n * @param asset the asset address\n * @param strategy funding strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFundingStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address inputToken\n ) public onlyOwner {\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\n }\n\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\n return fundingStrategiesConfig[asset];\n }\n\n /**\n * @dev configures the Jarvis pool of a Jarvis synthetic token\n * @param syntheticToken the synthetic token address\n * @param collateralToken the collateral token address\n * @param liquidityPool the liquidity pool address\n * @param expirationTime the operation expiration time\n */\n function setJarvisPool(\n address syntheticToken,\n address collateralToken,\n address liquidityPool,\n uint256 expirationTime\n ) public onlyOwner {\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\n }\n\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\n }\n\n /**\n * @dev Sets an address for an id replacing the address saved in the addresses map\n * @param id The id\n * @param newAddress The address to set\n */\n function setAddress(string calldata id, address newAddress) external onlyOwner {\n _addresses[id] = newAddress;\n }\n\n /**\n * @dev Returns an address by id\n * @return The address\n */\n function getAddress(string calldata id) public view returns (address) {\n return _addresses[id];\n }\n\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\n return curveSwapPoolsConfig;\n }\n\n function getJarvisPools() public view returns (JarvisPool[] memory) {\n return jarvisPoolsConfig;\n }\n\n function setBalancerPoolForTokens(\n address inputToken,\n address outputToken,\n address pool\n ) external onlyOwner {\n balancerPoolForTokens[inputToken][outputToken] = pool;\n }\n\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\n return balancerPoolForTokens[inputToken][outputToken];\n }\n}\n" + }, + "contracts/ionic/AuthoritiesRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\n PoolRolesAuthority public poolAuthLogic;\n address public leveredPositionsFactory;\n bool public noAuthRequired;\n\n function initialize(address _leveredPositionsFactory) public initializer {\n __SafeOwnable_init(msg.sender);\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n }\n\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n // for Neon the auth is not required\n noAuthRequired = block.chainid == 245022934;\n }\n\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\n require(address(poolsAuthorities[pool]) == address(0), \"already created\");\n\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \"\");\n auth = PoolRolesAuthority(address(proxy));\n auth.initialize(address(this));\n poolsAuthorities[pool] = auth;\n\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\n // sets the registry owner as the auth owner\n reconfigureAuthority(pool);\n }\n\n function reconfigureAuthority(address poolAddress) public {\n IonicComptroller pool = IonicComptroller(poolAddress);\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\n\n if (msg.sender != poolAddress || address(auth) != address(0)) {\n require(address(auth) != address(0), \"no such authority\");\n require(msg.sender == owner() || msg.sender == poolAddress, \"not owner or pool\");\n\n auth.configureRegistryCapabilities();\n auth.configurePoolSupplierCapabilities(pool);\n auth.configurePoolBorrowerCapabilities(pool);\n // everyone can be a liquidator\n auth.configureOpenPoolLiquidatorCapabilities(pool);\n auth.configureLeveredPositionCapabilities(pool);\n\n if (auth.owner() != owner()) {\n auth.setOwner(owner());\n }\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\n if (address(authorityForPool) == address(0)) {\n return noAuthRequired;\n } else {\n // allow only if an auth exists and it allows the action\n return authorityForPool.canCall(user, target, functionSig);\n }\n }\n\n function setUserRole(\n address pool,\n address user,\n uint8 role,\n bool enabled\n ) external {\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\n\n require(address(poolAuth) != address(0), \"auth does not exist\");\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \"not owner or factory\");\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \"only lev pos role\");\n\n poolAuth.setUserRole(user, role, enabled);\n }\n}\n" + }, + "contracts/ionic/DiamondExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @notice a base contract for logic extensions that use the diamond pattern storage\n * to map the functions when looking up the extension contract to delegate to.\n */\nabstract contract DiamondExtension {\n /**\n * @return a list of all the function selectors that this logic extension exposes\n */\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\n}\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\n// When no extension exists for function called\nerror ExtensionNotFound(bytes4 _functionSelector);\n\n// When the function is already added\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\n\nabstract contract DiamondBase {\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\n\n function _listExtensions() public view returns (address[] memory) {\n return LibDiamond.listExtensions();\n }\n\n fallback() external {\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n\n/**\n * @notice a library to use in a contract, whose logic is extended with diamond extension\n */\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.extensions.diamond.storage\");\n\n struct Function {\n address extension;\n bytes4 selector;\n }\n\n struct LogicStorage {\n Function[] functions;\n address[] extensions;\n }\n\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\n return getExtensionForSelector(msgSig, diamondStorage());\n }\n\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n function listExtensions() internal view returns (address[] memory) {\n return diamondStorage().extensions;\n }\n\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\n if (address(extensionToReplace) != address(0)) {\n removeExtension(extensionToReplace);\n }\n addExtension(extensionToAdd);\n }\n\n function removeExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n // remove all functions of the extension to replace\n removeExtensionFunctions(extension);\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n if (ds.extensions[i] == address(extension)) {\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\n ds.extensions.pop();\n }\n }\n }\n\n function addExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n require(ds.extensions[i] != address(extension), \"extension already added\");\n }\n addExtensionFunctions(extension);\n ds.extensions.push(address(extension));\n }\n\n function removeExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\n bytes4 selectorToRemove = fnsToRemove[i];\n // must never fail\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\n // swap with the last element in the selectorAtIndex array and remove the last element\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\n ds.functions.pop();\n }\n }\n\n function addExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n uint16 functionsCount = uint16(ds.functions.length);\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\n bytes4 selector = fnsToAdd[functionsIndex];\n address oldImplementation = getExtensionForSelector(selector, ds);\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\n ds.functions.push(Function(address(extension), selector));\n functionsCount++;\n }\n }\n\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\n uint256 fnsLen = ds.functions.length;\n for (uint256 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\n }\n\n return address(0);\n }\n\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\n uint16 fnsLen = uint16(ds.functions.length);\n for (uint16 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return i;\n }\n\n return type(uint16).max;\n }\n}\n" + }, + "contracts/ionic/IFlashLoanReceiver.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface IFlashLoanReceiver {\n function receiveFlashLoan(\n address borrowedAsset,\n uint256 borrowedAmount,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/ionic/levered/ILeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILeveredPositionFactoryStorage {\n function feeDistributor() external view returns (IFeeDistributor);\n\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\n\n function blocksPerYear() external view returns (uint256);\n\n function owner() external view returns (address);\n}\n\ninterface ILeveredPositionFactoryBase {\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external;\n}\n\ninterface ILeveredPositionFactoryFirstExtension {\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getMinBorrowNative() external view returns (uint256);\n\n function removeClosedPosition(address closedPosition) external returns (bool removed);\n\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\n\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\n\n function getAccountsWithOpenPositions() external view returns (address[] memory);\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\n}\n\ninterface ILeveredPositionFactorySecondExtension {\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) external returns (LeveredPosition);\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition);\n}\n\ninterface ILeveredPositionFactoryExtension is\n ILeveredPositionFactoryFirstExtension,\n ILeveredPositionFactorySecondExtension\n{}\n\ninterface ILeveredPositionFactory is\n ILeveredPositionFactoryStorage,\n ILeveredPositionFactoryBase,\n ILeveredPositionFactoryExtension\n{}\n" + }, + "contracts/ionic/levered/LeveredPosition.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IFlashLoanReceiver } from \"../IFlashLoanReceiver.sol\";\nimport { IonicFlywheel } from \"../../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { LeveredPositionStorage } from \"./LeveredPositionStorage.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFlywheelLensRouter_LP {\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\n}\n\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error OnlyWhenClosed();\n error NotPositionOwner();\n error OnlyFactoryOwner();\n error AssetNotRescuable();\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\n\n error ConvertFundsFailed();\n error ExitFailed(uint256 errorCode);\n error RedeemFailed(uint256 errorCode);\n error SupplyCollateralFailed(uint256 errorCode);\n error BorrowStableFailed(uint256 errorCode);\n error RepayBorrowFailed(uint256 errorCode);\n error RedeemCollateralFailed(uint256 errorCode);\n error ExtNotFound(bytes4 _functionSelector);\n\n constructor(\n address _positionOwner,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket\n ) LeveredPositionStorage(_positionOwner) {\n IonicComptroller collateralPool = _collateralMarket.comptroller();\n IonicComptroller stablePool = _stableMarket.comptroller();\n require(collateralPool == stablePool, \"markets pools differ\");\n pool = collateralPool;\n\n collateralMarket = _collateralMarket;\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\n stableMarket = _stableMarket;\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\n\n factory = ILeveredPositionFactory(msg.sender);\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\n _supplyCollateral(fundingAsset);\n\n if (!pool.checkMembership(address(this), collateralMarket)) {\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(collateralMarket);\n pool.enterMarkets(cTokens);\n }\n }\n\n function closePosition() public returns (uint256) {\n return closePosition(msg.sender);\n }\n\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n _leverDown(1e18);\n\n // calling accrue and exit allows to redeem the full underlying balance\n collateralMarket.accrueInterest();\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\n if (errorCode != 0) revert ExitFailed(errorCode);\n\n // redeem all cTokens should leave no dust\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\n if (errorCode != 0) revert RedeemFailed(errorCode);\n\n if (stableAsset.balanceOf(address(this)) > 0) {\n // convert all overborrowed leftovers/profits to the collateral asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // withdraw the redeemed collateral\n withdrawAmount = collateralAsset.balanceOf(address(this));\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\n }\n\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n // anything under 1x means removing the leverage\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\n\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\n else _leverDown(targetRatioMantissa);\n\n // return the de facto achieved ratio\n return getCurrentLeverageRatio();\n }\n\n function receiveFlashLoan(\n address assetAddress,\n uint256 borrowedAmount,\n bytes calldata data\n ) external override {\n if (msg.sender == address(collateralMarket)) {\n // increasing the leverage ratio\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\n _leverUpPostFL(stableBorrowAmount);\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\n if (positionCollateralBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\n } else if (msg.sender == address(stableMarket)) {\n // decreasing the leverage ratio\n uint256 amountToRedeem = abi.decode(data, (uint256));\n _leverDownPostFL(borrowedAmount, amountToRedeem);\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\n if (positionStableBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\n } else {\n revert(\"!fl not from either markets\");\n }\n\n // repay FL\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\n }\n\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\n if (msg.sender != positionOwner) revert NotPositionOwner();\n if (!isPositionClosed()) revert OnlyWhenClosed();\n\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\n return stableLeftovers;\n }\n\n function claimRewards() public {\n claimRewards(msg.sender);\n }\n\n function claimRewards(address withdrawTo) public {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n address[] memory flywheels = pool.getRewardsDistributors();\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n fw.claimRewards(address(this));\n ERC20 rewardToken = fw.rewardToken();\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\n if (rewardsAccrued > 0) {\n rewardToken.transfer(withdrawTo, rewardsAccrued);\n }\n }\n }\n\n function rescueTokens(IERC20Upgradeable asset) external {\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\n\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\n }\n\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\n }\n return (rewardTokens, rewards);\n }\n\n fallback() external {\n address extension = factory.getPositionsExtension(msg.sig);\n if (extension == address(0)) revert ExtNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getAccruedRewards()\n external\n returns (\n /*view*/\n ERC20[] memory rewardTokens,\n uint256[] memory amounts\n )\n {\n address[] memory flywheels = pool.getRewardsDistributors();\n\n rewardTokens = new ERC20[](flywheels.length);\n amounts = new uint256[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n rewardTokens[i] = fw.rewardToken();\n amounts[i] = fw.rewardsAccrued(address(this));\n }\n }\n\n function getCurrentLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtValue = 0;\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n if (debtAmount > 0) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n }\n\n // TODO check if positionValue > debtValue\n // s / ( s - b )\n return (positionValue * 1e18) / (positionValue - debtValue);\n }\n\n function getMinLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\n }\n\n function getMaxLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\n }\n\n function _getLeverageRatioAfterBorrow(\n uint256 newBorrowsAmount,\n uint256 positionSupplyAmount,\n uint256 positionBorrowAmount\n ) internal view returns (uint256 r) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\n\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n {\n // add 10 bps just to not go under the min borrow value\n assumedSlippage += 10;\n }\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\n\n int256 s = int256(positionValue);\n int256 b = int256(currentBorrowsValue);\n int256 x = int256(topUpCollateralValue);\n\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\n }\n\n function isPositionClosed() public view returns (bool) {\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\n }\n\n function getEquityAmount() external view returns (uint256 equityAmount) {\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n\n uint256 equityValue = positionValue - debtValue;\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\n }\n\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentRatio = getCurrentLeverageRatio();\n bool up = targetRatio > currentRatio;\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\n }\n\n function _getSupplyAmountDelta(\n bool up,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 assumedSlippage;\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\n\n uint256 supplyValueDeltaAbs;\n {\n // s = supply value before\n // b = borrow value before\n // r = target ratio after\n // c = borrow value coefficient to account for the slippage\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\n int256 r = int256(targetRatio);\n int256 r1 = r - 1e18;\n int256 c = int256(slippageFactor);\n\n // some math magic here\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\n\n // x = supplyValueDelta\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\n }\n\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\n\n if (up) {\n // stables to borrow = c * x\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\n } else {\n // amount to redeem = c * x\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\n }\n }\n\n /*----------------------------------------------------------------\n Internal Functions\n ----------------------------------------------------------------*/\n\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\n // in case the funding is with a different asset\n if (address(collateralAsset) != address(fundingAsset)) {\n // swap for collateral asset\n convertAllTo(fundingAsset, collateralAsset);\n }\n\n // supply the collateral\n amountToSupply = collateralAsset.balanceOf(address(this));\n collateralAsset.approve(address(collateralMarket), amountToSupply);\n uint256 errorCode = collateralMarket.mint(amountToSupply);\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\n }\n\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\n function _leverUp(uint256 targetRatio) internal {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\n true,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n\n // all stables are swapped for collateral to repay the FL\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\n if (collateralLeftovers > 0) {\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\n collateralMarket.mint(collateralLeftovers);\n }\n }\n\n // @dev supply the flash loaned collateral and then borrow stables with it\n function _leverUpPostFL(uint256 stableToBorrow) internal {\n // supply the flash loaned collateral\n _supplyCollateral(collateralAsset);\n\n // borrow stables that will be swapped to repay the FL\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\n function _leverDown(uint256 targetRatio) internal {\n uint256 amountToRedeem;\n uint256 borrowsToRepay;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n if (targetRatio <= 1e18) {\n // if max levering down, then derive the amount to redeem from the debt to be repaid\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\n } else {\n // else derive the debt to be repaid from the amount to redeem\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\n false,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n // the slippage is already accounted for in _getSupplyAmountDelta\n }\n\n if (borrowsToRepay > 0) {\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n }\n\n // all the redeemed collateral is swapped for stables to repay the FL\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n if (stableLeftovers > 0) {\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n if (borrowBalance > 0) {\n // whatever is smaller\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\n stableAsset.approve(address(stableMarket), amountToRepay);\n stableMarket.repayBorrow(amountToRepay);\n }\n }\n }\n\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\n // repay the borrows\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\n stableAsset.approve(address(stableMarket), repayAmount);\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\n\n // redeem the corresponding amount needed to repay the FL\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(collateralAsset, stableAsset);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n private\n returns (uint256 outputAmount)\n {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\n .getRedemptionStrategies(inputToken, outputToken);\n\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\n\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\n inputAmount = outputAmount;\n inputToken = outputToken;\n }\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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" + }, + "contracts/ionic/levered/LeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { DiamondBase, DiamondExtension, LibDiamond } from \"../../ionic/DiamondExtension.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactory is LeveredPositionFactoryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /*----------------------------------------------------------------\n Constructor\n ----------------------------------------------------------------*/\n\n constructor(\n IFeeDistributor _feeDistributor,\n ILiquidatorsRegistry _registry,\n uint256 _blocksPerYear\n ) {\n feeDistributor = _feeDistributor;\n liquidatorsRegistry = _registry;\n blocksPerYear = _blocksPerYear;\n }\n\n /*----------------------------------------------------------------\n Admin Functions\n ----------------------------------------------------------------*/\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external onlyOwner {\n require(_collateralMarket.comptroller() == _stableMarket.comptroller(), \"markets not of the same pool\");\n\n if (_whitelisted) {\n collateralMarkets.add(address(_collateralMarket));\n borrowableMarketsByCollateral[_collateralMarket].add(address(_stableMarket));\n } else {\n borrowableMarketsByCollateral[_collateralMarket].remove(address(_stableMarket));\n if (borrowableMarketsByCollateral[_collateralMarket].length() == 0)\n collateralMarkets.remove(address(_collateralMarket));\n }\n }\n\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external onlyOwner {\n liquidatorsRegistry = _liquidatorsRegistry;\n }\n\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactoryFirstExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactoryFirstExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactoryFirstExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n error NoSuchPosition();\n error PositionNotClosed();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 10;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.removeClosedPosition.selector;\n functionSelectors[--fnsCount] = this.closeAndRemoveUserPosition.selector;\n functionSelectors[--fnsCount] = this.getMinBorrowNative.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getBorrowableMarketsByCollateral.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedCollateralMarkets.selector;\n functionSelectors[--fnsCount] = this.getAccountsWithOpenPositions.selector;\n functionSelectors[--fnsCount] = this.getPositionsByAccount.selector;\n functionSelectors[--fnsCount] = this.getPositionsExtension.selector;\n functionSelectors[--fnsCount] = this._setPositionsExtension.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n // @return true if removed, otherwise false\n function removeClosedPosition(address closedPosition) external returns (bool) {\n return _removeClosedPosition(closedPosition, msg.sender);\n }\n\n function closeAndRemoveUserPosition(LeveredPosition position) external onlyOwner returns (bool) {\n address positionOwner = position.positionOwner();\n position.closePosition(positionOwner);\n return _removeClosedPosition(address(position), positionOwner);\n }\n\n function _removeClosedPosition(address closedPosition, address positionOwner) internal returns (bool removed) {\n EnumerableSet.AddressSet storage userPositions = positionsByAccount[positionOwner];\n if (!userPositions.contains(closedPosition)) revert NoSuchPosition();\n if (!LeveredPosition(closedPosition).isPositionClosed()) revert PositionNotClosed();\n\n removed = userPositions.remove(closedPosition);\n if (userPositions.length() == 0) accountsWithOpenPositions.remove(positionOwner);\n }\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external onlyOwner {\n _positionsExtensions[msgSig] = extension;\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n function getMinBorrowNative() external view returns (uint256) {\n return feeDistributor.minBorrowEth();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n return liquidatorsRegistry.getRedemptionStrategies(inputToken, outputToken);\n }\n\n function getPositionsByAccount(\n address account\n ) external view returns (address[] memory positions, bool[] memory closed) {\n positions = positionsByAccount[account].values();\n closed = new bool[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n closed[i] = LeveredPosition(positions[i]).isPositionClosed();\n }\n }\n\n function getAccountsWithOpenPositions() external view returns (address[] memory) {\n return accountsWithOpenPositions.values();\n }\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory) {\n return collateralMarkets.values();\n }\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory) {\n return borrowableMarketsByCollateral[_collateralMarket].values();\n }\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address) {\n return _positionsExtensions[msgSig];\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactorySecondExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactorySecondExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactorySecondExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 3;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.createPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPositionAtRatio.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) public returns (LeveredPosition) {\n if (!borrowableMarketsByCollateral[_collateralMarket].contains(address(_stableMarket))) revert PairNotWhitelisted();\n\n LeveredPosition position = new LeveredPosition(msg.sender, _collateralMarket, _stableMarket);\n\n accountsWithOpenPositions.add(msg.sender);\n positionsByAccount[msg.sender].add(address(position));\n\n AuthoritiesRegistry authoritiesRegistry = feeDistributor.authoritiesRegistry();\n address poolAddress = address(_collateralMarket.comptroller());\n PoolRolesAuthority poolAuth = authoritiesRegistry.poolsAuthorities(poolAddress);\n if (address(poolAuth) != address(0)) {\n authoritiesRegistry.setUserRole(poolAddress, address(position), poolAuth.LEVERED_POSITION_ROLE(), true);\n }\n\n return position;\n }\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) public returns (LeveredPosition) {\n LeveredPosition position = createPosition(_collateralMarket, _stableMarket);\n _fundingAsset.safeTransferFrom(msg.sender, address(this), _fundingAmount);\n _fundingAsset.approve(address(position), _fundingAmount);\n position.fundPosition(_fundingAsset, _fundingAmount);\n return position;\n }\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition) {\n LeveredPosition position = createAndFundPosition(_collateralMarket, _stableMarket, _fundingAsset, _fundingAmount);\n if (_leverageRatio > 1e18) {\n position.adjustLeverageRatio(_leverageRatio);\n }\n return position;\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\n EnumerableSet.AddressSet internal collateralMarkets;\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\n\n IFeeDistributor public feeDistributor;\n ILiquidatorsRegistry public liquidatorsRegistry;\n uint256 public blocksPerYear;\n\n mapping(bytes4 => address) internal _positionsExtensions;\n}\n" + }, + "contracts/ionic/levered/LeveredPositionsLens.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract LeveredPositionsLens is Initializable {\n ILeveredPositionFactory public factory;\n\n function initialize(ILeveredPositionFactory _factory) external initializer {\n factory = _factory;\n }\n\n function reinitialize(ILeveredPositionFactory _factory) external reinitializer(2) {\n factory = _factory;\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\n function getCollateralMarkets()\n external\n view\n returns (\n address[] memory markets,\n IonicComptroller[] memory poolOfMarket,\n address[] memory underlyings,\n uint256[] memory underlyingPrices,\n string[] memory names,\n string[] memory symbols,\n uint8[] memory decimals,\n uint256[] memory totalUnderlyingSupplied,\n uint256[] memory ratesPerBlock\n )\n {\n markets = factory.getWhitelistedCollateralMarkets();\n poolOfMarket = new IonicComptroller[](markets.length);\n underlyings = new address[](markets.length);\n underlyingPrices = new uint256[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n totalUnderlyingSupplied = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n ratesPerBlock = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n poolOfMarket[i] = market.comptroller();\n underlyingPrices[i] = BasePriceOracle(poolOfMarket[i].oracle()).getUnderlyingPrice(market);\n underlyings[i] = market.underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyings[i]);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n decimals[i] = underlying.decimals();\n totalUnderlyingSupplied[i] = market.getTotalUnderlyingSupplied();\n ratesPerBlock[i] = market.supplyRatePerBlock();\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\n function getBorrowRateAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _equityAmount,\n uint256 _targetLeverageRatio\n ) external view returns (uint256) {\n IonicComptroller pool = IonicComptroller(_stableMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(_stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n uint256 borrowAmount = ((_targetLeverageRatio - 1e18) * _equityAmount * collateralAssetPrice) /\n (stableAssetPrice * 1e18);\n return _stableMarket.borrowRatePerBlockAfterBorrow(borrowAmount) * factory.blocksPerYear();\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\n function getBorrowableMarketsAndRates(ICErc20 _collateralMarket)\n external\n view\n returns (\n address[] memory markets,\n address[] memory underlyings,\n uint256[] memory underlyingsPrices,\n string[] memory names,\n string[] memory symbols,\n uint256[] memory rates,\n uint8[] memory decimals\n )\n {\n markets = factory.getBorrowableMarketsByCollateral(_collateralMarket);\n underlyings = new address[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n rates = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n underlyingsPrices = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n address underlyingAddress = market.underlying();\n underlyings[i] = underlyingAddress;\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyingAddress);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n rates[i] = market.borrowRatePerBlock();\n decimals[i] = underlying.decimals();\n underlyingsPrices[i] = market.comptroller().oracle().getUnderlyingPrice(market);\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getNetAPY(\n uint256 _supplyAPY,\n uint256 _supplyAmount,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _targetLeverageRatio\n ) public view returns (int256 netAPY) {\n if (_supplyAmount == 0 || _targetLeverageRatio <= 1e18) return 0;\n\n IonicComptroller pool = IonicComptroller(_collateralMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n // TODO the calcs can be implemented without using collateralAssetPrice\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n // total collateral = base collateral + levered collateral\n uint256 totalCollateral = (_supplyAmount * _targetLeverageRatio) / 1e18;\n uint256 yieldFromTotalSupplyScaled = _supplyAPY * totalCollateral;\n int256 yieldValueScaled = int256((yieldFromTotalSupplyScaled * collateralAssetPrice) / 1e18);\n\n uint256 borrowedValueScaled = (totalCollateral - _supplyAmount) * collateralAssetPrice;\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n int256 borrowInterestValueScaled = int256((_borrowRate * borrowedValueScaled) / 1e18);\n\n int256 netValueDiffScaled = yieldValueScaled - borrowInterestValueScaled;\n\n netAPY = ((netValueDiffScaled / int256(collateralAssetPrice)) * 1e18) / int256(_supplyAmount);\n }\n\n function getPositionsInfo(LeveredPosition[] calldata positions, uint256[] calldata supplyApys)\n external\n view\n returns (PositionInfo[] memory infos)\n {\n infos = new PositionInfo[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n infos[i] = getPositionInfo(positions[i], supplyApys[i]);\n }\n }\n\n function getLeverageRatioAfterFunding(LeveredPosition pos, uint256 newFunding) public view returns (uint256) {\n uint256 equityAmount = pos.getEquityAmount();\n if (equityAmount == 0 && newFunding == 0) return 0;\n\n uint256 suppliedCollateralCurrent = pos.collateralMarket().balanceOfUnderlying(address(pos));\n return ((suppliedCollateralCurrent + newFunding) * 1e18) / (equityAmount + newFunding);\n }\n\n function getNetApyForPositionAfterFunding(\n LeveredPosition pos,\n uint256 supplyAPY,\n uint256 newFunding\n ) public view returns (int256) {\n return\n getNetAPY(\n supplyAPY,\n pos.getEquityAmount() + newFunding,\n pos.collateralMarket(),\n pos.stableMarket(),\n getLeverageRatioAfterFunding(pos, newFunding)\n );\n }\n\n function getNetApyForPosition(LeveredPosition pos, uint256 supplyAPY) public view returns (int256) {\n return getNetApyForPositionAfterFunding(pos, supplyAPY, 0);\n }\n\n struct PositionInfo {\n uint256 collateralAssetPrice;\n uint256 borrowedAssetPrice;\n uint256 positionSupplyAmount;\n uint256 positionValue;\n uint256 debtAmount;\n uint256 debtValue;\n uint256 equityAmount;\n uint256 equityValue;\n int256 currentApy;\n uint256 debtRatio;\n uint256 liquidationThreshold;\n uint256 safetyBuffer;\n }\n\n function getPositionInfo(LeveredPosition pos, uint256 supplyApy) public view returns (PositionInfo memory info) {\n ICErc20 collateralMarket = pos.collateralMarket();\n IonicComptroller pool = pos.pool();\n info.collateralAssetPrice = pool.oracle().getUnderlyingPrice(collateralMarket);\n {\n info.positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(pos));\n info.positionValue = (info.collateralAssetPrice * info.positionSupplyAmount) / 1e18;\n info.currentApy = getNetApyForPosition(pos, supplyApy);\n }\n\n {\n ICErc20 stableMarket = pos.stableMarket();\n info.borrowedAssetPrice = pool.oracle().getUnderlyingPrice(stableMarket);\n info.debtAmount = stableMarket.borrowBalanceCurrent(address(pos));\n info.debtValue = (info.borrowedAssetPrice * info.debtAmount) / 1e18;\n info.equityValue = info.positionValue - info.debtValue;\n info.debtRatio = info.positionValue == 0 ? 0 : (info.debtValue * 1e18) / info.positionValue;\n info.equityAmount = (info.equityValue * 1e18) / info.collateralAssetPrice;\n }\n\n {\n (, uint256 collateralFactor) = pool.markets(address(collateralMarket));\n info.liquidationThreshold = collateralFactor;\n info.safetyBuffer = collateralFactor - info.debtRatio;\n }\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract LeveredPositionStorage {\n address public immutable positionOwner;\n ILeveredPositionFactory public factory;\n\n ICErc20 public collateralMarket;\n ICErc20 public stableMarket;\n IonicComptroller public pool;\n\n IERC20Upgradeable public collateralAsset;\n IERC20Upgradeable public stableAsset;\n\n constructor(address _positionOwner) {\n positionOwner = _positionOwner;\n }\n}\n" + }, + "contracts/ionic/PoolRolesAuthority.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller, ComptrollerInterface } from \"../compound/ComptrollerInterface.sol\";\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \"../compound/CTokenInterfaces.sol\";\n\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\n constructor() RolesAuthority(address(0), Authority(address(0))) {\n _disableInitializers();\n }\n\n function initialize(address _owner) public initializer {\n owner = _owner;\n authority = this;\n }\n\n // up to 256 roles\n uint8 public constant REGISTRY_ROLE = 0;\n uint8 public constant SUPPLIER_ROLE = 1;\n uint8 public constant BORROWER_ROLE = 2;\n uint8 public constant LIQUIDATOR_ROLE = 3;\n uint8 public constant LEVERED_POSITION_ROLE = 4;\n\n function configureRegistryCapabilities() external requiresAuth {\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\n true\n );\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\n }\n\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, true);\n }\n\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, false);\n }\n\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\n }\n }\n }\n\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\n }\n\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\n uint8 fnsCount = 6;\n selectors = new bytes4[](fnsCount);\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return selectors;\n }\n\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\n }\n }\n }\n\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, true);\n }\n\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, false);\n }\n\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\n }\n }\n\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n // borrowers have the SUPPLIER_ROLE capabilities by default\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n // TODO this leaves redeeming open for everyone\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\n\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n}\n" + }, + "contracts/ionic/SafeOwnable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nabstract contract SafeOwnable is Ownable2Step {\n function renounceOwnership() public override onlyOwner {\n revert(\"renounce ownership not allowed\");\n }\n}\n" + }, + "contracts/ionic/SafeOwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\n/**\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\n * that will shift the other.\n */\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\n /**\n * @notice Pending owner of this contract\n */\n address public pendingOwner;\n\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\n __Ownable_init();\n _transferOwnership(owner_);\n }\n\n struct AddressSlot {\n address value;\n }\n\n modifier onlyOwnerOrAdmin() {\n bool isOwner = owner() == _msgSender();\n if (!isOwner) {\n address admin = _getProxyAdmin();\n bool isAdmin = admin == _msgSender();\n require(isAdmin, \"Ownable: caller is neither the owner nor the admin\");\n }\n _;\n }\n\n /**\n * @notice Emitted when pendingOwner is changed\n */\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\n\n /**\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\n */\n event NewOwner(address oldOwner, address newOwner);\n\n /**\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @param newPendingOwner New pending owner.\n */\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\n // Save current value, if any, for inclusion in log\n address oldPendingOwner = pendingOwner;\n\n // Store pendingOwner with value newPendingOwner\n pendingOwner = newPendingOwner;\n\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\n }\n\n /**\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\n * @dev Owner function for pending owner to accept role and update owner\n */\n function _acceptOwner() public {\n // Check caller is pendingOwner and pendingOwner ≠ address(0)\n require(msg.sender == pendingOwner, \"not the pending owner\");\n\n // Save current values for inclusion in log\n address oldOwner = owner();\n address oldPendingOwner = pendingOwner;\n\n // Store owner with value pendingOwner\n _transferOwnership(pendingOwner);\n\n // Clear the pending value\n pendingOwner = address(0);\n\n emit NewOwner(oldOwner, pendingOwner);\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\n }\n\n function renounceOwnership() public override onlyOwner {\n // do not remove this overriding fn\n revert(\"not used anymore\");\n }\n\n function transferOwnership(address newOwner) public override onlyOwner {\n emit NewPendingOwner(pendingOwner, newOwner);\n pendingOwner = newOwner;\n }\n\n function _getProxyAdmin() internal view returns (address admin) {\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n AddressSlot storage adminSlot;\n assembly {\n adminSlot.slot := _ADMIN_SLOT\n }\n admin = adminSlot.value;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IFlywheelBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/**\n @title Balance Booster Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\n \n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\n\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\n*/\ninterface IFlywheelBooster {\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IIonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ninterface IIonicFlywheel {\n function isRewardsDistributor() external returns (bool);\n\n function isFlywheel() external returns (bool);\n\n function flywheelPreSupplierAction(address market, address supplier) external;\n\n function flywheelPreBorrowerAction(address market, address borrower) external;\n\n function flywheelPreTransferAction(address market, address src, address dst) external;\n\n function compAccrued(address user) external view returns (uint256);\n\n function addMarketForRewards(ERC20 strategy) external;\n\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport \"./IIonicFlywheel.sol\";\n\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\n bool public constant isRewardsDistributor = true;\n bool public constant isFlywheel = true;\n\n function flywheelPreSupplierAction(address market, address supplier) external {\n accrue(ERC20(market), supplier);\n }\n\n function flywheelPreBorrowerAction(address market, address borrower) external {}\n\n function flywheelPreTransferAction(address market, address src, address dst) external {\n accrue(ERC20(market), src, dst);\n }\n\n function compAccrued(address user) external view returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n // TODO remove\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\nimport { SafeCastLib } from \"solmate/utils/SafeCastLib.sol\";\n\nimport { IFlywheelRewards } from \"./rewards/IFlywheelRewards.sol\";\nimport { IFlywheelBooster } from \"./IFlywheelBooster.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n /// @notice How much rewardsToken will be send to treasury\n uint256 public performanceFee;\n\n /// @notice Address that gets rewardsToken accrued by performanceFee\n address public feeRecipient;\n\n /// @notice The token to reward\n ERC20 public rewardToken;\n\n /// @notice append-only list of strategies added\n ERC20[] public allStrategies;\n\n /// @notice the rewards contract for managing streams\n IFlywheelRewards public flywheelRewards;\n\n /// @notice optional booster module for calculating virtual balances on strategies\n IFlywheelBooster public flywheelBooster;\n\n /// @notice The accrued but not yet transferred rewards for each user\n mapping(address => uint256) internal _rewardsAccrued;\n\n /// @notice The strategy index and last updated per strategy\n mapping(ERC20 => RewardsState) internal _strategyState;\n\n /// @notice user index per strategy\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\n\n constructor() {\n // prevents the misusage of the implementation contract\n _disableInitializers();\n }\n\n function initialize(\n ERC20 _rewardToken,\n IFlywheelRewards _flywheelRewards,\n IFlywheelBooster _flywheelBooster,\n address _owner\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n\n rewardToken = _rewardToken;\n flywheelRewards = _flywheelRewards;\n flywheelBooster = _flywheelBooster;\n\n _transferOwnership(_owner);\n\n performanceFee = 10e16; // 10%\n feeRecipient = _owner;\n }\n\n /*----------------------------------------------------------------\n ACCRUE/CLAIM LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a user's rewards accrue to a given strategy.\n @param strategy the updated rewards strategy\n @param user the user of the rewards\n @param rewardsDelta how many new rewards accrued to the user\n @param rewardsIndex the market index for rewards per token accrued\n */\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\n\n /** \n @notice Emitted when a user claims accrued rewards.\n @param user the user of the rewards\n @param amount the amount of rewards claimed\n */\n event ClaimRewards(address indexed user, uint256 amount);\n\n /** \n @notice accrue rewards for a single user on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the user to be accrued\n @return the cumulative amount of rewards accrued to user (including prior)\n */\n function accrue(ERC20 strategy, address user) public returns (uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return 0;\n\n state = accrueStrategy(strategy, state);\n return accrueUser(strategy, user, state);\n }\n\n /** \n @notice accrue rewards for a two users on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the first user to be accrued\n @param user the second user to be accrued\n @return the cumulative amount of rewards accrued to the first user (including prior)\n @return the cumulative amount of rewards accrued to the second user (including prior)\n */\n function accrue(\n ERC20 strategy,\n address user,\n address secondUser\n ) public returns (uint256, uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return (0, 0);\n\n state = accrueStrategy(strategy, state);\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\n }\n\n /** \n @notice claim rewards for a given user\n @param user the user claiming rewards\n @dev this function is public, and all rewards transfer to the user\n */\n function claimRewards(address user) external {\n uint256 accrued = rewardsAccrued(user);\n\n if (accrued != 0) {\n _rewardsAccrued[user] = 0;\n\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\n\n emit ClaimRewards(user, accrued);\n }\n }\n\n /*----------------------------------------------------------------\n ADMIN LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a new strategy is added to flywheel by the admin\n @param newStrategy the new added strategy\n */\n event AddStrategy(address indexed newStrategy);\n\n /// @notice initialize a new strategy\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n function _addStrategyForRewards(ERC20 strategy) internal {\n (uint224 index, ) = strategyState(strategy);\n require(index == 0, \"strategy\");\n _strategyState[strategy] = RewardsState({\n index: (10**rewardToken.decimals()).safeCastTo224(),\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n\n function getAllStrategies() external view returns (ERC20[] memory) {\n return allStrategies;\n }\n\n /** \n @notice Emitted when the rewards module changes\n @param newFlywheelRewards the new rewards module\n */\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\n\n /// @notice swap out the flywheel rewards contract\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\n if (address(flywheelRewards) != address(0)) {\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\n if (oldRewardBalance > 0) {\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\n }\n }\n\n flywheelRewards = newFlywheelRewards;\n\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\n }\n\n /** \n @notice Emitted when the booster module changes\n @param newBooster the new booster module\n */\n event FlywheelBoosterUpdate(address indexed newBooster);\n\n /// @notice swap out the flywheel booster contract\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\n flywheelBooster = newBooster;\n\n emit FlywheelBoosterUpdate(address(newBooster));\n }\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n * @dev Claim rewards first from the previous feeRecipient before changing it\n */\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\n _updateFeeSettings(_performanceFee, _feeRecipient);\n }\n\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\n\n if (feeRecipient != _feeRecipient) {\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\n _rewardsAccrued[feeRecipient] = 0;\n }\n performanceFee = _performanceFee;\n feeRecipient = _feeRecipient;\n }\n\n /*----------------------------------------------------------------\n INTERNAL ACCOUNTING LOGIC\n ----------------------------------------------------------------*/\n\n struct RewardsState {\n /// @notice The strategy's last updated index\n uint224 index;\n /// @notice The timestamp the index was last updated at\n uint32 lastUpdatedTimestamp;\n }\n\n /// @notice accumulate global rewards on a strategy\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\n private\n returns (RewardsState memory rewardsState)\n {\n // calculate accrued rewards through module\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\n\n rewardsState = state;\n\n if (strategyRewardsAccrued > 0) {\n // use the booster or token supply to calculate reward index denominator\n uint256 supplyTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedTotalSupply(strategy)\n : strategy.totalSupply();\n\n // 100% = 100e16\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\n\n _rewardsAccrued[feeRecipient] += accruedFees;\n strategyRewardsAccrued -= accruedFees;\n\n uint224 deltaIndex;\n\n if (supplyTokens != 0)\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\n\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\n rewardsState = RewardsState({\n index: state.index + deltaIndex,\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n _strategyState[strategy] = rewardsState;\n }\n }\n\n /// @notice accumulate rewards on a strategy for a specific user\n function accrueUser(\n ERC20 strategy,\n address user,\n RewardsState memory state\n ) private returns (uint256) {\n // load indices\n uint224 strategyIndex = state.index;\n uint224 supplierIndex = userIndex(strategy, user);\n\n // sync user index to global\n _userIndex[strategy][user] = strategyIndex;\n\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\n // zero balances will have no effect other than syncing to global index\n if (supplierIndex == 0) {\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\n }\n\n uint224 deltaIndex = strategyIndex - supplierIndex;\n // use the booster or token balance to calculate reward balance multiplier\n uint256 supplierTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedBalanceOf(strategy, user)\n : strategy.balanceOf(user);\n\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\n\n _rewardsAccrued[user] = supplierAccrued;\n\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\n\n return supplierAccrued;\n }\n\n function rewardsAccrued(address user) public virtual returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\n return _userIndex[strategy][user];\n }\n\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport { IonicComptroller } from \"../../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { PoolDirectory } from \"../../../PoolDirectory.sol\";\n\ninterface IPriceOracle_IFLR {\n function getUnderlyingPrice(ERC20 cToken) external view returns (uint256);\n\n function price(address underlying) external view returns (uint256);\n}\n\ncontract IonicFlywheelLensRouter {\n PoolDirectory public fpd;\n\n constructor(PoolDirectory _fpd) {\n fpd = _fpd;\n }\n\n struct MarketRewardsInfo {\n /// @dev comptroller oracle price of market underlying\n uint256 underlyingPrice;\n ICErc20 market;\n RewardsInfo[] rewardsInfo;\n }\n\n struct RewardsInfo {\n /// @dev rewards in `rewardToken` paid per underlying staked token in `market` per second\n uint256 rewardSpeedPerSecondPerToken;\n /// @dev comptroller oracle price of reward token\n uint256 rewardTokenPrice;\n /// @dev APR scaled by 1e18. Calculated as rewardSpeedPerSecondPerToken * rewardTokenPrice * 365.25 days / underlyingPrice * 1e18 / market.exchangeRate\n uint256 formattedAPR;\n address flywheel;\n address rewardToken;\n }\n\n function getPoolMarketRewardsInfo(IonicComptroller comptroller) external returns (MarketRewardsInfo[] memory) {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n return _getMarketRewardsInfo(markets, comptroller);\n }\n\n function getMarketRewardsInfo(ICErc20[] memory markets) external returns (MarketRewardsInfo[] memory) {\n IonicComptroller pool;\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 asMarket = ICErc20(address(markets[i]));\n if (address(pool) == address(0)) pool = asMarket.comptroller();\n else require(asMarket.comptroller() == pool);\n }\n return _getMarketRewardsInfo(markets, pool);\n }\n\n function _getMarketRewardsInfo(ICErc20[] memory markets, IonicComptroller comptroller)\n internal\n returns (MarketRewardsInfo[] memory)\n {\n if (address(comptroller) == address(0) || markets.length == 0) return new MarketRewardsInfo[](0);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n address[] memory rewardTokens = new address[](flywheels.length);\n uint256[] memory rewardTokenPrices = new uint256[](flywheels.length);\n uint256[] memory rewardTokenDecimals = new uint256[](flywheels.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n MarketRewardsInfo[] memory infoList = new MarketRewardsInfo[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n RewardsInfo[] memory rewardsInfo = new RewardsInfo[](flywheels.length);\n\n ICErc20 market = ICErc20(address(markets[i]));\n uint256 price = oracle.price(market.underlying()); // scaled to 1e18\n\n if (i == 0) {\n for (uint256 j = 0; j < flywheels.length; j++) {\n ERC20 rewardToken = IonicFlywheelCore(flywheels[j]).rewardToken();\n rewardTokens[j] = address(rewardToken);\n rewardTokenPrices[j] = oracle.price(address(rewardToken)); // scaled to 1e18\n rewardTokenDecimals[j] = uint256(rewardToken.decimals());\n }\n }\n\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n rewardTokenDecimals[j]\n );\n uint256 apr = getApr(\n rewardSpeedPerSecondPerToken,\n rewardTokenPrices[j],\n price, \n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n rewardsInfo[j] = RewardsInfo({\n rewardSpeedPerSecondPerToken: rewardSpeedPerSecondPerToken, // scaled in 1e18\n rewardTokenPrice: rewardTokenPrices[j],\n formattedAPR: apr, // scaled in 1e18\n flywheel: address(flywheel),\n rewardToken: rewardTokens[j]\n });\n }\n\n infoList[i] = MarketRewardsInfo({ market: market, rewardsInfo: rewardsInfo, underlyingPrice: price });\n }\n\n return infoList;\n }\n\n function scaleIndexDiff(uint256 indexDiff, uint256 decimals) internal pure returns (uint256) {\n return decimals <= 18 ? uint256(indexDiff) * (10**(18 - decimals)) : uint256(indexDiff) / (10**(decimals - 18));\n }\n\n function getRewardSpeedPerSecondPerToken(\n IonicFlywheelCore flywheel,\n ICErc20 market,\n uint256 decimals\n ) internal returns (uint256 rewardSpeedPerSecondPerToken) {\n ERC20 strategy = ERC20(address(market));\n (uint224 indexBefore, uint32 lastUpdatedTimestampBefore) = flywheel.strategyState(strategy);\n flywheel.accrue(strategy, address(0));\n (uint224 indexAfter, uint32 lastUpdatedTimestampAfter) = flywheel.strategyState(strategy);\n if (lastUpdatedTimestampAfter > lastUpdatedTimestampBefore) {\n rewardSpeedPerSecondPerToken =\n scaleIndexDiff((indexAfter - indexBefore), decimals) /\n (lastUpdatedTimestampAfter - lastUpdatedTimestampBefore);\n }\n }\n\n function getApr(\n uint256 rewardSpeedPerSecondPerToken,\n uint256 rewardTokenPrice,\n uint256 underlyingPrice,\n uint256 exchangeRate,\n bool isBorrow\n ) internal pure returns (uint256) {\n if (rewardSpeedPerSecondPerToken == 0) return 0;\n uint256 nativeSpeedPerSecondPerCToken = rewardSpeedPerSecondPerToken * rewardTokenPrice; // scaled to 1e36\n uint256 nativeSpeedPerYearPerCToken = nativeSpeedPerSecondPerCToken * 365.25 days; // scaled to 1e36\n uint256 assetSpeedPerYearPerCToken = nativeSpeedPerYearPerCToken / underlyingPrice; // scaled to 1e18\n uint256 assetSpeedPerYearPerCTokenScaled = assetSpeedPerYearPerCToken * 1e18; // scaled to 1e36\n uint256 apr = assetSpeedPerYearPerCTokenScaled;\n if (!isBorrow) {\n // if not borrowing, use exchange rate to scale\n apr = assetSpeedPerYearPerCTokenScaled / exchangeRate; // scaled to 1e18\n } else {\n apr = assetSpeedPerYearPerCTokenScaled / 1e18; // scaled to 1e18\n }\n return apr;\n }\n\n function getRewardsAprForMarket(ICErc20 market) internal returns (int256 totalMarketRewardsApr) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPrice = oracle.getUnderlyingPrice(market);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n ERC20 rewardToken = flywheel.rewardToken();\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n uint256(rewardToken.decimals())\n );\n\n uint256 marketApr = getApr(\n rewardSpeedPerSecondPerToken,\n oracle.price(address(rewardToken)),\n underlyingPrice,\n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n totalMarketRewardsApr += int256(marketApr);\n }\n }\n\n function getUserNetValueDeltaForMarket(\n address user,\n ICErc20 market,\n int256 offchainApr,\n int256 blocksPerYear\n ) internal returns (int256) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n int256 netApr = getRewardsAprForMarket(market) +\n getUserInterestAprForMarket(user, market, blocksPerYear) +\n offchainApr;\n return (netApr * int256(market.balanceOfUnderlying(user)) * int256(oracle.getUnderlyingPrice(market))) / 1e36;\n }\n\n function getUserInterestAprForMarket(\n address user,\n ICErc20 market,\n int256 blocksPerYear\n ) internal returns (int256) {\n uint256 borrows = market.borrowBalanceCurrent(user);\n uint256 supplied = market.balanceOfUnderlying(user);\n uint256 supplyRatePerBlock = market.supplyRatePerBlock();\n uint256 borrowRatePerBlock = market.borrowRatePerBlock();\n\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 assetPrice = oracle.getUnderlyingPrice(market);\n uint256 collateralValue = (supplied * assetPrice) / 1e18;\n uint256 borrowsValue = (borrows * assetPrice) / 1e18;\n\n uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;\n uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;\n\n if (collateralValue == 0) return 0;\n return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);\n }\n\n struct AdjustedUserNetAprVars {\n int256 userNetAssetsValue;\n int256 userNetValueDelta;\n BasePriceOracle oracle;\n ICErc20[] markets;\n IonicComptroller pool;\n }\n\n function getAdjustedUserNetApr(\n address user,\n int256 blocksPerYear,\n address[] memory offchainRewardsAprMarkets,\n int256[] memory offchainRewardsAprs\n ) public returns (int256) {\n AdjustedUserNetAprVars memory vars;\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n vars.oracle = pool.oracle();\n vars.markets = pool.getAllMarkets();\n for (uint256 j = 0; j < vars.markets.length; j++) {\n int256 offchainRewardsApr = 0;\n for (uint256 k = 0; k < offchainRewardsAprMarkets.length; k++) {\n if (offchainRewardsAprMarkets[k] == address(vars.markets[j])) offchainRewardsApr = offchainRewardsAprs[k];\n }\n vars.userNetAssetsValue +=\n int256(vars.markets[j].balanceOfUnderlying(user) * vars.oracle.getUnderlyingPrice(vars.markets[j])) /\n 1e18;\n vars.userNetValueDelta += getUserNetValueDeltaForMarket(\n user,\n vars.markets[j],\n offchainRewardsApr,\n blocksPerYear\n );\n }\n }\n\n if (vars.userNetAssetsValue == 0) return 0;\n else return (vars.userNetValueDelta * 1e18) / vars.userNetAssetsValue;\n }\n\n function getUserNetApr(address user, int256 blocksPerYear) external returns (int256) {\n address[] memory emptyAddrArray = new address[](0);\n int256[] memory emptyIntArray = new int256[](0);\n return getAdjustedUserNetApr(user, blocksPerYear, emptyAddrArray, emptyIntArray);\n }\n\n function getAllRewardTokens() public view returns (address[] memory uniqueRewardTokens) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n uint256 rewardTokensCounter;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n rewardTokensCounter += fws.length;\n }\n\n address[] memory rewardTokens = new address[](rewardTokensCounter);\n\n uint256 uniqueRewardTokensCounter = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n for (uint256 j = 0; j < fws.length; j++) {\n address rwToken = address(IonicFlywheelCore(fws[j]).rewardToken());\n if (rwToken == address(0)) break;\n\n bool added;\n for (uint256 k = 0; k < rewardTokens.length; k++) {\n if (rwToken == rewardTokens[k]) {\n added = true;\n break;\n }\n }\n if (!added) rewardTokens[uniqueRewardTokensCounter++] = rwToken;\n }\n }\n\n uniqueRewardTokens = new address[](uniqueRewardTokensCounter);\n for (uint256 i = 0; i < uniqueRewardTokensCounter; i++) {\n uniqueRewardTokens[i] = rewardTokens[i];\n }\n }\n\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory) {\n address[] memory rewardTokens = getAllRewardTokens();\n uint256[] memory rewardsClaimedForToken = new uint256[](rewardTokens.length);\n\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n rewardsClaimedForToken[i] = claimRewardsOfRewardToken(user, rewardTokens[i]);\n }\n\n return (rewardTokens, rewardsClaimedForToken);\n }\n\n function claimRewardsOfRewardToken(address user, address rewardToken) public returns (uint256 rewardsClaimed) {\n uint256 balanceBefore = ERC20(rewardToken).balanceOf(user);\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ERC20[] memory markets;\n {\n ICErc20[] memory cerc20s = pool.getAllMarkets();\n markets = new ERC20[](cerc20s.length);\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n }\n\n address[] memory flywheelAddresses = pool.getAccruingFlywheels();\n for (uint256 k = 0; k < flywheelAddresses.length; k++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);\n if (address(flywheel.rewardToken()) == rewardToken) {\n for (uint256 m = 0; m < markets.length; m++) {\n flywheel.accrue(markets[m], user);\n }\n flywheel.claimRewards(user);\n }\n }\n }\n\n uint256 balanceAfter = ERC20(rewardToken).balanceOf(user);\n return balanceAfter - balanceBefore;\n }\n\n function claimRewardsForMarket(\n address user,\n ERC20 market,\n IonicFlywheelCore[] calldata flywheels,\n bool[] calldata accrue\n )\n external\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n uint256 size = flywheels.length;\n rewards = new uint256[](size);\n rewardTokens = new address[](size);\n\n for (uint256 i = 0; i < size; i++) {\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n\n function claimRewardsForPool(address user, IonicComptroller comptroller)\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory,\n uint256[] memory\n )\n {\n ICErc20[] memory cerc20s = comptroller.getAllMarkets();\n ERC20[] memory markets = new ERC20[](cerc20s.length);\n address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();\n IonicFlywheelCore[] memory flywheels = new IonicFlywheelCore[](flywheelAddresses.length);\n bool[] memory accrue = new bool[](flywheelAddresses.length);\n\n for (uint256 j = 0; j < flywheelAddresses.length; j++) {\n flywheels[j] = IonicFlywheelCore(flywheelAddresses[j]);\n accrue[j] = true;\n }\n\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n\n return claimRewardsForMarkets(user, markets, flywheels, accrue);\n }\n\n function claimRewardsForMarkets(\n address user,\n ERC20[] memory markets,\n IonicFlywheelCore[] memory flywheels,\n bool[] memory accrue\n )\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n rewards = new uint256[](flywheels.length);\n rewardTokens = new address[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n for (uint256 j = 0; j < markets.length; j++) {\n ERC20 market = markets[j];\n\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n }\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/**\n @title Rewards Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Rewards module is responsible for:\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\n * actually holding rewards that are yet to be claimed\n\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\n\n Different module strategies include:\n * a static reward rate per second\n * a decaying reward rate\n * a dynamic just-in-time reward stream\n * liquid governance reward delegation (Curve Gauge style)\n\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\n */\ninterface IFlywheelRewards {\n /**\n @notice calculate the rewards amount accrued to a strategy since the last update.\n @param strategy the strategy to accrue rewards for.\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\n @return rewards the amount of rewards accrued to the market\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\n\n /// @notice return the flywheel core address\n function flywheel() external view returns (IonicFlywheelCore);\n\n /// @notice return the reward token associated with flywheel core.\n function rewardToken() external view returns (ERC20);\n}\n" + }, + "contracts/IonicUniV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./external/uniswap/IUniswapV3FlashCallback.sol\";\nimport \"./external/uniswap/IUniswapV3Pool.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\nimport { IUniswapV3Quoter } from \"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IFlashLoanReceiver } from \"./ionic/IFlashLoanReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicUniV3Liquidator\n * @author Veliko Minkov (https://github.com/vminkov)\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\n */\ncontract IonicUniV3Liquidator is\n OwnableUpgradeable,\n ILiquidator,\n IUniswapV3FlashCallback,\n IExpressRelayFeeReceiver,\n IFlashLoanReceiver\n{\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n\n address public W_NATIVE_ADDRESS;\n mapping(address => bool) public redemptionStrategiesWhitelist;\n IUniswapV3Quoter public quoter;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(address _wtoken, address _quoter) external initializer {\n __Ownable_init();\n W_NATIVE_ADDRESS = _wtoken;\n quoter = IUniswapV3Quoter(_quoter);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n underlying.approve(address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateToTokensWithFlashLoan(\n LiquidateToTokensWithFlashSwapVars calldata vars\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\n flashSwapPool.flash(\n address(this),\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(\n LiquidateToTokensWithFlashSwapVars memory vars,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\n uint256 flashSwapReturnAmount = _flashSwapAmount;\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\n flashSwapReturnAmount += fee0;\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\n flashSwapReturnAmount += fee1;\n } else {\n revert(\"wrong pool or _flashSwapToken\");\n }\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay the borrowed asset directly\n collateralRequired = flashSwapReturnAmount;\n\n // Repay flashloan\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\n } else {\n // TODO swap within the same pool and then repay the FL to the pool\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\n\n {\n collateralRequired = quoter.quoteExactOutputSingle(\n zeroForOne ? pool.token0() : pool.token1(),\n zeroForOne ? pool.token1() : pool.token0(),\n pool.fee(),\n _flashSwapAmount,\n 0 // sqrtPriceLimitX96\n );\n }\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n\n // Repay flashloan\n pool.swap(\n address(pool),\n zeroForOne,\n int256(collateralRequired),\n 0, // sqrtPriceLimitX96\n \"\"\n );\n }\n\n return address(underlyingCollateral);\n } else {\n revert(\"the redemptions strategy did not swap to the flash swapped pool assets\");\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n bool[] calldata whitelisted\n ) external onlyOwner {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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" + }, + "contracts/liquidators/AerodromeCLLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { ISwapRouter_Aerodrome } from \"../external/aerodrome/IAerodromeSwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\ncontract AerodromeCLLiquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n ,\n address _outputToken,\n ISwapRouter_Aerodrome swapRouter,\n address _unwrappedInput,\n address _unwrappedOutput,\n int24 _tickSpacing\n ) = abi.decode(strategyData, (address, address, ISwapRouter_Aerodrome, address, address, int24));\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(_outputToken);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n ISwapRouter_Aerodrome.ExactInputSingleParams(\n address(inputToken),\n address(outputToken),\n _tickSpacing,\n address(this),\n block.timestamp,\n inputAmount,\n 0,\n 0\n )\n );\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(_outputToken), outputAmount);\n IERC4626(_outputToken).deposit(outputAmount, address(this));\n outputAmount = IERC4626(_unwrappedOutput).balanceOf(address(this));\n outputToken = IERC20Upgradeable(_outputToken);\n }\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"AerodromeCLLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AerodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\n\n/**\n * @title AerodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Aerodrome V2 router for use as a step in a liquidation.\n */\ncontract AerodromeV2Liquidator {\n function _swap(IRouter_Aerodrome router, uint256 inputAmount, IRouter_Aerodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"AerodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Aerodrome router, IRouter_Aerodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Aerodrome, IRouter_Aerodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid AerodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/liquidators/AlgebraSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/algebra/ISwapRouter.sol\";\n\n/**\n * @title AlgebraSwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Algebra router for use as a step in a liquidation.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract AlgebraSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address _outputToken, IAlgebraSwapRouter swapRouter) = abi.decode(strategyData, (address, IAlgebraSwapRouter));\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n IAlgebraSwapRouter.ExactInputSingleParams memory params = IAlgebraSwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n address(this),\n block.timestamp,\n inputAmount,\n 0, // amountOutMinimum\n 0 // limitSqrtPrice\n );\n\n outputAmount = swapRouter.exactInputSingle(params);\n }\n\n function name() public pure returns (string memory) {\n return \"AlgebraSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract BalancerSwapLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address outputTokenAddress, IBalancerPool pool) = abi.decode(strategyData, (address, IBalancerPool));\n\n IBalancerVault vault = pool.getVault();\n bytes32 poolId = pool.getPoolId();\n\n SingleSwap memory singleSwap = SingleSwap(\n poolId,\n SwapKind.GIVEN_IN,\n IAsset(address(inputToken)),\n IAsset(address(outputTokenAddress)),\n inputAmount,\n \"\"\n );\n\n FundManagement memory funds = FundManagement(\n address(this),\n false, // fromInternalBalance\n payable(address(this)),\n false // toInternalBalance\n );\n\n inputToken.approve(address(vault), inputAmount);\n vault.swap(singleSwap, funds, 0, block.timestamp + 10);\n outputAmount = IERC20Upgradeable(outputTokenAddress).balanceOf(address(this));\n return (IERC20Upgradeable(outputTokenAddress), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveLpTokenLiquidatorNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\nimport { WETH } from \"solmate/tokens/WETH.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLpTokenLiquidatorNoRegistry\n * @notice Redeems seized Curve LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLpTokenLiquidatorNoRegistry is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // TODO get the curvePool from the strategyData instead of the _oracle\n (address outputTokenAddress, address payable wtoken, address _oracle) = abi.decode(\n strategyData,\n (address, address, address)\n );\n // the oracle contains the pool registry\n CurveLpTokenPriceOracleNoRegistry oracle = CurveLpTokenPriceOracleNoRegistry(_oracle);\n\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(oracle.poolOf(address(inputToken)));\n\n uint8 outputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (outputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == outputTokenAddress) outputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(outputIndex)), 1);\n\n // better safe than sorry\n if (outputTokenAddress == address(0) || outputTokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n WETH(wtoken).deposit{ value: address(this).balance }();\n outputToken = IERC20Upgradeable(wtoken);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n outputAmount = outputToken.balanceOf(address(this));\n\n return (outputToken, outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenLiquidatorNoRegistry\";\n }\n}\n\ncontract CurveLpTokenWrapper is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (ICurvePool curvePool, address _outputTokenAddress) = abi.decode(strategyData, (ICurvePool, address));\n outputToken = IERC20Upgradeable(_outputTokenAddress);\n\n uint8 inputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (inputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == address(inputToken)) inputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n inputToken.approve(address(curvePool), inputAmount);\n uint256[2] memory amounts;\n amounts[inputIndex] = inputAmount;\n curvePool.add_liquidity(amounts, 1);\n\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nimport \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\n/**\n * @title CurveSwapLiquidator\n * @notice Swaps seized token collateral via Curve as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable, uint256) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address outputTokenAddress,\n address _unwrappedInput,\n address _unwrappedOutput\n ) = abi.decode(strategyData, (CurveV2LpTokenPriceOracleNoRegistry, address, address, address));\n\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n address inputTokenAddress = address(inputToken);\n\n ICurvePool curvePool;\n int128 i;\n int128 j;\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, address(outputToken));\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n inputToken.approve(address(curvePool), inputAmount);\n outputAmount = curvePool.exchange(i, j, inputAmount, 0);\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(outputTokenAddress), outputAmount);\n IERC4626(outputTokenAddress).deposit(outputAmount, address(this));\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n outputAmount = outputToken.balanceOf(address(this));\n return (outputToken, outputAmount);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"CurveSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/IFundsConversionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFundsConversionStrategy is IRedemptionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\n}\n" + }, + "contracts/liquidators/IRedemptionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\n/**\n * @title IRedemptionStrategy\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function name() external view returns (string memory);\n}\n" + }, + "contracts/liquidators/JarvisLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { ISynthereumLiquidityPool } from \"../external/jarvis/ISynthereumLiquidityPool.sol\";\n\ncontract JarvisLiquidatorFunder is IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n\n // approve so the pool can pull out the input tokens\n inputToken.approve(address(pool), inputAmount);\n\n IERC20Upgradeable collateralToken = pool.collateralToken();\n IERC20Upgradeable syntheticToken = pool.syntheticToken();\n\n if (inputToken == syntheticToken) {\n outputToken = collateralToken;\n\n uint256 shutdownPrice = 0;\n // TODO figure out why this method was removed and what to use instead\n try pool.emergencyShutdownPrice() returns (uint256 price) {\n shutdownPrice = price;\n } catch {}\n\n if (shutdownPrice > 0) {\n // emergency shutdowns cannot be reverted, so this corner case must be covered\n (, uint256 collateralSettled) = pool.settleEmergencyShutdown();\n outputAmount = collateralSettled;\n // outputToken = collateralToken;\n } else {\n // redeem the underlying BUSD\n // fetch the estimated redeemable collateral in BUSD, less the fee paid\n (uint256 redeemableCollateralAmount, ) = pool.getRedeemTradeInfo(inputAmount);\n\n (uint256 collateralAmountReceived, ) = pool.redeem(\n ISynthereumLiquidityPool.RedeemParams(inputAmount, redeemableCollateralAmount, block.timestamp, address(this))\n );\n\n outputAmount = collateralAmountReceived;\n }\n } else if (inputToken == collateralToken) {\n outputToken = syntheticToken;\n\n // mint jBRL from the supplied bUSD\n (uint256 synthTokensReceived, ) = pool.getMintTradeInfo(inputAmount);\n\n (uint256 syntheticTokensMinted, ) = pool.mint(\n ISynthereumLiquidityPool.MintParams(synthTokensReceived, inputAmount, block.timestamp, address(this))\n );\n\n outputAmount = syntheticTokensMinted;\n } else {\n revert(\"unknown input token\");\n }\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address inputTokenAddress, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n\n inputToken = IERC20Upgradeable(inputTokenAddress);\n\n uint8 decimals = 18;\n try IERC20MetadataUpgradeable(inputTokenAddress).decimals() returns (uint8 dec) {\n decimals = dec;\n } catch {}\n uint256 ONE = 10**decimals;\n\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n if (inputToken == pool.syntheticToken()) {\n // collateralAmountReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / collateralAmountReceived\n (uint256 collateralAmountReceived, ) = ISynthereumLiquidityPool(poolAddress).getRedeemTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, collateralAmountReceived);\n } else if (inputToken == pool.collateralToken()) {\n // synthTokensReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / synthTokensReceived\n (uint256 synthTokensReceived, ) = ISynthereumLiquidityPool(poolAddress).getMintTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, synthTokensReceived);\n } else {\n revert(\"unknown input token\");\n }\n }\n\n function name() public pure returns (string memory) {\n return \"JarvisLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/registry/ILiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILiquidatorsRegistryStorage {\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\n\n function redemptionStrategiesByTokens(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy);\n\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\n\n function owner() external view returns (address);\n\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\n\n function customUniV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (address);\n}\n\ninterface ILiquidatorsRegistryExtension {\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\n\n function getAllRedemptionStrategies() external view returns (address[] memory);\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage);\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256);\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage);\n}\n\ninterface ILiquidatorsRegistrySecondExtension {\n function getAllPairsStrategies()\n external\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n );\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool);\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool);\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool);\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external;\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external;\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external;\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external;\n\n function optimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IERC20Upgradeable[] memory);\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external;\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\n}\n\ninterface ILiquidatorsRegistry is\n ILiquidatorsRegistryExtension,\n ILiquidatorsRegistrySecondExtension,\n ILiquidatorsRegistryStorage\n{}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\nimport \"./LiquidatorsRegistryExtension.sol\";\n\ncontract LiquidatorsRegistry is LiquidatorsRegistryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n constructor(AddressesProvider _ap) SafeOwnable() {\n ap = _ap;\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function asExtension() public view returns (LiquidatorsRegistryExtension) {\n return LiquidatorsRegistryExtension(address(this));\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../IRedemptionStrategy.sol\";\nimport \"../../ionic/DiamondExtension.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \"../../external/aerodrome/IAerodromeRouter.sol\";\nimport { IRouter_Velodrome as IVelodromeV2Router } from \"../../external/velodrome/IVelodromeRouter.sol\";\nimport { IRouter } from \"../../external/solidly/IRouter.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error NoRedemptionPath();\n error OutputTokenMismatch();\n\n event SlippageUpdated(\n IERC20Upgradeable indexed from,\n IERC20Upgradeable indexed to,\n uint256 prevValue,\n uint256 newValue\n );\n\n // @notice maximum slippage in swaps, in bps\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 7;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\n functionSelectors[--fnsCount] = this.swap.selector;\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\n functionSelectors[--fnsCount] = this.getSlippage.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage) {\n slippage = conversionSlippage[inputToken][outputToken];\n // TODO slippage == 0 should be allowed\n if (slippage == 0) return MAX_SLIPPAGE;\n }\n\n function getAllRedemptionStrategies() public view returns (address[] memory) {\n return redemptionStrategies.values();\n }\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage) {\n if (inputAmount == 0) return (0, 0);\n\n outputAmount = swap(inputToken, inputAmount, outputToken);\n if (outputAmount == 0) return (0, 0);\n\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n uint256 inputTokenPrice = mpo.price(address(inputToken));\n uint256 outputTokenPrice = mpo.price(address(outputToken));\n\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\n\n if (outputTokensValue < inputTokensValue) {\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\n }\n // min slippage should be non-zero\n // just in case of rounding errors\n slippage += 1;\n\n // cache the slippage\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\n\n conversionSlippage[inputToken][outputToken] = slippage;\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\n }\n }\n\n /// @dev returns price scaled to 1e36 - decimals\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\n return\n tokenDecimals <= 18\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\n }\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) public returns (uint256 outputAmount) {\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\n outputAmount = convertAllTo(inputToken, outputToken);\n outputToken.safeTransfer(msg.sender, outputAmount);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\n inputToken,\n outputToken\n );\n\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\n\n IERC20Upgradeable swapInputToken = inputToken;\n uint256 swapInputAmount = inputAmount;\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\n swapInputToken,\n swapInputAmount,\n redemptionStrategy,\n strategyData\n );\n swapInputAmount = swapOutputAmount;\n swapInputToken = swapOutputToken;\n }\n\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\n return outputToken.balanceOf(address(this));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\n return inputTokensByOutputToken[outputToken].values();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n IERC20Upgradeable tokenToRedeem = inputToken;\n IERC20Upgradeable targetOutputToken = outputToken;\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\n bytes[] memory strategiesDataTemp = new bytes[](10);\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\n uint256 optimalPathIterator = 0;\n\n uint256 k = 0;\n while (tokenToRedeem != targetOutputToken) {\n IERC20Upgradeable nextRedeemedToken;\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\n if (address(directStrategy) != address(0)) {\n nextRedeemedToken = targetOutputToken;\n } else {\n // check if an optimal path is preconfigured\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\n }\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\n nextRedeemedToken = optimalPath[optimalPathIterator++];\n } else {\n // else if no optimal path is available, use the default\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\n }\n }\n\n // check if going in an endless loop\n for (uint256 i = 0; i < tokenPath.length; i++) {\n if (nextRedeemedToken == tokenPath[i]) break;\n }\n\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\n tokenToRedeem,\n nextRedeemedToken\n );\n if (address(strategy) == address(0)) break;\n\n strategiesTemp[k] = strategy;\n strategiesDataTemp[k] = strategyData;\n tokenPath[k] = nextRedeemedToken;\n tokenToRedeem = nextRedeemedToken;\n\n k++;\n if (k == 10) break;\n }\n\n strategies = new IRedemptionStrategy[](k);\n strategiesData = new bytes[](k);\n\n for (uint8 i = 0; i < k; i++) {\n strategies[i] = strategiesTemp[i];\n strategiesData[i] = strategiesDataTemp[i];\n }\n }\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\n\n if (isStrategy(strategy, \"UniswapV2LiquidatorFunder\") || isStrategy(strategy, \"KimUniV2Liquidator\")) {\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"UniswapV3LiquidatorFunder\")) {\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AlgebraSwapLiquidator\")) {\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeV2Liquidator\")) {\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeCLLiquidator\")) {\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"CurveSwapLiquidator\")) {\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"VelodromeV2Liquidator\")) {\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\n } else {\n revert(\"no strategy data\");\n }\n }\n\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\n }\n\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\n }\n address wnative = ap.getAddress(\"wtoken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wnative) return wnative;\n }\n address stableToken = ap.getAddress(\"stableToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == stableToken) return stableToken;\n }\n address wbtc = ap.getAddress(\"wBTCToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wbtc) return wbtc;\n }\n return tokens[0];\n }\n\n function getUniswapV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (address) {\n address customRouter = customUniV3Router[inputToken][outputToken];\n if (customRouter == address(0)) {\n customRouter = customUniV3Router[outputToken][inputToken];\n }\n\n if (customRouter != address(0)) {\n return customRouter;\n } else {\n // get asset specific router or default\n return ap.getAddress(\"UNISWAP_V3_ROUTER\");\n }\n }\n\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"IUniswapV2Router02\");\n }\n\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_V2_ROUTER\");\n }\n\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_CL_ROUTER\");\n }\n\n function uniswapV3LiquidatorFunderData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\n if (fee == 0) fee = 500;\n\n address router = getUniswapV3Router(inputToken, outputToken);\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\"Quoter\"));\n }\n\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\n return _wrappedToUnwrapped4626[address(inputToken)];\n }\n\n function getAeroCLTickSpacing(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (int24) {\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\n if (tickSpacing == 0) {\n tickSpacing = 1;\n }\n return tickSpacing;\n }\n\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\n }\n\n function uniswapV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\n swapPath[0] = inputToken;\n swapPath[1] = outputToken;\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\n }\n\n function aerodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\n swapPath[0] = IAerodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken),\n factory: ap.getAddress(\"AERODROME_V2_FACTORY\")\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n\n function aerodromeCLLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n inputToken,\n outputToken,\n getAerodromeCLRouter(inputToken),\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken),\n getAeroCLTickSpacing(inputToken, outputToken)\n );\n }\n\n function algebraSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(outputToken, ap.getAddress(\"ALGEBRA_SWAP_ROUTER\"));\n }\n\n function curveSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n ap.getAddress(\"CURVE_V2_ORACLE_NO_REGISTRY\"),\n outputToken,\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken)\n );\n }\n\n function velodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\n swapPath[0] = IVelodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken)\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../../ionic/DiamondExtension.sol\";\n\ncontract LiquidatorsRegistrySecondExtension is\n LiquidatorsRegistryStorage,\n DiamondExtension,\n ILiquidatorsRegistrySecondExtension\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 20;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getAllPairsStrategies.selector;\n functionSelectors[--fnsCount] = this.pairsStrategiesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsFeesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsRoutersMatch.selector;\n functionSelectors[--fnsCount] = this._setSlippages.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Fees.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Routers.selector;\n functionSelectors[--fnsCount] = this._setDefaultOutputToken.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this._removeRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._resetRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.optimalSwapPath.selector;\n functionSelectors[--fnsCount] = this._setOptimalSwapPath.selector;\n functionSelectors[--fnsCount] = this.wrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this.aeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this.aeroV2IsStable.selector;\n functionSelectors[--fnsCount] = this._setWrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this._setAeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this._setAeroV2IsStable.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external onlyOwner {\n require(slippages.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < slippages.length; i++) {\n conversionSlippage[inputTokens[i]][outputTokens[i]] = slippages[i];\n }\n }\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external onlyOwner {\n require(fees.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < fees.length; i++) {\n uniswapV3Fees[inputTokens[i]][outputTokens[i]] = fees[i];\n }\n }\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external onlyOwner {\n require(routers.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < routers.length; i++) {\n customUniV3Router[inputTokens[i]][outputTokens[i]] = routers[i];\n }\n }\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external onlyOwner {\n defaultOutputToken[inputToken] = outputToken;\n }\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public onlyOwner {\n string memory name = strategy.name();\n IRedemptionStrategy oldStrategy = redemptionStrategiesByName[name];\n\n redemptionStrategiesByTokens[inputToken][outputToken] = strategy;\n redemptionStrategiesByName[name] = strategy;\n\n redemptionStrategies.remove(address(oldStrategy));\n redemptionStrategies.add(address(strategy));\n\n if (defaultOutputToken[inputToken] == IERC20Upgradeable(address(0))) {\n defaultOutputToken[inputToken] = outputToken;\n }\n inputTokensByOutputToken[outputToken].add(address(inputToken));\n outputTokensSet.add(address(outputToken));\n }\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n // empty the input/output token mappings/sets\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n outputTokensSet.remove(_outputTokens[i]);\n }\n\n // empty the strategies mappings/sets\n address[] memory _currentStrategies = redemptionStrategies.values();\n for (uint256 i = 0; i < _currentStrategies.length; i++) {\n IRedemptionStrategy _currentStrategy = IRedemptionStrategy(_currentStrategies[i]);\n string memory _name = _currentStrategy.name();\n redemptionStrategiesByName[_name] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(_currentStrategies[i]);\n }\n\n // write the new strategies and their tokens configs\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external onlyOwner {\n // check all the input/output tokens if they match the strategy to remove\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n IRedemptionStrategy _currentStrategy = redemptionStrategiesByTokens[_inputToken][_outputToken];\n\n // only nullify the input/output tokens config if the strategy matches\n if (_currentStrategy == strategyToRemove) {\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n if (defaultOutputToken[_inputToken] == _outputToken) {\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n }\n }\n if (inputTokensByOutputToken[_outputToken].length() == 0) {\n outputTokensSet.remove(address(_outputToken));\n }\n }\n\n redemptionStrategiesByName[strategyToRemove.name()] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(address(strategyToRemove));\n }\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool) {\n // find a match for each config fee\n for (uint256 i = 0; i < configFees.length; i++) {\n if (uniswapV3Fees[configInputTokens[i]][configOutputTokens[i]] != configFees[i]) return false;\n }\n\n return true;\n }\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool) {\n // find a match for each config router\n for (uint256 i = 0; i < configRouters.length; i++) {\n if (customUniV3Router[configInputTokens[i]][configOutputTokens[i]] != configRouters[i]) return false;\n }\n\n return true;\n }\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool) {\n (\n IRedemptionStrategy[] memory onChainStrategies,\n IERC20Upgradeable[] memory onChainInputTokens,\n IERC20Upgradeable[] memory onChainOutputTokens\n ) = getAllPairsStrategies();\n // find a match for each config strategy\n for (uint256 i = 0; i < configStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < onChainStrategies.length; j++) {\n if (\n onChainStrategies[j] == configStrategies[i] &&\n onChainInputTokens[j] == configInputTokens[i] &&\n onChainOutputTokens[j] == configOutputTokens[i]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n // find a match for each on-chain strategy\n for (uint256 i = 0; i < onChainStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < configStrategies.length; j++) {\n if (\n onChainStrategies[i] == configStrategies[j] &&\n onChainInputTokens[i] == configInputTokens[j] &&\n onChainOutputTokens[i] == configOutputTokens[j]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n return true;\n }\n\n function getAllPairsStrategies()\n public\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n )\n {\n address[] memory _outputTokens = outputTokensSet.values();\n uint256 pairsCounter = 0;\n\n {\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n pairsCounter += _inputTokens.length;\n }\n\n strategies = new IRedemptionStrategy[](pairsCounter);\n inputTokens = new IERC20Upgradeable[](pairsCounter);\n outputTokens = new IERC20Upgradeable[](pairsCounter);\n }\n\n pairsCounter = 0;\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n strategies[pairsCounter] = redemptionStrategiesByTokens[_inputToken][_outputToken];\n inputTokens[pairsCounter] = _inputToken;\n outputTokens[pairsCounter] = _outputToken;\n pairsCounter++;\n }\n }\n }\n\n function optimalSwapPath(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IERC20Upgradeable[] memory)\n {\n return _optimalSwapPath[inputToken][outputToken];\n }\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external onlyOwner {\n _optimalSwapPath[inputToken][outputToken] = optimalPath;\n }\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address) {\n return _wrappedToUnwrapped4626[wrapped];\n }\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24) {\n return _aeroCLTickSpacings[inputToken][outputToken];\n }\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool) {\n return _aeroV2IsStable[inputToken][outputToken];\n }\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external onlyOwner {\n _wrappedToUnwrapped4626[wrapped] = unwrapped;\n }\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external onlyOwner {\n _aeroCLTickSpacings[inputToken][outputToken] = tickSpacing;\n }\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external onlyOwner {\n _aeroV2IsStable[inputToken][outputToken] = isStable;\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../IRedemptionStrategy.sol\";\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\n AddressesProvider public ap;\n\n EnumerableSet.AddressSet internal redemptionStrategies;\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\n EnumerableSet.AddressSet internal outputTokensSet;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\n mapping(address => address) internal _wrappedToUnwrapped4626;\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\n}\n" + }, + "contracts/liquidators/SolidlyLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/solidly/IRouter.sol\";\nimport \"../external/solidly/IPair.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlyLpTokenLiquidator\n * @notice Exchanges seized Solidly LP token collateral for underlying tokens for use as a step in a liquidation.\n */\ncontract SolidlyLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) internal {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Uniswap pool\n IPair pair = IPair(address(inputToken));\n bool stable = pair.stable();\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n pair.transfer(address(pair), inputAmount);\n (uint256 amount0, uint256 amount1) = pair.burn(address(this));\n\n // Swap underlying tokens\n (IRouter solidlyRouter, address tokenTo) = abi.decode(strategyData, (IRouter, address));\n\n if (tokenTo != token0) {\n safeApprove(IERC20Upgradeable(token0), address(solidlyRouter), amount0);\n solidlyRouter.swapExactTokensForTokensSimple(amount0, 0, token0, tokenTo, stable, address(this), block.timestamp);\n } else {\n safeApprove(IERC20Upgradeable(token1), address(solidlyRouter), amount1);\n solidlyRouter.swapExactTokensForTokensSimple(amount1, 0, token1, tokenTo, stable, address(this), block.timestamp);\n }\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenLiquidator\";\n }\n}\n\ncontract SolidlyLpTokenWrapper is IRedemptionStrategy {\n struct WrapSolidlyLpTokenVars {\n uint256 amountToSwapOfToken0ForToken1;\n uint256 amountToSwapOfToken1ForToken0;\n IRouter solidlyRouter;\n IERC20Upgradeable token0;\n IERC20Upgradeable token1;\n bool stable;\n IPair pair;\n IRouter.Route[] swapPath0;\n IRouter.Route[] swapPath1;\n uint256 ratio;\n }\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n WrapSolidlyLpTokenVars memory vars;\n (vars.solidlyRouter, vars.pair, vars.swapPath0, vars.swapPath1) = abi.decode(\n strategyData,\n (IRouter, IPair, IRouter.Route[], IRouter.Route[])\n );\n vars.token0 = IERC20Upgradeable(vars.pair.token0());\n vars.token1 = IERC20Upgradeable(vars.pair.token1());\n vars.stable = vars.pair.stable();\n\n // calculate the amount for token0 or token1 that needs to be swapped for the other\n {\n vars.amountToSwapOfToken1ForToken0 = inputAmount / 2;\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n if (vars.token0 == inputToken) {\n uint256 out1 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken0ForToken1, vars.swapPath0)[\n vars.swapPath0.length\n ];\n // price1For0 is scaled to 18 + token1.decimals - token0.decimals\n uint256 price1For0 = (out1 * 1e18) / vars.amountToSwapOfToken0ForToken1;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n vars.amountToSwapOfToken1ForToken0,\n out1\n );\n\n vars.ratio = (amount1 * 1e36) / (amount0 * price1For0);\n }\n\n if (vars.token1 == inputToken) {\n uint256 out0 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken1ForToken0, vars.swapPath1)[\n vars.swapPath1.length\n ];\n // price0For1 is scaled to 18 + token0.decimals - token1.decimals\n uint256 price0For1 = (out0 * 1e18) / vars.amountToSwapOfToken1ForToken0;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n out0,\n vars.amountToSwapOfToken0ForToken1\n );\n\n vars.ratio = (amount1 * price0For1) / amount0;\n }\n\n // recalculate the amounts to swap based on the ratio of the value of the required input amounts\n vars.amountToSwapOfToken1ForToken0 = (inputAmount * 1e18) / (vars.ratio + 1e18);\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n }\n\n // swap a part of the input token amount for the other token\n if (vars.token0 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken0ForToken1);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken0ForToken1,\n 0,\n vars.swapPath0,\n address(this),\n block.timestamp\n );\n }\n if (vars.token1 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken1ForToken0);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken1ForToken0,\n 0,\n vars.swapPath1,\n address(this),\n block.timestamp\n );\n }\n\n // provide the liquidity\n uint256 token0Balance = vars.token0.balanceOf(address(this));\n uint256 token1Balance = vars.token1.balanceOf(address(this));\n\n vars.token0.approve(address(vars.solidlyRouter), token0Balance);\n vars.token1.approve(address(vars.solidlyRouter), token1Balance);\n vars.solidlyRouter.addLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n token0Balance,\n token1Balance,\n 1,\n 1,\n address(this),\n block.timestamp\n );\n\n outputToken = IERC20Upgradeable(address(vars.pair));\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/SolidlySwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { IRouter } from \"../external/solidly/IRouter.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlySwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Solidly router for use as a step in a liquidation.\n */\ncontract SolidlySwapLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Solidly router and path\n (IRouter solidlyRouter, address tokenTo, bool stable) = abi.decode(strategyData, (IRouter, address, bool));\n\n // Swap underlying tokens\n inputToken.approve(address(solidlyRouter), inputAmount);\n solidlyRouter.swapExactTokensForTokensSimple(\n inputAmount,\n 0,\n address(inputToken),\n tokenTo,\n stable,\n address(this),\n block.timestamp\n );\n\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlySwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { IV3SwapRouter } from \"../external/uniswap/IV3SwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract UniswapV3Liquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address _outputToken, uint24 fee, IV3SwapRouter swapRouter, ) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, address)\n );\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n IV3SwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n fee,\n address(this),\n inputAmount,\n 0,\n 0\n )\n );\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"UniswapV3Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport \"./UniswapV3Liquidator.sol\";\n\nimport { Quoter } from \"../external/uniswap/quoter/Quoter.sol\";\n\ncontract UniswapV3LiquidatorFunder is UniswapV3Liquidator, IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address _inputToken, address _outputToken, uint24 fee, , Quoter quoter) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, Quoter)\n );\n\n inputAmount = quoter.estimateMinSwapUniswapV3(_inputToken, _outputToken, outputAmount, fee);\n inputToken = IERC20Upgradeable(_inputToken);\n }\n\n function name() public pure override(UniswapV3Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV3LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/VelodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\n\n/**\n * @title VelodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Velodrome V2 router for use as a step in a liquidation.\n */\ncontract VelodromeV2Liquidator {\n function _swap(IRouter_Velodrome router, uint256 inputAmount, IRouter_Velodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"VelodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Velodrome router, IRouter_Velodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Velodrome, IRouter_Velodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid VelodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/oracles/BasePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../compound/CTokenInterfaces.sol\";\n\n/**\n * @title BasePriceOracle\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\n * @dev Implements the `PriceOracle` interface.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface BasePriceOracle {\n /**\n * @notice Get the price of an underlying asset.\n * @param underlying The underlying asset to get the price of.\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function price(address underlying) external view returns (uint256);\n\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\n}\n" + }, + "contracts/oracles/default/CurveLpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/curve/ICurvePool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracleNoRegistry\n * @author David Lucid (https://github.com/davidlucid)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract CurveLpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Curve LP token addresses to underlying token addresses.\n */\n mapping(address => address[]) public underlyingTokens;\n\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n * @param _poolUnderlyings The underlying token addresses of a pool\n */\n function initialize(\n address[] memory _lpTokens,\n address[] memory _pools,\n address[][] memory _poolUnderlyings\n ) public initializer {\n require(\n _lpTokens.length == _pools.length && _lpTokens.length == _poolUnderlyings.length,\n \"No LP tokens supplied or array lengths not equal.\"\n );\n\n __SafeOwnable_init(msg.sender);\n for (uint256 i = 0; i < _lpTokens.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n underlyingTokens[_lpTokens[i]] = _poolUnderlyings[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), 0, 0);\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Curve, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/CurveOracle.sol\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(pool != address(0), \"LP token is not registered.\");\n address[] memory tokens = underlyingTokens[lpToken];\n uint256 minPx = type(uint256).max;\n uint256 n = tokens.length;\n\n for (uint256 i = 0; i < n; i++) {\n address ulToken = tokens[i];\n uint256 tokenPx = BasePriceOracle(msg.sender).price(ulToken);\n if (tokenPx < minPx) minPx = tokenPx;\n }\n\n require(minPx != type(uint256).max, \"No minimum underlying token price found.\");\n return (minPx * ICurvePool(pool).get_virtual_price()) / 1e18; // Use min underlying token prices\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n * @param _underlyings Underlying addresses.\n */\n function registerPool(\n address _lpToken,\n address _pool,\n address[] memory _underlyings\n ) external onlyOwner {\n poolOf[_lpToken] = _pool;\n underlyingTokens[_lpToken] = _underlyings;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n\n /**\n * @dev getter for the underlying tokens\n * @param lpToken the LP token address.\n * @return _underlyings Underlying addresses.\n */\n function getUnderlyingTokens(address lpToken) public view returns (address[] memory) {\n return underlyingTokens[lpToken];\n }\n}\n" + }, + "contracts/oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\nimport \"../../external/curve/ICurveV2Pool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve V2 LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract CurveV2LpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n address public usdToken;\n MasterPriceOracle public masterPriceOracle;\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n */\n function initialize(address[] memory _lpTokens, address[] memory _pools) public initializer {\n require(_lpTokens.length == _pools.length, \"No LP tokens supplied or array lengths not equal.\");\n __SafeOwnable_init(msg.sender);\n\n for (uint256 i = 0; i < _pools.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), int128(0), int128(0));\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token price from Curve, with 18 decimals of precision.\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(address(pool) != address(0), \"LP token is not registered.\");\n\n address baseToken = ICurvePool(pool).coins(0);\n uint256 lpPrice = ICurveV2Pool(pool).lp_price();\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n return (lpPrice * baseTokenPrice) / 10**18;\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n */\n function registerPool(address _lpToken, address _pool) external onlyOwner {\n address pool = poolOf[_lpToken];\n require(pool == address(0), \"This LP token is already registered.\");\n poolOf[_lpToken] = _pool;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracle is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWeETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWeETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A) {\n underlying = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWrsETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWrsETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd) {\n underlying = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/VelodromePriceOracleFraxtal.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ninterface Prices {\n function getRate(address srcToken, address dstToken, bool useSrcWrappers) external view returns (uint256 weightedRate);\n}\n\ncontract VelodromePriceOracleFraxtal is BasePriceOracle {\n Prices immutable prices;\n\n constructor(address _prices) {\n prices = Prices(_prices);\n }\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n return prices.getRate(token, 0xFC00000000000000000000000000000000000006, false);\n }\n}\n" + }, + "contracts/oracles/MasterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BasePriceOracle } from \"./BasePriceOracle.sol\";\n\n/**\n * @title MasterPriceOracle\n * @notice Use a combination of price oracles.\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public oracles;\n\n /**\n * @dev Default/fallback `PriceOracle`.\n */\n BasePriceOracle public defaultOracle;\n\n /**\n * @dev The administrator of this `MasterPriceOracle`.\n */\n address public admin;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool internal noAdminOverwrite;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public wtoken;\n\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public fallbackOracles;\n\n /**\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n function canAdminOverwrite() external view returns (bool) {\n return !noAdminOverwrite;\n }\n\n /**\n * @dev Event emitted when `admin` is changed.\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @dev Event emitted when the default oracle is changed.\n */\n event NewDefaultOracle(address oldOracle, address newOracle);\n\n /**\n * @dev Event emitted when an underlying token's oracle is changed.\n */\n event NewOracle(address underlying, address oldOracle, address newOracle);\n\n /**\n * @dev Initialize state variables.\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\n * @param _defaultOracle The default `PriceOracle` contract to use.\n * @param _admin The admin who can assign oracles to underlying tokens.\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n * @param _wtoken The Wrapped native asset address\n */\n function initialize(\n address[] memory underlyings,\n BasePriceOracle[] memory _oracles,\n BasePriceOracle _defaultOracle,\n address _admin,\n bool _canAdminOverwrite,\n address _wtoken\n ) external initializer {\n // Input validation\n require(underlyings.length == _oracles.length, \"Lengths of both arrays must be equal.\");\n\n // Initialize state variables\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, address(0), address(newOracle));\n }\n\n defaultOracle = _defaultOracle;\n admin = _admin;\n noAdminOverwrite = !_canAdminOverwrite;\n wtoken = _wtoken;\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(oracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(fallbackOracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n fallbackOracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Changes the default price oracle\n */\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\n BasePriceOracle oldOracle = defaultOracle;\n defaultOracle = newOracle;\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\n }\n\n /**\n * @dev Changes the admin and emits an event.\n */\n function changeAdmin(address newAdmin) external onlyAdmin {\n address oldAdmin = admin;\n admin = newAdmin;\n emit NewAdmin(oldAdmin, newAdmin);\n }\n\n /**\n * @dev Modifier that checks if `msg.sender == admin`.\n */\n modifier onlyAdmin() {\n require(msg.sender == admin, \"Sender is not the admin.\");\n _;\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = address(ICErc20(address(cToken)).underlying());\n\n if (underlying == wtoken) return 1e18;\n\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n\n /**\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) public view override returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == wtoken) return 1e18;\n\n // Get underlying price from assigned oracle\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n}\n" + }, + "contracts/PoolDirectory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./compound/Unitroller.sol\";\nimport \"./ionic/SafeOwnableUpgradeable.sol\";\nimport \"./ionic/DiamondExtension.sol\";\n\n/**\n * @title PoolDirectory\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\n */\ncontract PoolDirectory is SafeOwnableUpgradeable {\n /**\n * @dev Initializes a deployer whitelist if desired.\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\n */\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\n __SafeOwnable_init(msg.sender);\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\n }\n\n /**\n * @dev Struct for a Ionic interest rate pool.\n */\n struct Pool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n /**\n * @dev Array of Ionic interest rate pools.\n */\n Pool[] public pools;\n\n /**\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\n */\n mapping(address => uint256[]) private _poolsByAccount;\n\n /**\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\n */\n mapping(address => bool) public poolExists;\n\n /**\n * @dev Emitted when a new Ionic pool is added to the directory.\n */\n event PoolRegistered(uint256 index, Pool pool);\n\n /**\n * @dev Booleans indicating if the deployer whitelist is enforced.\n */\n bool public enforceDeployerWhitelist;\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\n */\n mapping(address => bool) public deployerWhitelist;\n\n /**\n * @dev Controls if the deployer whitelist is to be enforced.\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\n */\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\n enforceDeployerWhitelist = enforce;\n }\n\n /**\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\n * @param deployers Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\n require(deployers.length > 0, \"No deployers supplied.\");\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\n }\n\n /**\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\n * @param name The name of the pool.\n * @param comptroller The pool's Comptroller proxy contract address.\n * @return The index of the registered Ionic pool.\n */\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\n require(!poolExists[comptroller], \"Pool already exists in the directory.\");\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \"Sender is not on deployer whitelist.\");\n require(bytes(name).length <= 100, \"No pool name supplied.\");\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\n pools.push(pool);\n _poolsByAccount[msg.sender].push(pools.length - 1);\n poolExists[comptroller] = true;\n emit PoolRegistered(pools.length - 1, pool);\n return pools.length - 1;\n }\n\n function _deprecatePool(address comptroller) external onlyOwner {\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller == comptroller) {\n _deprecatePool(i);\n break;\n }\n }\n }\n\n function _deprecatePool(uint256 index) public onlyOwner {\n Pool storage ionicPool = pools[index];\n\n require(ionicPool.comptroller != address(0), \"pool already deprecated\");\n\n // swap with the last pool of the creator and delete\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\n for (uint256 i = 0; i < creatorPools.length; i++) {\n if (creatorPools[i] == index) {\n creatorPools[i] = creatorPools[creatorPools.length - 1];\n creatorPools.pop();\n break;\n }\n }\n\n // leave it to true to deny the re-registering of the same pool\n poolExists[ionicPool.comptroller] = true;\n\n // nullify the storage\n ionicPool.comptroller = address(0);\n ionicPool.creator = address(0);\n ionicPool.name = \"\";\n ionicPool.blockPosted = 0;\n ionicPool.timestampPosted = 0;\n }\n\n /**\n * @dev Deploys a new Ionic pool and adds to the directory.\n * @param name The name of the pool.\n * @param implementation The Comptroller implementation contract address.\n * @param constructorData Encoded construction data for `Unitroller constructor()`\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\n * @param closeFactor The pool's close factor (scaled by 1e18).\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\n * @param priceOracle The pool's PriceOracle contract address.\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\n */\n function deployPool(\n string memory name,\n address implementation,\n bytes calldata constructorData,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive,\n address priceOracle\n ) external returns (uint256, address) {\n // Input validation\n require(implementation != address(0), \"No Comptroller implementation contract address specified.\");\n require(priceOracle != address(0), \"No PriceOracle contract address specified.\");\n\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(\n 0,\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\n unitrollerCreationCode\n );\n\n // Setup the pool\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\n // Set up the extensions\n comptrollerProxy._upgrade();\n\n // Set pool parameters\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \"Failed to set pool close factor.\");\n require(\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\n \"Failed to set pool liquidation incentive.\"\n );\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \"Failed to set pool price oracle.\");\n\n // Whitelist\n if (enforceWhitelist)\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \"Failed to enforce supplier/borrower whitelist.\");\n\n // Make msg.sender the admin\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \"Failed to set pending admin on Unitroller.\");\n\n // Register the pool with this PoolDirectory\n return (_registerPool(name, proxy), proxy);\n }\n\n /**\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory activePools = new Pool[](count);\n uint256[] memory poolIds = new uint256[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n poolIds[index] = i;\n activePools[index] = pools[i];\n index++;\n }\n }\n\n return (poolIds, activePools);\n }\n\n /**\n * @notice Returns arrays of all Ionic pools' data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getAllPools() public view returns (Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory result = new Pool[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n result[index++] = pools[i];\n }\n }\n\n return result;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n indexes[index] = i;\n poolsOfUser[index] = activePools[i];\n index++;\n }\n\n return (indexes, poolsOfUser);\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\n */\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\n (, Pool[] memory activePools) = getActivePools();\n\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\n indexes[i] = _poolsByAccount[account][i];\n accountPools[i] = activePools[_poolsByAccount[account][i]];\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Modify existing Ionic pool name.\n */\n function setPoolName(uint256 index, string calldata name) external {\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\n require(\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\n \"!permission\"\n );\n pools[index].name = name;\n }\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\n */\n mapping(address => bool) public adminWhitelist;\n\n /**\n * @dev used as salt for the creation of new pools\n */\n uint256 public poolsCounter;\n\n /**\n * @dev Event emitted when the admin whitelist is updated.\n */\n event AdminWhitelistUpdated(address[] admins, bool status);\n\n /**\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\n * @param admins Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\n require(admins.length > 0, \"No admins supplied.\");\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\n emit AdminWhitelistUpdated(admins, status);\n }\n\n /**\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getVerifiedPoolsOfWhitelistedAccount(address account)\n external\n view\n returns (uint256[] memory, Pool[] memory)\n {\n uint256 arrayLength = 0;\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n indexes[index] = i;\n accountWhitelistedPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, accountWhitelistedPools);\n }\n}\n" + }, + "contracts/PoolLens.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"./oracles/MasterPriceOracle.sol\";\n\n/**\n * @title PoolLens\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLens is Initializable {\n error ComptrollerError(uint256 errCode);\n\n /**\n * @notice Initialize the `PoolDirectory` contract object.\n * @param _directory The PoolDirectory\n * @param _name Name for the nativeToken\n * @param _symbol Symbol for the nativeToken\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\n * @param _hardcodedNames Harcoded name for these tokens\n * @param _hardcodedSymbols Harcoded symbol for these tokens\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\n */\n function initialize(\n PoolDirectory _directory,\n string memory _name,\n string memory _symbol,\n address[] memory _hardcodedAddresses,\n string[] memory _hardcodedNames,\n string[] memory _hardcodedSymbols,\n string[] memory _uniswapLPTokenNames,\n string[] memory _uniswapLPTokenSymbols,\n string[] memory _uniswapLPTokenDisplayNames\n ) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n require(\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\n \"Hardcoded addresses lengths not equal.\"\n );\n require(\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\n \"Uniswap LP token names lengths not equal.\"\n );\n\n directory = _directory;\n name = _name;\n symbol = _symbol;\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\n }\n\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\n uniswapData.push(\n UniswapData({\n name: _uniswapLPTokenNames[i],\n symbol: _uniswapLPTokenSymbols[i],\n displayName: _uniswapLPTokenDisplayNames[i]\n })\n );\n }\n }\n\n string public name;\n string public symbol;\n\n struct TokenData {\n string name;\n string symbol;\n }\n mapping(address => TokenData) hardcoded;\n\n struct UniswapData {\n string name; // ie \"Uniswap V2\" or \"SushiSwap LP Token\"\n string symbol; // ie \"UNI-V2\" or \"SLP\"\n string displayName; // ie \"SushiSwap\" or \"Uniswap\"\n }\n UniswapData[] uniswapData;\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @dev Struct for Ionic pool summary data.\n */\n struct IonicPoolData {\n uint256 totalSupply;\n uint256 totalBorrow;\n address[] underlyingTokens;\n string[] underlyingSymbols;\n bool whitelistedAdmin;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsWithData()\n external\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\n {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsByVerificationWithData(\n bool whitelistedAdmin\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\n whitelistedAdmin\n );\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsOIonicrWithData(\n address user\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\n return (indexes, userPools, data, errored);\n }\n\n /**\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\n bool[] memory errored = new bool[](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\n uint256 _totalSupply,\n uint256 _totalBorrow,\n address[] memory _underlyingTokens,\n string[] memory _underlyingSymbols,\n bool _whitelistedAdmin\n ) {\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\n } catch {\n errored[i] = true;\n }\n }\n\n return (data, errored);\n }\n\n /**\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\n */\n function getPoolSummary(\n IonicComptroller comptroller\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\n uint256 totalBorrow = 0;\n uint256 totalSupply = 0;\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n address[] memory underlyingTokens = new address[](cTokens.length);\n string[] memory underlyingSymbols = new string[](cTokens.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n cToken.accrueInterest();\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\n uint256 assetTotalSupply = cToken.getCash() +\n assetTotalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\n\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\n }\n\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\n }\n\n /**\n * @dev Struct for a Ionic pool asset.\n */\n struct PoolAsset {\n address cToken;\n address underlyingToken;\n string underlyingName;\n string underlyingSymbol;\n uint256 underlyingDecimals;\n uint256 underlyingBalance;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 totalSupply;\n uint256 totalBorrow;\n uint256 supplyBalance;\n uint256 borrowBalance;\n uint256 liquidity;\n bool membership;\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\n address oracle;\n uint256 collateralFactor;\n uint256 reserveFactor;\n uint256 adminFee;\n uint256 ionicFee;\n bool borrowGuardianPaused;\n bool mintGuardianPaused;\n }\n\n /**\n * @notice Returns data on the specified assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\n * @param cTokens The cToken contract addresses of the assets to query.\n * @param user The user for which to get account data.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(\n IonicComptroller comptroller,\n ICErc20[] memory cTokens,\n address user\n ) internal returns (PoolAsset[] memory) {\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\n if (isListed) arrayLength++;\n }\n\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\n uint256 index = 0;\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n // Check if market is listed and get collateral factor\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\n if (!isListed) continue;\n\n // Start adding data to PoolAsset\n PoolAsset memory asset;\n ICErc20 cToken = cTokens[i];\n asset.cToken = address(cToken);\n\n cToken.accrueInterest();\n\n // Get underlying asset data\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\n asset.underlyingDecimals = underlying.decimals();\n asset.underlyingBalance = underlying.balanceOf(user);\n\n // Get cToken data\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\n asset.liquidity = cToken.getCash();\n asset.totalBorrow = cToken.totalBorrowsCurrent();\n asset.totalSupply =\n asset.liquidity +\n asset.totalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\n asset.membership = comptroller.checkMembership(user, cToken);\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\n\n // Get oracle for this cToken\n asset.oracle = address(oracle);\n\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\n asset.oracle = address(_oracle);\n } catch {}\n\n // More cToken data\n asset.collateralFactor = collateralFactorMantissa;\n asset.reserveFactor = cToken.reserveFactorMantissa();\n asset.adminFee = cToken.adminFeeMantissa();\n asset.ionicFee = cToken.ionicFeeMantissa();\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\n\n // Add to assets array and increment index\n detailedAssets[index] = asset;\n index++;\n }\n\n return (detailedAssets);\n }\n\n function getBorrowCapsPerCollateral(\n ICErc20 borrowedAsset,\n IonicComptroller comptroller\n )\n internal\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsAgainstCollateral,\n bool[] memory borrowingBlacklistedAgainstCollateral\n )\n {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n collateral = new address[](poolMarkets.length);\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\n\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n address collateralAddress = address(poolMarkets[i]);\n if (collateralAddress != address(borrowedAsset)) {\n collateral[i] = collateralAddress;\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\n address(borrowedAsset),\n collateralAddress\n );\n }\n }\n }\n\n /**\n * @notice Returns the `name` and `symbol` of `token`.\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\n * @param token An ERC20 token contract object.\n * @return The `name` and `symbol`.\n */\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\n // i.e. MKR is a DSToken and uses bytes32\n if (bytes(hardcoded[token].symbol).length != 0) {\n return (hardcoded[token].name, hardcoded[token].symbol);\n }\n\n // Get name and symbol from token contract\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\n string memory _name = tokenContract.name();\n string memory _symbol = tokenContract.symbol();\n\n return (_name, _symbol);\n }\n\n /**\n * @notice Returns the assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\n }\n\n /**\n * @dev Struct for a Ionic pool user.\n */\n struct IonicPoolUser {\n address account;\n uint256 totalBorrow;\n uint256 totalCollateral;\n uint256 health;\n }\n\n /**\n * @notice Returns arrays of PoolAsset for a specific user\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\n return assets;\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n }\n\n return (assets, supplyCapsPerAsset);\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsDataForPool(\n IonicComptroller comptroller\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\n }\n\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\n }\n\n /**\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n }\n\n /**\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsDataForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap,\n uint256 nonWhitelistedTotalBorrows\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n uint256 totalBorrows = asset.totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\n * Note that the whitelist does not have to be enforced.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getWhitelistedPoolsByAccount(\n address account\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) {\n indexes[index] = i;\n accountPools[index] = pools[i];\n index++;\n break;\n }\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getWhitelistedPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\n }\n\n function getHealthFactorHypothetical(\n IonicComptroller pool,\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\n account,\n cTokenModify,\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n\n if (err != 0) revert ComptrollerError(err);\n\n if (shortfall > 0) {\n // HF < 1.0\n return (collateralValue * 1e18) / (collateralValue + shortfall);\n } else {\n // HF >= 1.0\n if (collateralValue <= liquidity) return type(uint256).max;\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\n }\n }\n}\n" + }, + "contracts/PoolLensSecondary.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"./external/uniswap/IUniswapV2Pair.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\n\ninterface IRewardsDistributor_PLS {\n function rewardToken() external view returns (address);\n\n function compSupplySpeeds(address) external view returns (uint256);\n\n function compBorrowSpeeds(address) external view returns (uint256);\n\n function compAccrued(address) external view returns (uint256);\n\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n}\n\n/**\n * @title PoolLensSecondary\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLensSecondary is Initializable {\n /**\n * @notice Constructor to set the `PoolDirectory` contract object.\n */\n function initialize(PoolDirectory _directory) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n directory = _directory;\n }\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @notice Struct for ownership over a CToken.\n */\n struct CTokenOwnership {\n address cToken;\n address admin;\n bool adminHasRights;\n bool ionicAdminHasRights;\n }\n\n /**\n * @notice Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolOwnership(IonicComptroller comptroller)\n external\n view\n returns (\n address,\n bool,\n bool,\n CTokenOwnership[] memory\n )\n {\n // Get pool ownership\n address comptrollerAdmin = comptroller.admin();\n bool comptrollerAdminHasRights = comptroller.adminHasRights();\n bool comptrollerIonicAdminHasRights = comptroller.ionicAdminHasRights();\n\n // Get cToken ownership\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) arrayLength++;\n }\n\n CTokenOwnership[] memory outliers = new CTokenOwnership[](arrayLength);\n uint256 arrayIndex = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array and increment array index\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) {\n outliers[arrayIndex] = CTokenOwnership(\n address(cToken),\n cTokenAdmin,\n cTokenAdminHasRights,\n cTokenIonicAdminHasRights\n );\n arrayIndex++;\n }\n }\n\n return (comptrollerAdmin, comptrollerAdminHasRights, comptrollerIonicAdminHasRights, outliers);\n }\n\n /**\n * @notice Determine the maximum redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum redeem amount.\n */\n function getMaxRedeem(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, false);\n }\n\n /**\n * @notice Determine the maximum borrow amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow amount.\n */\n function getMaxBorrow(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, true);\n }\n\n /**\n * @dev Internal function to determine the maximum borrow/redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow/redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow/redeem amount.\n */\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal returns (uint256) {\n IonicComptroller comptroller = IonicComptroller(cTokenModify.comptroller());\n return comptroller.getMaxRedeemOrBorrow(account, cTokenModify, isBorrow);\n }\n\n /**\n * @notice Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptroller The Ionic pool Comptroller to check.\n */\n function getRewardSpeedsByPool(IonicComptroller comptroller)\n public\n view\n returns (\n ICErc20[] memory,\n address[] memory,\n address[] memory,\n uint256[][] memory,\n uint256[][] memory\n )\n {\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n address[] memory distributors;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors = _distributors;\n } catch {\n distributors = new address[](0);\n }\n\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[][] memory supplySpeeds = new uint256[][](allMarkets.length);\n uint256[][] memory borrowSpeeds = new uint256[][](allMarkets.length);\n\n // Get reward tokens for each distributor\n for (uint256 i = 0; i < distributors.length; i++) {\n rewardTokens[i] = IRewardsDistributor_PLS(distributors[i]).rewardToken();\n }\n\n // Get reward speeds for each market for each distributor\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address cToken = address(allMarkets[i]);\n supplySpeeds[i] = new uint256[](distributors.length);\n borrowSpeeds[i] = new uint256[](distributors.length);\n\n for (uint256 j = 0; j < distributors.length; j++) {\n IRewardsDistributor_PLS distributor = IRewardsDistributor_PLS(distributors[j]);\n supplySpeeds[i][j] = distributor.compSupplySpeeds(cToken);\n borrowSpeeds[i][j] = distributor.compBorrowSpeeds(cToken);\n }\n }\n\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptrollers The Ionic pool Comptrollers to check.\n */\n function getRewardSpeedsByPools(IonicComptroller[] memory comptrollers)\n external\n view\n returns (\n ICErc20[][] memory,\n address[][] memory,\n address[][] memory,\n uint256[][][] memory,\n uint256[][][] memory\n )\n {\n ICErc20[][] memory allMarkets = new ICErc20[][](comptrollers.length);\n address[][] memory distributors = new address[][](comptrollers.length);\n address[][] memory rewardTokens = new address[][](comptrollers.length);\n uint256[][][] memory supplySpeeds = new uint256[][][](comptrollers.length);\n uint256[][][] memory borrowSpeeds = new uint256[][][](comptrollers.length);\n for (uint256 i = 0; i < comptrollers.length; i++)\n (allMarkets[i], distributors[i], rewardTokens[i], supplySpeeds[i], borrowSpeeds[i]) = getRewardSpeedsByPool(\n comptrollers[i]\n );\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice Returns unaccrued rewards by `holder` from `cToken` on `distributor`.\n * @param holder The address to check.\n * @param distributor The RewardsDistributor to check.\n * @param cToken The CToken to check.\n * @return Unaccrued (unclaimed) supply-side rewards and unaccrued (unclaimed) borrow-side rewards.\n */\n function getUnaccruedRewards(\n address holder,\n IRewardsDistributor_PLS distributor,\n ICErc20 cToken\n ) internal returns (uint256, uint256) {\n // Get unaccrued supply rewards\n uint256 compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreSupplierAction(address(cToken), holder);\n uint256 supplyRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Get unaccrued borrow rewards\n compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreBorrowerAction(address(cToken), holder);\n uint256 borrowRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Return both\n return (supplyRewardsUnaccrued, borrowRewardsUnaccrued);\n }\n\n /**\n * @notice Returns all unclaimed rewards accrued by the `holder` on `distributors`.\n * @param holder The address to check.\n * @param distributors The `RewardsDistributor` contracts to check.\n * @return For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\n */\n function getUnclaimedRewardsByDistributors(address holder, IRewardsDistributor_PLS[] memory distributors)\n external\n returns (\n address[] memory,\n uint256[] memory,\n ICErc20[][] memory,\n uint256[2][][] memory,\n uint256[] memory\n )\n {\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[] memory compUnclaimedTotal = new uint256[](distributors.length);\n ICErc20[][] memory allMarkets = new ICErc20[][](distributors.length);\n uint256[2][][] memory rewardsUnaccrued = new uint256[2][][](distributors.length);\n uint256[] memory distributorFunds = new uint256[](distributors.length);\n\n for (uint256 i = 0; i < distributors.length; i++) {\n IRewardsDistributor_PLS distributor = distributors[i];\n rewardTokens[i] = distributor.rewardToken();\n allMarkets[i] = distributor.getAllMarkets();\n rewardsUnaccrued[i] = new uint256[2][](allMarkets[i].length);\n for (uint256 j = 0; j < allMarkets[i].length; j++)\n (rewardsUnaccrued[i][j][0], rewardsUnaccrued[i][j][1]) = getUnaccruedRewards(\n holder,\n distributor,\n allMarkets[i][j]\n );\n compUnclaimedTotal[i] = distributor.compAccrued(holder);\n distributorFunds[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(distributor));\n }\n\n return (rewardTokens, compUnclaimedTotal, allMarkets, rewardsUnaccrued, distributorFunds);\n }\n\n /**\n * @notice Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getRewardsDistributorsBySupplier(address supplier)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n // Get array length\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n try IonicComptroller(pools[i].comptroller).suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) arrayLength++;\n } catch {}\n }\n\n // Build array\n uint256[] memory indexes = new uint256[](arrayLength);\n IonicComptroller[] memory comptrollers = new IonicComptroller[](arrayLength);\n address[][] memory distributors = new address[][](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n try comptroller.suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) {\n indexes[index] = i;\n comptrollers[index] = comptroller;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors[index] = _distributors;\n } catch {}\n\n index++;\n }\n } catch {}\n }\n\n // Return distributors\n return (indexes, comptrollers, distributors);\n }\n\n /**\n * @notice The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getFlywheelsToClaim(address user)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n\n IonicComptroller[] memory comptrollers = new IonicComptroller[](pools.length);\n address[][] memory distributors = new address[][](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n comptrollers[i] = comptroller;\n distributors[i] = flywheelsWithRewardsForPoolUser(user, _distributors);\n } catch {}\n }\n\n return (poolIds, comptrollers, distributors);\n }\n\n function flywheelsWithRewardsForPoolUser(address user, address[] memory _distributors)\n internal\n view\n returns (address[] memory)\n {\n address[] memory distributors = new address[](_distributors.length);\n for (uint256 j = 0; j < _distributors.length; j++) {\n if (IRewardsDistributor_PLS(_distributors[j]).compAccrued(user) > 0) {\n distributors[j] = _distributors[j];\n }\n }\n\n return distributors;\n }\n}\n" + }, + "contracts/test/config/BaseTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\nimport \"forge-std/Test.sol\";\nimport \"forge-std/console.sol\";\n\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\nabstract contract BaseTest is Test {\n uint128 constant ETHEREUM_MAINNET = 1;\n uint128 constant BSC_MAINNET = 56;\n uint128 constant POLYGON_MAINNET = 137;\n uint128 constant ARBITRUM_ONE = 42161;\n\n uint128 constant BSC_CHAPEL = 97;\n uint128 constant NEON_MAINNET = 245022934;\n uint128 constant LINEA_MAINNET = 59144;\n uint128 constant ZKEVM_MAINNET = 1101;\n uint128 constant MODE_MAINNET = 34443;\n uint128 constant BASE_MAINNET = 8453;\n\n // taken from ERC1967Upgrade\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n AddressesProvider public ap;\n ProxyAdmin public dpa;\n\n mapping(uint128 => uint256) private forkIds;\n\n constructor() {\n configureAddressesProvider(0);\n }\n\n uint256 constant CRITICAL = 100;\n uint256 constant NORMAL = 90;\n uint256 constant LOW = 80;\n\n modifier importance(uint256 testImportance) {\n uint256 runLevel = NORMAL;\n\n try vm.envUint(\"TEST_RUN_LEVEL\") returns (uint256 level) {\n runLevel = level;\n } catch {\n emit log(\"failed to get env param TEST_RUN_LEVEL\");\n }\n\n if (testImportance >= runLevel) {\n _;\n } else {\n emit log(\"not running the test\");\n }\n }\n\n modifier debuggingOnly() {\n try vm.envBool(\"LOCAL_FORGE_ENV\") returns (bool run) {\n if (run) _;\n } catch {\n emit log(\"skipping this test in the CI/CD - add LOCAL_FORGE_ENV=true to your .env file to run locally\");\n }\n }\n\n modifier fork(uint128 chainid) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, 0);\n _;\n }\n }\n\n modifier forkAtBlock(uint128 chainid, uint256 blockNumber) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, blockNumber);\n _;\n }\n }\n\n modifier whenForking() {\n try vm.activeFork() returns (uint256) {\n _;\n } catch {}\n }\n\n function shouldRunForChain(uint256 chainid) internal returns (bool) {\n bool run = true;\n try vm.envUint(\"TEST_RUN_CHAINID\") returns (uint256 envChainId) {\n run = envChainId == chainid;\n } catch {\n emit log(\"failed to get env param TEST_RUN_CHAINID\");\n }\n return run;\n }\n\n function _forkAtBlock(uint128 chainid, uint256 blockNumber) internal {\n if (block.chainid != chainid) {\n if (blockNumber != 0) {\n vm.selectFork(getArchiveForkId(chainid));\n vm.rollFork(blockNumber);\n } else {\n vm.selectFork(getForkId(chainid));\n }\n }\n configureAddressesProvider(chainid);\n afterForkSetUp();\n }\n\n function getForkId(uint128 chainid, bool archive) private returns (uint256) {\n return archive ? getForkId(chainid) : getArchiveForkId(chainid);\n }\n\n function getForkId(uint128 chainid) private returns (uint256) {\n if (forkIds[chainid] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc_chapel\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"polygon\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"neon\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"arbitrum\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"ethereum\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"linea\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"zkevm\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"mode\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"base\")) + 100;\n }\n }\n\n return forkIds[chainid] - 100;\n }\n\n function getArchiveForkId(uint128 chainid) private returns (uint256) {\n // store the archive rpc urls in the forkIds mapping at an offset\n uint128 chainidWithOffset = chainid + type(uint64).max;\n if (forkIds[chainidWithOffset] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_archive\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_chapel_archive\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"polygon_archive\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"neon_archive\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"arbitrum_archive\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"ethereum_archive\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"linea_archive\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"zkevm_archive\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"mode_archive\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"base_archive\")) + 100;\n }\n }\n return forkIds[chainidWithOffset] - 100;\n }\n\n function afterForkSetUp() internal virtual {}\n\n function configureAddressesProvider(uint128 chainid) private {\n if (chainid == BSC_MAINNET) {\n ap = AddressesProvider(address(0));\n } else if (chainid == BSC_CHAPEL) {\n ap = AddressesProvider(0x3dc8CE9f581e49B9E5304CF580940ad341F64c3f);\n } else if (block.chainid == POLYGON_MAINNET) {\n ap = AddressesProvider(0xE31baC0B582AA248c0017F87F24087cEa7A55E26);\n } else if (chainid == NEON_MAINNET) {\n ap = AddressesProvider(0xF4C60F6ac6b3AF54044757a1a54D76EEe28244CE);\n } else if (chainid == ARBITRUM_ONE) {\n ap = AddressesProvider(0x3B12BA992259Fb3855C4E1D452a754dCa2E276fC);\n } else if (chainid == LINEA_MAINNET) {\n ap = AddressesProvider(0x914694DA0bED80e74ef1a28029f016119782C0f1);\n } else if (chainid == ZKEVM_MAINNET) {\n ap = AddressesProvider(0x27aA55A3D55959261e119d75256aadAB79aE897C);\n } else if (chainid == MODE_MAINNET) {\n ap = AddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n } else if (chainid == BASE_MAINNET) {\n ap = AddressesProvider(0xcD4D7c8e2bA627684a9B18F7fe88239341D3ba5c);\n } else {\n dpa = new ProxyAdmin();\n AddressesProvider logic = new AddressesProvider();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(logic),\n address(dpa),\n abi.encodeWithSelector(ap.initialize.selector, address(this))\n );\n ap = AddressesProvider(address(proxy));\n ap.setAddress(\"DefaultProxyAdmin\", address(dpa));\n }\n dpa = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n if (ap.owner() == address(0)) {\n ap.initialize(address(this));\n }\n if (ap.getAddress(\"deployer\") == address(0)) {\n vm.prank(ap.owner());\n ap.setAddress(\"deployer\", 0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n }\n\n function diff(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n } else {\n return b - a;\n }\n }\n\n function compareStrings(string memory a, string memory b) public pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function asArray(address value) public pure returns (address[] memory) {\n address[] memory array = new address[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(address value0, address value1) public pure returns (address[] memory) {\n address[] memory array = new address[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n address value0,\n address value1,\n address value2\n ) public pure returns (address[] memory) {\n address[] memory array = new address[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function asArray(bool value) public pure returns (bool[] memory) {\n bool[] memory array = new bool[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(uint256 value0, uint256 value1) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(uint256 value) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value0, bytes memory value1) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n bytes memory value0,\n bytes memory value1,\n bytes memory value2\n ) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function sqrt(uint256 x) public pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n}\n" + }, + "contracts/test/config/MarketsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./BaseTest.t.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../../compound/CErc20RewardsDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { DiamondExtension } from \"../../ionic/DiamondExtension.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MarketsTest is BaseTest {\n FeeDistributor internal ffd;\n\n CErc20Delegate internal cErc20Delegate;\n CErc20PluginDelegate internal cErc20PluginDelegate;\n CErc20RewardsDelegate internal cErc20RewardsDelegate;\n CErc20PluginRewardsDelegate internal cErc20PluginRewardsDelegate;\n CTokenFirstExtension internal newCTokenExtension;\n\n address payable internal latestComptrollerImplementation;\n ComptrollerFirstExtension internal comptrollerExtension;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n upgradeFfd();\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20RewardsDelegate = new CErc20RewardsDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n newCTokenExtension = new CTokenFirstExtension();\n\n comptrollerExtension = new ComptrollerFirstExtension();\n Comptroller newComptrollerImplementation = new Comptroller();\n latestComptrollerImplementation = payable(address(newComptrollerImplementation));\n }\n\n function upgradeFfd() internal {\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffd)));\n bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n if (address(ffd.authoritiesRegistry()) == address(0)) {\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n vm.prank(ffd.owner());\n ffd.reinitialize(newAr);\n }\n }\n\n function _prepareCTokenUpgrade(ICErc20 market) internal returns (address) {\n address implBefore = market.implementation();\n //emit log(\"implementation before\");\n //emit log_address(implBefore);\n\n CErc20Delegate newImpl;\n if (market.delegateType() == 1) {\n newImpl = cErc20Delegate;\n } else if (market.delegateType() == 2) {\n newImpl = cErc20PluginDelegate;\n } else if (market.delegateType() == 3) {\n newImpl = cErc20RewardsDelegate;\n } else {\n newImpl = cErc20PluginRewardsDelegate;\n }\n\n // set the new ctoken delegate as the latest\n uint8 delegateType = market.delegateType();\n vm.prank(ffd.owner());\n ffd._setLatestCErc20Delegate(delegateType, address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = DiamondExtension(newImpl);\n cErc20DelegateExtensions[1] = newCTokenExtension;\n vm.prank(ffd.owner());\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n\n return address(newImpl);\n }\n\n function _upgradeMarket(ICErc20 market) internal {\n address newDelegate = _prepareCTokenUpgrade(market);\n\n bytes memory becomeImplData = (address(newDelegate) == address(cErc20Delegate))\n ? bytes(\"\")\n : abi.encode(address(0));\n vm.prank(market.ionicAdmin());\n market._setImplementationSafe(newDelegate, becomeImplData);\n }\n\n function _prepareComptrollerUpgrade(address oldCompImpl) internal {\n vm.startPrank(ffd.owner());\n ffd._setLatestComptrollerImplementation(oldCompImpl, latestComptrollerImplementation);\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = comptrollerExtension;\n extensions[1] = Comptroller(latestComptrollerImplementation);\n ffd._setComptrollerExtensions(latestComptrollerImplementation, extensions);\n vm.stopPrank();\n }\n\n function _upgradeExistingPool(address poolAddress) internal {\n Unitroller asUnitroller = Unitroller(payable(poolAddress));\n // change the implementation to the new that can add extensions\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n _prepareComptrollerUpgrade(oldComptrollerImplementation);\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n}\n" + }, + "contracts/test/DevTesting.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport \"./config/BaseTest.t.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ISwapRouter } from \"../external/uniswap/ISwapRouter.sol\";\nimport { RedstoneAdapterPriceOracle } from \"../oracles/default/RedstoneAdapterPriceOracle.sol\";\nimport { RedstoneAdapterPriceOracleWrsETH } from \"../oracles/default/RedstoneAdapterPriceOracleWrsETH.sol\";\nimport { RedstoneAdapterPriceOracleWeETH } from \"../oracles/default/RedstoneAdapterPriceOracleWeETH.sol\";\nimport { MasterPriceOracle, BasePriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { LeveredPositionFactory } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { LeveredPositionStorage } from \"../ionic/levered/LeveredPositionStorage.sol\";\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle_IFLR } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { CurveSwapLiquidator } from \"../liquidators/CurveSwapLiquidator.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\nimport { VelodromeV2Liquidator } from \"../liquidators/VelodromeV2Liquidator.sol\";\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport \"forge-std/console.sol\";\n\nstruct HealthFactorVars {\n uint256 usdcSupplied;\n uint256 wethSupplied;\n uint256 ezEthSuppled;\n uint256 stoneSupplied;\n uint256 wbtcSupplied;\n uint256 weEthSupplied;\n uint256 merlinBTCSupplied;\n uint256 usdcBorrowed;\n uint256 wethBorrowed;\n uint256 ezEthBorrowed;\n uint256 stoneBorrowed;\n uint256 wbtcBorrowed;\n uint256 weEthBorrowed;\n uint256 merlinBTCBorrowed;\n ICErc20 testCToken;\n address testUnderlying;\n uint256 amountBorrow;\n}\n\ncontract DevTesting is BaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n LeveredPositionsLens levPosLens;\n\n address deployer = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n ICErc20 ezEthMarket;\n ICErc20 stoneMarket;\n ICErc20 weEthMarket;\n ICErc20 merlinBTCMarket;\n\n // mode mainnet assets\n address WETH = 0x4200000000000000000000000000000000000006;\n address USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address USDT = 0xf0F161fDA2712DB8b566946122a5af183995e2eD;\n address WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;\n address UNI = 0x3e7eF8f50246f725885102E8238CBba33F276747;\n address SNX = 0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3;\n address LINK = 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb;\n address DAI = 0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea;\n address BAL = 0xD08a2917653d4E460893203471f0000826fb4034;\n address AAVE = 0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2;\n address weETH = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n address merlinBTC = 0x59889b7021243dB5B1e065385F918316cD90D46c;\n IERC20Upgradeable wsuperOETH = IERC20Upgradeable(0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6);\n IERC20Upgradeable superOETH = IERC20Upgradeable(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n ezEthMarket = ICErc20(0x59e710215d45F584f44c0FEe83DA6d43D762D857);\n stoneMarket = ICErc20(0x959FA710CCBb22c7Ce1e59Da82A247e686629310);\n weEthMarket = ICErc20(0xA0D844742B4abbbc43d8931a6Edb00C56325aA18);\n merlinBTCMarket = ICErc20(0x19F245782b1258cf3e11Eda25784A378cC18c108);\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n } else {}\n levPosLens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testModePoolBorrowers() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_array(\"borrowers\", pool.getAllBorrowers());\n }\n\n function testModeLiquidationShortfall() public debuggingOnly fork(MODE_MAINNET) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(\n 0xa75F9C8246f7269279bE4c969e7Bc6Eb619cC204\n );\n\n emit log_named_uint(\"err\", err);\n emit log_named_uint(\"collateralValue\", collateralValue);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n }\n\n function testModeHealthFactor() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n\n uint256 wethSupplied = wethMarket.balanceOfUnderlying(rahul);\n uint256 usdcSupplied = usdcMarket.balanceOfUnderlying(rahul);\n uint256 usdtSupplied = usdtMarket.balanceOfUnderlying(rahul);\n uint256 wbtcSupplied = wbtcMarket.balanceOfUnderlying(rahul);\n // emit log_named_uint(\"wethSupplied\", wethSupplied);\n emit log_named_uint(\"usdcSupplied\", usdcSupplied);\n emit log_named_uint(\"usdtSupplied\", usdtSupplied);\n emit log_named_uint(\"wbtcSupplied\", wbtcSupplied);\n emit log_named_uint(\"value of wethSupplied\", wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n emit log_named_uint(\"value of usdcSupplied\", usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n emit log_named_uint(\"value of usdtSupplied\", usdtSupplied * pool.oracle().getUnderlyingPrice(usdtMarket));\n emit log_named_uint(\"value of wbtcSupplied\", wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n PoolLens newImpl = new PoolLens();\n // TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(lens)));\n // vm.prank(dpa.owner());\n // proxy.upgradeTo(address(newImpl));\n\n uint256 hf = newImpl.getHealthFactor(rahul, pool);\n\n emit log_named_uint(\"hf\", hf);\n }\n\n function testNetAprMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 8479829) {\n address user = 0x30D5047e839f079bDE1Ab16b34668f57391DacB3;\n int256 blocks = 30 * 24 * 365 * 60;\n IonicFlywheelLensRouter lensRouter = new IonicFlywheelLensRouter(\n PoolDirectory(0x39C353Cf9041CcF467A04d0e78B63d961E81458a)\n );\n int256 apr = lensRouter.getUserNetApr(user, blocks);\n\n emit log_named_int(\"apr\", apr);\n }\n\n function testModeUsdcBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdcMarket);\n }\n\n function testHypotheticalPosition() public debuggingOnly forkAtBlock(MODE_MAINNET, 8028296) {\n HealthFactorVars memory vars;\n\n address wolfy = 0x7d922bf0975424b3371074f54cC784AF738Dac0D;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n address wbtcWhale = 0xBD8CCf3ebE4CC2D57962cdC2756B143ce0135a6B;\n address wethWhale = 0xD746A2a6048C5D3AFF5766a8c4A0C8cFD2311745;\n\n address whale = wbtcWhale;\n vars.testCToken = wethMarket;\n vars.testUnderlying = WETH;\n vars.amountBorrow = 1e18 / 2;\n\n address[] memory cTokens = new address[](1);\n\n vm.startPrank(usdcWhale);\n ERC20(USDC).transfer(wolfy, ERC20(USDC).balanceOf(usdcWhale));\n vm.stopPrank();\n\n vm.startPrank(wbtcWhale);\n ERC20(WBTC).transfer(wolfy, ERC20(WBTC).balanceOf(wbtcWhale));\n vm.stopPrank();\n\n vm.startPrank(wethWhale);\n ERC20(WETH).transfer(wolfy, ERC20(WETH).balanceOf(wethWhale));\n vm.stopPrank();\n\n // emit log_named_uint(\"USDC balance\", ERC20(USDC).balanceOf(wolfy));\n // emit log_named_uint(\"WBTC balance\", ERC20(WBTC).balanceOf(wolfy));\n // emit log_named_uint(\"WETH balance\", ERC20(WETH).balanceOf(wolfy));\n\n vm.startPrank(wolfy);\n\n ERC20(USDC).approve(address(usdcMarket), ERC20(USDC).balanceOf(wolfy));\n usdcMarket.mint(ERC20(USDC).balanceOf(wolfy));\n cTokens[0] = address(usdcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WBTC).approve(address(wbtcMarket), ERC20(WBTC).balanceOf(wolfy));\n wbtcMarket.mint(ERC20(WBTC).balanceOf(wolfy));\n cTokens[0] = address(wbtcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WETH).approve(address(wethMarket), ERC20(WETH).balanceOf(wolfy));\n wethMarket.mint(ERC20(WETH).balanceOf(wolfy));\n cTokens[0] = address(wethMarket);\n pool.enterMarkets(cTokens);\n\n wethMarket.borrow(1e18);\n\n vm.stopPrank();\n\n vars.usdcSupplied = usdcMarket.balanceOfUnderlying(wolfy);\n vars.wethSupplied = wethMarket.balanceOfUnderlying(wolfy);\n vars.ezEthSuppled = ezEthMarket.balanceOfUnderlying(wolfy);\n vars.stoneSupplied = stoneMarket.balanceOfUnderlying(wolfy);\n vars.wbtcSupplied = wbtcMarket.balanceOfUnderlying(wolfy);\n vars.weEthSupplied = weEthMarket.balanceOfUnderlying(wolfy);\n vars.merlinBTCSupplied = merlinBTCMarket.balanceOfUnderlying(wolfy);\n\n vars.usdcBorrowed = usdcMarket.borrowBalanceCurrent(wolfy);\n vars.wethBorrowed = wethMarket.borrowBalanceCurrent(wolfy);\n vars.ezEthBorrowed = ezEthMarket.borrowBalanceCurrent(wolfy);\n vars.stoneBorrowed = stoneMarket.borrowBalanceCurrent(wolfy);\n vars.wbtcBorrowed = wbtcMarket.borrowBalanceCurrent(wolfy);\n vars.weEthBorrowed = weEthMarket.borrowBalanceCurrent(wolfy);\n vars.merlinBTCBorrowed = merlinBTCMarket.borrowBalanceCurrent(wolfy);\n\n emit log_named_uint(\"usdcSupplied\", vars.usdcSupplied);\n emit log_named_uint(\"wethSupplied\", vars.wethSupplied);\n emit log_named_uint(\"ezEthSupplied\", vars.ezEthSuppled);\n emit log_named_uint(\"stoneSupplied\", vars.stoneSupplied);\n emit log_named_uint(\"wbtcSupplied\", vars.wbtcSupplied);\n emit log_named_uint(\"weEthSupplied\", vars.weEthSupplied);\n emit log_named_uint(\"merlinBTCSupplied\", vars.merlinBTCSupplied);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"usdcBorrowed\", vars.usdcBorrowed);\n emit log_named_uint(\"wethBorrowed\", vars.wethBorrowed);\n emit log_named_uint(\"ezEthBorrowed\", vars.ezEthBorrowed);\n emit log_named_uint(\"stoneBorrowed\", vars.stoneBorrowed);\n emit log_named_uint(\"wbtcBorrowed\", vars.wbtcBorrowed);\n emit log_named_uint(\"weEthBorrowed\", vars.weEthBorrowed);\n emit log_named_uint(\"merlinBTCBorrowed\", vars.merlinBTCBorrowed);\n\n // emit log_named_uint(\"value of usdcSupplied\", vars.usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethSupplied\", vars.wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthSupplied\", vars.ezEthSuppled * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneSupplied\", vars.stoneSupplied * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcSupplied\", vars.wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n // emit log_named_uint(\"value of usdcBorrowed\", vars.usdcBorrowed * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethBorrowed\", vars.wethBorrowed * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthBorrowed\", vars.ezEthBorrowed * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneBorrowed\", vars.stoneBorrowed * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcBorrowed\", vars.wbtcBorrowed * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n vm.startPrank(whale);\n ERC20(vars.testUnderlying).transfer(wolfy, ERC20(vars.testUnderlying).balanceOf(whale));\n vm.stopPrank();\n\n uint256 hf = lens.getHealthFactor(wolfy, pool);\n uint256 hypothetical = lens.getHealthFactorHypothetical(\n pool,\n wolfy,\n address(vars.testCToken),\n 0,\n 0,\n vars.amountBorrow\n );\n\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value Before\", collateralValue);\n emit log_named_uint(\"Liquidity Before\", liquidity);\n emit log_named_uint(\"hf before\", hf);\n emit log_named_uint(\"hypothetical hf\", hypothetical);\n\n vm.startPrank(wolfy);\n ERC20(vars.testUnderlying).approve(address(vars.testCToken), vars.amountBorrow);\n vars.testCToken.repayBorrow(vars.amountBorrow);\n vm.stopPrank();\n\n uint256 hfAfter = lens.getHealthFactor(wolfy, pool);\n (err, collateralValue, liquidity, shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value After\", collateralValue);\n emit log_named_uint(\"Liquidity After\", liquidity);\n emit log_named_uint(\"hf after\", hfAfter);\n emit log_named_uint(\"user balance after\", ERC20(vars.testUnderlying).balanceOf(wolfy));\n emit log_named_uint(\"new borrow balance after repay\", vars.testCToken.borrowBalanceCurrent(wolfy));\n }\n\n function testModeUsdtBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdtMarket);\n }\n\n function testModeWethBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(wethMarket);\n wethMarket.accrueInterest();\n _testModeBorrowCaps(wethMarket);\n }\n\n function _testModeBorrowCaps(ICErc20 market) internal {\n uint256 borrowCapUsdc = pool.borrowCaps(address(market));\n uint256 totalBorrowsCurrent = market.totalBorrowsCurrent();\n\n uint256 wethBorrowAmount = 154753148031252;\n console.log(\"borrowCapUsdc %e\", borrowCapUsdc);\n console.log(\"totalBorrowsCurrent %e\", totalBorrowsCurrent);\n console.log(\"new totalBorrowsCurrent %e\", totalBorrowsCurrent + wethBorrowAmount);\n }\n\n function testMarketMember() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; i++) {\n if (pool.checkMembership(rahul, markets[i])) {\n emit log(\"is a member\");\n } else {\n emit log(\"NOT a member\");\n }\n }\n }\n\n function testGetCashError() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20 market = ICErc20(0x49950319aBE7CE5c3A6C90698381b45989C99b46);\n market.getCash();\n }\n\n function testWrsEthBalanceOfError() public debuggingOnly fork(MODE_MAINNET) {\n address wrsEthMarketAddress = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ERC20 wrsEth = ERC20(0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd);\n wrsEth.balanceOf(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n\n function testModeRepay() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0x1A3C4E9B49e4fc595fB7e5f723159bA73a9426e7;\n ICErc20 market = usdcMarket;\n ERC20 asset = ERC20(market.underlying());\n\n uint256 borrowBalance = market.borrowBalanceCurrent(user);\n emit log_named_uint(\"borrowBalance\", borrowBalance);\n\n vm.startPrank(user);\n asset.approve(address(market), borrowBalance);\n uint256 err = market.repayBorrow(borrowBalance / 2);\n\n emit log_named_uint(\"error\", err);\n }\n\n function testAssetsPrices() public debuggingOnly fork(MODE_MAINNET) {\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n emit log_named_uint(\"WETH price\", mpo.price(WETH));\n emit log_named_uint(\"USDC price\", mpo.price(USDC));\n emit log_named_uint(\"USDT price\", mpo.price(USDT));\n emit log_named_uint(\"UNI price\", mpo.price(UNI));\n emit log_named_uint(\"SNX price\", mpo.price(SNX));\n emit log_named_uint(\"LINK price\", mpo.price(LINK));\n emit log_named_uint(\"DAI price\", mpo.price(DAI));\n emit log_named_uint(\"BAL price\", mpo.price(BAL));\n emit log_named_uint(\"AAVE price\", mpo.price(AAVE));\n emit log_named_uint(\"WBTC price\", mpo.price(WBTC));\n }\n\n function testDeployedMarkets() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n emit log_named_address(\"market\", address(markets[i]));\n emit log(markets[i].symbol());\n emit log(markets[i].name());\n }\n }\n\n function testDisableCollateralUsdc() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0xF70CBE91fB1b1AfdeB3C45Fb8CDD2E1249b5b75E;\n address usdcMarketAddr = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n\n vm.startPrank(user);\n\n uint256 borrowed = ICErc20(usdcMarketAddr).borrowBalanceCurrent(user);\n\n emit log_named_uint(\"borrowed\", borrowed);\n\n pool.exitMarket(usdcMarketAddr);\n }\n\n function testBorrowRateAtRatio() public debuggingOnly fork(MODE_MAINNET) {\n uint256 rate = levPosLens.getBorrowRateAtRatio(wethMarket, ezEthMarket, 9988992945501686, 2e18);\n emit log_named_uint(\"borrow rate at ratio\", rate);\n }\n\n function testAssetAsCollateralCap() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ezEthWhale = 0x2344F131B07E6AFd943b0901C55898573F0d1561;\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_EZETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Renzo Restaked ETH\",\n \"ionezETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 ezEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(ezEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(ezEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(ezEthWhale);\n ERC20(MODE_EZETH).approve(address(ezEthMarket), 1e36);\n errCode = ezEthMarket.mint(1e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testNewStoneMarketCapped() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_STONE = 0x80137510979822322193FC997d400D5A6C747bf7;\n address stoneWhale = 0x76486cbED5216C82d26Ee60113E48E06C189541A;\n\n address redstoneOracleAddress = 0x63A1531a06F0Ac597a0DfA5A516a37073c3E1e0a;\n RedstoneAdapterPriceOracle oracle = RedstoneAdapterPriceOracle(redstoneOracleAddress);\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(mpo.admin());\n mpo.add(asArray(MODE_STONE), oracles);\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_STONE,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic StakeStone Ether\",\n \"ionSTONE\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 stoneMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(stoneMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(stoneMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(stoneWhale);\n ERC20(MODE_STONE).approve(address(stoneMarket), 1e36);\n vm.expectRevert(\"not authorized\");\n errCode = stoneMarket.mint(1e18);\n //require(errCode != 0, \"should be unable to supply\");\n }\n\n function testRegisterSFS() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_address(\"pool admin\", pool.admin());\n\n vm.startPrank(multisig);\n pool.registerInSFS();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n markets[i].registerInSFS();\n }\n }\n\n function upgradePool() internal {\n ComptrollerFirstExtension newComptrollerExtension = new ComptrollerFirstExtension();\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n\n // upgrade to the new comptroller extension\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(newComptrollerExtension, DiamondExtension(asUnitroller._listExtensions()[1]));\n\n //asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function testModeBorrowRate() public fork(MODE_MAINNET) {\n //ICErc20[] memory markets = pool.getAllMarkets();\n\n IonicComptroller pool = ezEthMarket.comptroller();\n vm.prank(pool.admin());\n ezEthMarket._setInterestRateModel(JumpRateModel(0x413aD59b80b1632988d478115a466bdF9B26743a));\n\n JumpRateModel discRateModel = JumpRateModel(ezEthMarket.interestRateModel());\n\n uint256 borrows = 200e18;\n uint256 cash = 5000e18 - borrows;\n uint256 reserves = 1e18;\n uint256 rate = discRateModel.getBorrowRate(cash, borrows, reserves);\n\n emit log_named_uint(\"rate per year %e\", rate * discRateModel.blocksPerYear());\n }\n\n function testModeFetchBorrowers() public fork(MODE_MAINNET) {\n // address[] memory borrowers = pool.getAllBorrowers();\n // emit log_named_uint(\"borrowers.len\", borrowers.length);\n\n //upgradePool();\n\n (uint256 totalPages, address[] memory borrowersPage) = pool.getPaginatedBorrowers(1, 0);\n\n emit log_named_uint(\"total pages with 300 size (default)\", totalPages);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(totalPages - 1, 50);\n emit log_named_array(\"last page of 300 borrowers\", borrowersPage);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(1, 50);\n emit log_named_uint(\"total pages with 50 size\", totalPages);\n emit log_named_array(\"page of 50 borrowers\", borrowersPage);\n\n // for (uint256 i = 0; i < borrowers.length; i++) {\n // (\n // uint256 error,\n // uint256 collateralValue,\n // uint256 liquidity,\n // uint256 shortfall\n // ) = pool.getAccountLiquidity(borrowers[i]);\n //\n // emit log(\"\");\n // emit log_named_address(\"user\", borrowers[i]);\n // emit log_named_uint(\"collateralValue\", collateralValue);\n // if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n // if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n // }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testModeDeployMarket() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n address weEthWhale = 0x6e55a90772B92f17f87Be04F9562f3faafd0cc38;\n\n vm.startPrank(pool.admin());\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_WEETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Wrapped eETH\",\n \"ionweETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 weEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(weEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(weEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(weEthWhale);\n ERC20(MODE_WEETH).approve(address(weEthMarket), 1e36);\n errCode = weEthMarket.mint(0.01e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testModeWrsETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6635923) {\n address wrsEth = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n RedstoneAdapterPriceOracleWrsETH oracle = new RedstoneAdapterPriceOracleWrsETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(wrsEth), oracles);\n\n uint256 price = mpo.price(wrsEth);\n emit log_named_uint(\"price of wrsEth\", price);\n }\n\n function testModeWeETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6861468) {\n address weEth = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n RedstoneAdapterPriceOracleWeETH oracle = new RedstoneAdapterPriceOracleWeETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(weEth), oracles);\n\n uint256 price = mpo.price(weEth);\n emit log_named_uint(\"price of weEth\", price);\n assertEq(price, 1036212437077011599);\n }\n\n function testPERLiquidation() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n vm.prank(0x5Cc070844E98F4ceC5f2fBE1592fB1ed73aB7b48);\n _functionCall(\n 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A,\n hex\"20b72325000000000000000000000000f28570694a6c9cd0494955966ae75af61abf5a0700000000000000000000000000000000000000000000000001bc1214ed792fbb0000000000000000000000004341620757bee7eb4553912fafc963e59c949147000000000000000000000000c53edeafb6d502daec5a7015d67936cea0cd0f520000000000000000000000000000000000000000000000000000000000000000\",\n \"error in call\"\n );\n }\n\n function testCtokenUpgrade() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n CErc20PluginRewardsDelegate newImpl = new CErc20PluginRewardsDelegate();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(wethMarket)));\n\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = PoolDirectory(\n 0x39C353Cf9041CcF467A04d0e78B63d961E81458a\n ).getActivePools();\n\n emit log_named_uint(\"First Pool ID\", poolIds[0]);\n emit log_named_uint(\"First Pool ID\", poolIds[1]);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_address(\"First Pool Address\", pools[0].creator);\n emit log_named_address(\"First Pool Address\", pools[1].creator);\n emit log_named_address(\"First Pool Address\", pools[0].comptroller);\n emit log_named_address(\"First Pool Address\", pools[1].comptroller);\n //bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n //address admin = address(uint160(uint256(bytesAtSlot)));\n //vm.prank(admin);\n //proxy.upgradeTo(address(newImpl));\n\n //vm.prank(dpa.owner());\n //proxy.upgradeTo(address(newImpl));\n }\n\n function testAerodromeV2Liquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeV2Liquidator liquidator = new AerodromeV2Liquidator();\n IERC20Upgradeable hyUSD = IERC20Upgradeable(0xCc7FF230365bD730eE4B352cC2492CEdAC49383e);\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n IERC20Upgradeable usdc = IERC20Upgradeable(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);\n address hyusdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0xaac391f166f33CdaEfaa4AfA6616A3BEA66B694d;\n address eusdWhale = 0xEE8Bd6594E046d72D592ac0e278E3CA179b8f189;\n address aerodromeV2Router = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;\n\n vm.startPrank(eusdWhale);\n eUSD.transfer(address(liquidator), 1000 ether);\n IRouter_Aerodrome.Route[] memory path = new IRouter_Aerodrome.Route[](1);\n path[0] = IRouter_Aerodrome.Route({\n from: address(eUSD),\n to: address(usdc),\n stable: true,\n factory: 0x420DD381b31aEf6683db6B902084cB0FFECe40Da\n });\n liquidator.redeem(eUSD, 1000 ether, abi.encode(aerodromeV2Router, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address superOETHWhale = 0xF1010eE787Ee588766b441d7cC397b40DdFB17a3;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n vm.startPrank(superOETHWhale);\n superOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(superOETH, 1 ether, abi.encode(address(superOETH), address(weth), int24(1), aerodromeCLRouter));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorWrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 20203998) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wethWhale = 0x751b77C43643a63362Ab024d466fcC1d75354295;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = AerodromeCLLiquidator(0xb50De36105F6053006306553AB54e77224818B9B);\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n weth,\n 1 ether,\n abi.encode(address(weth), address(wsuperOETH), aerodromeCLRouter, address(0), address(superOETH), 1)\n );\n emit log_named_uint(\"wsuperOETH received\", wsuperOETH.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorUnwrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wsuperOethWhale = 0x0EEaCD4c475040463389d15EAd034d1291b008b1;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n\n vm.startPrank(wsuperOethWhale);\n wsuperOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n wsuperOETH,\n 1 ether,\n abi.encode(address(wsuperOETH), address(weth), aerodromeCLRouter, address(superOETH), address(0), 1)\n );\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testCurveSwapLiquidatorUSDCtowUSDM() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address usdcWhale = 0x134575ff75F9882ca905EE1D78C9340C091d6056;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n vm.prank(usdcWhale);\n IERC20Upgradeable(usdc).transfer(address(liquidator), 100e6);\n liquidator.redeem(IERC20Upgradeable(usdc), 100e6, abi.encode(oracle, wUSDM, address(0), usdm));\n emit log_named_uint(\"wUSDM received\", IERC20Upgradeable(wUSDM).balanceOf(address(liquidator)));\n }\n\n function testCurveSwapLiquidatorwUSDMtoUSDC() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address wusdmWhale = 0x9b8b04B6f82cD5e1dae58cA3614d445F93DeFc5c;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n\n vm.startPrank(wusdmWhale);\n IERC20Upgradeable(wUSDM).transfer(address(liquidator), 30 ether);\n liquidator.redeem(IERC20Upgradeable(wUSDM), 30 ether, abi.encode(oracle, usdc, usdm, address(0)));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testKimLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 13579406) {\n address weth = 0x4200000000000000000000000000000000000006;\n address usdc = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address kimRouter = 0xAc48FcF1049668B285f3dC72483DF5Ae2162f7e8;\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n AlgebraSwapLiquidator liquidator = AlgebraSwapLiquidator(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vm.startPrank(wethWhale);\n IERC20Upgradeable(weth).transfer(address(liquidator), 2018770577362160);\n liquidator.redeem(IERC20Upgradeable(weth), 2018770577362160, abi.encode(usdc, kimRouter));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testVelodromeV2Liquidator_mode_usdcToWeth() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address usdcWhale = 0xFd1D36995d76c0F75bbe4637C84C06E4A68bBB3a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(usdcWhale);\n usdc.transfer(address(liquidator), 1000 * 10e6);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(usdc), to: address(weth), stable: false });\n liquidator.redeem(usdc, 1000 * 10e6, abi.encode(veloRouter, path));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testVelodromeV2Liquidator_mode_wethToUSDC() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(weth), to: address(usdc), stable: false });\n\n liquidator.redeem(weth, 1 ether, abi.encode(veloRouter, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function test_claimRewardFromLeveredPosition() public debuggingOnly fork(BASE_MAINNET) {\n LeveredPosition position = LeveredPosition(\n 0x3a0eA2C577b0e0f2CAaEcC2b8fF8fF1850267ba2 // 20 days old\n );\n ILeveredPositionFactory factory = position.factory();\n\n vm.prank(address(factory));\n LeveredPosition dummy = new LeveredPosition(\n msg.sender,\n ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3),\n ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0)\n );\n emit log_named_address(\"dummy\", address(dummy));\n\n vm.startPrank(factory.owner());\n DiamondBase(address(factory))._registerExtension(\n new LeveredPositionFactoryFirstExtension(),\n DiamondExtension(0x115455f15ef67e298F012F225B606D3c4Daa1d60)\n );\n factory._setPositionsExtension(LeveredPosition.claimRewardsFromRouter.selector, address(dummy));\n vm.stopPrank();\n\n {\n // mock the usdz call\n vm.mockCall(\n 0x04D5ddf5f3a8939889F11E97f8c4BB48317F1938,\n abi.encodeWithSelector(IERC20Upgradeable.balanceOf.selector),\n abi.encode(53307671999615298341926)\n );\n }\n\n vm.startPrank(0xC13110d04f22ed464Cb72A620fF8163585358Ff9);\n (address[] memory rewardTokens, uint256[] memory rewards) = position.claimRewardsFromRouter(\n 0xB1402333b12fc066C3D7F55d37944D5e281a3e8B\n );\n emit log_named_uint(\"reward tokens\", rewardTokens.length);\n emit log_named_uint(\"rewards\", rewards.length);\n vm.stopPrank();\n }\n\n function test_liquidateWithAggregator() public debuggingOnly forkAtBlock(MODE_MAINNET, 15435970) {\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(0x50F13EC4B68c9522260d3ccd4F19826679B3Ce5C));\n emit log_named_address(\"liquidator\", address(liquidator));\n address cErc20 = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18; // weEth\n address cTokenCollateral = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038; // usdc\n uint256 repayAmount = 843900759317990;\n address borrower = 0x1Bec4f239F1Ec11FD8DC7B31A8fea7A5bA5a9Aa4;\n address aggregatorTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE; // lifi\n // 0xd988097fb8612cc24eeC14542bC03424c656005f usdc\n // 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A weeth\n bytes memory aggregatorData = vm.parseBytes(\n \"0x4666fc800d27477c9a16fe2929353656c1222839791dbe26e815e7533f731ea9a6b919bb00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000050f13ec4b68c9522260d3ccd4f19826679b3ce5c0000000000000000000000000000000000000000000000000002ff85fb26dbe8000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c7848740000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c784874000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a000000000000000000000000000000000000000000000000000000000027891800000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000f283bd37f90001d988097fb8612cc24eec14542bc03424c656005f000104c0599ae5a44757c0af6f9ec3b93da8976c150a0327891807030361590977620147ae00019b57dca972db5d8866c630554acdbdfe58b2659c000000011231deb6f5749ef6ce6943a275a1d3e7486f4eae59725ade04010205000601020203000205000100010400ff0000000000000000000000000053e85d00f2c6578a1205b842255ab9df9d05374425ba258e510faca5ab7ff941a1584bdd2174c94dd988097fb8612cc24eec14542bc03424c656005f4200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000\"\n );\n\n emit log_named_uint(\n \"before collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"before borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidator.safeLiquidateWithAggregator(\n borrower,\n repayAmount,\n ICErc20(cErc20),\n ICErc20(cTokenCollateral),\n aggregatorTarget,\n aggregatorData\n );\n vm.stopPrank();\n\n emit log_named_uint(\n \"profit collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"profit borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testRawCall() public debuggingOnly forkAtBlock(BASE_MAINNET, 20569373) {\n address caller = 0xC13110d04f22ed464Cb72A620fF8163585358Ff9;\n address target = 0x180272dDf5767C771b3a8d37A2DC6cA507aaa1d9;\n\n ILeveredPositionFactory factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(WETH);\n IERC20Upgradeable outputToken = wsuperOETH;\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(aerodomeClLiquidator, inputToken, outputToken);\n registry._setRedemptionStrategy(aerodomeClLiquidator, outputToken, inputToken);\n vm.stopPrank();\n\n bytes memory data = hex\"c393d0e3\";\n vm.prank(caller);\n _functionCall(target, data, \"raw call failed\");\n\n uint256 superOETHBalance = superOETH.balanceOf(target);\n emit log_named_uint(\"balance of levered position\", superOETHBalance);\n }\n}\n" + }, + "contracts/test/LeveredPositionTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest, BaseTest } from \"./config/MarketsTest.t.sol\";\nimport { DiamondBase, DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { LeveredPositionFactory, IFeeDistributor } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { JarvisLiquidatorFunder } from \"../liquidators/JarvisLiquidatorFunder.sol\";\nimport { BalancerSwapLiquidator } from \"../liquidators/BalancerSwapLiquidator.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { SolidlyLpTokenLiquidator, SolidlyLpTokenWrapper } from \"../liquidators/SolidlyLpTokenLiquidator.sol\";\nimport { SolidlySwapLiquidator } from \"../liquidators/SolidlySwapLiquidator.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\n\nimport { CurveLpTokenLiquidatorNoRegistry } from \"../liquidators/CurveLpTokenLiquidatorNoRegistry.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { LiquidatorsRegistry } from \"../liquidators/registry/LiquidatorsRegistry.sol\";\nimport { LiquidatorsRegistryExtension } from \"../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { SafeOwnable } from \"../ionic/SafeOwnable.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract LeveredPositionLensTest is BaseTest {\n LeveredPositionsLens lens;\n ILeveredPositionFactory factory;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n emit log_named_address(\"factory\", address(factory));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n // lens = new LeveredPositionsLens();\n // lens.initialize(factory);\n }\n\n function testLPLens() public debuggingOnly fork(BSC_CHAPEL) {\n _testLPLens();\n }\n\n function _testLPLens() internal {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(0xb6c11605e971ab46B9BE4fDC48C9650A257075db);\n\n // address[] memory accounts = factory.getAccountsWithOpenPositions();\n // for (uint256 i = 0; i < accounts.length; i++) {\n // (positions, closed) = factory.getPositionsByAccount(accounts[i]);\n // if (positions.length > 0) break;\n // }\n\n uint256[] memory apys = new uint256[](positions.length);\n LeveredPosition[] memory pos = new LeveredPosition[](positions.length);\n for (uint256 j = 0; j < positions.length; j++) {\n apys[j] = 1e17;\n\n if (address(0) == positions[j]) revert(\"zero pos address\");\n pos[j] = LeveredPosition(positions[j]);\n }\n\n LeveredPositionsLens.PositionInfo[] memory infos = lens.getPositionsInfo(pos, apys);\n\n for (uint256 k = 0; k < infos.length; k++) {\n emit log_named_address(\"address\", address(pos[k]));\n emit log_named_uint(\"positionSupplyAmount\", infos[k].positionSupplyAmount);\n emit log_named_uint(\"positionValue\", infos[k].positionValue);\n emit log_named_uint(\"debtAmount\", infos[k].debtAmount);\n emit log_named_uint(\"debtValue\", infos[k].debtValue);\n emit log_named_uint(\"equityValue\", infos[k].equityValue);\n emit log_named_uint(\"equityAmount\", infos[k].equityAmount);\n emit log_named_int(\"currentApy\", infos[k].currentApy);\n emit log_named_uint(\"debtRatio\", infos[k].debtRatio);\n emit log_named_uint(\"liquidationThreshold\", infos[k].liquidationThreshold);\n emit log_named_uint(\"safetyBuffer\", infos[k].safetyBuffer);\n\n emit log(\"\");\n }\n }\n\n function testPrintLeveredPositions() public debuggingOnly fork(POLYGON_MAINNET) {\n address[] memory accounts = factory.getAccountsWithOpenPositions();\n\n emit log_named_array(\"accounts\", accounts);\n\n for (uint256 j = 0; j < accounts.length; j++) {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(accounts[j]);\n emit log_named_array(\"positions\", positions);\n //emit log_named_array(\"closed\", closed);\n }\n }\n\n function testScenarioLeverageFailed() public debuggingOnly forkAtBlock(MODE_MAINNET, 10672173) {\n address USER = 0x95Ce459B20586cf44ee6d295C4f28e1a134CF529;\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006).approve(\n // address(factory),\n // 100000 ether\n // );\n vm.prank(ap.owner());\n ap.setAddress(\"IUniswapV2Router02\", 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45);\n vm.startPrank(USER);\n LeveredPosition position = factory.createAndFundPositionAtRatio(\n ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n IERC20Upgradeable(0x4200000000000000000000000000000000000006),\n 16754252276537996590,\n 3000000000000000000\n );\n emit log_named_address(\"position\", address(position));\n\n // vm.stopPrank();\n // ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n // vm.startPrank(registry.owner());\n // registry._setRedemptionStrategy(\n // new UniswapV3LiquidatorFunder(),\n // IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f),\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006)\n // );\n // vm.stopPrank();\n // vm.startPrank(USER);\n\n vm.roll(10673509);\n position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(10852409);\n // position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(11268772);\n // position.adjustLeverageRatio(3000000000000000000);\n vm.stopPrank();\n }\n}\n\ncontract LeveredPositionFactoryTest is BaseTest {\n ILeveredPositionFactory factory;\n LeveredPositionsLens lens;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testChapelNetApy() public debuggingOnly fork(BSC_CHAPEL) {\n ICErc20 _stableMarket = ICErc20(address(1)); // DAI\n\n uint256 borrowRate = 5.2e16; // 5.2%\n vm.mockCall(\n address(_stableMarket),\n abi.encodeWithSelector(_stableMarket.borrowRatePerBlock.selector),\n abi.encode(borrowRate / factory.blocksPerYear())\n );\n\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n emit log_named_uint(\"_borrowRate\", _borrowRate);\n\n int256 netApy = lens.getNetAPY(\n 2.7e16, // 2.7%\n 1e18, // supply amount\n ICErc20(address(0)), // BOMB\n _stableMarket,\n 2e18 // ratio\n );\n\n emit log_named_int(\"net apy\", netApy);\n\n // boosted APY = 2x 2.7% = 5.4 % of the equity\n // borrow APR = 5.2%\n // diff = 5.4 - 5.2 = 0.2%\n assertApproxEqRel(netApy, 0.2e16, 1e12, \"!net apy\");\n }\n}\n\nabstract contract LeveredPositionTest is MarketsTest {\n ICErc20 collateralMarket;\n ICErc20 stableMarket;\n ILeveredPositionFactory factory;\n ILiquidatorsRegistry registry;\n LeveredPosition position;\n LeveredPositionsLens lens;\n\n uint256 minLevRatio;\n uint256 maxLevRatio;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n registry = factory.liquidatorsRegistry();\n {\n // upgrade the registry\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n\n vm.startPrank(registry.owner());\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory oldExts = asBase._listExtensions();\n\n if (oldExts.length == 1) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(address(0)));\n } else if (oldExts.length == 2) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(oldExts[1]));\n }\n vm.stopPrank();\n }\n\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function upgradePoolAndMarkets() internal {\n _upgradeExistingPool(address(collateralMarket.comptroller()));\n _upgradeMarket(collateralMarket);\n _upgradeMarket(stableMarket);\n }\n\n function _unpauseMarkets(address collat, address stable) internal {\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(address(ICErc20(stable).comptroller()));\n vm.startPrank(asExtension.admin());\n asExtension._setMintPaused(ICErc20(collat), false);\n asExtension._setMintPaused(ICErc20(stable), false);\n asExtension._setBorrowPaused(ICErc20(stable), false);\n vm.stopPrank();\n }\n\n function _configurePairAndLiquidator(address _collat, address _stable, IRedemptionStrategy _liquidator) internal {\n _configurePair(_collat, _stable);\n _configureTwoWayLiquidator(_collat, _stable, _liquidator);\n }\n\n function _configurePair(address _collat, address _stable) internal {\n collateralMarket = ICErc20(_collat);\n stableMarket = ICErc20(_stable);\n\n //upgradePoolAndMarkets();\n //_unpauseMarkets(_collat, _stable);\n vm.prank(factory.owner());\n factory._setPairWhitelisted(collateralMarket, stableMarket, true);\n }\n\n function _whitelistTestUser(address user) internal {\n address pool = address(collateralMarket.comptroller());\n PoolRolesAuthority pra = ffd.authoritiesRegistry().poolsAuthorities(pool);\n\n vm.startPrank(pra.owner());\n pra.setUserRole(user, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n }\n\n function _configureTwoWayLiquidator(\n address inputMarket,\n address outputMarket,\n IRedemptionStrategy strategy\n ) internal {\n IERC20Upgradeable inputToken = underlying(inputMarket);\n IERC20Upgradeable outputToken = underlying(outputMarket);\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(strategy, inputToken, outputToken);\n registry._setRedemptionStrategy(strategy, outputToken, inputToken);\n vm.stopPrank();\n }\n\n function underlying(address market) internal view returns (IERC20Upgradeable) {\n return IERC20Upgradeable(ICErc20(market).underlying());\n }\n\n struct Liquidator {\n IERC20Upgradeable inputToken;\n IERC20Upgradeable outputToken;\n IRedemptionStrategy strategy;\n }\n\n function _configureMultipleLiquidators(Liquidator[] memory liquidators) internal {\n IRedemptionStrategy[] memory strategies = new IRedemptionStrategy[](liquidators.length);\n IERC20Upgradeable[] memory inputTokens = new IERC20Upgradeable[](liquidators.length);\n IERC20Upgradeable[] memory outputTokens = new IERC20Upgradeable[](liquidators.length);\n for (uint256 i = 0; i < liquidators.length; i++) {\n strategies[i] = liquidators[i].strategy;\n inputTokens[i] = liquidators[i].inputToken;\n outputTokens[i] = liquidators[i].outputToken;\n }\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategies(strategies, inputTokens, outputTokens);\n vm.stopPrank();\n }\n\n function _fundMarketAndSelf(ICErc20 market, address whale) internal {\n IERC20Upgradeable token = IERC20Upgradeable(market.underlying());\n\n if (whale == address(0)) {\n whale = address(911);\n //vm.deal(address(token), whale, 100e18);\n }\n\n uint256 allTokens = token.balanceOf(whale);\n vm.prank(whale);\n token.transfer(address(this), allTokens / 20);\n\n if (market.getCash() < allTokens / 2) {\n _whitelistTestUser(whale);\n vm.startPrank(whale);\n token.approve(address(market), allTokens / 2);\n market.mint(allTokens / 2);\n vm.stopPrank();\n }\n }\n\n function _openLeveredPosition(\n address _positionOwner,\n uint256 _depositAmount\n ) internal returns (LeveredPosition _position, uint256 _maxRatio, uint256 _minRatio) {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(_positionOwner, _depositAmount);\n\n vm.startPrank(_positionOwner);\n collateralToken.approve(address(factory), _depositAmount);\n _position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, _depositAmount);\n vm.stopPrank();\n\n _maxRatio = _position.getMaxLeverageRatio();\n emit log_named_uint(\"max ratio\", _maxRatio);\n _minRatio = _position.getMinLeverageRatio();\n emit log_named_uint(\"min ratio\", _minRatio);\n\n assertGt(_maxRatio, _minRatio, \"max ratio <= min ratio\");\n }\n\n function testOpenLeveredPosition() public virtual whenForking {\n assertApproxEqRel(position.getCurrentLeverageRatio(), 1e18, 4e16, \"initial leverage ratio should be 1.0 (1e18)\");\n }\n\n function testAnyLeverageRatio(uint64 ratioDiff) public debuggingOnly whenForking {\n // ratioDiff is between 0 and 2^64 ~= 18.446e18\n uint256 targetLeverageRatio = 1e18 + uint256(ratioDiff);\n emit log_named_uint(\"fuzz max ratio\", maxLevRatio);\n emit log_named_uint(\"fuzz min ratio\", minLevRatio);\n emit log_named_uint(\"target ratio\", targetLeverageRatio);\n vm.assume(targetLeverageRatio < maxLevRatio);\n vm.assume(minLevRatio < targetLeverageRatio);\n\n uint256 borrowedAssetPrice = stableMarket.comptroller().oracle().getUnderlyingPrice(stableMarket);\n (uint256 sd, uint256 bd) = position.getSupplyAmountDelta(targetLeverageRatio);\n emit log_named_uint(\"borrows delta val\", (bd * borrowedAssetPrice) / 1e18);\n emit log_named_uint(\"min borrow value\", ffd.getMinBorrowEth(stableMarket));\n\n uint256 equityAmount = position.getEquityAmount();\n emit log_named_uint(\"equity amount\", equityAmount);\n\n uint256 currentLeverageRatio = position.getCurrentLeverageRatio();\n emit log_named_uint(\"current ratio\", currentLeverageRatio);\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(targetLeverageRatio);\n emit log_named_uint(\"equity amount\", position.getEquityAmount());\n assertApproxEqRel(leverageRatioRealized, targetLeverageRatio, 4e16, \"target ratio not matching\");\n }\n\n function testMinMaxLeverageRatio() public whenForking {\n assertGt(maxLevRatio, minLevRatio, \"max ratio <= min ratio\");\n\n // attempting to adjust to minLevRatio - 0.01 should fail\n vm.expectRevert(abi.encodeWithSelector(LeveredPosition.BorrowStableFailed.selector, 0x3fa));\n position.adjustLeverageRatio((minLevRatio + 1e18) / 2);\n // just testing\n position.adjustLeverageRatio(maxLevRatio);\n // but adjusting to the minLevRatio + 0.01 should succeed\n position.adjustLeverageRatio(minLevRatio + 0.01e18);\n }\n\n function testMaxLeverageRatio() public whenForking {\n uint256 _equityAmount = position.getEquityAmount();\n uint256 rate = lens.getBorrowRateAtRatio(collateralMarket, stableMarket, _equityAmount, maxLevRatio);\n emit log_named_uint(\"borrow rate at max ratio\", rate);\n\n position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(position.getCurrentLeverageRatio(), maxLevRatio, 4e16, \"target max ratio not matching\");\n }\n\n function testRewardsAccruedClaimed() public whenForking {\n address[] memory flywheels = position.pool().getRewardsDistributors();\n if (flywheels.length > 0) {\n vm.warp(block.timestamp + 60 * 60 * 24);\n vm.roll(block.number + 10000);\n\n (ERC20[] memory rewardTokens, uint256[] memory amounts) = position.getAccruedRewards();\n\n ERC20 rewardToken;\n bool atLeastOneAccrued = false;\n for (uint256 i = 0; i < amounts.length; i++) {\n atLeastOneAccrued = amounts[i] > 0;\n if (atLeastOneAccrued) {\n rewardToken = rewardTokens[i];\n emit log_named_address(\"accrued from reward token\", address(rewardTokens[i]));\n break;\n }\n }\n\n assertEq(atLeastOneAccrued, true, \"!should have accrued at least one reward token\");\n\n if (atLeastOneAccrued) {\n uint256 rewardsBalanceBefore = rewardToken.balanceOf(address(this));\n position.claimRewards();\n uint256 rewardsBalanceAfter = rewardToken.balanceOf(address(this));\n assertGt(rewardsBalanceAfter - rewardsBalanceBefore, 0, \"should have claimed some rewards\");\n }\n } else {\n emit log(\"no flywheels/rewards for the pair pool\");\n }\n }\n\n function testLeverMaxDown() public whenForking {\n IERC20Upgradeable stableAsset = IERC20Upgradeable(stableMarket.underlying());\n IERC20Upgradeable collateralAsset = IERC20Upgradeable(collateralMarket.underlying());\n uint256 startingEquity = position.getEquityAmount();\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(leverageRatioRealized, maxLevRatio, 4e16, \"target ratio not matching\");\n\n // decrease the ratio in 10 equal steps\n uint256 ratioDiffStep = (maxLevRatio - 1e18) / 9;\n while (leverageRatioRealized > 1e18) {\n uint256 targetLeverDownRatio = leverageRatioRealized - ratioDiffStep;\n if (targetLeverDownRatio < minLevRatio) targetLeverDownRatio = 1e18;\n leverageRatioRealized = position.adjustLeverageRatio(targetLeverDownRatio);\n assertApproxEqRel(leverageRatioRealized, targetLeverDownRatio, 3e16, \"target lever down ratio not matching\");\n }\n\n uint256 withdrawAmount = position.closePosition();\n emit log_named_uint(\"withdraw amount\", withdrawAmount);\n assertApproxEqRel(startingEquity, withdrawAmount, 5e16, \"!withdraw amount\");\n\n assertEq(position.getEquityAmount(), 0, \"!nonzero equity amount\");\n assertEq(position.getCurrentLeverageRatio(), 0, \"!nonzero leverage ratio\");\n }\n}\n\ncontract WmaticMaticXLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 500e18;\n\n address wmaticMarket = 0xCb8D7c2690536d3444Da3d207f62A939483c8A93;\n address maticxMarket = 0x6ebdbEe1a509247B4A3ac3b73a43bd434C52C7c2;\n address wmaticWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;\n address maticxWhale = 0x72f0275444F2aF8dBf13F78D54A8D3aD7b6E68db;\n\n _configurePair(wmaticMarket, maticxMarket);\n _fundMarketAndSelf(ICErc20(wmaticMarket), wmaticWhale);\n _fundMarketAndSelf(ICErc20(maticxMarket), maticxWhale);\n\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n\n vm.startPrank(wmaticWhale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 100e18, stableToken);\n vm.stopPrank();\n vm.startPrank(maticxWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 100e18, collateralToken);\n vm.stopPrank();\n\n emit log_named_uint(\"slippage coll->stable\", registry.getSlippage(collateralToken, stableToken));\n emit log_named_uint(\"slippage stable->coll\", registry.getSlippage(stableToken, collateralToken));\n }\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract StkBnbWBnbLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 2e18;\n\n address stkBnbMarket = 0xAcfbf93d8fD1A9869bAb2328669dDba33296a421;\n address wbnbMarket = 0x3Af258d24EBdC03127ED6cEb8e58cA90835fbca5;\n address stkBnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n address wbnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n\n AlgebraSwapLiquidator liquidator = new AlgebraSwapLiquidator();\n _configurePairAndLiquidator(stkBnbMarket, wbnbMarket, liquidator);\n _fundMarketAndSelf(ICErc20(stkBnbMarket), stkBnbWhale);\n _fundMarketAndSelf(ICErc20(wbnbMarket), wbnbWhale);\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(address(this), depositAmount);\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, depositAmount);\n }\n}\n\ninterface TwoBrl {\n function minter() external view returns (address);\n\n function mint(address payable _to, uint256 _value) external returns (bool);\n}\n\ncontract Jbrl2BrlLeveredPositionTest is LeveredPositionTest {\n IonicComptroller pool;\n ComptrollerFirstExtension asExtension;\n\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1000e18;\n\n address twoBrlMarket = 0xf0a2852958aD041a9Fb35c312605482Ca3Ec17ba; // 2brl as collateral\n address jBrlMarket = 0x82A3103bc306293227B756f7554AfAeE82F8ab7a; // jbrl as borrowable\n address payable twoBrlWhale = payable(address(177)); // empty account\n address jBrlWhale = 0xA0695f78AF837F570bcc50f53e58Cda300798B65; // solidly pair BRZ-JBRL\n\n TwoBrl twoBrl = TwoBrl(ICErc20(twoBrlMarket).underlying());\n vm.prank(twoBrl.minter());\n twoBrl.mint(twoBrlWhale, depositAmount * 100);\n\n _configurePair(twoBrlMarket, jBrlMarket);\n _fundMarketAndSelf(ICErc20(twoBrlMarket), twoBrlWhale);\n _fundMarketAndSelf(ICErc20(jBrlMarket), jBrlWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract BombWbnbLeveredPositionTest is LeveredPositionTest {\n uint256 depositAmount = 100e18;\n address whale = 0xe7B7dF67C1fe053f1C6B965826d3bFF19603c482;\n address wbnbWhale = 0x57E30beb8054B248CE301FeabfD0c74677Fa40f0;\n uint256 ratioOnCreation = 1.0e18;\n uint256 minBorrowNative = 1e17;\n\n function setUp() public fork(BSC_CHAPEL) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n vm.mockCall(\n address(ffd),\n abi.encodeWithSelector(IFeeDistributor.minBorrowEth.selector),\n abi.encode(minBorrowNative)\n );\n\n address xMarket = 0x9B6E1039103812E0dcC1100a158e4a68014b2571; // BOMB\n address yMarket = 0x9dD00920f5B74A31177cbaB834AB0904703c31B1; // WBNB\n\n collateralMarket = ICErc20(xMarket);\n stableMarket = ICErc20(yMarket);\n\n //upgradePoolAndMarkets();\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n vm.startPrank(whale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 1e18, stableToken);\n collateralToken.transfer(address(this), depositAmount);\n vm.stopPrank();\n\n vm.startPrank(wbnbWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 1e18, collateralToken);\n vm.stopPrank();\n }\n\n vm.prank(whale);\n collateralToken.transfer(address(this), depositAmount);\n\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPositionAtRatio(\n collateralMarket,\n stableMarket,\n collateralToken,\n depositAmount,\n ratioOnCreation\n );\n\n maxLevRatio = position.getMaxLeverageRatio();\n minLevRatio = position.getMinLeverageRatio();\n\n vm.label(address(position), \"Levered Position\");\n }\n}\n\ncontract PearlWUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address wusdrMarket = 0x26EA46e975778662f98dAa0E7a12858dA9139262;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address wUsdrWhale = 0x8711a1a52c34EDe8E61eF40496ab2618a8F6EA4B;\n\n _configurePair(lpTokenMarket, wusdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wusdrMarket), wUsdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdrLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 800e9;\n\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n IRedemptionStrategy liquidator = new SolidlySwapLiquidator();\n _configurePairAndLiquidator(usdrMarket, usdcMarket, liquidator);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrDaiUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 2e18;\n\n // LP token underlying 0xBD02973b441Aa83c8EecEA158b98B5984bb1036E\n address lpTokenMarket = 0xBcE30B4D78cEb9a75A1Aa62156529c3592b3F08b;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x85Fa2331040933A02b154579fAbE6A6a5A765279; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrTngblUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.02e18;\n\n // LP token underlying 0x0Edc235693C20943780b76D79DD763236E94C751\n address lpTokenMarket = 0x2E870Aeee3D9d1eA29Ec93d2c0A99A4e0D5EB697;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdaeF32cA8D699015fcFB2884F6902fFCebE51c5b; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWbtcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.000000071325342755e18;\n\n // LP token underlying 0xb95E1C22dd965FafE926b2A793e9D6757b6613F4\n address lpTokenMarket = 0xffc8c8d747E52fAfbf973c64Bab10d38A6902c46;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x39976f6328ebA2a3C860b7DE5cF2c1bB41581FB8; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWethUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.004081e18;\n\n // LP token underlying 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127\n address lpTokenMarket = 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x7D02A8b758791A03319102f81bF61E220F73e43D; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrMaticUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.05e18;\n\n // LP token underlying vAMM-WMATIC/USDR\n address lpTokenMarket = 0xfacEdA4f9731797102f040380aD5e234c92d1942;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdA0AfBeEEBef6dA2F060237D35cab759b99B13B6; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 300e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 700e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashUsdcLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 300e18;\n\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(cashMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroWethAWbtcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xWBTC-WETH05\n address lpTokenMarket = 0xCB1a06eff3459078c26516ae3a1dB44A61D2DbCA;\n address wethMarket = 0x2469B23354cb7cA50b798663Ec5812Bf28d15e9e;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n\n _configurePair(lpTokenMarket, wethMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract DavosUsdcDusdLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 500e18;\n\n address dusdMarket = 0xE70d09dA78900A0429ee70b35200F70A30d7d2B9;\n address usdcMarket = 0x14787e50578d8c606C3d57bDbA53dD65Fd665449;\n address dusdWhale = 0xE69a1876bdACfa7A7a4F6D531BE2FDE843D2165C;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(dusdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(dusdMarket), dusdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e17;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wethWhale = 0x7380511493DD4c2f1dD75E9CCe5bD52C787D4B51;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wethMarket, USDCMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDCMarket), USDCWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wethWhale = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n\n _configurePair(wethMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wbtcWhale = 0x3f3429D28438Cc14133966820b8A9Ea61Cf1D4F0;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n IERC20Upgradeable token = IERC20Upgradeable(ICErc20(wbtcMarket).underlying());\n\n _configurePair(wbtcMarket, USDCMarket);\n\n uint256 allTokens = token.balanceOf(wbtcWhale);\n\n vm.prank(wbtcWhale);\n token.transfer(address(this), allTokens);\n vm.stopPrank();\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wbtcWhale = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wbtcMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wbtcMarket), wbtcWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address usdcMarket = 0xa900A17a49Bc4D442bA7F72c39FA2108865671f0;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n\n {\n IERC20Upgradeable x = IERC20Upgradeable(ICErc20(hyUsdMarket).underlying());\n IERC20Upgradeable y = IERC20Upgradeable(ICErc20(usdcMarket).underlying());\n IERC20Upgradeable[] memory xToYPath = new IERC20Upgradeable[](2);\n IERC20Upgradeable[] memory yToXPath = new IERC20Upgradeable[](2);\n\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n xToYPath[0] = eUSD;\n yToXPath[0] = eUSD;\n xToYPath[1] = y;\n yToXPath[1] = x;\n\n vm.startPrank(registry.owner());\n registry._setOptimalSwapPath(IERC20Upgradeable(x), IERC20Upgradeable(y), xToYPath);\n registry._setOptimalSwapPath(IERC20Upgradeable(y), IERC20Upgradeable(x), yToXPath);\n vm.stopPrank();\n }\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePair(hyUsdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDeUSDLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address eUsdMarket = 0x9c2A4f9c5471fd36bE3BBd8437A33935107215A1;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address eUsdWhale = 0xa9E0588E82E9Ee1440f7e5375970a429D09646c1;\n AerodromeV2Liquidator aerodomeV2Liquidator = AerodromeV2Liquidator(0xD46b85409C43571145206B11D370A62AaeB22475);\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(hyUsdMarket, eUsdMarket, IRedemptionStrategy(address(aerodomeV2Liquidator)));\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(eUsdMarket), eUsdWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract WSuperOETHWETHLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n address wsuperOeth = 0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6;\n address weth = 0x4200000000000000000000000000000000000006;\n\n uint256 depositAmount = 1e18;\n\n address wsuperOethMarket = 0xC462eb5587062e2f2391990b8609D2428d8Cf598;\n address wethMarket = 0x49420311B518f3d0c94e897592014de53831cfA3;\n address wsuperOethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address wethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(wethMarket);\n\n uint256[] memory newSupplyCaps = new uint256[](1);\n newSupplyCaps[0] = 1e36;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(cTokens, newSupplyCaps);\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n vm.prank(registry.owner());\n registry._setWrappedToUnwrapped4626(address(wsuperOeth), address(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3));\n // vm.prank(aerodomeClLiquidator.owner());\n // emit log_named_address(\"wsuperOeth\", address(wsuperOeth));\n // aerodomeClLiquidator.setWrappedToUnwrapped(\n // address(wsuperOeth),\n // 0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3\n // );\n _configurePairAndLiquidator(wsuperOethMarket, wethMarket, IRedemptionStrategy(address(aerodomeClLiquidator)));\n _fundMarketAndSelf(ICErc20(wsuperOethMarket), wsuperOethWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\n/*\ncontract XYLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(X_CHAIN_ID) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address xMarket = 0x...1;\n address yMarket = 0x...2;\n address xWhale = 0x...3;\n address yWhale = 0x...4;\n\n IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(xMarket, yMarket, liquidator);\n _fundMarketAndSelf(ICErc20(xMarket), xWhale);\n _fundMarketAndSelf(ICErc20(yMarket), yWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n*/\n" + }, + "contracts/utils/IMulticall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Multicall interface\n/// @notice Enables calling multiple methods in a single call to the contract\ninterface IMulticall {\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n /// @param data The encoded function data for each of the calls to make to this contract\n /// @return results The results from each of the calls passed in via data\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n}\n" + }, + "contracts/utils/Multicall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./IMulticall.sol\";\n\n/// @title Multicall\n/// @notice Enables calling multiple methods in a single call to the contract\nabstract contract Multicall is IMulticall {\n /// @inheritdoc IMulticall\n function multicall(bytes[] calldata data) public payable virtual override returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n if (!success) {\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n if (result.length < 68) revert();\n assembly {\n result := add(result, 0x04)\n }\n revert(abi.decode(result, (string)));\n }\n\n results[i] = result;\n }\n }\n}\n" + }, + "ds-test/test.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.5.0;\n\ncontract DSTest {\n event log (string);\n event logs (bytes);\n\n event log_address (address);\n event log_bytes32 (bytes32);\n event log_int (int);\n event log_uint (uint);\n event log_bytes (bytes);\n event log_string (string);\n\n event log_named_address (string key, address val);\n event log_named_bytes32 (string key, bytes32 val);\n event log_named_decimal_int (string key, int val, uint decimals);\n event log_named_decimal_uint (string key, uint val, uint decimals);\n event log_named_int (string key, int val);\n event log_named_uint (string key, uint val);\n event log_named_bytes (string key, bytes val);\n event log_named_string (string key, string val);\n\n bool public IS_TEST = true;\n bool private _failed;\n\n address constant HEVM_ADDRESS =\n address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));\n\n modifier mayRevert() { _; }\n modifier testopts(string memory) { _; }\n\n function failed() public returns (bool) {\n if (_failed) {\n return _failed;\n } else {\n bool globalFailed = false;\n if (hasHEVMContext()) {\n (, bytes memory retdata) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"load(address,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"))\n )\n );\n globalFailed = abi.decode(retdata, (bool));\n }\n return globalFailed;\n }\n }\n\n function fail() internal virtual {\n if (hasHEVMContext()) {\n (bool status, ) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"store(address,bytes32,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"), bytes32(uint256(0x01)))\n )\n );\n status; // Silence compiler warnings\n }\n _failed = true;\n }\n\n function hasHEVMContext() internal view returns (bool) {\n uint256 hevmCodeSize = 0;\n assembly {\n hevmCodeSize := extcodesize(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D)\n }\n return hevmCodeSize > 0;\n }\n\n modifier logs_gas() {\n uint startGas = gasleft();\n _;\n uint endGas = gasleft();\n emit log_named_uint(\"gas\", startGas - endGas);\n }\n\n function assertTrue(bool condition) internal {\n if (!condition) {\n emit log(\"Error: Assertion Failed\");\n fail();\n }\n }\n\n function assertTrue(bool condition, string memory err) internal {\n if (!condition) {\n emit log_named_string(\"Error\", err);\n assertTrue(condition);\n }\n }\n\n function assertEq(address a, address b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [address]\");\n emit log_named_address(\" Left\", a);\n emit log_named_address(\" Right\", b);\n fail();\n }\n }\n function assertEq(address a, address b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes32 a, bytes32 b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bytes32]\");\n emit log_named_bytes32(\" Left\", a);\n emit log_named_bytes32(\" Right\", b);\n fail();\n }\n }\n function assertEq(bytes32 a, bytes32 b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq32(bytes32 a, bytes32 b) internal {\n assertEq(a, b);\n }\n function assertEq32(bytes32 a, bytes32 b, string memory err) internal {\n assertEq(a, b, err);\n }\n\n function assertEq(int a, int b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n fail();\n }\n }\n function assertEq(int a, int b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq(uint a, uint b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n fail();\n }\n }\n function assertEq(uint a, uint b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEqDecimal(int a, int b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n\n function assertGt(uint a, uint b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGt(uint a, uint b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGt(int a, int b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGt(int a, int b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGtDecimal(int a, int b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n\n function assertGe(uint a, uint b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGe(uint a, uint b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGe(int a, int b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGe(int a, int b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGeDecimal(int a, int b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n\n function assertLt(uint a, uint b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLt(uint a, uint b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLt(int a, int b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLt(int a, int b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLtDecimal(int a, int b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n\n function assertLe(uint a, uint b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLe(uint a, uint b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLe(int a, int b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLe(int a, int b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLeDecimal(int a, int b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n\n function assertEq(string memory a, string memory b) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log(\"Error: a == b not satisfied [string]\");\n emit log_named_string(\" Left\", a);\n emit log_named_string(\" Right\", b);\n fail();\n }\n }\n function assertEq(string memory a, string memory b, string memory err) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function checkEq0(bytes memory a, bytes memory b) internal pure returns (bool ok) {\n ok = true;\n if (a.length == b.length) {\n for (uint i = 0; i < a.length; i++) {\n if (a[i] != b[i]) {\n ok = false;\n }\n }\n } else {\n ok = false;\n }\n }\n function assertEq0(bytes memory a, bytes memory b) internal {\n if (!checkEq0(a, b)) {\n emit log(\"Error: a == b not satisfied [bytes]\");\n emit log_named_bytes(\" Left\", a);\n emit log_named_bytes(\" Right\", b);\n fail();\n }\n }\n function assertEq0(bytes memory a, bytes memory b, string memory err) internal {\n if (!checkEq0(a, b)) {\n emit log_named_string(\"Error\", err);\n assertEq0(a, b);\n }\n }\n}\n" + }, + "forge-std/Base.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {StdStorage} from \"./StdStorage.sol\";\nimport {Vm, VmSafe} from \"./Vm.sol\";\n\nabstract contract CommonBase {\n // Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.\n address internal constant VM_ADDRESS = address(uint160(uint256(keccak256(\"hevm cheat code\"))));\n // console.sol and console2.sol work by executing a staticcall to this address.\n address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;\n // Default address for tx.origin and msg.sender, 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38.\n address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256(\"foundry default caller\"))));\n // Address of the test contract, deployed by the DEFAULT_SENDER.\n address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;\n // Deterministic deployment address of the Multicall3 contract.\n address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;\n\n uint256 internal constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n Vm internal constant vm = Vm(VM_ADDRESS);\n StdStorage internal stdstore;\n}\n\nabstract contract TestBase is CommonBase {}\n\nabstract contract ScriptBase is CommonBase {\n // Used when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);\n}\n" + }, + "forge-std/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n }\n\n function logUint(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n }\n\n function log(uint p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n }\n\n function log(uint p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n }\n\n function log(uint p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n }\n\n function log(string memory p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/console2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\n/// @dev The original console.sol uses `int` and `uint` for computing function selectors, but it should\n/// use `int256` and `uint256`. This modified version fixes that. This version is recommended\n/// over `console.sol` if you don't need compatibility with Hardhat as the logs will show up in\n/// forge stack traces. If you do need compatibility with Hardhat, you must use `console.sol`.\n/// Reference: https://github.com/NomicFoundation/hardhat/issues/2178\nlibrary console2 {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, int256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,int256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/interfaces/IMulticall3.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ninterface IMulticall3 {\n struct Call {\n address target;\n bytes callData;\n }\n\n struct Call3 {\n address target;\n bool allowFailure;\n bytes callData;\n }\n\n struct Call3Value {\n address target;\n bool allowFailure;\n uint256 value;\n bytes callData;\n }\n\n struct Result {\n bool success;\n bytes returnData;\n }\n\n function aggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes[] memory returnData);\n\n function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);\n\n function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);\n\n function blockAndAggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n\n function getBasefee() external view returns (uint256 basefee);\n\n function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);\n\n function getBlockNumber() external view returns (uint256 blockNumber);\n\n function getChainId() external view returns (uint256 chainid);\n\n function getCurrentBlockCoinbase() external view returns (address coinbase);\n\n function getCurrentBlockDifficulty() external view returns (uint256 difficulty);\n\n function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);\n\n function getCurrentBlockTimestamp() external view returns (uint256 timestamp);\n\n function getEthBalance(address addr) external view returns (uint256 balance);\n\n function getLastBlockHash() external view returns (bytes32 blockHash);\n\n function tryAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (Result[] memory returnData);\n\n function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n}\n" + }, + "forge-std/StdAssertions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {DSTest} from \"ds-test/test.sol\";\nimport {stdMath} from \"./StdMath.sol\";\n\nabstract contract StdAssertions is DSTest {\n event log_array(uint256[] val);\n event log_array(int256[] val);\n event log_array(address[] val);\n event log_named_array(string key, uint256[] val);\n event log_named_array(string key, int256[] val);\n event log_named_array(string key, address[] val);\n\n function fail(string memory err) internal virtual {\n emit log_named_string(\"Error\", err);\n fail();\n }\n\n function assertFalse(bool data) internal virtual {\n assertTrue(!data);\n }\n\n function assertFalse(bool data, string memory err) internal virtual {\n assertTrue(!data, err);\n }\n\n function assertEq(bool a, bool b) internal virtual {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bool]\");\n emit log_named_string(\" Left\", a ? \"true\" : \"false\");\n emit log_named_string(\" Right\", b ? \"true\" : \"false\");\n fail();\n }\n }\n\n function assertEq(bool a, bool b, string memory err) internal virtual {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes memory a, bytes memory b) internal virtual {\n assertEq0(a, b);\n }\n\n function assertEq(bytes memory a, bytes memory b, string memory err) internal virtual {\n assertEq0(a, b, err);\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [uint[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [int[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(address[] memory a, address[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [address[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(address[] memory a, address[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n // Legacy helper\n function assertEqUint(uint256 a, uint256 b) internal virtual {\n assertEq(uint256(a), uint256(b));\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100%\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals,\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta, string memory err) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual {\n assertEqCall(target, callDataA, target, callDataB, true);\n }\n\n function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)\n internal\n virtual\n {\n assertEqCall(targetA, callDataA, targetB, callDataB, true);\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)\n internal\n virtual\n {\n assertEqCall(target, callDataA, target, callDataB, strictRevertData);\n }\n\n function assertEqCall(\n address targetA,\n bytes memory callDataA,\n address targetB,\n bytes memory callDataB,\n bool strictRevertData\n ) internal virtual {\n (bool successA, bytes memory returnDataA) = address(targetA).call(callDataA);\n (bool successB, bytes memory returnDataB) = address(targetB).call(callDataB);\n\n if (successA && successB) {\n assertEq(returnDataA, returnDataB, \"Call return data does not match\");\n }\n\n if (!successA && !successB && strictRevertData) {\n assertEq(returnDataA, returnDataB, \"Call revert data does not match\");\n }\n\n if (!successA && successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call revert data\", returnDataA);\n emit log_named_bytes(\" Right call return data\", returnDataB);\n fail();\n }\n\n if (successA && !successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call return data\", returnDataA);\n emit log_named_bytes(\" Right call revert data\", returnDataB);\n fail();\n }\n }\n}\n" + }, + "forge-std/StdChains.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n/**\n * StdChains provides information about EVM compatible chains that can be used in scripts/tests.\n * For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are\n * identified by their alias, which is the same as the alias in the `[rpc_endpoints]` section of\n * the `foundry.toml` file. For best UX, ensure the alias in the `foundry.toml` file match the\n * alias used in this contract, which can be found as the first argument to the\n * `setChainWithDefaultRpcUrl` call in the `initialize` function.\n *\n * There are two main ways to use this contract:\n * 1. Set a chain with `setChain(string memory chainAlias, ChainData memory chain)` or\n * `setChain(string memory chainAlias, Chain memory chain)`\n * 2. Get a chain with `getChain(string memory chainAlias)` or `getChain(uint256 chainId)`.\n *\n * The first time either of those are used, chains are initialized with the default set of RPC URLs.\n * This is done in `initialize`, which uses `setChainWithDefaultRpcUrl`. Defaults are recorded in\n * `defaultRpcUrls`.\n *\n * The `setChain` function is straightforward, and it simply saves off the given chain data.\n *\n * The `getChain` methods use `getChainWithUpdatedRpcUrl` to return a chain. For example, let's say\n * we want to retrieve `mainnet`'s RPC URL:\n * - If you haven't set any mainnet chain info with `setChain`, you haven't specified that\n * chain in `foundry.toml` and no env var is set, the default data and RPC URL will be returned.\n * - If you have set a mainnet RPC URL in `foundry.toml` it will return that, if valid (e.g. if\n * a URL is given or if an environment variable is given and that environment variable exists).\n * Otherwise, the default data is returned.\n * - If you specified data with `setChain` it will return that.\n *\n * Summarizing the above, the prioritization hierarchy is `setChain` -> `foundry.toml` -> environment variable -> defaults.\n */\nabstract contract StdChains {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private initialized;\n\n struct ChainData {\n string name;\n uint256 chainId;\n string rpcUrl;\n }\n\n struct Chain {\n // The chain name.\n string name;\n // The chain's Chain ID.\n uint256 chainId;\n // The chain's alias. (i.e. what gets specified in `foundry.toml`).\n string chainAlias;\n // A default RPC endpoint for this chain.\n // NOTE: This default RPC URL is included for convenience to facilitate quick tests and\n // experimentation. Do not use this RPC URL for production test suites, CI, or other heavy\n // usage as you will be throttled and this is a disservice to others who need this endpoint.\n string rpcUrl;\n }\n\n // Maps from the chain's alias (matching the alias in the `foundry.toml` file) to chain data.\n mapping(string => Chain) private chains;\n // Maps from the chain's alias to it's default RPC URL.\n mapping(string => string) private defaultRpcUrls;\n // Maps from a chain ID to it's alias.\n mapping(uint256 => string) private idToAlias;\n\n bool private fallbackToDefaultRpcUrls = true;\n\n // The RPC URL will be fetched from config or defaultRpcUrls if possible.\n function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {\n require(bytes(chainAlias).length != 0, \"StdChains getChain(string): Chain alias cannot be the empty string.\");\n\n initialize();\n chain = chains[chainAlias];\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(string): Chain with alias \\\"\", chainAlias, \"\\\" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {\n require(chainId != 0, \"StdChains getChain(uint256): Chain ID cannot be 0.\");\n initialize();\n string memory chainAlias = idToAlias[chainId];\n\n chain = chains[chainAlias];\n\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(uint256): Chain with ID \", vm.toString(chainId), \" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, ChainData memory chain) internal virtual {\n require(\n bytes(chainAlias).length != 0,\n \"StdChains setChain(string,ChainData): Chain alias cannot be the empty string.\"\n );\n\n require(chain.chainId != 0, \"StdChains setChain(string,ChainData): Chain ID cannot be 0.\");\n\n initialize();\n string memory foundAlias = idToAlias[chain.chainId];\n\n require(\n bytes(foundAlias).length == 0 || keccak256(bytes(foundAlias)) == keccak256(bytes(chainAlias)),\n string(\n abi.encodePacked(\n \"StdChains setChain(string,ChainData): Chain ID \",\n vm.toString(chain.chainId),\n \" already used by \\\"\",\n foundAlias,\n \"\\\".\"\n )\n )\n );\n\n uint256 oldChainId = chains[chainAlias].chainId;\n delete idToAlias[oldChainId];\n\n chains[chainAlias] =\n Chain({name: chain.name, chainId: chain.chainId, chainAlias: chainAlias, rpcUrl: chain.rpcUrl});\n idToAlias[chain.chainId] = chainAlias;\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, Chain memory chain) internal virtual {\n setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));\n }\n\n function _toUpper(string memory str) private pure returns (string memory) {\n bytes memory strb = bytes(str);\n bytes memory copy = new bytes(strb.length);\n for (uint256 i = 0; i < strb.length; i++) {\n bytes1 b = strb[i];\n if (b >= 0x61 && b <= 0x7A) {\n copy[i] = bytes1(uint8(b) - 32);\n } else {\n copy[i] = b;\n }\n }\n return string(copy);\n }\n\n // lookup rpcUrl, in descending order of priority:\n // current -> config (foundry.toml) -> environment variable -> default\n function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private returns (Chain memory) {\n if (bytes(chain.rpcUrl).length == 0) {\n try vm.rpcUrl(chainAlias) returns (string memory configRpcUrl) {\n chain.rpcUrl = configRpcUrl;\n } catch (bytes memory err) {\n string memory envName = string(abi.encodePacked(_toUpper(chainAlias), \"_RPC_URL\"));\n if (fallbackToDefaultRpcUrls) {\n chain.rpcUrl = vm.envOr(envName, defaultRpcUrls[chainAlias]);\n } else {\n chain.rpcUrl = vm.envString(envName);\n }\n // distinguish 'not found' from 'cannot read'\n bytes memory notFoundError =\n abi.encodeWithSignature(\"CheatCodeError\", string(abi.encodePacked(\"invalid rpc url \", chainAlias)));\n if (keccak256(notFoundError) != keccak256(err) || bytes(chain.rpcUrl).length == 0) {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, err), mload(err))\n }\n }\n }\n }\n return chain;\n }\n\n function setFallbackToDefaultRpcUrls(bool useDefault) internal {\n fallbackToDefaultRpcUrls = useDefault;\n }\n\n function initialize() private {\n if (initialized) return;\n\n initialized = true;\n\n // If adding an RPC here, make sure to test the default RPC URL in `testRpcs`\n setChainWithDefaultRpcUrl(\"anvil\", ChainData(\"Anvil\", 31337, \"http://127.0.0.1:8545\"));\n setChainWithDefaultRpcUrl(\n \"mainnet\", ChainData(\"Mainnet\", 1, \"https://mainnet.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"goerli\", ChainData(\"Goerli\", 5, \"https://goerli.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"sepolia\", ChainData(\"Sepolia\", 11155111, \"https://sepolia.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\"optimism\", ChainData(\"Optimism\", 10, \"https://mainnet.optimism.io\"));\n setChainWithDefaultRpcUrl(\"optimism_goerli\", ChainData(\"Optimism Goerli\", 420, \"https://goerli.optimism.io\"));\n setChainWithDefaultRpcUrl(\"arbitrum_one\", ChainData(\"Arbitrum One\", 42161, \"https://arb1.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\n \"arbitrum_one_goerli\", ChainData(\"Arbitrum One Goerli\", 421613, \"https://goerli-rollup.arbitrum.io/rpc\")\n );\n setChainWithDefaultRpcUrl(\"arbitrum_nova\", ChainData(\"Arbitrum Nova\", 42170, \"https://nova.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\"polygon\", ChainData(\"Polygon\", 137, \"https://polygon-rpc.com\"));\n setChainWithDefaultRpcUrl(\n \"polygon_mumbai\", ChainData(\"Polygon Mumbai\", 80001, \"https://rpc-mumbai.maticvigil.com\")\n );\n setChainWithDefaultRpcUrl(\"avalanche\", ChainData(\"Avalanche\", 43114, \"https://api.avax.network/ext/bc/C/rpc\"));\n setChainWithDefaultRpcUrl(\n \"avalanche_fuji\", ChainData(\"Avalanche Fuji\", 43113, \"https://api.avax-test.network/ext/bc/C/rpc\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain\", ChainData(\"BNB Smart Chain\", 56, \"https://bsc-dataseed1.binance.org\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain_testnet\",\n ChainData(\"BNB Smart Chain Testnet\", 97, \"https://rpc.ankr.com/bsc_testnet_chapel\")\n );\n setChainWithDefaultRpcUrl(\"gnosis_chain\", ChainData(\"Gnosis Chain\", 100, \"https://rpc.gnosischain.com\"));\n }\n\n // set chain info, with priority to chainAlias' rpc url in foundry.toml\n function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private {\n string memory rpcUrl = chain.rpcUrl;\n defaultRpcUrls[chainAlias] = rpcUrl;\n chain.rpcUrl = \"\";\n setChain(chainAlias, chain);\n chain.rpcUrl = rpcUrl; // restore argument\n }\n}\n" + }, + "forge-std/StdCheats.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {Vm} from \"./Vm.sol\";\n\nabstract contract StdCheatsSafe {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private gasMeteringOff;\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawTx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n // json value name = function\n string functionSig;\n bytes32 hash;\n // json value name = tx\n RawTx1559Detail txDetail;\n // json value name = type\n string opcode;\n }\n\n struct RawTx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n bytes gas;\n bytes nonce;\n address to;\n bytes txType;\n bytes value;\n }\n\n struct Tx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n bytes32 hash;\n Tx1559Detail txDetail;\n string opcode;\n }\n\n struct Tx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n uint256 gas;\n uint256 nonce;\n address to;\n uint256 txType;\n uint256 value;\n }\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that DO NOT conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct TxLegacy {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n string hash;\n string opcode;\n TxDetailLegacy transaction;\n }\n\n struct TxDetailLegacy {\n AccessList[] accessList;\n uint256 chainId;\n bytes data;\n address from;\n uint256 gas;\n uint256 gasPrice;\n bytes32 hash;\n uint256 nonce;\n bytes1 opcode;\n bytes32 r;\n bytes32 s;\n uint256 txType;\n address to;\n uint8 v;\n uint256 value;\n }\n\n struct AccessList {\n address accessAddress;\n bytes32[] storageKeys;\n }\n\n // Data structures to parse Receipt objects from the broadcast artifact.\n // The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawReceipt {\n bytes32 blockHash;\n bytes blockNumber;\n address contractAddress;\n bytes cumulativeGasUsed;\n bytes effectiveGasPrice;\n address from;\n bytes gasUsed;\n RawReceiptLog[] logs;\n bytes logsBloom;\n bytes status;\n address to;\n bytes32 transactionHash;\n bytes transactionIndex;\n }\n\n struct Receipt {\n bytes32 blockHash;\n uint256 blockNumber;\n address contractAddress;\n uint256 cumulativeGasUsed;\n uint256 effectiveGasPrice;\n address from;\n uint256 gasUsed;\n ReceiptLog[] logs;\n bytes logsBloom;\n uint256 status;\n address to;\n bytes32 transactionHash;\n uint256 transactionIndex;\n }\n\n // Data structures to parse the entire broadcast artifact, assuming the\n // transactions conform to EIP1559.\n\n struct EIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n Receipt[] receipts;\n uint256 timestamp;\n Tx1559[] transactions;\n TxReturn[] txReturns;\n }\n\n struct RawEIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n RawReceipt[] receipts;\n TxReturn[] txReturns;\n uint256 timestamp;\n RawTx1559[] transactions;\n }\n\n struct RawReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n bytes blockNumber;\n bytes data;\n bytes logIndex;\n bool removed;\n bytes32[] topics;\n bytes32 transactionHash;\n bytes transactionIndex;\n bytes transactionLogIndex;\n }\n\n struct ReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n uint256 blockNumber;\n bytes data;\n uint256 logIndex;\n bytes32[] topics;\n uint256 transactionIndex;\n uint256 transactionLogIndex;\n bool removed;\n }\n\n struct TxReturn {\n string internalType;\n string value;\n }\n\n function assumeNoPrecompiles(address addr) internal virtual {\n // Assembly required since `block.chainid` was introduced in 0.8.0.\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n assumeNoPrecompiles(addr, chainId);\n }\n\n function assumeNoPrecompiles(address addr, uint256 chainId) internal pure virtual {\n // Note: For some chains like Optimism these are technically predeploys (i.e. bytecode placed at a specific\n // address), but the same rationale for excluding them applies so we include those too.\n\n // These should be present on all EVM-compatible chains.\n vm.assume(addr < address(0x1) || addr > address(0x9));\n\n // forgefmt: disable-start\n if (chainId == 10 || chainId == 420) {\n // https://github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.go#L6-L21\n vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));\n } else if (chainId == 42161 || chainId == 421613) {\n // https://developer.arbitrum.io/useful-addresses#arbitrum-precompiles-l2-same-on-all-arb-chains\n vm.assume(addr < address(0x0000000000000000000000000000000000000064) || addr > address(0x0000000000000000000000000000000000000068));\n } else if (chainId == 43114 || chainId == 43113) {\n // https://github.com/ava-labs/subnet-evm/blob/47c03fd007ecaa6de2c52ea081596e0a88401f58/precompile/params.go#L18-L59\n vm.assume(addr < address(0x0100000000000000000000000000000000000000) || addr > address(0x01000000000000000000000000000000000000ff));\n vm.assume(addr < address(0x0200000000000000000000000000000000000000) || addr > address(0x02000000000000000000000000000000000000FF));\n vm.assume(addr < address(0x0300000000000000000000000000000000000000) || addr > address(0x03000000000000000000000000000000000000Ff));\n }\n // forgefmt: disable-end\n }\n\n function readEIP1559ScriptArtifact(string memory path)\n internal\n view\n virtual\n returns (EIP1559ScriptArtifact memory)\n {\n string memory data = vm.readFile(path);\n bytes memory parsedData = vm.parseJson(data);\n RawEIP1559ScriptArtifact memory rawArtifact = abi.decode(parsedData, (RawEIP1559ScriptArtifact));\n EIP1559ScriptArtifact memory artifact;\n artifact.libraries = rawArtifact.libraries;\n artifact.path = rawArtifact.path;\n artifact.timestamp = rawArtifact.timestamp;\n artifact.pending = rawArtifact.pending;\n artifact.txReturns = rawArtifact.txReturns;\n artifact.receipts = rawToConvertedReceipts(rawArtifact.receipts);\n artifact.transactions = rawToConvertedEIPTx1559s(rawArtifact.transactions);\n return artifact;\n }\n\n function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory) {\n Tx1559[] memory txs = new Tx1559[](rawTxs.length);\n for (uint256 i; i < rawTxs.length; i++) {\n txs[i] = rawToConvertedEIPTx1559(rawTxs[i]);\n }\n return txs;\n }\n\n function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory) {\n Tx1559 memory transaction;\n transaction.arguments = rawTx.arguments;\n transaction.contractName = rawTx.contractName;\n transaction.functionSig = rawTx.functionSig;\n transaction.hash = rawTx.hash;\n transaction.txDetail = rawToConvertedEIP1559Detail(rawTx.txDetail);\n transaction.opcode = rawTx.opcode;\n return transaction;\n }\n\n function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)\n internal\n pure\n virtual\n returns (Tx1559Detail memory)\n {\n Tx1559Detail memory txDetail;\n txDetail.data = rawDetail.data;\n txDetail.from = rawDetail.from;\n txDetail.to = rawDetail.to;\n txDetail.nonce = _bytesToUint(rawDetail.nonce);\n txDetail.txType = _bytesToUint(rawDetail.txType);\n txDetail.value = _bytesToUint(rawDetail.value);\n txDetail.gas = _bytesToUint(rawDetail.gas);\n txDetail.accessList = rawDetail.accessList;\n return txDetail;\n }\n\n function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".transactions\");\n RawTx1559[] memory rawTxs = abi.decode(parsedDeployData, (RawTx1559[]));\n return rawToConvertedEIPTx1559s(rawTxs);\n }\n\n function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".transactions[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawTx1559 memory rawTx = abi.decode(parsedDeployData, (RawTx1559));\n return rawToConvertedEIPTx1559(rawTx);\n }\n\n // Analogous to readTransactions, but for receipts.\n function readReceipts(string memory path) internal view virtual returns (Receipt[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".receipts\");\n RawReceipt[] memory rawReceipts = abi.decode(parsedDeployData, (RawReceipt[]));\n return rawToConvertedReceipts(rawReceipts);\n }\n\n function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".receipts[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawReceipt memory rawReceipt = abi.decode(parsedDeployData, (RawReceipt));\n return rawToConvertedReceipt(rawReceipt);\n }\n\n function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory) {\n Receipt[] memory receipts = new Receipt[](rawReceipts.length);\n for (uint256 i; i < rawReceipts.length; i++) {\n receipts[i] = rawToConvertedReceipt(rawReceipts[i]);\n }\n return receipts;\n }\n\n function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory) {\n Receipt memory receipt;\n receipt.blockHash = rawReceipt.blockHash;\n receipt.to = rawReceipt.to;\n receipt.from = rawReceipt.from;\n receipt.contractAddress = rawReceipt.contractAddress;\n receipt.effectiveGasPrice = _bytesToUint(rawReceipt.effectiveGasPrice);\n receipt.cumulativeGasUsed = _bytesToUint(rawReceipt.cumulativeGasUsed);\n receipt.gasUsed = _bytesToUint(rawReceipt.gasUsed);\n receipt.status = _bytesToUint(rawReceipt.status);\n receipt.transactionIndex = _bytesToUint(rawReceipt.transactionIndex);\n receipt.blockNumber = _bytesToUint(rawReceipt.blockNumber);\n receipt.logs = rawToConvertedReceiptLogs(rawReceipt.logs);\n receipt.logsBloom = rawReceipt.logsBloom;\n receipt.transactionHash = rawReceipt.transactionHash;\n return receipt;\n }\n\n function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)\n internal\n pure\n virtual\n returns (ReceiptLog[] memory)\n {\n ReceiptLog[] memory logs = new ReceiptLog[](rawLogs.length);\n for (uint256 i; i < rawLogs.length; i++) {\n logs[i].logAddress = rawLogs[i].logAddress;\n logs[i].blockHash = rawLogs[i].blockHash;\n logs[i].blockNumber = _bytesToUint(rawLogs[i].blockNumber);\n logs[i].data = rawLogs[i].data;\n logs[i].logIndex = _bytesToUint(rawLogs[i].logIndex);\n logs[i].topics = rawLogs[i].topics;\n logs[i].transactionIndex = _bytesToUint(rawLogs[i].transactionIndex);\n logs[i].transactionLogIndex = _bytesToUint(rawLogs[i].transactionLogIndex);\n logs[i].removed = rawLogs[i].removed;\n }\n return logs;\n }\n\n // Deploy a contract by fetching the contract bytecode from\n // the artifacts directory\n // e.g. `deployCode(code, abi.encode(arg1,arg2,arg3))`\n function deployCode(string memory what, bytes memory args) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes): Deployment failed.\");\n }\n\n function deployCode(string memory what) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string): Deployment failed.\");\n }\n\n /// @dev deploy contract with value on construction\n function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes,uint256): Deployment failed.\");\n }\n\n function deployCode(string memory what, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,uint256): Deployment failed.\");\n }\n\n // creates a labeled address and the corresponding private key\n function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey) {\n privateKey = uint256(keccak256(abi.encodePacked(name)));\n addr = vm.addr(privateKey);\n vm.label(addr, name);\n }\n\n // creates a labeled address\n function makeAddr(string memory name) internal virtual returns (address addr) {\n (addr,) = makeAddrAndKey(name);\n }\n\n function deriveRememberKey(string memory mnemonic, uint32 index)\n internal\n virtual\n returns (address who, uint256 privateKey)\n {\n privateKey = vm.deriveKey(mnemonic, index);\n who = vm.rememberKey(privateKey);\n }\n\n function _bytesToUint(bytes memory b) private pure returns (uint256) {\n require(b.length <= 32, \"StdCheats _bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n function isFork() internal view virtual returns (bool status) {\n try vm.activeFork() {\n status = true;\n } catch (bytes memory) {}\n }\n\n modifier skipWhenForking() {\n if (!isFork()) {\n _;\n }\n }\n\n modifier skipWhenNotForking() {\n if (isFork()) {\n _;\n }\n }\n\n modifier noGasMetering() {\n vm.pauseGasMetering();\n // To prevent turning gas monitoring back on with nested functions that use this modifier,\n // we check if gasMetering started in the off position. If it did, we don't want to turn\n // it back on until we exit the top level function that used the modifier\n //\n // i.e. funcA() noGasMetering { funcB() }, where funcB has noGasMetering as well.\n // funcA will have `gasStartedOff` as false, funcB will have it as true,\n // so we only turn metering back on at the end of the funcA\n bool gasStartedOff = gasMeteringOff;\n gasMeteringOff = true;\n\n _;\n\n // if gas metering was on when this modifier was called, turn it back on at the end\n if (!gasStartedOff) {\n gasMeteringOff = false;\n vm.resumeGasMetering();\n }\n }\n\n // a cheat for fuzzing addresses that are payable only\n // see https://github.com/foundry-rs/foundry/issues/3631\n function assumePayable(address addr) internal virtual {\n (bool success,) = payable(addr).call{value: 0}(\"\");\n vm.assume(success);\n }\n}\n\n// Wrappers around cheatcodes to avoid footguns\nabstract contract StdCheats is StdCheatsSafe {\n using stdStorage for StdStorage;\n\n StdStorage private stdstore;\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n // Skip forward or rewind time by the specified number of seconds\n function skip(uint256 time) internal virtual {\n vm.warp(block.timestamp + time);\n }\n\n function rewind(uint256 time) internal virtual {\n vm.warp(block.timestamp - time);\n }\n\n // Setup a prank from an address that has some ether\n function hoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender, origin);\n }\n\n function hoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender, origin);\n }\n\n // Start perpetual prank from an address that has some ether\n function startHoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender);\n }\n\n function startHoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender);\n }\n\n // Start perpetual prank from an address that has some ether\n // tx.origin is set to the origin parameter\n function startHoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender, origin);\n }\n\n function startHoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender, origin);\n }\n\n function changePrank(address msgSender) internal virtual {\n vm.stopPrank();\n vm.startPrank(msgSender);\n }\n\n // The same as Vm's `deal`\n // Use the alternative signature for ERC20 tokens\n function deal(address to, uint256 give) internal virtual {\n vm.deal(to, give);\n }\n\n // Set the balance of an account for any ERC20 token\n // Use the alternative signature to update `totalSupply`\n function deal(address token, address to, uint256 give) internal virtual {\n deal(token, to, give, false);\n }\n\n // Set the balance of an account for any ERC1155 token\n // Use the alternative signature to update `totalSupply`\n function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual {\n dealERC1155(token, to, id, give, false);\n }\n\n function deal(address token, address to, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0x18160ddd));\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0x18160ddd).checked_write(totSup);\n }\n }\n\n function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x00fdd58e, to, id));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0xbd85b039, id));\n require(\n totSupData.length != 0,\n \"StdCheats deal(address,address,uint,uint,bool): target contract is not ERC1155Supply.\"\n );\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);\n }\n }\n\n function dealERC721(address token, address to, uint256 id) internal virtual {\n // check if token id is already minted and the actual owner.\n (bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id));\n require(successMinted, \"StdCheats deal(address,address,uint,bool): id not minted.\");\n\n // get owner current balance\n (, bytes memory fromBalData) = token.call(abi.encodeWithSelector(0x70a08231, abi.decode(ownerData, (address))));\n uint256 fromPrevBal = abi.decode(fromBalData, (uint256));\n\n // get new user current balance\n (, bytes memory toBalData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 toPrevBal = abi.decode(toBalData, (uint256));\n\n // update balances\n stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);\n\n // update owner\n stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);\n }\n}\n" + }, + "forge-std/StdError.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Panics work for versions >=0.8.0, but we lowered the pragma to make this compatible with Test\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdError {\n bytes public constant assertionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x01);\n bytes public constant arithmeticError = abi.encodeWithSignature(\"Panic(uint256)\", 0x11);\n bytes public constant divisionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x12);\n bytes public constant enumConversionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x21);\n bytes public constant encodeStorageError = abi.encodeWithSignature(\"Panic(uint256)\", 0x22);\n bytes public constant popError = abi.encodeWithSignature(\"Panic(uint256)\", 0x31);\n bytes public constant indexOOBError = abi.encodeWithSignature(\"Panic(uint256)\", 0x32);\n bytes public constant memOverflowError = abi.encodeWithSignature(\"Panic(uint256)\", 0x41);\n bytes public constant zeroVarError = abi.encodeWithSignature(\"Panic(uint256)\", 0x51);\n}\n" + }, + "forge-std/StdInvariant.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ncontract StdInvariant {\n struct FuzzSelector {\n address addr;\n bytes4[] selectors;\n }\n\n address[] private _excludedContracts;\n address[] private _excludedSenders;\n address[] private _targetedContracts;\n address[] private _targetedSenders;\n\n string[] private _excludedArtifacts;\n string[] private _targetedArtifacts;\n\n FuzzSelector[] private _targetedArtifactSelectors;\n FuzzSelector[] private _targetedSelectors;\n\n // Functions for users:\n // These are intended to be called in tests.\n\n function excludeContract(address newExcludedContract_) internal {\n _excludedContracts.push(newExcludedContract_);\n }\n\n function excludeSender(address newExcludedSender_) internal {\n _excludedSenders.push(newExcludedSender_);\n }\n\n function excludeArtifact(string memory newExcludedArtifact_) internal {\n _excludedArtifacts.push(newExcludedArtifact_);\n }\n\n function targetArtifact(string memory newTargetedArtifact_) internal {\n _targetedArtifacts.push(newTargetedArtifact_);\n }\n\n function targetArtifactSelector(FuzzSelector memory newTargetedArtifactSelector_) internal {\n _targetedArtifactSelectors.push(newTargetedArtifactSelector_);\n }\n\n function targetContract(address newTargetedContract_) internal {\n _targetedContracts.push(newTargetedContract_);\n }\n\n function targetSelector(FuzzSelector memory newTargetedSelector_) internal {\n _targetedSelectors.push(newTargetedSelector_);\n }\n\n function targetSender(address newTargetedSender_) internal {\n _targetedSenders.push(newTargetedSender_);\n }\n\n // Functions for forge:\n // These are called by forge to run invariant tests and don't need to be called in tests.\n\n function excludeArtifacts() public view returns (string[] memory excludedArtifacts_) {\n excludedArtifacts_ = _excludedArtifacts;\n }\n\n function excludeContracts() public view returns (address[] memory excludedContracts_) {\n excludedContracts_ = _excludedContracts;\n }\n\n function excludeSenders() public view returns (address[] memory excludedSenders_) {\n excludedSenders_ = _excludedSenders;\n }\n\n function targetArtifacts() public view returns (string[] memory targetedArtifacts_) {\n targetedArtifacts_ = _targetedArtifacts;\n }\n\n function targetArtifactSelectors() public view returns (FuzzSelector[] memory targetedArtifactSelectors_) {\n targetedArtifactSelectors_ = _targetedArtifactSelectors;\n }\n\n function targetContracts() public view returns (address[] memory targetedContracts_) {\n targetedContracts_ = _targetedContracts;\n }\n\n function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_) {\n targetedSelectors_ = _targetedSelectors;\n }\n\n function targetSenders() public view returns (address[] memory targetedSenders_) {\n targetedSenders_ = _targetedSenders;\n }\n}\n" + }, + "forge-std/StdJson.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n// Helpers for parsing and writing JSON files\n// To parse:\n// ```\n// using stdJson for string;\n// string memory json = vm.readFile(\"some_peth\");\n// json.parseUint(\"\");\n// ```\n// To write:\n// ```\n// using stdJson for string;\n// string memory json = \"deploymentArtifact\";\n// Contract contract = new Contract();\n// json.serialize(\"contractAddress\", address(contract));\n// json = json.serialize(\"deploymentTimes\", uint(1));\n// // store the stringified JSON to the 'json' variable we have been using as a key\n// // as we won't need it any longer\n// string memory json2 = \"finalArtifact\";\n// string memory final = json2.serialize(\"depArtifact\", json);\n// final.write(\"\");\n// ```\n\nlibrary stdJson {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {\n return vm.parseJson(json, key);\n }\n\n function readUint(string memory json, string memory key) internal returns (uint256) {\n return vm.parseJsonUint(json, key);\n }\n\n function readUintArray(string memory json, string memory key) internal returns (uint256[] memory) {\n return vm.parseJsonUintArray(json, key);\n }\n\n function readInt(string memory json, string memory key) internal returns (int256) {\n return vm.parseJsonInt(json, key);\n }\n\n function readIntArray(string memory json, string memory key) internal returns (int256[] memory) {\n return vm.parseJsonIntArray(json, key);\n }\n\n function readBytes32(string memory json, string memory key) internal returns (bytes32) {\n return vm.parseJsonBytes32(json, key);\n }\n\n function readBytes32Array(string memory json, string memory key) internal returns (bytes32[] memory) {\n return vm.parseJsonBytes32Array(json, key);\n }\n\n function readString(string memory json, string memory key) internal returns (string memory) {\n return vm.parseJsonString(json, key);\n }\n\n function readStringArray(string memory json, string memory key) internal returns (string[] memory) {\n return vm.parseJsonStringArray(json, key);\n }\n\n function readAddress(string memory json, string memory key) internal returns (address) {\n return vm.parseJsonAddress(json, key);\n }\n\n function readAddressArray(string memory json, string memory key) internal returns (address[] memory) {\n return vm.parseJsonAddressArray(json, key);\n }\n\n function readBool(string memory json, string memory key) internal returns (bool) {\n return vm.parseJsonBool(json, key);\n }\n\n function readBoolArray(string memory json, string memory key) internal returns (bool[] memory) {\n return vm.parseJsonBoolArray(json, key);\n }\n\n function readBytes(string memory json, string memory key) internal returns (bytes memory) {\n return vm.parseJsonBytes(json, key);\n }\n\n function readBytesArray(string memory json, string memory key) internal returns (bytes[] memory) {\n return vm.parseJsonBytesArray(json, key);\n }\n\n function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory) {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bool[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory) {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory) {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory) {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory) {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory) {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function write(string memory jsonKey, string memory path) internal {\n vm.writeJson(jsonKey, path);\n }\n\n function write(string memory jsonKey, string memory path, string memory valueKey) internal {\n vm.writeJson(jsonKey, path, valueKey);\n }\n}\n" + }, + "forge-std/StdMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdMath {\n int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;\n\n function abs(int256 a) internal pure returns (uint256) {\n // Required or it will fail when `a = type(int256).min`\n if (a == INT256_MIN) {\n return 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n }\n\n return uint256(a > 0 ? a : -a);\n }\n\n function delta(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : b - a;\n }\n\n function delta(int256 a, int256 b) internal pure returns (uint256) {\n // a and b are of the same sign\n // this works thanks to two's complement, the left-most bit is the sign bit\n if ((a ^ b) > -1) {\n return delta(abs(a), abs(b));\n }\n\n // a and b are of opposite signs\n return abs(a) + abs(b);\n }\n\n function percentDelta(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n\n return absDelta * 1e18 / b;\n }\n\n function percentDelta(int256 a, int256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n uint256 absB = abs(b);\n\n return absDelta * 1e18 / absB;\n }\n}\n" + }, + "forge-std/StdStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nstruct StdStorage {\n mapping(address => mapping(bytes4 => mapping(bytes32 => uint256))) slots;\n mapping(address => mapping(bytes4 => mapping(bytes32 => bool))) finds;\n bytes32[] _keys;\n bytes4 _sig;\n uint256 _depth;\n address _target;\n bytes32 _set;\n}\n\nlibrary stdStorageSafe {\n event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);\n event WARNING_UninitedSlot(address who, uint256 slot);\n\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return bytes4(keccak256(bytes(sigStr)));\n }\n\n /// @notice find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against\n // slot complexity:\n // if flat, will be bytes32(uint256(uint));\n // if map, will be keccak256(abi.encode(key, uint(slot)));\n // if deep map, will be keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))));\n // if map struct, will be bytes32(uint256(keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))))) + structFieldDepth);\n function find(StdStorage storage self) internal returns (uint256) {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n // calldata to test against\n if (self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n vm.record();\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n (bytes32[] memory reads,) = vm.accesses(address(who));\n if (reads.length == 1) {\n bytes32 curr = vm.load(who, reads[0]);\n if (curr == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[0]));\n }\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[0]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[0]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n } else if (reads.length > 1) {\n for (uint256 i = 0; i < reads.length; i++) {\n bytes32 prev = vm.load(who, reads[i]);\n if (prev == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[i]));\n }\n // store\n vm.store(who, reads[i], bytes32(hex\"1337\"));\n bool success;\n bytes memory rdat;\n {\n (success, rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n if (success && fdat == bytes32(hex\"1337\")) {\n // we found which of the slots is the actual one\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[i]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[i]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n vm.store(who, reads[i], prev);\n break;\n }\n vm.store(who, reads[i], prev);\n }\n } else {\n revert(\"stdStorage find(StdStorage): No storage use detected for target.\");\n }\n\n require(\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))],\n \"stdStorage find(StdStorage): Slot(s) not found.\"\n );\n\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n self._target = _target;\n return self;\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n self._sig = _sig;\n return self;\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n self._sig = sigs(_sig);\n return self;\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n self._keys.push(bytes32(uint256(uint160(who))));\n return self;\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n self._keys.push(bytes32(amt));\n return self;\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n self._keys.push(key);\n return self;\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n self._depth = _depth;\n return self;\n }\n\n function read(StdStorage storage self) private returns (bytes memory) {\n address t = self._target;\n uint256 s = find(self);\n return abi.encode(vm.load(t, bytes32(s)));\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return abi.decode(read(self), (bytes32));\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n int256 v = read_int(self);\n if (v == 0) return false;\n if (v == 1) return true;\n revert(\"stdStorage read_bool(StdStorage): Cannot decode. Make sure you are reading a bool.\");\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return abi.decode(read(self), (address));\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return abi.decode(read(self), (uint256));\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return abi.decode(read(self), (int256));\n }\n\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n\nlibrary stdStorage {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return stdStorageSafe.sigs(sigStr);\n }\n\n function find(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.find(self);\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n return stdStorageSafe.target(self, _target);\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, who);\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, amt);\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, key);\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n return stdStorageSafe.depth(self, _depth);\n }\n\n function checked_write(StdStorage storage self, address who) internal {\n checked_write(self, bytes32(uint256(uint160(who))));\n }\n\n function checked_write(StdStorage storage self, uint256 amt) internal {\n checked_write(self, bytes32(amt));\n }\n\n function checked_write(StdStorage storage self, bool write) internal {\n bytes32 t;\n /// @solidity memory-safe-assembly\n assembly {\n t := write\n }\n checked_write(self, t);\n }\n\n function checked_write(StdStorage storage self, bytes32 set) internal {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n if (!self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n find(self);\n }\n bytes32 slot = bytes32(self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]);\n\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n bytes32 curr = vm.load(who, slot);\n\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n vm.store(who, slot, set);\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return stdStorageSafe.read_bytes32(self);\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n return stdStorageSafe.read_bool(self);\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return stdStorageSafe.read_address(self);\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.read_uint(self);\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return stdStorageSafe.read_int(self);\n }\n\n // Private function so needs to be copied over\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n // Private function so needs to be copied over\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n" + }, + "forge-std/StdStyle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nlibrary StdStyle {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n string constant RED = \"\\u001b[91m\";\n string constant GREEN = \"\\u001b[92m\";\n string constant YELLOW = \"\\u001b[93m\";\n string constant BLUE = \"\\u001b[94m\";\n string constant MAGENTA = \"\\u001b[95m\";\n string constant CYAN = \"\\u001b[96m\";\n string constant BOLD = \"\\u001b[1m\";\n string constant DIM = \"\\u001b[2m\";\n string constant ITALIC = \"\\u001b[3m\";\n string constant UNDERLINE = \"\\u001b[4m\";\n string constant INVERSE = \"\\u001b[7m\";\n string constant RESET = \"\\u001b[0m\";\n\n function styleConcat(string memory style, string memory self) private pure returns (string memory) {\n return string(abi.encodePacked(style, self, RESET));\n }\n\n function red(string memory self) internal pure returns (string memory) {\n return styleConcat(RED, self);\n }\n\n function red(uint256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(int256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(address self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(bool self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes(bytes memory self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes32(bytes32 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function green(string memory self) internal pure returns (string memory) {\n return styleConcat(GREEN, self);\n }\n\n function green(uint256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(int256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(address self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(bool self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes(bytes memory self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes32(bytes32 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function yellow(string memory self) internal pure returns (string memory) {\n return styleConcat(YELLOW, self);\n }\n\n function yellow(uint256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(int256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(address self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(bool self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes(bytes memory self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes32(bytes32 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function blue(string memory self) internal pure returns (string memory) {\n return styleConcat(BLUE, self);\n }\n\n function blue(uint256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(int256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(address self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(bool self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes(bytes memory self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes32(bytes32 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function magenta(string memory self) internal pure returns (string memory) {\n return styleConcat(MAGENTA, self);\n }\n\n function magenta(uint256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(int256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(address self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(bool self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes(bytes memory self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes32(bytes32 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function cyan(string memory self) internal pure returns (string memory) {\n return styleConcat(CYAN, self);\n }\n\n function cyan(uint256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(int256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(address self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(bool self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes(bytes memory self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes32(bytes32 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function bold(string memory self) internal pure returns (string memory) {\n return styleConcat(BOLD, self);\n }\n\n function bold(uint256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(int256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(address self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(bool self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes(bytes memory self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes32(bytes32 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function dim(string memory self) internal pure returns (string memory) {\n return styleConcat(DIM, self);\n }\n\n function dim(uint256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(int256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(address self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(bool self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes(bytes memory self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes32(bytes32 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function italic(string memory self) internal pure returns (string memory) {\n return styleConcat(ITALIC, self);\n }\n\n function italic(uint256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(int256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(address self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(bool self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes(bytes memory self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes32(bytes32 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function underline(string memory self) internal pure returns (string memory) {\n return styleConcat(UNDERLINE, self);\n }\n\n function underline(uint256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(int256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(address self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(bool self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes(bytes memory self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes32(bytes32 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function inverse(string memory self) internal pure returns (string memory) {\n return styleConcat(INVERSE, self);\n }\n\n function inverse(uint256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(int256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(address self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(bool self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes(bytes memory self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes32(bytes32 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n}\n" + }, + "forge-std/StdUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {IMulticall3} from \"./interfaces/IMulticall3.sol\";\n// TODO Remove import.\nimport {VmSafe} from \"./Vm.sol\";\n\nabstract contract StdUtils {\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n //////////////////////////////////////////////////////////////////////////*/\n\n IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;\n uint256 private constant INT256_MIN_ABS =\n 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n uint256 private constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n // Used by default when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n /*//////////////////////////////////////////////////////////////////////////\n INTERNAL FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result) {\n require(min <= max, \"StdUtils bound(uint256,uint256,uint256): Max is less than min.\");\n // If x is between min and max, return x directly. This is to ensure that dictionary values\n // do not get shifted if the min is nonzero. More info: https://github.com/foundry-rs/forge-std/issues/188\n if (x >= min && x <= max) return x;\n\n uint256 size = max - min + 1;\n\n // If the value is 0, 1, 2, 3, warp that to min, min+1, min+2, min+3. Similarly for the UINT256_MAX side.\n // This helps ensure coverage of the min/max values.\n if (x <= 3 && size > x) return min + x;\n if (x >= UINT256_MAX - 3 && size > UINT256_MAX - x) return max - (UINT256_MAX - x);\n\n // Otherwise, wrap x into the range [min, max], i.e. the range is inclusive.\n if (x > max) {\n uint256 diff = x - max;\n uint256 rem = diff % size;\n if (rem == 0) return max;\n result = min + rem - 1;\n } else if (x < min) {\n uint256 diff = min - x;\n uint256 rem = diff % size;\n if (rem == 0) return min;\n result = max - rem + 1;\n }\n }\n\n function bound(uint256 x, uint256 min, uint256 max) internal view virtual returns (uint256 result) {\n result = _bound(x, min, max);\n console2_log(\"Bound Result\", result);\n }\n\n function bound(int256 x, int256 min, int256 max) internal view virtual returns (int256 result) {\n require(min <= max, \"StdUtils bound(int256,int256,int256): Max is less than min.\");\n\n // Shifting all int256 values to uint256 to use _bound function. The range of two types are:\n // int256 : -(2**255) ~ (2**255 - 1)\n // uint256: 0 ~ (2**256 - 1)\n // So, add 2**255, INT256_MIN_ABS to the integer values.\n //\n // If the given integer value is -2**255, we cannot use `-uint256(-x)` because of the overflow.\n // So, use `~uint256(x) + 1` instead.\n uint256 _x = x < 0 ? (INT256_MIN_ABS - ~uint256(x) - 1) : (uint256(x) + INT256_MIN_ABS);\n uint256 _min = min < 0 ? (INT256_MIN_ABS - ~uint256(min) - 1) : (uint256(min) + INT256_MIN_ABS);\n uint256 _max = max < 0 ? (INT256_MIN_ABS - ~uint256(max) - 1) : (uint256(max) + INT256_MIN_ABS);\n\n uint256 y = _bound(_x, _min, _max);\n\n // To move it back to int256 value, subtract INT256_MIN_ABS at here.\n result = y < INT256_MIN_ABS ? int256(~(INT256_MIN_ABS - y) + 1) : int256(y - INT256_MIN_ABS);\n console2_log(\"Bound result\", vm.toString(result));\n }\n\n function bytesToUint(bytes memory b) internal pure virtual returns (uint256) {\n require(b.length <= 32, \"StdUtils bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n /// @dev Compute the address a contract will be deployed at for a given deployer address and nonce\n /// @notice adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)\n function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address) {\n // forgefmt: disable-start\n // The integer zero is treated as an empty byte string, and as a result it only has a length prefix, 0x80, computed via 0x80 + 0.\n // A one byte integer uses its own value as its length prefix, there is no additional \"0x80 + length\" prefix that comes before it.\n if (nonce == 0x00) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, bytes1(0x80))));\n if (nonce <= 0x7f) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, uint8(nonce))));\n\n // Nonces greater than 1 byte all follow a consistent encoding scheme, where each value is preceded by a prefix of 0x80 + length.\n if (nonce <= 2**8 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd7), bytes1(0x94), deployer, bytes1(0x81), uint8(nonce))));\n if (nonce <= 2**16 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd8), bytes1(0x94), deployer, bytes1(0x82), uint16(nonce))));\n if (nonce <= 2**24 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd9), bytes1(0x94), deployer, bytes1(0x83), uint24(nonce))));\n // forgefmt: disable-end\n\n // More details about RLP encoding can be found here: https://eth.wiki/fundamentals/rlp\n // 0xda = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x84 ++ nonce)\n // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex)\n // 0x84 = 0x80 + 0x04 (0x04 = the bytes length of the nonce, 4 bytes, in hex)\n // We assume nobody can have a nonce large enough to require more than 32 bytes.\n return addressFromLast20Bytes(\n keccak256(abi.encodePacked(bytes1(0xda), bytes1(0x94), deployer, bytes1(0x84), uint32(nonce)))\n );\n }\n\n function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)\n internal\n pure\n virtual\n returns (address)\n {\n return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, initcodeHash)));\n }\n\n /// @dev returns the address of a contract created with CREATE2 using the default CREATE2 deployer\n function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address) {\n return computeCreate2Address(salt, initCodeHash, CREATE2_FACTORY);\n }\n\n /// @dev returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n function hashInitCode(bytes memory creationCode) internal pure returns (bytes32) {\n return hashInitCode(creationCode, \"\");\n }\n\n /// @dev returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n /// @param args the ABI-encoded arguments to the constructor of C\n function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(creationCode, args));\n }\n\n // Performs a single call with Multicall3 to query the ERC-20 token balances of the given addresses.\n function getTokenBalances(address token, address[] memory addresses)\n internal\n virtual\n returns (uint256[] memory balances)\n {\n uint256 tokenCodeSize;\n assembly {\n tokenCodeSize := extcodesize(token)\n }\n require(tokenCodeSize > 0, \"StdUtils getTokenBalances(address,address[]): Token address is not a contract.\");\n\n // ABI encode the aggregate call to Multicall3.\n uint256 length = addresses.length;\n IMulticall3.Call[] memory calls = new IMulticall3.Call[](length);\n for (uint256 i = 0; i < length; ++i) {\n // 0x70a08231 = bytes4(\"balanceOf(address)\"))\n calls[i] = IMulticall3.Call({target: token, callData: abi.encodeWithSelector(0x70a08231, (addresses[i]))});\n }\n\n // Make the aggregate call.\n (, bytes[] memory returnData) = multicall.aggregate(calls);\n\n // ABI decode the return data and return the balances.\n balances = new uint256[](length);\n for (uint256 i = 0; i < length; ++i) {\n balances[i] = abi.decode(returnData[i], (uint256));\n }\n }\n\n /*//////////////////////////////////////////////////////////////////////////\n PRIVATE FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address) {\n return address(uint160(uint256(bytesValue)));\n }\n\n // Used to prevent the compilation of console, which shortens the compilation time when console is not used elsewhere.\n\n function console2_log(string memory p0, uint256 p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n status;\n }\n\n function console2_log(string memory p0, string memory p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n status;\n }\n}\n" + }, + "forge-std/Test.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// 💬 ABOUT\n// Standard Library's default Test\n\n// 🧩 MODULES\nimport {console} from \"./console.sol\";\nimport {console2} from \"./console2.sol\";\nimport {StdAssertions} from \"./StdAssertions.sol\";\nimport {StdChains} from \"./StdChains.sol\";\nimport {StdCheats} from \"./StdCheats.sol\";\nimport {stdError} from \"./StdError.sol\";\nimport {StdInvariant} from \"./StdInvariant.sol\";\nimport {stdJson} from \"./StdJson.sol\";\nimport {stdMath} from \"./StdMath.sol\";\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {StdUtils} from \"./StdUtils.sol\";\nimport {Vm} from \"./Vm.sol\";\nimport {StdStyle} from \"./StdStyle.sol\";\n\n// 📦 BOILERPLATE\nimport {TestBase} from \"./Base.sol\";\nimport {DSTest} from \"ds-test/test.sol\";\n\n// ⭐️ TEST\nabstract contract Test is DSTest, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils, TestBase {\n// Note: IS_TEST() must return true.\n// Note: Must have failure system, https://github.com/dapphub/ds-test/blob/cd98eff28324bfac652e63a239a60632a761790b/src/test.sol#L39-L76.\n}\n" + }, + "forge-std/Vm.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// Cheatcodes are marked as view/pure/none using the following rules:\n// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,\n// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure (you are modifying some state be it the EVM, interpreter, filesystem, etc),\n// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,\n// 3. Otherwise you're `pure`.\n\ninterface VmSafe {\n struct Log {\n bytes32[] topics;\n bytes data;\n address emitter;\n }\n\n struct Rpc {\n string key;\n string url;\n }\n\n struct FsMetadata {\n bool isDir;\n bool isSymlink;\n uint256 length;\n bool readOnly;\n uint256 modified;\n uint256 accessed;\n uint256 created;\n }\n\n // Loads a storage slot from an address\n function load(address target, bytes32 slot) external view returns (bytes32 data);\n // Signs data\n function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);\n // Gets the address for a given private key\n function addr(uint256 privateKey) external pure returns (address keyAddr);\n // Gets the nonce of an account\n function getNonce(address account) external view returns (uint64 nonce);\n // Performs a foreign function call via the terminal\n function ffi(string[] calldata commandInput) external returns (bytes memory result);\n // Sets environment variables\n function setEnv(string calldata name, string calldata value) external;\n // Reads environment variables, (name) => (value)\n function envBool(string calldata name) external view returns (bool value);\n function envUint(string calldata name) external view returns (uint256 value);\n function envInt(string calldata name) external view returns (int256 value);\n function envAddress(string calldata name) external view returns (address value);\n function envBytes32(string calldata name) external view returns (bytes32 value);\n function envString(string calldata name) external view returns (string memory value);\n function envBytes(string calldata name) external view returns (bytes memory value);\n // Reads environment variables as arrays\n function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);\n function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);\n function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);\n function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);\n function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);\n function envString(string calldata name, string calldata delim) external view returns (string[] memory value);\n function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);\n // Read environment variables with default value\n function envOr(string calldata name, bool defaultValue) external returns (bool value);\n function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);\n function envOr(string calldata name, int256 defaultValue) external returns (int256 value);\n function envOr(string calldata name, address defaultValue) external returns (address value);\n function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);\n function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);\n function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);\n // Read environment variables as arrays with default value\n function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)\n external\n returns (bool[] memory value);\n function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)\n external\n returns (uint256[] memory value);\n function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)\n external\n returns (int256[] memory value);\n function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)\n external\n returns (address[] memory value);\n function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)\n external\n returns (bytes32[] memory value);\n function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)\n external\n returns (string[] memory value);\n function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)\n external\n returns (bytes[] memory value);\n // Records all storage reads and writes\n function record() external;\n // Gets all accessed reads and write slot from a recording session, for a given address\n function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);\n // Gets the _creation_ bytecode from an artifact file. Takes in the relative path to the json file\n function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);\n // Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file\n function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);\n // Labels an address in call traces\n function label(address account, string calldata newLabel) external;\n // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain\n function broadcast() external;\n // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain\n function broadcast(address signer) external;\n // Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain\n function broadcast(uint256 privateKey) external;\n // Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain\n function startBroadcast() external;\n // Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain\n function startBroadcast(address signer) external;\n // Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain\n function startBroadcast(uint256 privateKey) external;\n // Stops collecting onchain transactions\n function stopBroadcast() external;\n // Reads the entire content of file to string\n function readFile(string calldata path) external view returns (string memory data);\n // Reads the entire content of file as binary. Path is relative to the project root.\n function readFileBinary(string calldata path) external view returns (bytes memory data);\n // Get the path of the current project root\n function projectRoot() external view returns (string memory path);\n // Get the metadata for a file/directory\n function fsMetadata(string calldata fileOrDir) external returns (FsMetadata memory metadata);\n // Reads next line of file to string\n function readLine(string calldata path) external view returns (string memory line);\n // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n function writeFile(string calldata path, string calldata data) external;\n // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n // Path is relative to the project root.\n function writeFileBinary(string calldata path, bytes calldata data) external;\n // Writes line to file, creating a file if it does not exist.\n function writeLine(string calldata path, string calldata data) external;\n // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n function closeFile(string calldata path) external;\n // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases:\n // - Path points to a directory.\n // - The file doesn't exist.\n // - The user lacks permissions to remove the file.\n function removeFile(string calldata path) external;\n // Convert values to a string\n function toString(address value) external pure returns (string memory stringifiedValue);\n function toString(bytes calldata value) external pure returns (string memory stringifiedValue);\n function toString(bytes32 value) external pure returns (string memory stringifiedValue);\n function toString(bool value) external pure returns (string memory stringifiedValue);\n function toString(uint256 value) external pure returns (string memory stringifiedValue);\n function toString(int256 value) external pure returns (string memory stringifiedValue);\n // Convert values from a string\n function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);\n function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);\n function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);\n function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);\n function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);\n function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);\n // Record all the transaction logs\n function recordLogs() external;\n // Gets all the recorded logs\n function getRecordedLogs() external returns (Log[] memory logs);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path m/44'/60'/0'/0/{index}\n function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at {derivationPath}{index}\n function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)\n external\n pure\n returns (uint256 privateKey);\n // Adds a private key to the local forge wallet and returns the address\n function rememberKey(uint256 privateKey) external returns (address keyAddr);\n //\n // parseJson\n //\n // ----\n // In case the returned value is a JSON object, it's encoded as a ABI-encoded tuple. As JSON objects\n // don't have the notion of ordered, but tuples do, they JSON object is encoded with it's fields ordered in\n // ALPHABETICAL order. That means that in order to successfully decode the tuple, we need to define a tuple that\n // encodes the fields in the same order, which is alphabetical. In the case of Solidity structs, they are encoded\n // as tuples, with the attributes in the order in which they are defined.\n // For example: json = { 'a': 1, 'b': 0xa4tb......3xs}\n // a: uint256\n // b: address\n // To decode that json, we need to define a struct or a tuple as follows:\n // struct json = { uint256 a; address b; }\n // If we defined a json struct with the opposite order, meaning placing the address b first, it would try to\n // decode the tuple in that order, and thus fail.\n // ----\n // Given a string of JSON, return it as ABI-encoded\n function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);\n function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);\n\n // The following parseJson cheatcodes will do type coercion, for the type that they indicate.\n // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12'\n // and hex numbers '0xEF'.\n // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not\n // a JSON object.\n function parseJsonUint(string calldata, string calldata) external returns (uint256);\n function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);\n function parseJsonInt(string calldata, string calldata) external returns (int256);\n function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);\n function parseJsonBool(string calldata, string calldata) external returns (bool);\n function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);\n function parseJsonAddress(string calldata, string calldata) external returns (address);\n function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);\n function parseJsonString(string calldata, string calldata) external returns (string memory);\n function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);\n function parseJsonBytes(string calldata, string calldata) external returns (bytes memory);\n function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory);\n function parseJsonBytes32(string calldata, string calldata) external returns (bytes32);\n function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory);\n\n // Serialize a key and value to a JSON object stored in-memory that can be later written to a file\n // It returns the stringified version of the specific JSON file up to that moment.\n function serializeBool(string calldata objectKey, string calldata valueKey, bool value)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address value)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)\n external\n returns (string memory json);\n\n function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)\n external\n returns (string memory json);\n\n //\n // writeJson\n //\n // ----\n // Write a serialized JSON object to a file. If the file exists, it will be overwritten.\n // Let's assume we want to write the following JSON to a file:\n //\n // { \"boolean\": true, \"number\": 342, \"object\": { \"title\": \"finally json serialization\" } }\n //\n // ```\n // string memory json1 = \"some key\";\n // vm.serializeBool(json1, \"boolean\", true);\n // vm.serializeBool(json1, \"number\", uint256(342));\n // json2 = \"some other key\";\n // string memory output = vm.serializeString(json2, \"title\", \"finally json serialization\");\n // string memory finalJson = vm.serialize(json1, \"object\", output);\n // vm.writeJson(finalJson, \"./output/example.json\");\n // ```\n // The critical insight is that every invocation of serialization will return the stringified version of the JSON\n // up to that point. That means we can construct arbitrary JSON objects and then use the return stringified version\n // to serialize them as values to another JSON object.\n //\n // json1 and json2 are simply keys used by the backend to keep track of the objects. So vm.serializeJson(json1,..)\n // will find the object in-memory that is keyed by \"some key\".\n function writeJson(string calldata json, string calldata path) external;\n // Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \n // This is useful to replace a specific value of a JSON file, without having to parse the entire thing\n function writeJson(string calldata json, string calldata path, string calldata valueKey) external;\n // Returns the RPC url for the given alias\n function rpcUrl(string calldata rpcAlias) external view returns (string memory json);\n // Returns all rpc urls and their aliases `[alias, url][]`\n function rpcUrls() external view returns (string[2][] memory urls);\n // Returns all rpc urls and their aliases as structs.\n function rpcUrlStructs() external view returns (Rpc[] memory urls);\n // If the condition is false, discard this run's fuzz inputs and generate new ones.\n function assume(bool condition) external pure;\n // Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.\n function pauseGasMetering() external;\n // Resumes gas metering (i.e. gas usage is counted again). Noop if already on.\n function resumeGasMetering() external;\n}\n\ninterface Vm is VmSafe {\n // Sets block.timestamp\n function warp(uint256 newTimestamp) external;\n // Sets block.height\n function roll(uint256 newHeight) external;\n // Sets block.basefee\n function fee(uint256 newBasefee) external;\n // Sets block.difficulty\n function difficulty(uint256 newDifficulty) external;\n // Sets block.chainid\n function chainId(uint256 newChainId) external;\n // Stores a value to an address' storage slot.\n function store(address target, bytes32 slot, bytes32 value) external;\n // Sets the nonce of an account; must be higher than the current nonce of the account\n function setNonce(address account, uint64 newNonce) external;\n // Sets the *next* call's msg.sender to be the input address\n function prank(address msgSender) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called\n function startPrank(address msgSender) external;\n // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input\n function prank(address msgSender, address txOrigin) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input\n function startPrank(address msgSender, address txOrigin) external;\n // Resets subsequent calls' msg.sender to be `address(this)`\n function stopPrank() external;\n // Sets an address' balance\n function deal(address account, uint256 newBalance) external;\n // Sets an address' code\n function etch(address target, bytes calldata newRuntimeBytecode) external;\n // Expects an error on next call\n function expectRevert(bytes calldata revertData) external;\n function expectRevert(bytes4 revertData) external;\n function expectRevert() external;\n // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData).\n // Call this function, then emit an event, then call a function. Internally after the call, we check if\n // logs were emitted in the expected order with the expected topics and data (as specified by the booleans)\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)\n external;\n // Mocks a call to an address, returning specified data.\n // Calldata can either be strict or a partial match, e.g. if you only\n // pass a Solidity selector to the expected calldata, then the entire Solidity\n // function will be mocked.\n function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;\n // Mocks a call to an address with a specific msg.value, returning specified data.\n // Calldata match takes precedence over msg.value in case of ambiguity.\n function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;\n // Clears all mocked calls\n function clearMockedCalls() external;\n // Expects a call to an address with the specified calldata.\n // Calldata can either be a strict or a partial match\n function expectCall(address callee, bytes calldata data) external;\n // Expects a call to an address with the specified msg.value and calldata\n function expectCall(address callee, uint256 msgValue, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value, gas, and calldata.\n function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas.\n function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;\n // Sets block.coinbase\n function coinbase(address newCoinbase) external;\n // Snapshot the current state of the evm.\n // Returns the id of the snapshot that was created.\n // To revert a snapshot use `revertTo`\n function snapshot() external returns (uint256 snapshotId);\n // Revert the state of the EVM to a previous snapshot\n // Takes the snapshot id to revert to.\n // This deletes the snapshot and all snapshots taken after the given snapshot id.\n function revertTo(uint256 snapshotId) external returns (bool success);\n // Creates a new fork with the given endpoint and block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction,\n // and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before\n // the transaction, returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.\n function selectFork(uint256 forkId) external;\n /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.\n function activeFork() external view returns (uint256 forkId);\n // Updates the currently active fork to given block number\n // This is similar to `roll` but for the currently active fork\n function rollFork(uint256 blockNumber) external;\n // Updates the currently active fork to given transaction\n // this will `rollFork` with the number of the block the transaction was mined in and replays all transaction mined before it in the block\n function rollFork(bytes32 txHash) external;\n // Updates the given fork to given block number\n function rollFork(uint256 forkId, uint256 blockNumber) external;\n // Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block\n function rollFork(uint256 forkId, bytes32 txHash) external;\n // Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\n // Meaning, changes made to the state of this account will be kept when switching forks\n function makePersistent(address account) external;\n function makePersistent(address account0, address account1) external;\n function makePersistent(address account0, address account1, address account2) external;\n function makePersistent(address[] calldata accounts) external;\n // Revokes persistent status from the address, previously added via `makePersistent`\n function revokePersistent(address account) external;\n function revokePersistent(address[] calldata accounts) external;\n // Returns true if the account is marked as persistent\n function isPersistent(address account) external view returns (bool persistent);\n // In forking mode, explicitly grant the given address cheatcode access\n function allowCheatcodes(address account) external;\n // Fetches the given transaction from the active fork and executes it on the current state\n function transact(bytes32 txHash) external;\n // Fetches the given transaction from the given fork and executes it on the current state\n function transact(uint256 forkId, bytes32 txHash) external;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/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/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2Upgradeable {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(\n uint256 amount,\n bytes32 salt,\n bytes memory bytecode\n ) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(\n bytes32 salt,\n bytes32 bytecodeHash,\n address deployer\n ) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n" + }, + "solmate/auth/Auth.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\nabstract contract Auth {\n event OwnerUpdated(address indexed user, address indexed newOwner);\n\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\n\n address public owner;\n\n Authority public authority;\n\n constructor(address _owner, Authority _authority) {\n owner = _owner;\n authority = _authority;\n\n emit OwnerUpdated(msg.sender, _owner);\n emit AuthorityUpdated(msg.sender, _authority);\n }\n\n modifier requiresAuth() virtual {\n require(isAuthorized(msg.sender, msg.sig), \"UNAUTHORIZED\");\n\n _;\n }\n\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\n\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\n }\n\n function setAuthority(Authority newAuthority) public virtual {\n // We check if the caller is the owner first because we want to ensure they can\n // always swap out the authority even if it's reverting or using up a lot of gas.\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\n\n authority = newAuthority;\n\n emit AuthorityUpdated(msg.sender, newAuthority);\n }\n\n function setOwner(address newOwner) public virtual requiresAuth {\n owner = newOwner;\n\n emit OwnerUpdated(msg.sender, newOwner);\n }\n}\n\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\ninterface Authority {\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n}\n" + }, + "solmate/auth/authorities/RolesAuthority.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {Auth, Authority} from \"../Auth.sol\";\n\n/// @notice Role based Authority that supports up to 256 roles.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\ncontract RolesAuthority is Auth, Authority {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\n\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\n\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\n\n /*//////////////////////////////////////////////////////////////\n ROLE/USER STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(address => bytes32) public getUserRoles;\n\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\n\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\n\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\n }\n\n function doesRoleHaveCapability(\n uint8 role,\n address target,\n bytes4 functionSig\n ) public view virtual returns (bool) {\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\n }\n\n /*//////////////////////////////////////////////////////////////\n AUTHORIZATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) public view virtual override returns (bool) {\n return\n isCapabilityPublic[target][functionSig] ||\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\n }\n\n /*//////////////////////////////////////////////////////////////\n ROLE CAPABILITY CONFIGURATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setPublicCapability(\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n isCapabilityPublic[target][functionSig] = enabled;\n\n emit PublicCapabilityUpdated(target, functionSig, enabled);\n }\n\n function setRoleCapability(\n uint8 role,\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\n } else {\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\n }\n\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\n }\n\n /*//////////////////////////////////////////////////////////////\n USER ROLE ASSIGNMENT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setUserRole(\n address user,\n uint8 role,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getUserRoles[user] |= bytes32(1 << role);\n } else {\n getUserRoles[user] &= ~bytes32(1 << role);\n }\n\n emit UserRoleUpdated(user, role, enabled);\n }\n}\n" + }, + "solmate/tokens/ERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" + }, + "solmate/tokens/WETH.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"./ERC20.sol\";\n\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\n\n/// @notice Minimalist and modern Wrapped Ether implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)\n/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)\ncontract WETH is ERC20(\"Wrapped Ether\", \"WETH\", 18) {\n using SafeTransferLib for address;\n\n event Deposit(address indexed from, uint256 amount);\n\n event Withdrawal(address indexed to, uint256 amount);\n\n function deposit() public payable virtual {\n _mint(msg.sender, msg.value);\n\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 amount) public virtual {\n _burn(msg.sender, amount);\n\n emit Withdrawal(msg.sender, amount);\n\n msg.sender.safeTransferETH(amount);\n }\n\n receive() external payable virtual {\n deposit();\n }\n}\n" + }, + "solmate/utils/FixedPointMathLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // Divide z by the denominator.\n z := div(z, denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // First, divide z - 1 by the denominator and add 1.\n // We allow z - 1 to underflow if z is 0, because we multiply the\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n assembly {\n let y := x // We start y at x, which will help us make our initial estimate.\n\n z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n // We check y >= 2^(k + 8) but shift right by k bits\n // each branch to ensure that if x >= 256, then y >= 256.\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n y := shr(128, y)\n z := shl(64, z)\n }\n if iszero(lt(y, 0x1000000000000000000)) {\n y := shr(64, y)\n z := shl(32, z)\n }\n if iszero(lt(y, 0x10000000000)) {\n y := shr(32, y)\n z := shl(16, z)\n }\n if iszero(lt(y, 0x1000000)) {\n y := shr(16, y)\n z := shl(8, z)\n }\n\n // Goal was to get z*z*y within a small factor of x. More iterations could\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n // There is no overflow risk here since y < 2^136 after the first branch above.\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // If x+1 is a perfect square, the Babylonian method cycles between\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n z := sub(z, lt(div(x, z), z))\n }\n }\n\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Mod x by y. Note this will return\n // 0 instead of reverting if y is zero.\n z := mod(x, y)\n }\n }\n\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\n assembly {\n // Divide x by y. Note this will return\n // 0 instead of reverting if y is zero.\n r := div(x, y)\n }\n }\n\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Add 1 to x * y if x % y > 0. Note this will\n // return 0 instead of reverting if y is zero.\n z := add(gt(mod(x, y), 0), div(x, y))\n }\n }\n}\n" + }, + "solmate/utils/SafeCastLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Safe unsigned integer casting library that reverts on overflow.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\nlibrary SafeCastLib {\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\n require(x < 1 << 248);\n\n y = uint248(x);\n }\n\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\n require(x < 1 << 224);\n\n y = uint224(x);\n }\n\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\n require(x < 1 << 192);\n\n y = uint192(x);\n }\n\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\n require(x < 1 << 160);\n\n y = uint160(x);\n }\n\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\n require(x < 1 << 128);\n\n y = uint128(x);\n }\n\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\n require(x < 1 << 96);\n\n y = uint96(x);\n }\n\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\n require(x < 1 << 64);\n\n y = uint64(x);\n }\n\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\n require(x < 1 << 32);\n\n y = uint32(x);\n }\n\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\n require(x < 1 << 24);\n\n y = uint24(x);\n }\n\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\n require(x < 1 << 16);\n\n y = uint16(x);\n }\n\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\n require(x < 1 << 8);\n\n y = uint8(x);\n }\n}\n" + }, + "solmate/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/solcInputs/0e89febeebc7444140de8e67c9067d2c.json b/packages/contracts/deployments/superseed/solcInputs/0e89febeebc7444140de8e67c9067d2c.json new file mode 100644 index 0000000000..6eb5ed905b --- /dev/null +++ b/packages/contracts/deployments/superseed/solcInputs/0e89febeebc7444140de8e67c9067d2c.json @@ -0,0 +1,80 @@ +{ + "language": "Solidity", + "sources": { + "solc_0.8/openzeppelin/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor (address initialOwner) {\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "solc_0.8/openzeppelin/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" + }, + "solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n\n constructor (address initialOwner) Ownable(initialOwner) {}\n\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view virtual returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(Address.isContract(IBeacon(newBeacon).implementation()), \"ERC1967: beacon implementation is not a contract\");\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "solc_0.8/openzeppelin/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "solc_0.8/openzeppelin/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract OptimizedTransparentUpgradeableProxy is ERC1967Proxy {\n address internal immutable _ADMIN;\n\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _ADMIN = admin_;\n\n // still store it to work with EIP-1967\n bytes32 slot = _ADMIN_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, admin_)\n }\n emit AdminChanged(address(0), admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n\n function _getAdmin() internal view virtual override returns (address) {\n return _ADMIN;\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/utils/UUPSUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate that the this implementation remains valid after an upgrade.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeTo(address newImplementation) external virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n}\n" + }, + "solc_0.8/openzeppelin/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/UpgradeableBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n\n constructor(address implementation_, address initialOwner) Ownable(initialOwner) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" + }, + "solc_0.8/openzeppelin/proxy/beacon/BeaconProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 999999 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/solcInputs/1e4f471f16b899e44d9741c8c59a2559.json b/packages/contracts/deployments/superseed/solcInputs/1e4f471f16b899e44d9741c8c59a2559.json new file mode 100644 index 0000000000..3bcce8e5e0 --- /dev/null +++ b/packages/contracts/deployments/superseed/solcInputs/1e4f471f16b899e44d9741c8c59a2559.json @@ -0,0 +1,732 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable2Step.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 \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.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/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "adrastia-periphery/rates/IHistoricalRates.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\nimport \"./RateLibrary.sol\";\n\n/**\n * @title IHistoricalRates\n * @notice An interface that defines a contract that stores historical rates.\n */\ninterface IHistoricalRates {\n /// @notice Gets an rate for a token at a specific index.\n /// @param token The address of the token to get the rates for.\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\n /// index contains the oldest rate (uses reverse chronological ordering).\n /// @return rate The rate for the token at the specified index.\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @param offset The index of the first rate to get (default: 0).\n /// @param increment The increment between rates to get (default: 1).\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the number of rates for a token.\n /// @param token The address of the token to get the number of rates for.\n /// @return count The number of rates for the token.\n function getRatesCount(address token) external view returns (uint256);\n\n /// @notice Gets the capacity of rates for a token.\n /// @param token The address of the token to get the capacity of rates for.\n /// @return capacity The capacity of rates for the token.\n function getRatesCapacity(address token) external view returns (uint256);\n\n /// @notice Sets the capacity of rates for a token.\n /// @param token The address of the token to set the capacity of rates for.\n /// @param amount The new capacity of rates for the token.\n function setRatesCapacity(address token, uint256 amount) external;\n}\n" + }, + "adrastia-periphery/rates/RateLibrary.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nlibrary RateLibrary {\n struct Rate {\n uint64 target;\n uint64 current;\n uint32 timestamp;\n }\n}\n" + }, + "contracts/adrastia/PrudentiaLib.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nlibrary PrudentiaLib {\n struct PrudentiaConfig {\n address controller; // Adrastia Prudentia controller address\n uint8 offset; // Offset for delayed rate activation\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\n }\n}\n" + }, + "contracts/compound/CarefulMath.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Careful Math\n * @author Compound\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint256 c;\n unchecked {\n c = a * b;\n }\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n uint256 c;\n unchecked {\n c = a + b;\n }\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(\n uint256 a,\n uint256 b,\n uint256 c\n ) internal pure returns (MathError, uint256) {\n (MathError err0, uint256 sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/compound/CErc20Delegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CToken.sol\";\n\n/**\n * @title Compound's CErc20Delegate Contract\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\n * @author Compound\n */\ncontract CErc20Delegate is CErc20 {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 3;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n */\n function _becomeImplementation(bytes memory) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 1;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20Delegate\";\n }\n}\n" + }, + "contracts/compound/CErc20Delegator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ComptrollerInterface.sol\";\nimport \"./InterestRateModel.sol\";\nimport \"../ionic/DiamondExtension.sol\";\nimport { CErc20DelegatorBase, CDelegateInterface } from \"./CTokenInterfaces.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\n/**\n * @title Compound's CErc20Delegator Contract\n * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Compound\n */\ncontract CErc20Delegator is CErc20DelegatorBase, DiamondBase {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param ionicAdmin_ The FeeDistributor contract address.\n * @param interestRateModel_ The address of the interest rate model\n * @param name_ ERC-20 name of this token\n * @param symbol_ ERC-20 symbol of this token\n */\n constructor(\n address underlying_,\n IonicComptroller comptroller_,\n address payable ionicAdmin_,\n InterestRateModel interestRateModel_,\n string memory name_,\n string memory symbol_,\n uint256 reserveFactorMantissa_,\n uint256 adminFeeMantissa_\n ) {\n require(msg.sender == ionicAdmin_, \"!admin\");\n uint8 decimals_ = EIP20Interface(underlying_).decimals();\n {\n ionicAdmin = ionicAdmin_;\n\n // Set initial exchange rate\n initialExchangeRateMantissa = 0.2e18;\n\n // Set the comptroller\n comptroller = comptroller_;\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = 1e18;\n\n // Set the interest rate model (depends on block number / borrow index)\n require(interestRateModel_.isInterestRateModel(), \"!notIrm\");\n interestRateModel = interestRateModel_;\n emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // Set reserve factor\n // Check newReserveFactor ≤ maxReserveFactor\n require(\n reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!rf:set\"\n );\n reserveFactorMantissa = reserveFactorMantissa_;\n emit NewReserveFactor(0, reserveFactorMantissa_);\n\n // Set admin fee\n // Sanitize adminFeeMantissa_\n if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n require(\n reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!adminFee:set\"\n );\n adminFeeMantissa = adminFeeMantissa_;\n emit NewAdminFee(0, adminFeeMantissa_);\n ionicFeeMantissa = newIonicFeeMantissa;\n emit NewIonicFee(0, newIonicFeeMantissa);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n function implementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"delegateType()\"))));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {\n // Check admin rights\n require(hasAdminRights(), \"!admin\");\n\n // Set implementation\n _setImplementationInternal(implementation_, becomeImplementationData);\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self or admin\");\n\n (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature(\"delegateType()\"));\n require(success, \"no delegate type\");\n\n uint8 currentDelegateType = abi.decode(data, (uint8));\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)\n .latestCErc20Delegate(currentDelegateType);\n\n address currentDelegate = implementation();\n if (currentDelegate != latestCErc20Delegate) {\n _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);\n } else {\n // only update the extensions without reinitializing with becomeImplementationData\n _updateExtensions(currentDelegate);\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(msg.sender == address(ionicAdmin), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n /**\n * @dev Internal function to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {\n address delegateBefore = implementation();\n _updateExtensions(implementation_);\n\n _functionCall(\n address(this),\n abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),\n \"!become impl\"\n );\n\n emit NewImplementation(delegateBefore, implementation_);\n }\n\n function _updateExtensions(address newDelegate) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CErc20PluginDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\nimport \"./IERC4626.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\n/**\n * @title Rari's CErc20Plugin's Contract\n * @notice CToken which outsources token logic to a plugin\n * @author Joey Santoro\n *\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\n */\ncontract CErc20PluginDelegate is CErc20Delegate {\n event NewPluginImplementation(address oldImpl, address newImpl);\n\n /**\n * @notice Plugin address\n */\n IERC4626 public plugin;\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Delegate interface to become the implementation\n * @param data The encoded arguments for becoming\n */\n function _becomeImplementation(bytes memory data) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _becomeImplementation\");\n\n address _plugin = abi.decode(data, (address));\n\n if (_plugin == address(0) && address(plugin) != address(0)) {\n // if no new plugin address is given, use the latest implementation\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\n }\n\n if (_plugin != address(0) && _plugin != address(plugin)) {\n _updatePlugin(_plugin);\n }\n }\n\n /**\n * @notice Update the plugin implementation to a whitelisted implementation\n * @param _plugin The address of the plugin implementation to use\n */\n function _updatePlugin(address _plugin) public {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _updatePlugin\");\n\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\n\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\n }\n\n plugin = IERC4626(_plugin);\n\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\n\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\n if (amount != 0) {\n deposit(amount);\n }\n\n emit NewPluginImplementation(oldImplementation, _plugin);\n }\n\n /*** CToken Overrides ***/\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of the plugin in terms of the underlying\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view override returns (uint256) {\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\n }\n\n /**\n * @notice Transfer the underlying to the cToken and trigger a deposit\n * @param from Address to transfer funds from\n * @param amount Amount of underlying to transfer\n * @return The actual amount that is transferred\n */\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\n // Perform the EIP-20 transfer in\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \"send\");\n\n deposit(amount);\n return amount;\n }\n\n function deposit(uint256 amount) internal {\n plugin.deposit(amount, address(this));\n }\n\n /**\n * @notice Transfer the underlying from plugin to destination\n * @param to Address to transfer funds to\n * @param amount Amount of underlying to transfer\n */\n function doTransferOut(address to, uint256 amount) internal override {\n plugin.withdraw(amount, to, address(this));\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 2;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20PluginDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20PluginRewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20PluginDelegate.sol\";\n\ncontract CErc20PluginRewardsDelegate is CErc20PluginDelegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying && _token != address(plugin), \"!token\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 4;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20PluginRewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20RewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\n\ncontract CErc20RewardsDelegate is CErc20Delegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n \n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying, \"!underlying\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 3;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20RewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/Comptroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./Unitroller.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { IIonicFlywheel } from \"../ionic/strategies/flywheel/IIonicFlywheel.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\n */\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when an admin supports a market\n event MarketListed(ICErc20 cToken);\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(ICErc20 cToken, address account);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(ICErc20 cToken, address account);\n\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\n\n /// @notice Emitted when the whitelist enforcement is changed\n event WhitelistEnforcementChanged(bool enforce);\n\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\n event AddedRewardsDistributor(address rewardsDistributor);\n\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n // liquidationIncentiveMantissa must be no less than this value\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\n\n // liquidationIncentiveMantissa must be no greater than this value\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\n\n modifier isAuthorized() {\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \"not authorized\");\n _;\n }\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\n return ComptrollerBase.effectiveSupplyCaps(cToken);\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\n return ComptrollerBase.effectiveBorrowCaps(cToken);\n }\n\n /*** Assets You Are In ***/\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\n ICErc20[] memory assetsIn = accountAssets[account];\n\n return assetsIn;\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param cToken The cToken to check\n * @return True if the account is in the asset, otherwise false.\n */\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\n return markets[address(cToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param cTokens The list of addresses of the cToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\n uint256 len = cTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i = 0; i < len; i++) {\n ICErc20 cToken = ICErc20(cTokens[i]);\n\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param cToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\n Market storage marketToJoin = markets[address(cToken)];\n\n if (!marketToJoin.isListed) {\n // market is not listed, cannot join\n return Error.MARKET_NOT_LISTED;\n }\n\n if (marketToJoin.accountMembership[borrower] == true) {\n // already joined\n return Error.NO_ERROR;\n }\n\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(cToken);\n\n // Add to allBorrowers\n if (!borrowers[borrower]) {\n allBorrowers.push(borrower);\n borrowers[borrower] = true;\n borrowerIndexes[borrower] = allBorrowers.length - 1;\n }\n\n emit MarketEntered(cToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow.\n * @param cTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\n // TODO\n require(markets[cTokenAddress].isListed, \"!Comptroller:exitMarket\");\n\n ICErc20 cToken = ICErc20(cTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"!exitMarket\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[cTokenAddress];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set cToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete cToken from the account’s list of assets */\n // load into memory for faster iteration\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n ICErc20[] storage storedList = accountAssets[msg.sender];\n storedList[assetIndex] = storedList[storedList.length - 1];\n storedList.pop();\n\n // If the user has exited all markets, remove them from the `allBorrowers` array\n if (storedList.length == 0) {\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\n allBorrowers.pop(); // Reduce length by 1\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\n }\n\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Policy Hooks ***/\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param cTokenAddress The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintGuardianPaused[cTokenAddress], \"!mint:paused\");\n\n // Make sure market is listed\n if (!markets[cTokenAddress].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure minter is whitelisted\n if (enforceWhitelist && !whitelist[minter]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\n\n // Supply cap of 0 corresponds to unlimited supplying\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\n uint256 nonWhitelistedTotalSupply;\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\n\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \"!supply cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cTokenAddress, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param cToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n function redeemAllowedInternal(\n address cToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[cToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n ICErc20(cToken),\n redeemTokens,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint and reverts on rejection. May emit logs.\n * @param cToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n // Add minter to suppliers mapping\n suppliers[minter] = true;\n }\n\n /**\n * @notice Validates redeem and reverts on rejection. May emit logs.\n * @param cToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(\n address cToken,\n address redeemer,\n uint256 redeemAmount,\n uint256 redeemTokens\n ) external override {\n require(markets[msg.sender].isListed, \"!market\");\n\n // Require tokens is zero or amount is also zero\n if (redeemTokens == 0 && redeemAmount > 0) {\n revert(\"!zero\");\n }\n }\n\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) external view override returns (uint256) {\n address cToken = address(cTokenModify);\n // Accrue interest\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\n\n // Get account liquidity\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n isBorrow ? cTokenModify : ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n require(err == Error.NO_ERROR, \"!liquidity\");\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\n\n // Get max borrow/redeem\n uint256 maxBorrowOrRedeemAmount;\n\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\n // Max redeem = balance of underlying if not used as collateral\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\n } else {\n // Avoid \"stack too deep\" error by separating this logic\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\n\n // Redeem only: max out at underlying balance\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\n }\n\n // Get max borrow or redeem considering cToken liquidity\n uint256 cTokenLiquidity = cTokenModify.getCash();\n\n // Return the minimum of the two maximums\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\n }\n\n /**\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \"stack too deep\" errors.\n */\n function _getMaxRedeemOrBorrow(\n uint256 liquidity,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal view returns (uint256) {\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\n\n // Get the normalized price of the asset\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\n require(conversionFactor > 0, \"!oracle\");\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n if (!isBorrow) {\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\n }\n\n // Get max borrow or redeem considering excess account liquidity\n return (liquidity * 1e18) / conversionFactor;\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!borrowGuardianPaused[cToken], \"!borrow:paused\");\n\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n if (!markets[cToken].accountMembership[borrower]) {\n // only cTokens may call borrowAllowed if borrower not in market\n require(msg.sender == cToken, \"!ctoken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n // it should be impossible to break the important invariant\n assert(markets[cToken].accountMembership[borrower]);\n }\n\n // Make sure oracle price is available\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n // Make sure borrower is whitelisted\n if (enforceWhitelist && !whitelist[borrower]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 borrowCap = effectiveBorrowCaps(cToken);\n\n // Borrow cap of 0 corresponds to unlimited borrowing\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\n uint256 nonWhitelistedTotalBorrows;\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \"!borrow:cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n // Perform a hypothetical liquidity check to guard against shortfall\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\n if (err != uint256(Error.NO_ERROR)) {\n return err;\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken Asset whose underlying is being borrowed\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\n */\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\n // Check if min borrow exists\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\n\n if (minBorrowEth > 0) {\n // Get new underlying borrow balance of account for this cToken\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\n Exp({ mantissa: oraclePriceMantissa }),\n accountBorrowsNew\n );\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\n\n // Check against min borrow\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\n }\n\n // Return no error\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param cToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which would borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure markets are listed\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Get borrowers' underlying borrow balance\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\n\n /* allow accounts to be liquidated if the market is deprecated */\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\n require(borrowBalance >= repayAmount, \"!borrow>repay\");\n } else {\n /* The borrower must have shortfall in order to be liquidateable */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n /* The liquidator may not repay more than what is allowed by the closeFactor */\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\n if (repayAmount > maxClose) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!seizeGuardianPaused, \"!seize:paused\");\n\n // Make sure markets are listed\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure cToken Comptrollers are identical\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param cToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of cTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address cToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!transferGuardianPaused, \"!transfer:paused\");\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cToken, src, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Flywheel Hooks ***/\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\n * @param cToken The relevant market\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n */\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\n }\n\n /*** Liquidity/Liquidation Calculations ***/\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n ICErc20 asset;\n uint256 sumCollateral;\n uint256 sumBorrowPlusEffects;\n uint256 cTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n uint256 borrowCapForCollateral;\n uint256 borrowedAssetPrice;\n uint256 assetAsCollateralValueCap;\n }\n\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(\n account,\n ICErc20(cTokenModify),\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code,\n hypothetical account collateral value,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n ICErc20 cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) internal view returns (Error, uint256, uint256, uint256) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n\n if (address(cTokenModify) != address(0)) {\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n }\n\n // For each asset the account is in\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\n vars.asset = accountAssets[account][i];\n\n {\n // Read the balances and exchange rate from the cToken\n uint256 oErr;\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\n }\n }\n {\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\n if (vars.oraclePriceMantissa == 0) {\n return (Error.PRICE_ERROR, 0, 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n }\n {\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\n vars.asset,\n cTokenModify,\n redeemTokens > 0,\n account\n );\n\n // accumulate the collateral value to sumCollateral\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\n assetCollateralValue = vars.assetAsCollateralValueCap;\n vars.sumCollateral += assetCollateralValue;\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with cTokenModify\n if (vars.asset == cTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\n if (repayEffect >= vars.sumBorrowPlusEffects) {\n vars.sumBorrowPlusEffects = 0;\n } else {\n vars.sumBorrowPlusEffects -= repayEffect;\n }\n }\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\n * @param cTokenBorrowed The address of the borrowed cToken\n * @param cTokenCollateral The address of the collateral cToken\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 actualRepayAmount\n ) external view override returns (uint256, uint256) {\n /* Read oracle prices for borrowed and collateral markets */\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\n uint256 seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\n\n /*\n * The liquidation penalty includes\n * - the liquidator incentive\n * - the protocol fees (Ionic admin fees)\n * - the market fee\n */\n Exp memory totalPenaltyMantissa = add_(\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\n Exp({ mantissa: feeSeizeShareMantissa })\n );\n\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n return (uint256(Error.NO_ERROR), seizeTokens);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Add a RewardsDistributor contracts.\n * @dev Admin function to add a RewardsDistributor contract\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addRewardsDistributor(address distributor) external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n\n // Check marker method\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \"!isRewardsDistributor\");\n\n // Check for existing RewardsDistributor\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \"!added\");\n\n // Add RewardsDistributor to array\n rewardsDistributors.push(distributor);\n emit AddedRewardsDistributor(distributor);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist enforcement for the comptroller\n * @dev Admin function to set a new whitelist enforcement boolean\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\n }\n\n // Check if `enforceWhitelist` already equals `enforce`\n if (enforceWhitelist == enforce) {\n return uint256(Error.NO_ERROR);\n }\n\n // Set comptroller's `enforceWhitelist` to `enforce`\n enforceWhitelist = enforce;\n\n // Emit WhitelistEnforcementChanged(bool enforce);\n emit WhitelistEnforcementChanged(enforce);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist `statuses` for `suppliers`\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\n }\n\n // Set whitelist statuses for suppliers\n for (uint256 i = 0; i < suppliers.length; i++) {\n address supplier = suppliers[i];\n\n if (statuses[i]) {\n // If not already whitelisted, add to whitelist\n if (!whitelist[supplier]) {\n whitelist[supplier] = true;\n whitelistArray.push(supplier);\n whitelistIndexes[supplier] = whitelistArray.length - 1;\n }\n } else {\n // If whitelisted, remove from whitelist\n if (whitelist[supplier]) {\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\n whitelistArray.pop(); // Reduce length by 1\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\n }\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Admin function to set a new price oracle\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\n }\n\n // Track the old oracle for the comptroller\n BasePriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Admin function to set closeFactor\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\n }\n\n // Check limits\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n if (lessThanExp(highLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n // Set pool close factor to new close factor, remember old value\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n\n // Emit event\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Admin function to set per-market collateralFactor\n * @param cToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\n }\n\n // Verify market is listed\n Market storage market = markets[address(cToken)];\n if (!market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\n }\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n // Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Admin function to set liquidationIncentive\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\n }\n\n // Check de-scaled min <= newLiquidationIncentive <= max\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Admin function to set isListed and add support for the market\n * @param cToken The address of the market (token) to list\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Is market already listed?\n if (markets[address(cToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // Check cToken.comptroller == this\n require(address(cToken.comptroller()) == address(this), \"!comptroller\");\n\n // Make sure market is not already listed\n address underlying = ICErc20(address(cToken)).underlying();\n\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // List market and emit event\n Market storage market = markets[address(cToken)];\n market.isListed = true;\n market.collateralFactorMantissa = 0;\n allMarkets.push(cToken);\n cTokensByUnderlying[underlying] = cToken;\n emit MarketListed(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _deployMarket(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\n bool oldIonicAdminHasRights = ionicAdminHasRights;\n ionicAdminHasRights = true;\n\n // Deploy via Ionic admin\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\n // Reset Ionic admin rights to the original value\n ionicAdminHasRights = oldIonicAdminHasRights;\n // Support market here in the Comptroller\n uint256 err = _supportMarket(cToken);\n\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\n\n // Set collateral factor\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\n }\n\n function _becomeImplementation() external {\n require(msg.sender == address(this), \"!self call\");\n\n if (!_notEnteredInitialized) {\n _notEntered = true;\n _notEnteredInitialized = true;\n }\n }\n\n /*** Helper Functions ***/\n\n /**\n * @notice Returns true if the given cToken market has been deprecated\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\n * @param cToken The market to check if deprecated\n */\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\n return\n markets[address(cToken)].collateralFactorMantissa == 0 &&\n borrowGuardianPaused[address(cToken)] == true &&\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\n }\n\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\n return ComptrollerExtensionInterface(address(this));\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 32;\n\n functionSelectors = new bytes4[](fnsCount);\n\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\n functionSelectors[--fnsCount] = this._deployMarket.selector;\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\n functionSelectors[--fnsCount] = this.checkMembership.selector;\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\n functionSelectors[--fnsCount] = this.exitMarket.selector;\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\n functionSelectors[--fnsCount] = this.mintVerify.selector;\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n /**\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _beforeNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_beforeNonReentrant\");\n require(_notEntered, \"!reentered\");\n _notEntered = false;\n }\n\n /**\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _afterNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_afterNonReentrant\");\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n}\n" + }, + "contracts/compound/ComptrollerFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ComptrollerFirstExtension is\n DiamondExtension,\n ComptrollerBase,\n ComptrollerExtensionInterface,\n ComptrollerErrorReporter\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when supply cap for a cToken is changed\n event NewSupplyCap(ICErc20 indexed cToken, uint256 newSupplyCap);\n\n /// @notice Emitted when borrow cap for a cToken is changed\n event NewBorrowCap(ICErc20 indexed cToken, uint256 newBorrowCap);\n\n /// @notice Emitted when borrow cap guardian is changed\n event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused globally\n event ActionPaused(string action, bool pauseState);\n\n /// @notice Emitted when an action is paused on a market\n event MarketActionPaused(ICErc20 cToken, string action, bool pauseState);\n\n /// @notice Emitted when an admin unsupports a market\n event MarketUnlisted(ICErc20 cToken);\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 33;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector;\n functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector;\n functionSelectors[--fnsCount] = this._setMarketBorrowCaps.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._supplyCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._borrowCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapGuardian.selector;\n functionSelectors[--fnsCount] = this._setPauseGuardian.selector;\n functionSelectors[--fnsCount] = this._setMintPaused.selector;\n functionSelectors[--fnsCount] = this._setBorrowPaused.selector;\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this._unsupportMarket.selector;\n functionSelectors[--fnsCount] = this.getAllMarkets.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowers.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowersCount.selector;\n functionSelectors[--fnsCount] = this.getPaginatedBorrowers.selector;\n functionSelectors[--fnsCount] = this.getWhitelist.selector;\n functionSelectors[--fnsCount] = this.getRewardsDistributors.selector;\n functionSelectors[--fnsCount] = this.isUserOfPool.selector;\n functionSelectors[--fnsCount] = this.getAccruingFlywheels.selector;\n functionSelectors[--fnsCount] = this._removeFlywheel.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateral.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateral.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapForCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBlacklistBorrowingAgainstCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isSupplyCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector;\n functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /**\n * @notice Returns true if the accruing flyhwheel was found and replaced\n * @dev Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\n * @param flywheelAddress The address of the flywheel to add to the non-accruing\n */\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n require(flywheelAddress != nonAccruingRewardsDistributors[i], \"!alreadyadded\");\n }\n\n // add it to the non-accruing\n nonAccruingRewardsDistributors.push(flywheelAddress);\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256) {\n if (address(collateral) == address(cTokenModify) && !redeeming) {\n // the collateral asset counts as 0 liquidity when borrowed\n return 0;\n }\n\n uint256 assetAsCollateralValueCap = type(uint256).max;\n if (address(cTokenModify) != address(0)) {\n // if the borrowed asset is blacklisted against this collateral & account is not whitelisted\n if (\n borrowingAgainstCollateralBlacklist[address(cTokenModify)][address(collateral)] &&\n !borrowingAgainstCollateralBlacklistWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n assetAsCollateralValueCap = 0;\n } else {\n // for each user the value of this kind of collateral is capped regardless of the amount borrowed\n // denominated in the borrowed asset\n uint256 borrowCapForCollateral = borrowCapForCollateral[address(cTokenModify)][address(collateral)];\n // check if set to any value & account is not whitelisted\n if (\n borrowCapForCollateral != 0 &&\n !borrowCapForCollateralWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n // this asset usage as collateral is capped at the native value of the borrow cap\n assetAsCollateralValueCap = (borrowCapForCollateral * borrowedAssetPrice) / 1e18;\n }\n }\n }\n\n uint256 supplyCap = effectiveSupplyCaps(address(collateral));\n\n // if there is any supply cap, don't allow donations to the market/plugin to go around it\n if (supplyCap > 0 && !supplyCapWhitelist[address(collateral)].contains(account)) {\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateral);\n uint256 supplyCapValue = (supplyCap * collateralAssetPrice) / 1e18;\n supplyCapValue = (supplyCapValue * markets[address(collateral)].collateralFactorMantissa) / 1e18;\n if (supplyCapValue < assetAsCollateralValueCap) assetAsCollateralValueCap = supplyCapValue;\n }\n\n return assetAsCollateralValueCap;\n }\n\n /**\n * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\n * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\n * @param cTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\n */\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n supplyCaps[address(cTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(cTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\n * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\n * @param cTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\n */\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n borrowCaps[address(cTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Admin function to change the Borrow Cap Guardian\n * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian\n */\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external {\n require(msg.sender == admin, \"!admin\");\n\n // Save current value for inclusion in log\n address oldBorrowCapGuardian = borrowCapGuardian;\n\n // Store borrowCapGuardian with value newBorrowCapGuardian\n borrowCapGuardian = newBorrowCapGuardian;\n\n // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)\n emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(address newPauseGuardian) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);\n }\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setMintPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n mintGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Mint\", state);\n return state;\n }\n\n function _setBorrowPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n borrowGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Borrow\", state);\n return state;\n }\n\n function _setTransferPaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n transferGuardianPaused = state;\n emit ActionPaused(\"Transfer\", state);\n return state;\n }\n\n function _setSeizePaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n seizeGuardianPaused = state;\n emit ActionPaused(\"Seize\", state);\n return state;\n }\n\n /**\n * @notice Removed a market from the markets mapping and sets it as unlisted\n * @dev Admin function unset isListed and collateralFactorMantissa and unadd support for the market\n * @param cToken The address of the market (token) to unlist\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _unsupportMarket(ICErc20 cToken) external returns (uint256) {\n // Check admin rights\n if (!hasAdminRights()) return fail(Error.UNAUTHORIZED, FailureInfo.UNSUPPORT_MARKET_OWNER_CHECK);\n\n // Check if market is already unlisted\n if (!markets[address(cToken)].isListed)\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNSUPPORT_MARKET_DOES_NOT_EXIST);\n\n // Check if market is in use\n if (cToken.totalSupply() > 0) return fail(Error.NONZERO_TOTAL_SUPPLY, FailureInfo.UNSUPPORT_MARKET_IN_USE);\n\n // Unlist market\n delete markets[address(cToken)];\n\n /* Delete cToken from allMarkets */\n // load into memory for faster iteration\n ICErc20[] memory _allMarkets = allMarkets;\n uint256 len = _allMarkets.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (_allMarkets[i] == cToken) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n allMarkets[assetIndex] = allMarkets[allMarkets.length - 1];\n allMarkets.pop();\n\n cTokensByUnderlying[ICErc20(address(cToken)).underlying()] = ICErc20(address(0));\n emit MarketUnlisted(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) public {\n require(hasAdminRights(), \"!admin\");\n borrowCapForCollateral[cTokenBorrow][cTokenCollateral] = borrowCap;\n }\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n borrowingAgainstCollateralBlacklist[cTokenBorrow][cTokenCollateral] = blacklisted;\n }\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) supplyCapWhitelist[cToken].add(account);\n else supplyCapWhitelist[cToken].remove(account);\n }\n\n function isSupplyCapWhitelisted(address cToken, address account) public view returns (bool) {\n return supplyCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedSuppliersSupply(address cToken) public view returns (uint256 supplied) {\n address[] memory whitelistedSuppliers = supplyCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedSuppliers.length; i++) {\n supplied += ICErc20(cToken).balanceOfUnderlying(whitelistedSuppliers[i]);\n }\n }\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapWhitelist[cToken].add(account);\n else borrowCapWhitelist[cToken].remove(account);\n }\n\n function isBorrowCapWhitelisted(address cToken, address account) public view returns (bool) {\n return borrowCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedBorrowersBorrows(address cToken) public view returns (uint256 borrowed) {\n address[] memory whitelistedBorrowers = borrowCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedBorrowers.length; i++) {\n borrowed += ICErc20(cToken).borrowBalanceCurrent(whitelistedBorrowers[i]);\n }\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market.\n * @return The list of market addresses\n */\n function getAllMarkets() public view returns (ICErc20[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Return all of the borrowers\n * @dev The automatic getter may be used to access an individual borrower.\n * @return The list of borrower account addresses\n */\n function getAllBorrowers() public view returns (address[] memory) {\n return allBorrowers;\n }\n\n function getAllBorrowersCount() public view returns (uint256) {\n return allBorrowers.length;\n }\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) public view returns (uint256 _totalPages, address[] memory _pageOfBorrowers) {\n uint256 allBorrowersCount = allBorrowers.length;\n if (allBorrowersCount == 0) {\n return (0, new address[](0));\n }\n\n if (pageSize == 0) pageSize = 300;\n uint256 currentPageSize = pageSize;\n uint256 sizeOfPageFromRemainder = allBorrowersCount % pageSize;\n\n _totalPages = allBorrowersCount / pageSize;\n if (sizeOfPageFromRemainder > 0) {\n _totalPages++;\n if (page + 1 == _totalPages) {\n currentPageSize = sizeOfPageFromRemainder;\n }\n }\n\n if (page + 1 > _totalPages) {\n return (_totalPages, new address[](0));\n }\n\n uint256 offset = page * pageSize;\n _pageOfBorrowers = new address[](currentPageSize);\n for (uint256 i = 0; i < currentPageSize; i++) {\n _pageOfBorrowers[i] = allBorrowers[i + offset];\n }\n }\n\n /**\n * @notice Return all of the whitelist\n * @dev The automatic getter may be used to access an individual whitelist status.\n * @return The list of borrower account addresses\n */\n function getWhitelist() external view returns (address[] memory) {\n return whitelistArray;\n }\n\n /**\n * @notice Returns an array of all accruing and non-accruing flywheels\n */\n function getRewardsDistributors() external view returns (address[] memory) {\n address[] memory allFlywheels = new address[](rewardsDistributors.length + nonAccruingRewardsDistributors.length);\n\n uint8 i = 0;\n while (i < rewardsDistributors.length) {\n allFlywheels[i] = rewardsDistributors[i];\n i++;\n }\n uint8 j = 0;\n while (j < nonAccruingRewardsDistributors.length) {\n allFlywheels[i + j] = nonAccruingRewardsDistributors[j];\n j++;\n }\n\n return allFlywheels;\n }\n\n function getAccruingFlywheels() external view returns (address[] memory) {\n return rewardsDistributors;\n }\n\n /**\n * @dev Removes a flywheel from the accruing or non-accruing array\n * @param flywheelAddress The address of the flywheel to remove from the accruing or non-accruing array\n * @return true if the flywheel was found and removed\n */\n function _removeFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n // or remove it from the non-accruing\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n if (flywheelAddress == nonAccruingRewardsDistributors[i]) {\n nonAccruingRewardsDistributors[i] = nonAccruingRewardsDistributors[nonAccruingRewardsDistributors.length - 1];\n nonAccruingRewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function isUserOfPool(address user) external view returns (bool) {\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address marketAddress = address(allMarkets[i]);\n if (markets[marketAddress].accountMembership[user]) {\n return true;\n }\n }\n\n return false;\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n\n for (uint256 i = 0; i < allMarkets.length; i++) {\n allMarkets[i].registerInSFS();\n }\n\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/ComptrollerInterface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerV4Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\nimport { IHistoricalRates } from \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\ninterface ComptrollerInterface {\n function isDeprecated(ICErc20 cToken) external view returns (bool);\n\n function _becomeImplementation() external;\n\n function _deployMarket(\n uint8 delegateType,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\n\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\n\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _addRewardsDistributor(address distributor) external returns (uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) external view returns (uint256, uint256, uint256, uint256);\n\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cToken) external returns (uint256);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\n\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\n\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function getAccountLiquidity(\n address account\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\n\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 repayAmount\n ) external view returns (uint256, uint256);\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n function _beforeNonReentrant() external;\n\n function _afterNonReentrant() external;\n\n /*** New supply and borrow cap view functions ***/\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\n}\n\ninterface ComptrollerStorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function pendingAdmin() external view returns (address);\n\n function oracle() external view returns (BasePriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function enforceWhitelist() external view returns (bool);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function suppliers(address account) external view returns (bool);\n\n function cTokensByUnderlying(address) external view returns (address);\n\n /**\n * Gets the supply cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\n * `effectiveSupplyCaps` to get the correct supply cap.\n * @param cToken The address of the cToken.\n * @return The supply cap in the units of the underlying asset.\n */\n function supplyCaps(address cToken) external view returns (uint256);\n\n /**\n * Gets the borrow cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\n * `effectiveBorrowCaps` to get the correct borrow cap.\n * @param cToken The address of the cToken.\n * @return The borrow cap in the units of the underlying asset.\n */\n function borrowCaps(address cToken) external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function accountAssets(address, uint256) external view returns (address);\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function rewardsDistributors(uint256) external view returns (address);\n}\n\ninterface SFSRegister {\n function register(address _recipient) external returns (uint256 tokenId);\n}\n\ninterface ComptrollerExtensionInterface {\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function getAllBorrowersCount() external view returns (uint256);\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAccruingFlywheels() external view returns (address[] memory);\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) external;\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _removeFlywheel(address flywheelAddress) external returns (bool);\n\n function getWhitelist() external view returns (address[] memory);\n\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\n\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setTransferPaused(bool state) external returns (bool);\n\n function _setSeizePaused(bool state) external returns (bool);\n\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\n * @return The config.\n */\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\n * @return The config.\n */\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\n * @param newConfig The new config.\n */\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\n * @param newConfig The new config.\n */\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n}\n\ninterface UnitrollerInterface {\n function comptrollerImplementation() external view returns (address);\n\n function _upgrade() external;\n\n function _acceptAdmin() external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n\n function _toggleAdminRights(bool hasRights) external returns (uint256);\n}\n\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\n\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\n\ninterface IonicComptroller is\n ComptrollerInterface,\n ComptrollerExtensionInterface,\n UnitrollerInterface,\n ComptrollerStorageInterface\n{\n\n}\n\nabstract contract ComptrollerBase is ComptrollerV4Storage {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\n\n // Check if we're using Adrastia Prudentia for the supply cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the supply cap from Adrastia Prudentia\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n supplyCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n supplyCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local supply cap\n\n // Get the supply cap from the local supply cap\n supplyCap = supplyCaps[cToken];\n }\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\n\n // Check if we're using Adrastia Prudentia for the borrow cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the borrow cap from Adrastia Prudentia\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n borrowCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n borrowCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local borrow cap\n borrowCap = borrowCaps[cToken];\n }\n }\n}\n" + }, + "contracts/compound/ComptrollerPrudentiaCapsExt.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerPrudentiaCapsExtInterface, ComptrollerBase } from \"./ComptrollerInterface.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\n/**\n * @title ComptrollerPrudentiaCapsExt\n * @author Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)\n * @notice A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.\n */\ncontract ComptrollerPrudentiaCapsExt is DiamondExtension, ComptrollerBase, ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Emitted when the Adrastia Prudentia supply cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /**\n * @notice Emitted when the Adrastia Prudentia borrow cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = supplyCapConfig;\n supplyCapConfig = newConfig;\n\n emit NewSupplyCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = borrowCapConfig;\n borrowCapConfig = newConfig;\n\n emit NewBorrowCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return borrowCapConfig;\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return supplyCapConfig;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setSupplyCapConfig.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getSupplyCapConfig.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n" + }, + "contracts/compound/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IFeeDistributor.sol\";\nimport \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract UnitrollerAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Whether or not the Ionic admin has admin rights\n */\n bool public ionicAdminHasRights = true;\n\n /**\n * @notice Whether or not the admin has admin rights\n */\n bool public adminHasRights = true;\n\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\n }\n}\n\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n BasePriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /*\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 internal maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => ICErc20[]) public accountAssets;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n struct Market {\n // Whether or not this market is listed\n bool isListed;\n // Multiplier representing the most one can borrow against their collateral in this market.\n // For instance, 0.9 to allow borrowing 90% of collateral value.\n // Must be between 0 and 1, and stored as a mantissa.\n uint256 collateralFactorMantissa;\n // Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n }\n\n /**\n * @notice Official mapping of cTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /// @notice A list of all markets\n ICErc20[] public allMarkets;\n\n /**\n * @dev Maps borrowers to booleans indicating if they have entered any markets\n */\n mapping(address => bool) internal borrowers;\n\n /// @notice A list of all borrowers who have entered markets\n address[] public allBorrowers;\n\n // Indexes of borrower account addresses in the `allBorrowers` array\n mapping(address => uint256) internal borrowerIndexes;\n\n /**\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\n */\n mapping(address => bool) public suppliers;\n\n /// @notice All cTokens addresses mapped by their underlying token addresses\n mapping(address => ICErc20) public cTokensByUnderlying;\n\n /// @notice Whether or not the supplier whitelist is enforced\n bool public enforceWhitelist;\n\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\n mapping(address => bool) public whitelist;\n\n /// @notice An array of all whitelisted accounts\n address[] public whitelistArray;\n\n // Indexes of account addresses in the `whitelistArray` array\n mapping(address => uint256) internal whitelistIndexes;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n * Actions which allow users to remove their own assets cannot be paused.\n * Liquidation / seizing / transfer can only be paused globally, not by market.\n */\n address public pauseGuardian;\n bool public _mintGuardianPaused;\n bool public _borrowGuardianPaused;\n bool public transferGuardianPaused;\n bool public seizeGuardianPaused;\n mapping(address => bool) public mintGuardianPaused;\n mapping(address => bool) public borrowGuardianPaused;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\n mapping(address => uint256) public borrowCaps;\n\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\n mapping(address => uint256) public supplyCaps;\n\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\n address[] public rewardsDistributors;\n\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\n bool internal _notEntered;\n\n /// @dev Whether or not _notEntered has been initialized\n bool internal _notEnteredInitialized;\n\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\n address[] public nonAccruingRewardsDistributors;\n\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\n\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => mapping(address => EnumerableSet.AddressSet))\n internal borrowingAgainstCollateralBlacklistWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @dev Adrastia Prudentia config for controlling borrow caps.\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\n\n /// @dev Adrastia Prudentia config for controlling supply caps.\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\n}\n" + }, + "contracts/compound/CToken.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { CTokenSecondExtensionBase, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { DiamondExtension, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\n\n/**\n * @title Compound's CErc20 Contract\n * @notice CTokens which wrap an EIP-20 underlying\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\n * @author Compound\n */\nabstract contract CErc20 is CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n modifier isMinHFThresholdExceeded(address borrower) {\n PoolLens lens = PoolLens(ap.getAddress(\"PoolLens\"));\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\n require(msg.sender == address(liquidator), \"Health factor not low enough for non-permissioned liquidations\");\n _;\n } else {\n _;\n }\n }\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 13;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.mint.selector;\n functionSelectors[--fnsCount] = this.redeem.selector;\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\n functionSelectors[--fnsCount] = this.borrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\n functionSelectors[--fnsCount] = this.getCash.selector;\n functionSelectors[--fnsCount] = this.seize.selector;\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external override isAuthorized returns (uint256) {\n (uint256 err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external override isAuthorized returns (uint256) {\n return redeemInternal(redeemTokens);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized returns (uint256) {\n return redeemUnderlyingInternal(redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external override isAuthorized returns (uint256) {\n return borrowInternal(borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external override isAuthorized returns (uint256) {\n (uint256 err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized returns (uint256) {\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external override isAuthorized isMinHFThresholdExceeded(borrower) returns (uint256) {\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\n return err;\n }\n\n /**\n * @notice Get cash balance of this cToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view override returns (uint256) {\n return getCashInternal();\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another cToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override nonReentrant(true) returns (uint256) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n function selfTransferOut(address to, uint256 amount) external override {\n require(msg.sender == address(this), \"!self\");\n doTransferOut(to, amount);\n }\n\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\n require(msg.sender == address(this), \"!self\");\n return doTransferIn(from, amount);\n }\n\n /**\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\n }\n\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalIonicFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\n totalIonicFees = totalIonicFeesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(address(ionicAdmin), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces admin fees by transferring to admin\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalAdminFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n totalAdminFees = totalAdminFees - withdrawAmount;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view virtual returns (uint256) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\n \"TOKEN_TRANSFER_IN_FAILED\"\n );\n\n // Calculate the amount that was *actually* transferred\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address to, uint256 amount) internal virtual {\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\n \"TOKEN_TRANSFER_OUT_FAILED\"\n );\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n struct MintLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 mintTokens;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n uint256 actualMintAmount;\n }\n\n /**\n * @notice User supplies assets into the market and receives cTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\n /* Fail if mint not allowed */\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n // Check max supply\n // unused function\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n } */\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of cTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n // mintTokens is rounded down here - correct\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n require(vars.mathErr == MathError.NO_ERROR, \"MINT_EXCHANGE_CALCULATION_FAILED\");\n require(vars.mintTokens > 0, \"MINT_ZERO_CTOKENS_REJECTED\");\n\n /*\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\n\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, 0, redeemAmount);\n }\n\n struct RedeemLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 redeemTokens;\n uint256 redeemAmount;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n }\n\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\n res = (x * 1e18) / y;\n if (x % y != 0) res += 1;\n }\n\n /**\n * @notice User redeems cTokens in exchange for the underlying asset\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemFresh(\n address redeemer,\n uint256 redeemTokensIn,\n uint256 redeemAmountIn\n ) internal returns (uint256) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"!redeem tokens or amount\");\n\n RedeemLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n if (redeemTokensIn > 0) {\n // don't allow dust tokens/assets to be left after\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\n\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n } else {\n if (redeemAmountIn == type(uint256).max) {\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\n }\n\n // don't allow dust tokens/assets to be left after\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\n\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\n\n // don't allow dust tokens/assets to be left after\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashInternal() < vars.redeemAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the redeemer and the redeemAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(redeemer, vars.redeemAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\n\n /* We call the defense hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(msg.sender, borrowAmount);\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n }\n\n /**\n * @notice Users borrow assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\n /* Fail if borrow not allowed */\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\n }\n\n /* Fail gracefully if protocol has insufficient underlying cash */\n uint256 cashPrior = getCashInternal();\n\n if (cashPrior < borrowAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n uint256(vars.mathErr)\n );\n }\n\n // Check min borrow for this user for this asset\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the borrower and the borrowAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(borrower, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\n internal\n nonReentrant(false)\n returns (uint256, uint256)\n {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint256 repayAmount;\n uint256 borrowerIndex;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n uint256 actualRepayAmount;\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer the account paying off the borrow\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(\n address payer,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256, uint256) {\n /* Fail if repayBorrow not allowed */\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == type(uint256).max) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\");\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\");\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n ICErc20(cTokenCollateral).accrueInterest();\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal returns (uint256, uint256) {\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n cTokenCollateral,\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify cTokenCollateral market's block number equals current block number */\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == type(uint256).max) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n cTokenCollateral,\n actualRepayAmount\n );\n require(amountSeizeError == uint256(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint256 seizeError;\n if (cTokenCollateral == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"!seize\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n\n struct SeizeInternalLocalVars {\n MathError mathErr;\n uint256 borrowerTokensNew;\n uint256 liquidatorTokensNew;\n uint256 liquidatorSeizeTokens;\n uint256 protocolSeizeTokens;\n uint256 protocolSeizeAmount;\n uint256 exchangeRateMantissa;\n uint256 totalReservesNew;\n uint256 totalIonicFeeNew;\n uint256 totalSupplyNew;\n uint256 feeSeizeTokens;\n uint256 feeSeizeAmount;\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) internal returns (uint256) {\n /* Fail if seize not allowed */\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n SeizeInternalLocalVars memory vars;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\n }\n\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n vars.protocolSeizeAmount = mul_ScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n vars.protocolSeizeTokens\n );\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\n\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\n\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n totalReserves = vars.totalReservesNew;\n totalSupply = vars.totalSupplyNew;\n totalIonicFees = vars.totalIonicFeeNew;\n\n accountTokens[borrower] = vars.borrowerTokensNew;\n accountTokens[liquidator] = vars.liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n function asCTokenExtension() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\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 * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CTokenFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { IFlashLoanReceiver } from \"../ionic/IFlashLoanReceiver.sol\";\nimport { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { SFSRegister } from \"./ComptrollerInterface.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { Multicall } from \"../utils/Multicall.sol\";\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\n\ncontract CTokenFirstExtension is\n CErc20FirstExtensionBase,\n TokenErrorReporter,\n Exponential,\n DiamondExtension,\n Multicall\n{\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 25;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.transfer.selector;\n functionSelectors[--fnsCount] = this.transferFrom.selector;\n functionSelectors[--fnsCount] = this.allowance.selector;\n functionSelectors[--fnsCount] = this.approve.selector;\n functionSelectors[--fnsCount] = this.balanceOf.selector;\n functionSelectors[--fnsCount] = this._setAdminFee.selector;\n functionSelectors[--fnsCount] = this._setInterestRateModel.selector;\n functionSelectors[--fnsCount] = this._setNameAndSymbol.selector;\n functionSelectors[--fnsCount] = this._setAddressesProvider.selector;\n functionSelectors[--fnsCount] = this._setReserveFactor.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.exchangeRateCurrent.selector;\n functionSelectors[--fnsCount] = this.accrueInterest.selector;\n functionSelectors[--fnsCount] = this.totalBorrowsCurrent.selector;\n functionSelectors[--fnsCount] = this.balanceOfUnderlying.selector;\n functionSelectors[--fnsCount] = this.multicall.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterDeposit.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterWithdraw.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlockAfterBorrow.selector;\n functionSelectors[--fnsCount] = this.getTotalUnderlyingSupplied.selector;\n functionSelectors[--fnsCount] = this.flash.selector;\n functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;\n functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getTotalUnderlyingSupplied() public view override returns (uint256) {\n // (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees))\n return asCToken().getCash() + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees);\n }\n\n /* ERC20 fns */\n /**\n * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {\n /* Fail if transfer not allowed */\n uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint256 startingAllowance = 0;\n if (spender == src) {\n startingAllowance = type(uint256).max;\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint256 allowanceNew;\n uint256 srcTokensNew;\n uint256 dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srcTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != type(uint256).max) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) public override nonReentrant(false) isAuthorized returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) public override isAuthorized returns (bool) {\n address src = msg.sender;\n transferAllowances[src][spender] = amount;\n emit Approval(src, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) public view override returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) public view override returns (uint256) {\n return accountTokens[owner];\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice updates the cToken ERC20 name and symbol\n * @dev Admin function to update the cToken ERC20 name and symbol\n * @param _name the new ERC20 token name to use\n * @param _symbol the new ERC20 token symbol to use\n */\n function _setNameAndSymbol(string calldata _name, string calldata _symbol) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n // Set ERC20 name and symbol\n name = _name;\n symbol = _symbol;\n }\n\n function _setAddressesProvider(address _ap) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n ap = AddressesProvider(_ap);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(uint256 newReserveFactorMantissa) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK);\n }\n\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa + adminFeeMantissa + ionicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint256 oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\n * @dev Admin function to accrue interest and set a new admin fee\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setAdminFee(uint256 newAdminFeeMantissa) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_ADMIN_FEE_FRESH_CHECK);\n }\n\n // Sanitize newAdminFeeMantissa\n if (newAdminFeeMantissa == type(uint256).max) newAdminFeeMantissa = adminFeeMantissa;\n\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n\n // Check reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa ≤ reserveFactorPlusFeesMaxMantissa\n if (reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK);\n }\n\n // If setting admin fee\n if (adminFeeMantissa != newAdminFeeMantissa) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_ADMIN_FEE_ADMIN_CHECK);\n }\n\n // Set admin fee\n uint256 oldAdminFeeMantissa = adminFeeMantissa;\n adminFeeMantissa = newAdminFeeMantissa;\n\n // Emit event\n emit NewAdminFee(oldAdminFeeMantissa, newAdminFeeMantissa);\n }\n\n // If setting Ionic fee\n if (ionicFeeMantissa != newIonicFeeMantissa) {\n // Set Ionic fee\n uint256 oldIonicFeeMantissa = ionicFeeMantissa;\n ionicFeeMantissa = newIonicFeeMantissa;\n\n // Emit event\n emit NewIonicFee(oldIonicFeeMantissa, newIonicFeeMantissa);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(\n InterestRateModel newInterestRateModel\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);\n }\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n require(newInterestRateModel.isInterestRateModel(), \"!notIrm\");\n\n InterestRateModel oldInterestRateModel = interestRateModel;\n interestRateModel = newInterestRateModel;\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this cToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getBorrowRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) public view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= borrowAmount, \"market cash not enough\");\n\n return\n interestRateModel.getBorrowRate(\n cash - borrowAmount,\n totalBorrows + borrowAmount,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this cToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash() + mintAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= withdrawAmount, \"market cash not enough\");\n return\n interestRateModel.getSupplyRate(\n cash - withdrawAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public view override returns (uint256) {\n if (block.number == accrualBlockNumber) {\n return\n _exchangeRateHypothetical(\n totalSupply,\n initialExchangeRateMantissa,\n asCToken().getCash(),\n totalBorrows,\n totalReserves,\n totalAdminFees,\n totalIonicFees\n );\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n\n return\n _exchangeRateHypothetical(\n accrual.totalSupply,\n initialExchangeRateMantissa,\n cashPrior,\n accrual.totalBorrows,\n accrual.totalReserves,\n accrual.totalAdminFees,\n accrual.totalIonicFees\n );\n }\n }\n\n function _exchangeRateHypothetical(\n uint256 _totalSupply,\n uint256 _initialExchangeRateMantissa,\n uint256 _totalCash,\n uint256 _totalBorrows,\n uint256 _totalReserves,\n uint256 _totalAdminFees,\n uint256 _totalIonicFees\n ) internal pure returns (uint256) {\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return _initialExchangeRateMantissa;\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees)) / totalSupply\n */\n uint256 cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(\n _totalCash,\n _totalBorrows,\n _totalReserves + _totalAdminFees + _totalIonicFees\n );\n require(mathErr == MathError.NO_ERROR, \"!addThenSubUInt overflow check failed\");\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n require(mathErr == MathError.NO_ERROR, \"!getExp overflow check failed\");\n\n return exchangeRate.mantissa;\n }\n }\n\n struct InterestAccrual {\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalSupply;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n uint256 interestAccumulated;\n }\n\n function _accrueInterestHypothetical(\n uint256 blockNumber,\n uint256 cashPrior\n ) internal view returns (InterestAccrual memory accrual) {\n uint256 totalFees = totalAdminFees + totalIonicFees;\n uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);\n if (borrowRateMantissa > borrowRateMaxMantissa) {\n if (cashPrior > totalFees) revert(\"!borrowRate\");\n else borrowRateMantissa = borrowRateMaxMantissa;\n }\n (MathError mathErr, uint256 blockDelta) = subUInt(blockNumber, accrualBlockNumber);\n require(mathErr == MathError.NO_ERROR, \"!blockDelta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * totalIonicFeesNew = interestAccumulated * ionicFee + totalIonicFees\n * totalAdminFeesNew = interestAccumulated * adminFee + totalAdminFees\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n accrual.accrualBlockNumber = blockNumber;\n accrual.totalSupply = totalSupply;\n Exp memory simpleInterestFactor = mul_(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n accrual.interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, totalBorrows);\n accrual.totalBorrows = accrual.interestAccumulated + totalBorrows;\n accrual.totalReserves = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n accrual.interestAccumulated,\n totalReserves\n );\n accrual.totalIonicFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: ionicFeeMantissa }),\n accrual.interestAccumulated,\n totalIonicFees\n );\n accrual.totalAdminFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: adminFeeMantissa }),\n accrual.interestAccumulated,\n totalAdminFees\n );\n accrual.borrowIndex = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndex, borrowIndex);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public override returns (uint256) {\n /* Remember the initial block number */\n uint256 currentBlockNumber = block.number;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumber == currentBlockNumber) {\n return uint256(Error.NO_ERROR);\n }\n\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(currentBlockNumber, cashPrior);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = accrual.borrowIndex;\n totalBorrows = accrual.totalBorrows;\n totalReserves = accrual.totalReserves;\n totalIonicFees = accrual.totalIonicFees;\n totalAdminFees = accrual.totalAdminFees;\n emit AccrueInterest(cashPrior, accrual.interestAccumulated, borrowIndex, totalBorrows);\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external view override returns (uint256) {\n if (accrualBlockNumber == block.number) {\n return totalBorrows;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n return accrual.totalBorrows;\n }\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {\n uint256 cTokenBalance = accountTokens[account];\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n\n borrowBalance = borrowBalanceCurrent(account);\n\n exchangeRateMantissa = exchangeRateCurrent();\n\n return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\n * @param account The address whose balance should be calculated after recalculating the borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) public view override returns (uint256) {\n uint256 _borrowIndex;\n if (accrualBlockNumber == block.number) {\n _borrowIndex = borrowIndex;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n _borrowIndex = accrual.borrowIndex;\n }\n\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint256 principalTimesIndex;\n uint256 result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return 0;\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, _borrowIndex);\n require(mathErr == MathError.NO_ERROR, \"!mulUInt overflow check failed\");\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n require(mathErr == MathError.NO_ERROR, \"!divUInt overflow check failed\");\n\n return result;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external view override returns (uint256) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint256 balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n require(mErr == MathError.NO_ERROR, \"!balance\");\n return balance;\n }\n\n function flash(uint256 amount, bytes calldata data) public override isAuthorized {\n accrueInterest();\n\n totalBorrows += amount;\n asCToken().selfTransferOut(msg.sender, amount);\n\n IFlashLoanReceiver(msg.sender).receiveFlashLoan(underlying, amount, data);\n\n asCToken().selfTransferIn(msg.sender, amount);\n totalBorrows -= amount;\n\n emit Flash(msg.sender, amount);\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\n }\n\n function asCToken() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n function multicall(\n bytes[] calldata data\n ) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {\n return Multicall.multicall(data);\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights() || msg.sender == address(comptroller), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/CTokenInterfaces.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\n\nabstract contract CTokenAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n}\n\nabstract contract CErc20Storage is CTokenAdminStorage {\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /*\n * Maximum borrow rate that can ever be applied (.0005% / block)\n */\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /*\n * Maximum fraction of interest that can be set aside for reserves + fees\n */\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\n\n /**\n * @notice Contract which oversees inter-cToken operations\n */\n IonicComptroller public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /*\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\n */\n uint256 internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for admin fees\n */\n uint256 public adminFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for Ionic fees\n */\n uint256 public ionicFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint256 public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint256 public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint256 public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint256 public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint256 public totalReserves;\n\n /**\n * @notice Total amount of admin fees of the underlying held in this market\n */\n uint256 public totalAdminFees;\n\n /**\n * @notice Total amount of Ionic fees of the underlying held in this market\n */\n uint256 public totalIonicFees;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint256 public totalSupply;\n\n /*\n * Official record of token balances for each account\n */\n mapping(address => uint256) internal accountTokens;\n\n /*\n * Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint256)) internal transferAllowances;\n\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint256 principal;\n uint256 interestIndex;\n }\n\n /*\n * Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /*\n * Share of seized collateral that is added to reserves\n */\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\n\n /*\n * Share of seized collateral taken as fees\n */\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\n\n /**\n * @notice Underlying asset for this CToken\n */\n address public underlying;\n\n /**\n * @notice Addresses Provider\n */\n AddressesProvider public ap;\n}\n\nabstract contract CTokenBaseEvents {\n /* ERC20 */\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the admin fee is changed\n */\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\n\n /**\n * @notice Event emitted when the Ionic fee is changed\n */\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\n}\n\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\n event Flash(address receiver, uint256 amount);\n}\n\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral,\n uint256 seizeTokens\n );\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\n}\n\ninterface CTokenFirstExtensionInterface {\n /*** User Interface ***/\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n /*** Admin Functions ***/\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\n\n function getAccountSnapshot(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256\n );\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function exchangeRateCurrent() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function totalBorrowsCurrent() external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external view returns (uint256);\n\n function getTotalUnderlyingSupplied() external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external view returns (uint256);\n\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n\n function flash(uint256 amount, bytes calldata data) external;\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface CTokenSecondExtensionInterface {\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n /*** Admin Functions ***/\n\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\n\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\n\n function selfTransferOut(address to, uint256 amount) external;\n\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\n}\n\ninterface CDelegatorInterface {\n function implementation() external view returns (address);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external;\n}\n\ninterface CDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes calldata data) external;\n\n function delegateType() external pure returns (uint8);\n\n function contractType() external pure returns (string memory);\n}\n\nabstract contract CErc20AdminBase is CErc20Storage {\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\n return\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\n }\n}\n\nabstract contract CErc20FirstExtensionBase is\n CErc20AdminBase,\n CTokenFirstExtensionEvents,\n CTokenFirstExtensionInterface\n{}\n\nabstract contract CTokenSecondExtensionBase is\n CErc20AdminBase,\n CTokenSecondExtensionEvents,\n CTokenSecondExtensionInterface,\n CDelegateInterface\n{}\n\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\n\ninterface CErc20StorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function comptroller() external view returns (IonicComptroller);\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function accrualBlockNumber() external view returns (uint256);\n\n function underlying() external view returns (address);\n\n function borrowIndex() external view returns (uint256);\n\n function interestRateModel() external view returns (address);\n}\n\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\n function plugin() external view returns (address);\n}\n\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\n function approve(address, address) external;\n}\n\ninterface ICErc20 is\n CErc20StorageInterface,\n CTokenSecondExtensionInterface,\n CTokenFirstExtensionInterface,\n CDelegatorInterface,\n CDelegateInterface\n{}\n\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\n function _updatePlugin(address _plugin) external;\n}\n\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\n" + }, + "contracts/compound/EIP20Interface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title ERC 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return uint256 The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance uint256 The balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success bool Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/compound/ErrorReporter.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n SUPPLIER_NOT_WHITELISTED,\n BORROW_BELOW_MIN,\n SUPPLY_ABOVE_MAX,\n NONZERO_TOTAL_SUPPLY\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\n SET_WHITELIST_STATUS_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n UNSUPPORT_MARKET_OWNER_CHECK,\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\n UNSUPPORT_MARKET_IN_USE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return uint256(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n UTILIZATION_ABOVE_MAX\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n NEW_UTILIZATION_RATE_ABOVE_MAX,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\n WITHDRAW_IONIC_FEES_VALIDATION,\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\n WITHDRAW_ADMIN_FEES_VALIDATION,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\n SET_ADMIN_FEE_ADMIN_CHECK,\n SET_ADMIN_FEE_FRESH_CHECK,\n SET_ADMIN_FEE_BOUNDS_CHECK,\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\n SET_IONIC_FEE_FRESH_CHECK,\n SET_IONIC_FEE_BOUNDS_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\n }\n}\n" + }, + "contracts/compound/Exponential.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(\n Exp memory a,\n Exp memory b,\n Exp memory c\n ) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/compound/ExponentialNoError.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint256 constant expScale = 1e18;\n uint256 constant doubleScale = 1e36;\n uint256 constant halfExpScale = expScale / 2;\n uint256 constant mantissaOne = expScale;\n\n struct Exp {\n uint256 mantissa;\n }\n\n struct Double {\n uint256 mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint256) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(\n Exp memory a,\n uint256 scalar,\n uint256 addend\n ) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2**224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2**32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint256 c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/compound/IERC4626.sol": { + "content": "pragma solidity >=0.8.0;\npragma experimental ABIEncoderV2;\n\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\ninterface IERC4626 is EIP20Interface {\n /*----------------------------------------------------------------\n Events\n ----------------------------------------------------------------*/\n\n event Deposit(address indexed from, address indexed to, uint256 value);\n\n event Withdraw(address indexed from, address indexed to, uint256 value);\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n /**\n @notice Deposit a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to deposit.\n @param to The address to receive shares corresponding to the deposit\n @return shares The shares in the vault credited to `to`\n */\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\n\n /**\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\n @param shareAmount The amount of vault shares to mint.\n @param to The address to receive shares corresponding to the mint.\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\n */\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\n\n /**\n @notice Withdraw a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to withdraw.\n @param to The address to receive underlying corresponding to the withdrawal.\n @param from The address to burn shares from corresponding to the withdrawal.\n @return shares The shares in the vault burned from sender\n */\n function withdraw(\n uint256 underlyingAmount,\n address to,\n address from\n ) external returns (uint256 shares);\n\n /**\n @notice Redeem a specific amount of shares for underlying tokens.\n @param shareAmount The amount of shares to redeem.\n @param to The address to receive underlying corresponding to the redemption.\n @param from The address to burn shares from corresponding to the redemption.\n @return value The underlying amount transferred to `to`.\n */\n function redeem(\n uint256 shareAmount,\n address to,\n address from\n ) external returns (uint256 value);\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n /** \n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n @return the address of the asset\n */\n function asset() external view returns (address);\n\n /** \n @notice Returns a user's Vault balance in underlying tokens.\n @param user The user to get the underlying balance of.\n @return balance The user's Vault balance in underlying tokens.\n */\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\n\n /** \n @notice Calculates the total amount of underlying tokens the Vault manages.\n @return The total amount of underlying tokens the Vault manages.\n */\n function totalAssets() external view returns (uint256);\n\n /** \n @notice Returns the value in underlying terms of one vault token. \n */\n function exchangeRate() external view returns (uint256);\n\n /**\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\n */\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\n @param shareAmount the amount of shares from a mint call.\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\n */\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n\n /**\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\n */\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\n @param shareAmount the amount of shares from a redeem call.\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\n */\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n}\n" + }, + "contracts/compound/IFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../ionic/AuthoritiesRegistry.sol\";\n\ninterface IFeeDistributor {\n function minBorrowEth() external view returns (uint256);\n\n function maxUtilizationRate() external view returns (uint256);\n\n function interestFeeRate() external view returns (uint256);\n\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\n\n function latestCErc20Delegate(uint8 delegateType)\n external\n view\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\n\n function latestPluginImplementation(address oldImplementation) external view returns (address);\n\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\n\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address);\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\n\n fallback() external payable;\n\n receive() external payable;\n}\n" + }, + "contracts/compound/InterestRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's InterestRateModel Interface\n * @author Compound\n */\nabstract contract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual returns (uint256);\n}\n" + }, + "contracts/compound/JumpRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Compound's JumpRateModel Contract\n * @author Compound\n */\ncontract JumpRateModel is InterestRateModel {\n event NewInterestParams(\n uint256 baseRatePerBlock,\n uint256 multiplierPerBlock,\n uint256 jumpMultiplierPerBlock,\n uint256 kink\n );\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint256 public blocksPerYear;\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint256 public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint256 public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint256 public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint256 public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param _blocksPerYear The approximate number of blocks per year\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(\n uint256 _blocksPerYear,\n uint256 baseRatePerYear,\n uint256 multiplierPerYear,\n uint256 jumpMultiplierPerYear,\n uint256 kink_\n ) {\n blocksPerYear = _blocksPerYear;\n baseRatePerBlock = baseRatePerYear / blocksPerYear;\n multiplierPerBlock = multiplierPerYear / blocksPerYear;\n jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return (borrows * 1e18) / (cash + borrows - reserves);\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n uint256 util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return ((util * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n } else {\n uint256 normalRate = ((kink * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n uint256 excessUtil = util - kink;\n return ((excessUtil * jumpMultiplierPerBlock) / 1e18) + normalRate;\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\n }\n}\n" + }, + "contracts/compound/Unitroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ErrorReporter.sol\";\nimport \"./ComptrollerStorage.sol\";\nimport \"./Comptroller.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\n\n/**\n * @title Unitroller\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\n * CTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\n /**\n * @notice Event emitted when the admin rights are changed\n */\n event AdminRightsToggled(bool hasRights);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address payable _ionicAdmin) {\n admin = msg.sender;\n ionicAdmin = _ionicAdmin;\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Toggles admin rights.\n * @param hasRights Boolean indicating if the admin is to have rights.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\n }\n\n // Check that rights have not already been set to the desired value\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\n\n adminHasRights = hasRights;\n emit AdminRightsToggled(hasRights);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = newPendingAdmin;\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n function comptrollerImplementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"_deployMarket(uint8,bytes,bytes,uint256)\"))));\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n\n address currentImplementation = comptrollerImplementation();\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\n currentImplementation\n );\n\n _updateExtensions(latestComptrollerImplementation);\n\n if (currentImplementation != latestComptrollerImplementation) {\n // reinitialize\n _functionCall(address(this), abi.encodeWithSignature(\"_becomeImplementation()\"), \"!become impl\");\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function _updateExtensions(address currentComptroller) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(hasAdminRights(), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/external/aerodrome/IAerodromeRouter.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.10;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20_Router {\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(address from, address to, uint256 amount) external returns (bool);\n}\n\ninterface IWETH is IERC20_Router {\n function deposit() external payable;\n\n function withdraw(uint256) external;\n}\n\ninterface IRouter_Aerodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n address factory;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientAmountAOptimal();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidAmountInForETHDeposit();\n error InvalidTokenInForETHDeposit();\n error InvalidPath();\n error InvalidRouteA();\n error InvalidRouteB();\n error OnlyWETH();\n error PoolDoesNotExist();\n error PoolFactoryDoesNotExist();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of FactoryRegistry.sol\n function factoryRegistry() external view returns (address);\n\n /// @notice Address of Protocol PoolFactory.sol\n function defaultFactory() external view returns (address);\n\n /// @notice Address of Voter.sol\n function voter() external view returns (address);\n\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\n function weth() external view returns (IWETH);\n\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\n function ETHER() external view returns (address);\n\n /// @dev Struct containing information necessary to zap in and out of pools\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable Stable or volatile pool\n /// @param factory factory of pool\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\n struct Zap {\n address tokenA;\n address tokenB;\n bool stable;\n address factory;\n uint256 amountOutMinA;\n uint256 amountOutMinB;\n uint256 amountAMin;\n uint256 amountBMin;\n }\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\n /// Reverts if _factory is not approved by the FactoryRegistry\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of factory which created the pool\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n // **** SWAP ****\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap one token for another without slippage protection\n /// @return amounts Array of amounts to swap per route\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function UNSAFE_swapExactTokensForTokens(\n uint256[] memory amounts,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n // **** SWAP (supporting fee-on-transfer tokens) ****\n\n /// @notice Swap one token for another supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable;\n\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the initial swap.\n /// Additional slippage may be required when adding liquidity as the\n /// price of the token may have changed.\n /// @param tokenIn Token you are zapping in from (i.e. input token).\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param zapInPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @param to Address you wish to mint liquidity to.\n /// @param stake Auto-stake liquidity in corresponding gauge.\n /// @return liquidity Amount of LP tokens created from zapping in.\n function zapIn(\n address tokenIn,\n uint256 amountInA,\n uint256 amountInB,\n Zap calldata zapInPool,\n Route[] calldata routesA,\n Route[] calldata routesB,\n address to,\n bool stake\n ) external payable returns (uint256 liquidity);\n\n /// @notice Zap out a pool (B, C) into A.\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the removal of liquidity.\n /// Additional slippage may be required on the swap as the\n /// price of the token may have changed.\n /// @param tokenOut Token you are zapping out to (i.e. output token).\n /// @param liquidity Amount of liquidity you wish to remove.\n /// @param zapOutPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n function zapOut(\n address tokenOut,\n uint256 liquidity,\n Zap calldata zapOutPool,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external;\n\n /// @notice Used to generate params required for zapping in.\n /// Zap in => remove liquidity then swap.\n /// Apply slippage to expected swap values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap in from.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\n function generateZapInParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountInA,\n uint256 amountInB,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used to generate params required for zapping out.\n /// Zap out => swap then add liquidity.\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap out of.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\n function generateZapOutParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\n /// @dev Returns stable liquidity ratio of B to (A + B).\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\n /// Therefore you should deposit more of token A than B.\n /// @param tokenA tokenA of stable pool you are zapping into.\n /// @param tokenB tokenB of stable pool you are zapping into.\n /// @param factory Factory that created stable pool.\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\n function quoteStableLiquidityRatio(\n address tokenA,\n address tokenB,\n address factory\n ) external view returns (uint256 ratio);\n}\n" + }, + "contracts/external/aerodrome/IAerodromeSwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.10;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via CL\ninterface ISwapRouter_Aerodrome {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/algebra/IAlgebraSwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IAlgebraPoolActions#swap\n/// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraSwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call\n function algebraSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/algebra/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport \"./IAlgebraSwapCallback.sol\";\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Algebra\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-periphery\ninterface IAlgebraSwapRouter is IAlgebraSwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Unlike standard swaps, handles transferring from user before the actual swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingleSupportingFeeOnTransferTokens(ExactInputSingleParams calldata params)\n external\n returns (uint256 amountOut);\n}\n" + }, + "contracts/external/balancer/IBalancerPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\n\ninterface IBalancerPool {\n function getFinalTokens() external view returns (address[] memory);\n\n function getNormalizedWeight(address token) external view returns (uint256);\n\n function getNormalizedWeights() external view returns (uint256[] memory);\n\n function getSwapFee() external view returns (uint256);\n\n function getNumTokens() external view returns (uint256);\n\n function getBalance(address token) external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;\n\n function swapExactAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n address tokenOut,\n uint256 minAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter);\n\n function swapExactAmountOut(\n address tokenIn,\n uint256 maxAmountIn,\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountIn, uint256 spotPriceAfter);\n\n function joinswapExternAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n uint256 minPoolAmountOut\n ) external returns (uint256 poolAmountOut);\n\n function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;\n\n function exitswapExternAmountOut(\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPoolAmountIn\n ) external returns (uint256 poolAmountIn);\n}\n" + }, + "contracts/external/balancer/IBalancerVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IAsset {}\n\nenum UserBalanceOpKind {\n DEPOSIT_INTERNAL,\n WITHDRAW_INTERNAL,\n TRANSFER_INTERNAL,\n TRANSFER_EXTERNAL\n}\n\nenum SwapKind {\n GIVEN_IN,\n GIVEN_OUT\n}\n\nenum ExitKind {\n EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,\n EXACT_BPT_IN_FOR_TOKENS_OUT,\n BPT_IN_FOR_EXACT_TOKENS_OUT,\n MANAGEMENT_FEE_TOKENS_OUT\n}\n\nstruct UserBalanceOp {\n UserBalanceOpKind kind;\n IAsset asset;\n uint256 amount;\n address sender;\n address payable recipient;\n}\nstruct FundManagement {\n address sender;\n bool fromInternalBalance;\n address payable recipient;\n bool toInternalBalance;\n}\n\nstruct SingleSwap {\n bytes32 poolId;\n SwapKind kind;\n IAsset assetIn;\n IAsset assetOut;\n uint256 amount;\n bytes userData;\n}\n\nstruct ExitPoolRequest {\n IERC20Upgradeable[] assets;\n uint256[] minAmountsOut;\n bytes userData;\n bool toInternalBalance;\n}\n\ninterface IBalancerVault {\n function swap(\n SingleSwap memory singleSwap,\n FundManagement memory funds,\n uint256 limit,\n uint256 deadline\n ) external returns (uint256 amountCalculated);\n\n function manageUserBalance(UserBalanceOp[] memory ops) external payable;\n\n function getPoolTokens(bytes32 poolId)\n external\n view\n returns (\n IERC20Upgradeable[] memory tokens,\n uint256[] memory balances,\n uint256 lastChangeBlock\n );\n\n function exitPool(\n bytes32 poolId,\n address sender,\n address payable recipient,\n ExitPoolRequest memory request\n ) external;\n}\n" + }, + "contracts/external/chainlink/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "contracts/external/compound/IComptroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./IPriceOracle.sol\";\nimport \"./ICToken.sol\";\nimport \"./IUnitroller.sol\";\nimport \"./IRewardsDistributor.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n */\ninterface IComptroller {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function oracle() external view returns (IPriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function getAssetsIn(address account) external view returns (ICToken[] memory);\n\n function checkMembership(address account, ICToken cToken) external view returns (bool);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n )\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function getAccountLiquidity(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _become(IUnitroller unitroller) external;\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAllMarkets() external view returns (ICToken[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function suppliers(address account) external view returns (bool);\n\n function supplyCaps(address cToken) external view returns (uint256);\n\n function borrowCaps(address cToken) external view returns (uint256);\n\n function enforceWhitelist() external view returns (bool);\n\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cTokenAddress) external returns (uint256);\n\n function autoImplementation() external view returns (bool);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\n\n function _deployMarket(\n bool isCEther,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getMaxRedeemOrBorrow(\n address account,\n ICToken cTokenModify,\n bool isBorrow\n ) external view returns (uint256);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function isDeprecated(ICToken cToken) external view returns (bool);\n\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n}\n" + }, + "contracts/external/compound/ICToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's CToken Contract\n * @notice Abstract base for CTokens\n * @author Compound\n */\ninterface ICToken {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function symbol() external view returns (string memory);\n\n function comptroller() external view returns (address);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function isCToken() external view returns (bool);\n\n function isCEther() external view returns (bool);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function totalBorrowsCurrent() external returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external returns (uint256);\n\n function exchangeRateCurrent() external returns (uint256);\n\n function exchangeRateStored() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n}\n" + }, + "contracts/external/compound/IPriceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\ninterface IPriceOracle {\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\n}\n" + }, + "contracts/external/compound/IRewardsDistributor.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\n/**\n * @title RewardsDistributor\n * @author Compound\n */\ninterface IRewardsDistributor {\n /// @dev The token to reward (i.e., COMP)\n function rewardToken() external view returns (address);\n\n /// @notice The portion of compRate that each market currently receives\n function compSupplySpeeds(address) external view returns (uint256);\n\n /// @notice The portion of compRate that each market currently receives\n function compBorrowSpeeds(address) external view returns (uint256);\n\n /// @notice The COMP accrued but not yet transferred to each user\n function compAccrued(address) external view returns (uint256);\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n /**\n * @notice Returns an array of all markets.\n */\n function getAllMarkets() external view returns (ICToken[] memory);\n}\n" + }, + "contracts/external/compound/IUnitroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * CTokens should reference this contract as their comptroller.\n */\ninterface IUnitroller {\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n}\n" + }, + "contracts/external/curve/ICurvePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ICurvePool is IERC20Upgradeable {\n function get_virtual_price() external view returns (uint256);\n\n function remove_liquidity_one_coin(\n uint256 _token_amount,\n int128 i,\n uint256 min_amount\n ) external;\n\n function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);\n\n function add_liquidity(uint256[2] calldata _amounts, uint256 _min_mint_amount) external returns (uint256);\n\n function exchange(\n int128 i,\n int128 j,\n uint256 dx,\n uint256 min_dy\n ) external returns (uint256);\n\n function get_dy(\n int128 i,\n int128 j,\n uint256 _dx\n ) external view returns (uint256);\n\n function coins(uint256 index) external view returns (address);\n\n function lp_token() external view returns (address);\n}\n" + }, + "contracts/external/curve/ICurveV2Pool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurvePool } from \"./ICurvePool.sol\";\n\ninterface ICurveV2Pool is ICurvePool {\n function price_oracle() external view returns (uint256);\n\n function lp_price() external view returns (uint256);\n\n function coins(uint256 arg0) external view returns (address);\n}\n" + }, + "contracts/external/jarvis/ISynthereumDeployment.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./ISynthereumFinder.sol\";\n\n/**\n * @title Interface that a pool MUST have in order to be included in the deployer\n */\ninterface ISynthereumDeployment {\n /**\n * @notice Get Synthereum finder of the pool/self-minting derivative\n * @return finder Returns finder contract\n */\n function synthereumFinder() external view returns (ISynthereumFinder finder);\n\n /**\n * @notice Get Synthereum version\n * @return poolVersion Returns the version of this pool/self-minting derivative\n */\n function version() external view returns (uint8 poolVersion);\n\n /**\n * @notice Get the collateral token of this pool/self-minting derivative\n * @return collateralCurrency The ERC20 collateral token\n */\n function collateralToken() external view returns (IERC20Upgradeable collateralCurrency);\n\n /**\n * @notice Get the synthetic token associated to this pool/self-minting derivative\n * @return syntheticCurrency The ERC20 synthetic token\n */\n function syntheticToken() external view returns (IERC20Upgradeable syntheticCurrency);\n\n /**\n * @notice Get the synthetic token symbol associated to this pool/self-minting derivative\n * @return symbol The ERC20 synthetic token symbol\n */\n function syntheticTokenSymbol() external view returns (string memory symbol);\n}\n" + }, + "contracts/external/jarvis/ISynthereumFinder.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\n/**\n * @title Provides addresses of the contracts implementing certain interfaces.\n */\ninterface ISynthereumFinder {\n /**\n * @notice Updates the address of the contract that implements `interfaceName`.\n * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.\n * @param implementationAddress address of the deployed contract that implements the interface.\n */\n function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;\n\n /**\n * @notice Gets the address of the contract that implements the given `interfaceName`.\n * @param interfaceName queried interface.\n * @return implementationAddress Address of the deployed contract that implements the interface.\n */\n function getImplementationAddress(bytes32 interfaceName) external view returns (address);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPool.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumLiquidityPoolGeneral.sol\";\n\n//import {\n//IEmergencyShutdown\n//} from '../../../common/interfaces/IEmergencyShutdown.sol';\n//import {ISynthereumLiquidityPoolGeneral} from './ILiquidityPoolGeneral.sol';\n//import {ISynthereumLiquidityPoolStorage} from './ILiquidityPoolStorage.sol';\n//import {ITypology} from '../../../common/interfaces/ITypology.sol';\n\n/**\n * @title Token Issuer Contract Interface\n */\n//ITypology,\n//IEmergencyShutdown,\ninterface ISynthereumLiquidityPool is ISynthereumLiquidityPoolGeneral {\n struct MintParams {\n // Minimum amount of synthetic tokens that a user wants to mint using collateral (anti-slippage)\n uint256 minNumTokens;\n // Amount of collateral that a user wants to spend for minting\n uint256 collateralAmount;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send synthetic tokens minted\n address recipient;\n }\n\n struct RedeemParams {\n // Amount of synthetic tokens that user wants to use for redeeming\n uint256 numTokens;\n // Minimium amount of collateral that user wants to redeem (anti-slippage)\n uint256 minCollateral;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send collateral tokens redeemed\n address recipient;\n }\n\n // struct ExchangeParams {\n // // Destination pool\n // ISynthereumLiquidityPoolGeneral destPool;\n // // Amount of source synthetic tokens that user wants to use for exchanging\n // uint256 numTokens;\n // // Minimum Amount of destination synthetic tokens that user wants to receive (anti-slippage)\n // uint256 minDestNumTokens;\n // // Expiration time of the transaction\n // uint256 expiration;\n // // Address to which send synthetic tokens exchanged\n // address recipient;\n // }\n\n /**\n * @notice Mint synthetic tokens using fixed amount of collateral\n * @notice This calculate the price using on chain price feed\n * @notice User must approve collateral transfer for the mint request to succeed\n * @param mintParams Input parameters for minting (see MintParams struct)\n * @return syntheticTokensMinted Amount of synthetic tokens minted by a user\n * @return feePaid Amount of collateral paid by the user as fee\n */\n function mint(MintParams calldata mintParams) external returns (uint256 syntheticTokensMinted, uint256 feePaid);\n\n /**\n * @notice Redeem amount of collateral using fixed number of synthetic token\n * @notice This calculate the price using on chain price feed\n * @notice User must approve synthetic token transfer for the redeem request to succeed\n * @param redeemParams Input parameters for redeeming (see RedeemParams struct)\n * @return collateralRedeemed Amount of collateral redeem by user\n * @return feePaid Amount of collateral paid by user as fee\n */\n function redeem(RedeemParams calldata redeemParams) external returns (uint256 collateralRedeemed, uint256 feePaid);\n\n // /**\n // * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool\n // * @notice This calculate the price using on chain price feed\n // * @notice User must approve synthetic token transfer for the redeem request to succeed\n // * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct)\n // * @return destNumTokensMinted Amount of collateral redeem by user\n // * @return feePaid Amount of collateral paid by user as fee\n // */\n // function exchange(ExchangeParams calldata exchangeParams)\n // external\n // returns (uint256 destNumTokensMinted, uint256 feePaid);\n\n /**\n * @notice Withdraw unused deposited collateral by the LP\n * @notice Only a sender with LP role can call this function\n * @param collateralAmount Collateral to be withdrawn\n * @return remainingLiquidity Remaining unused collateral in the pool\n */\n function withdrawLiquidity(uint256 collateralAmount) external returns (uint256 remainingLiquidity);\n\n /**\n * @notice Increase collaterallization of Lp position\n * @notice Only a sender with LP role can call this function\n * @param collateralToTransfer Collateral to be transferred before increase collateral in the position\n * @param collateralToIncrease Collateral to be added to the position\n * @return newTotalCollateral New total collateral amount\n */\n function increaseCollateral(uint256 collateralToTransfer, uint256 collateralToIncrease)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Decrease collaterallization of Lp position\n * @notice Check that final poosition is not undercollateralized\n * @notice Only a sender with LP role can call this function\n * @param collateralToDecrease Collateral to decreased from the position\n * @param collateralToWithdraw Collateral to be transferred to the LP\n * @return newTotalCollateral New total collateral amount\n */\n function decreaseCollateral(uint256 collateralToDecrease, uint256 collateralToWithdraw)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Withdraw fees gained by the sender\n * @return feeClaimed Amount of fee claimed\n */\n function claimFee() external returns (uint256 feeClaimed);\n\n /**\n * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized\n * @notice Revert if position is not undercollateralized\n * @param numSynthTokens Number of synthetic tokens that user wants to liquidate\n * @return synthTokensLiquidated Amount of synthetic tokens liquidated\n * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated\n * @return rewardAmount Amount of received collateral as reward for the liquidation\n */\n function liquidate(uint256 numSynthTokens)\n external\n returns (\n uint256 synthTokensLiquidated,\n uint256 collateralReceived,\n uint256 rewardAmount\n );\n\n /**\n * @notice Redeem tokens after emergency shutdown\n * @return synthTokensSettled Amount of synthetic tokens liquidated\n * @return collateralSettled Amount of collateral withdrawn after emergency shutdown\n */\n function settleEmergencyShutdown() external returns (uint256 synthTokensSettled, uint256 collateralSettled);\n\n // /**\n // * @notice Update the fee percentage, recipients and recipient proportions\n // * @notice Only the maintainer can call this function\n // * @param _feeData Fee info (percentage + recipients + weigths)\n // */\n // function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData)\n // external;\n\n /**\n * @notice Update the fee percentage\n * @notice Only the maintainer can call this function\n * @param _feePercentage The new fee percentage\n */\n function setFeePercentage(uint256 _feePercentage) external;\n\n /**\n * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive\n * @notice Only the maintainer can call this function\n * @param feeRecipients An array of the addresses of recipients that will receive generated fees\n * @param feeProportions An array of the proportions of fees generated each recipient will receive\n */\n function setFeeRecipients(address[] calldata feeRecipients, uint32[] calldata feeProportions) external;\n\n /**\n * @notice Update the overcollateralization percentage\n * @notice Only the maintainer can call this function\n * @param _overCollateralization Overcollateralization percentage\n */\n function setOverCollateralization(uint256 _overCollateralization) external;\n\n /**\n * @notice Update the liquidation reward percentage\n * @notice Only the maintainer can call this function\n * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator\n */\n function setLiquidationReward(uint256 _liquidationReward) external;\n\n /**\n * @notice Returns fee percentage set by the maintainer\n * @return Fee percentage\n */\n function feePercentage() external view returns (uint256);\n\n /**\n * @notice Returns fee recipients info\n * @return Addresses, weigths and total of weigths\n */\n function feeRecipientsInfo()\n external\n view\n returns (\n address[] memory,\n uint32[] memory,\n uint256\n );\n\n /**\n * @notice Returns total number of synthetic tokens generated by this pool\n * @return Number of synthetic tokens\n */\n function totalSyntheticTokens() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP)\n * @return Total collateral amount\n */\n function totalCollateralAmount() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of fees to be withdrawn\n * @return Total fee amount\n */\n function totalFeeAmount() external view returns (uint256);\n\n /**\n * @notice Returns the user's fee to be withdrawn\n * @param user User's address\n * @return User's fee\n */\n function userFee(address user) external view returns (uint256);\n\n /**\n * @notice Returns the percentage of overcollateralization to which a liquidation can triggered\n * @return Percentage of overcollateralization\n */\n function collateralRequirement() external view returns (uint256);\n\n /**\n * @notice Returns the percentage of reward for correct liquidation by a liquidator\n * @return Percentage of reward\n */\n function liquidationReward() external view returns (uint256);\n\n /**\n * @notice Returns the price of the pair at the moment of the shutdown\n * @return Price of the pair\n */\n function emergencyShutdownPrice() external view returns (uint256);\n\n /**\n * @notice Returns the timestamp (unix time) at the moment of the shutdown\n * @return Timestamp\n */\n function emergencyShutdownTimestamp() external view returns (uint256);\n\n /**\n * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price\n * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized))\n */\n function collateralCoverage() external returns (bool, uint256);\n\n /**\n * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param inputCollateral Input collateral amount to be exchanged\n * @return synthTokensReceived Synthetic tokens will be minted\n * @return feePaid Collateral fee will be paid\n */\n function getMintTradeInfo(uint256 inputCollateral)\n external\n view\n returns (uint256 synthTokensReceived, uint256 feePaid);\n\n /**\n * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param syntheticTokens Amount of synthetic tokens to be exchanged\n * @return collateralAmountReceived Collateral amount will be received by the user\n * @return feePaid Collateral fee will be paid\n */\n function getRedeemTradeInfo(uint256 syntheticTokens)\n external\n view\n returns (uint256 collateralAmountReceived, uint256 feePaid);\n\n // /**\n // * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n // * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n // * @param syntheticTokens Amount of synthetic tokens to be exchanged\n // * @param destinationPool Pool in which mint the destination synthetic token\n // * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool\n // * @return feePaid Collateral fee will be paid\n // */\n // function getExchangeTradeInfo(\n // uint256 syntheticTokens,\n // ISynthereumLiquidityPoolGeneral destinationPool\n // )\n // external\n // view\n // returns (uint256 destSyntheticTokensReceived, uint256 feePaid);\n /**\n * @notice Shutdown the pool or self-minting-derivative in case of emergency\n * @notice Only Synthereum manager contract can call this function\n * @return timestamp Timestamp of emergency shutdown transaction\n * @return price Price of the pair at the moment of shutdown execution\n */\n function emergencyShutdown() external returns (uint256 timestamp, uint256 price);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPoolGeneral.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumDeployment.sol\";\n\ninterface ISynthereumLiquidityPoolGeneral is\n ISynthereumDeployment\n //,\n //ISynthereumLiquidityPoolInteraction\n{}\n" + }, + "contracts/external/pyth/IExpressRelay.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelay {\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\n // This will return true if and only if it's being called while executing the auction winner(s) call.\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\n // @param permissionId The id that represents the action being gated\n // @return permissioned True if the permission is allowed, false otherwise\n function isPermissioned(\n address protocolFeeReceiver,\n bytes calldata permissionId\n ) external view returns (bool permissioned);\n}\n" + }, + "contracts/external/pyth/IExpressRelayFeeReceiver.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelayFeeReceiver {\n // Receive the proceeds of an auction.\n // @param permissionKey The permission key where the auction was conducted on.\n function receiveAuctionProceedings(\n bytes calldata permissionKey\n ) external payable;\n}\n" + }, + "contracts/external/redstone/IRedstoneOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IRedstoneOracle {\n function priceOf(address asset) external view returns (uint256);\n\n function priceOfETH() external view returns (uint256);\n\n function getDataFeedIdForAsset(address asset) external view returns (bytes32);\n\n function getDataFeedIds() external view returns (bytes32[] memory dataFeedIds);\n}\n" + }, + "contracts/external/solidly/IPair.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nstruct Observation {\n uint256 timestamp;\n uint256 reserve0Cumulative;\n uint256 reserve1Cumulative;\n}\n\ninterface IPair {\n function observations(uint256 index) external pure returns (Observation memory);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function metadata()\n external\n view\n returns (\n uint256 dec0,\n uint256 dec1,\n uint256 r0,\n uint256 r1,\n bool st,\n address t0,\n address t1\n );\n\n function claimFees() external returns (uint256, uint256);\n\n function tokens() external returns (address, address);\n\n function stable() external view returns (bool);\n\n function observationLength() external view returns (uint256);\n\n function lastObservation() external view returns (Observation memory);\n\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\n\n function currentCumulativePrices()\n external\n view\n returns (\n uint256 reserve0Cumulative,\n uint256 reserve1Cumulative,\n uint256 blockTimestamp\n );\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\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 function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function sync() external;\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function getReserves()\n external\n view\n returns (\n uint256 _reserve0,\n uint256 _reserve1,\n uint256 _blockTimestampLast\n );\n\n function getAmountOut(uint256, address) external view returns (uint256);\n}\n" + }, + "contracts/external/solidly/IRouter.sol": { + "content": "pragma solidity >=0.8.0;\n\ninterface IRouter {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n function isPair(address pair) external view returns (bool);\n\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n function pairFor(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (address pair);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function swapExactTokensForTokensSimple(\n uint256 amountIn,\n uint256 amountOutMin,\n address tokenFrom,\n address tokenTo,\n bool stable,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n )\n external\n view\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n}\n" + }, + "contracts/external/uniswap/FullMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Rewrite unary negation of denominator, which is a uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = a * b\n // Compute the product mod 2**256 and mod 2**256 - 1\n // then use the Chinese Remainder Theorem to reconstruct\n // the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2**256 + prod0\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(a, b, not(0))\n prod0 := mul(a, b)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division\n if (prod1 == 0) {\n require(denominator > 0);\n assembly {\n result := div(prod0, denominator)\n }\n return result;\n }\n\n // Make sure the result is less than 2**256.\n // Also prevents denominator == 0\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0]\n // Compute remainder using mulmod\n uint256 remainder;\n assembly {\n remainder := mulmod(a, b, denominator)\n }\n // Subtract 256 bit number from 512 bit number\n assembly {\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator\n // Compute largest power of two divisor of denominator.\n // Always >= 1.\n uint256 twos = denominator & (~denominator + 1);\n\n // Divide denominator by power of two\n assembly {\n denominator := div(denominator, twos)\n }\n\n // Divide [prod1 prod0] by the factors of two\n assembly {\n prod0 := div(prod0, twos)\n }\n // Shift in bits from prod1 into prod0. For this we need\n // to flip `twos` such that it is 2**256 / twos.\n // If twos is zero, then it becomes one\n assembly {\n twos := add(div(sub(0, twos), twos), 1)\n }\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2**256\n // Now that denominator is an odd number, it has an inverse\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n // Compute the inverse by starting with a seed that is correct\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\n uint256 inv = (3 * denominator) ^ 2;\n // Now use Newton-Raphson iteration to improve the precision.\n // Thanks to Hensel's lifting lemma, this also works in modular\n // arithmetic, doubling the correct bits in each step.\n inv *= 2 - denominator * inv; // inverse mod 2**8\n inv *= 2 - denominator * inv; // inverse mod 2**16\n inv *= 2 - denominator * inv; // inverse mod 2**32\n inv *= 2 - denominator * inv; // inverse mod 2**64\n inv *= 2 - denominator * inv; // inverse mod 2**128\n inv *= 2 - denominator * inv; // inverse mod 2**256\n\n // Because the division is now exact we can divide by multiplying\n // with the modular inverse of denominator. This will give us the\n // correct result modulo 2**256. Since the precoditions guarantee\n // that the outcome is less than 2**256, this is the final result.\n // We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inv;\n return result;\n }\n }\n\n /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n function mulDivRoundingUp(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n result = mulDiv(a, b, denominator);\n if (mulmod(a, b, denominator) > 0) {\n require(result < type(uint256).max);\n result++;\n }\n }\n }\n}\n" + }, + "contracts/external/uniswap/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n function exactInput(ExactInputParams calldata params) external returns (uint256 amountOut);\n\n function exactOutputSingle(ExactOutputSingleParams calldata params) external returns (uint256 amountIn);\n\n function exactOutput(ExactOutputParams calldata params) external returns (uint256 amountIn);\n\n function factory() external returns (address);\n\n function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Callee.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Callee {\n function uniswapV2Call(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint256);\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n\n function allPairs(uint256) external view returns (address pair);\n\n function allPairsLength() external view returns (uint256);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Pair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router01.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (\n uint256 amountToken,\n uint256 amountETH,\n uint256 liquidity\n );\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router02.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Router01.sol\";\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n address referrer,\n uint256 deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title The interface for the Uniswap V3 Factory\n/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees\ninterface IUniswapV3Factory {\n /// @notice Emitted when the owner of the factory is changed\n /// @param oldOwner The owner before the owner was changed\n /// @param newOwner The owner after the owner was changed\n event OwnerChanged(address indexed oldOwner, address indexed newOwner);\n\n /// @notice Emitted when a pool is created\n /// @param token0 The first token of the pool by address sort order\n /// @param token1 The second token of the pool by address sort order\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks\n /// @param pool The address of the created pool\n event PoolCreated(\n address indexed token0,\n address indexed token1,\n uint24 indexed fee,\n int24 tickSpacing,\n address pool\n );\n\n /// @notice Emitted when a new fee amount is enabled for pool creation via the factory\n /// @param fee The enabled fee, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee\n event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);\n\n /// @notice Returns the current owner of the factory\n /// @dev Can be changed by the current owner via setOwner\n /// @return The address of the factory owner\n function owner() external view returns (address);\n\n /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled\n /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context\n /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee\n /// @return The tick spacing\n function feeAmountTickSpacing(uint24 fee) external view returns (int24);\n\n /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\n /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\n /// @param tokenA The contract address of either token0 or token1\n /// @param tokenB The contract address of the other token\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @return pool The pool address\n function getPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external view returns (address pool);\n\n /// @notice Creates a pool for the given two tokens and fee\n /// @param tokenA One of the two tokens in the desired pool\n /// @param tokenB The other of the two tokens in the desired pool\n /// @param fee The desired fee for the pool\n /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\n /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\n /// are invalid.\n /// @return pool The address of the newly created pool\n function createPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external returns (address pool);\n\n /// @notice Updates the owner of the factory\n /// @dev Must be called by the current owner\n /// @param _owner The new owner of the factory\n function setOwner(address _owner) external;\n\n /// @notice Enables a fee amount with the given tickSpacing\n /// @dev Fee amounts may never be removed once enabled\n /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)\n /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount\n function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3FlashCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#flash\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\ninterface IUniswapV3FlashCallback {\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\n function uniswapV3FlashCallback(\n uint256 fee0,\n uint256 fee1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV3PoolActions.sol\";\n\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function fee() external view returns (uint24);\n\n function slot0()\n external\n view\n returns (\n uint160 sqrtPriceX96,\n int24 tick,\n uint16 observationIndex,\n uint16 observationCardinality,\n uint16 observationCardinalityNext,\n uint8 feeProtocol,\n bool unlocked\n );\n\n function liquidity() external view returns (uint128);\n\n function observe(uint32[] calldata secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\n\n function observations(uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 liquidityCumulative,\n bool initialized\n );\n\n function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityGross,\n int128 liquidityNet,\n uint256 feeGrowthOutside0X128,\n uint256 feeGrowthOutside1X128,\n int56 tickCumulativeOutside,\n uint160 secondsPerLiquidityOutsideX128,\n uint32 secondsOutside,\n bool initialized\n );\n\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n\n function positions(bytes32 key)\n external\n view\n returns (\n uint128 _liquidity,\n uint256 feeGrowthInside0LastX128,\n uint256 feeGrowthInside1LastX128,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n /// @notice Sets the initial price for the pool\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n function initialize(uint160 sqrtPriceX96) external;\n\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n /// @param recipient The address for which the liquidity will be created\n /// @param tickLower The lower tick of the position in which to add liquidity\n /// @param tickUpper The upper tick of the position in which to add liquidity\n /// @param amount The amount of liquidity to mint\n /// @param data Any data that should be passed through to the callback\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n function mint(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount,\n bytes calldata data\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Collects tokens owed to a position\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n /// @param recipient The address which should receive the fees collected\n /// @param tickLower The lower tick of the position for which to collect fees\n /// @param tickUpper The upper tick of the position for which to collect fees\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n /// @return amount0 The amount of fees collected in token0\n /// @return amount1 The amount of fees collected in token1\n function collect(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n /// @dev Fees must be collected separately via a call to #collect\n /// @param tickLower The lower tick of the position for which to burn liquidity\n /// @param tickUpper The upper tick of the position for which to burn liquidity\n /// @param amount How much liquidity to burn\n /// @return amount0 The amount of token0 sent to the recipient\n /// @return amount1 The amount of token1 sent to the recipient\n function burn(\n int24 tickLower,\n int24 tickUpper,\n uint128 amount\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Swap token0 for token1, or token1 for token0\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n /// @param recipient The address to receive the output of the swap\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n /// @param data Any data to be passed through to the callback\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n /// @param recipient The address which will receive the token0 and token1 amounts\n /// @param amount0 The amount of token0 to send\n /// @param amount1 The amount of token1 to send\n /// @param data Any data to be passed through to the callback\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n /// the input observationCardinalityNext.\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolImmutables.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n /// @return The contract address\n function factory() external view returns (address);\n\n /// @notice The first of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token0() external view returns (address);\n\n /// @notice The second of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token1() external view returns (address);\n\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n /// @return The fee\n function fee() external view returns (uint24);\n\n /// @notice The pool tick spacing\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n /// This value is an int24 to avoid casting even though it is always positive.\n /// @return The tick spacing\n function tickSpacing() external view returns (int24);\n\n /// @notice The maximum amount of position liquidity that can use any tick in the range\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n /// @return The max amount of liquidity per tick\n function maxLiquidityPerTick() external view returns (uint128);\n}\n" + }, + "contracts/external/uniswap/IUniswapV3SwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IV3SwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport './IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IQuoter.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IQuoter {\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Quoter Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IUniswapV3Quoter {\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee\n /// @param amountIn The amount of the first token to swap\n /// @return amountOut The amount of the last token that would be received\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\n\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountIn The desired input amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountOut The amount of `tokenOut` that would be received\n function quoteExactInputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountIn,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountOut);\n\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n /// @param amountOut The amount of the last token to receive\n /// @return amountIn The amount of first token required to be paid\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\n\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountOut The desired output amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n function quoteExactOutputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountOut,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/BitMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title BitMath\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\nlibrary BitMath {\n /// @notice Returns the index of the most significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\n /// @param x the value for which to compute the most significant bit, must be greater than 0\n /// @return r the index of the most significant bit\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n if (x >= 0x100000000000000000000000000000000) {\n x >>= 128;\n r += 128;\n }\n if (x >= 0x10000000000000000) {\n x >>= 64;\n r += 64;\n }\n if (x >= 0x100000000) {\n x >>= 32;\n r += 32;\n }\n if (x >= 0x10000) {\n x >>= 16;\n r += 16;\n }\n if (x >= 0x100) {\n x >>= 8;\n r += 8;\n }\n if (x >= 0x10) {\n x >>= 4;\n r += 4;\n }\n if (x >= 0x4) {\n x >>= 2;\n r += 2;\n }\n if (x >= 0x2) r += 1;\n }\n\n /// @notice Returns the index of the least significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\n /// @param x the value for which to compute the least significant bit, must be greater than 0\n /// @return r the index of the least significant bit\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n r = 255;\n if (x & type(uint128).max > 0) {\n r -= 128;\n } else {\n x >>= 128;\n }\n if (x & type(uint64).max > 0) {\n r -= 64;\n } else {\n x >>= 64;\n }\n if (x & type(uint32).max > 0) {\n r -= 32;\n } else {\n x >>= 32;\n }\n if (x & type(uint16).max > 0) {\n r -= 16;\n } else {\n x >>= 16;\n }\n if (x & type(uint8).max > 0) {\n r -= 8;\n } else {\n x >>= 8;\n }\n if (x & 0xf > 0) {\n r -= 4;\n } else {\n x >>= 4;\n }\n if (x & 0x3 > 0) {\n r -= 2;\n } else {\n x >>= 2;\n }\n if (x & 0x1 > 0) r -= 1;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/FixedPoint96.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n uint8 internal constant RESOLUTION = 96;\n uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LiquidityMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math library for liquidity\nlibrary LiquidityMath {\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n /// @param x The liquidity before change\n /// @param y The delta by which liquidity should be changed\n /// @return z The liquidity delta\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\n if (y < 0) {\n require((z = x - uint128(-y)) < x, \"LS\");\n } else {\n require((z = x + uint128(y)) >= x, \"LA\");\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LowGasSafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\n/// @title Optimized overflow and underflow safe math operations\n/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost\nlibrary LowGasSafeMath {\n /// @notice Returns x + y, reverts if sum overflows uint256\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x);\n }\n\n /// @notice Returns x - y, reverts if underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x);\n }\n\n /// @notice Returns x * y, reverts if overflows\n /// @param x The multiplicand\n /// @param y The multiplier\n /// @return z The product of x and y\n function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require(x == 0 || (z = x * y) / x == y);\n }\n\n /// @notice Returns x + y, reverts if overflows or underflows\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x + y) >= x == (y >= 0));\n }\n\n /// @notice Returns x - y, reverts if overflows or underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x - y) <= x == (y >= 0));\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Safe casting methods\n/// @notice Contains methods for safely casting between types\nlibrary SafeCast {\n /// @notice Cast a uint256 to a uint160, revert on overflow\n /// @param y The uint256 to be downcasted\n /// @return z The downcasted integer, now type uint160\n function toUint160(uint256 y) internal pure returns (uint160 z) {\n require((z = uint160(y)) == y);\n }\n\n /// @notice Cast a int256 to a int128, revert on overflow or underflow\n /// @param y The int256 to be downcasted\n /// @return z The downcasted integer, now type int128\n function toInt128(int256 y) internal pure returns (int128 z) {\n require((z = int128(y)) == y);\n }\n\n /// @notice Cast a uint256 to a int256, revert on overflow\n /// @param y The uint256 to be casted\n /// @return z The casted integer, now type int256\n function toInt256(uint256 y) internal pure returns (int256 z) {\n require(y < 2**255);\n z = int256(y);\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SqrtPriceMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../FullMath.sol\";\nimport \"./UnsafeMath.sol\";\nimport \"./FixedPoint96.sol\";\nimport \"./BitMath.sol\";\n\n/// @title Functions based on Q64.96 sqrt price and liquidity\n/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas\nlibrary SqrtPriceMath {\n using LowGasSafeMath for uint256;\n using SafeCast for uint256;\n\n /// @notice Gets the next sqrt price given a delta of token0\n /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the\n /// price less in order to not send too much output.\n /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),\n /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).\n /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token0 to add or remove from virtual reserves\n /// @param add Whether to add or remove the amount of token0\n /// @return The price after adding or removing amount, depending on add\n function getNextSqrtPriceFromAmount0RoundingUp(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price\n if (amount == 0) return sqrtPX96;\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n\n bool overflow = false;\n if (numerator1 != 0 && sqrtPX96 != 0)\n overflow = uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(sqrtPX96)) >= 254;\n\n if (add) {\n uint256 product;\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 + product;\n if (denominator >= numerator1) {\n // always fits in 160 bits\n return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));\n }\n }\n\n return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));\n } else {\n uint256 product;\n // if the product overflows, we know the denominator underflows\n // in addition, we must check that the denominator does not underflow\n require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 - product;\n return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();\n }\n }\n\n /// @notice Gets the next sqrt price given a delta of token1\n /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the\n /// price less in order to not send too much output.\n /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity\n /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token1 to add, or remove, from virtual reserves\n /// @param add Whether to add, or remove, the amount of token1\n /// @return The price after adding or removing `amount`\n function getNextSqrtPriceFromAmount1RoundingDown(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // if we're adding (subtracting), rounding down requires rounding the quotient down (up)\n // in both cases, avoid a mulDiv for most inputs\n if (add) {\n uint256 quotient = (\n amount <= type(uint160).max\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\n );\n\n return uint256(sqrtPX96).add(quotient).toUint160();\n } else {\n uint256 quotient = (\n amount <= type(uint160).max\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\n );\n\n require(sqrtPX96 > quotient);\n // always fits 160 bits\n return uint160(sqrtPX96 - quotient);\n }\n }\n\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountIn How much of token0, or token1, is being swapped in\n /// @param zeroForOne Whether the amount in is token0 or token1\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\n function getNextSqrtPriceFromInput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountIn,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we don't pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\n }\n\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\n /// @param sqrtPX96 The starting price before accounting for the output amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountOut How much of token0, or token1, is being swapped out\n /// @param zeroForOne Whether the amount out is token0 or token1\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\n function getNextSqrtPriceFromOutput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountOut,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\n }\n\n /// @notice Gets the amount0 delta between two prices\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up or down\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount0) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\n require(sqrtRatioAX96 > 0);\n\n bool overflow = false;\n if (numerator1 != 0 && numerator2 != 0)\n overflow =\n uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(numerator2)) >= 254;\n\n if (overflow) {\n return\n roundUp\n ? FullMath.mulDivRoundingUp(\n FullMath.mulDivRoundingUp(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n )\n : FullMath.mulDiv(\n FullMath.mulDiv(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n );\n } else {\n return\n roundUp\n ? UnsafeMath.divRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96)\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\n }\n }\n\n /// @notice Gets the amount1 delta between two prices\n /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up, or down\n /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return\n roundUp\n ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)\n : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n }\n\n /// @notice Helper that gets signed token0 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount0 delta\n /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount0) {\n return\n liquidity < 0\n ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n\n /// @notice Helper that gets signed token1 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount1 delta\n /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount1) {\n return\n liquidity < 0\n ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SwapMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"../../FullMath.sol\";\nimport \"./SqrtPriceMath.sol\";\n\n/// @title Computes the result of a swap within ticks\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\nlibrary SwapMath {\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\n /// @param liquidity The usable liquidity\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\n /// @return feeAmount The amount of input that will be taken as a fee\n function computeSwapStep(\n uint160 sqrtRatioCurrentX96,\n uint160 sqrtRatioTargetX96,\n uint128 liquidity,\n int256 amountRemaining,\n uint24 feePips,\n bool zeroForOne\n )\n internal\n pure\n returns (\n uint160 sqrtRatioNextX96,\n uint256 amountIn,\n uint256 amountOut,\n uint256 feeAmount\n )\n {\n require(zeroForOne == sqrtRatioCurrentX96 >= sqrtRatioTargetX96, \"SPD\");\n bool exactIn = amountRemaining >= 0;\n\n if (exactIn) {\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\n amountIn = zeroForOne\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\n sqrtRatioCurrentX96,\n liquidity,\n amountRemainingLessFee,\n zeroForOne\n );\n } else {\n amountOut = zeroForOne\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\n\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\n sqrtRatioCurrentX96,\n liquidity,\n uint256(-amountRemaining),\n zeroForOne\n );\n }\n\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\n\n // get the input/output amounts\n if (zeroForOne) {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\n } else {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\n }\n\n // cap the output amount to not exceed the remaining output amount\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\n amountOut = uint256(-amountRemaining);\n }\n\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\n // we didn't reach the target, so take the remainder of the maximum input as fee\n feeAmount = uint256(amountRemaining) - amountIn;\n } else {\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/Tick.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../TickMath.sol\";\nimport \"./LiquidityMath.sol\";\n\n/// @title Tick\n/// @notice Contains functions for managing tick processes and relevant calculations\n\n/// Ithil to modify it, since it does not have access to storage arrays\nlibrary Tick {\n using LowGasSafeMath for int256;\n using SafeCast for int256;\n\n // info stored for each initialized individual tick\n struct Info {\n // the total position liquidity that references this tick\n uint128 liquidityGross;\n // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),\n int128 liquidityNet;\n // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint256 feeGrowthOutside0X128;\n uint256 feeGrowthOutside1X128;\n // the cumulative tick value on the other side of the tick\n int56 tickCumulativeOutside;\n // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint160 secondsPerLiquidityOutsideX128;\n // the seconds spent on the other side of the tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint32 secondsOutside;\n // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0\n // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks\n bool initialized;\n }\n\n /// @notice Derives max liquidity per tick from given tick spacing\n /// @dev Executed within the pool constructor\n /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`\n /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...\n /// @return The max liquidity per tick\n function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {\n int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\n int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\n uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;\n return type(uint128).max / numTicks;\n }\n\n /// @notice Retrieves fee growth data\n /// Ithil: only use it with lower = self[tickLower] and upper = self[tickUpper]\n /// @param lower The info of the lower tick boundary of the position\n /// @param upper The info of the upper tick boundary of the position\n /// @param tickLower The lower tick boundary of the position\n /// @param tickUpper The upper tick boundary of the position\n /// @param tickCurrent The current tick\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries\n /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries\n function getFeeGrowthInside(\n Tick.Info memory lower,\n Tick.Info memory upper,\n int24 tickLower,\n int24 tickUpper,\n int24 tickCurrent,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128\n ) internal pure returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n // calculate fee growth below\n uint256 feeGrowthBelow0X128;\n uint256 feeGrowthBelow1X128;\n if (tickCurrent >= tickLower) {\n feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;\n } else {\n feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;\n }\n\n // calculate fee growth above\n uint256 feeGrowthAbove0X128;\n uint256 feeGrowthAbove1X128;\n if (tickCurrent < tickUpper) {\n feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;\n } else {\n feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;\n }\n\n feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;\n feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;\n }\n\n /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa\n /// Ithil: always use with info = self[tick]\n /// @param info The info tick that will be updated\n /// @param tick The tick that will be updated\n /// @param tickCurrent The current tick\n /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block timestamp cast to a uint32\n /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick\n /// @param maxLiquidity The maximum liquidity allocation for a single tick\n /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa\n function update(\n Tick.Info memory info,\n int24 tick,\n int24 tickCurrent,\n int128 liquidityDelta,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time,\n bool upper,\n uint128 maxLiquidity\n ) internal pure returns (bool flipped) {\n uint128 liquidityGrossBefore = info.liquidityGross;\n uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);\n\n require(liquidityGrossAfter <= maxLiquidity, \"LO\");\n\n flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);\n\n if (liquidityGrossBefore == 0) {\n // by convention, we assume that all growth before a tick was initialized happened _below_ the tick\n if (tick <= tickCurrent) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;\n info.tickCumulativeOutside = tickCumulative;\n info.secondsOutside = time;\n }\n info.initialized = true;\n }\n\n info.liquidityGross = liquidityGrossAfter;\n\n // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)\n info.liquidityNet = upper\n ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()\n : int256(info.liquidityNet).add(liquidityDelta).toInt128();\n }\n\n /// @notice Transitions to next tick as needed by price movement\n /// @param info The result of the mapping containing all tick information for initialized ticks\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block.timestamp\n /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)\n function cross(\n Tick.Info memory info,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time\n ) internal pure returns (int128 liquidityNet) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;\n info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;\n info.secondsOutside = time - info.secondsOutside;\n liquidityNet = info.liquidityNet;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/TickBitmap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./BitMath.sol\";\n\n/// @title Packed tick initialized state library\n/// @notice Stores a packed mapping of tick index to its initialized state\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\nlibrary TickBitmap {\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\n /// @param tick The tick for which to compute the position\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\n /// @return bitPos The bit position in the word where the flag is stored\n /// @dev simply divides @param tick by 256 with remainder: tick = wordPos * 256 + bitPos\n function position(int24 tick) internal pure returns (int16 wordPos, uint8 bitPos) {\n wordPos = int16(tick >> 8);\n bitPos = uint8(int8(tick % 256));\n }\n\n /// Written by Ithil\n function computeWordPos(\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int16 wordPos) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n (wordPos, ) = lte ? position(compressed) : position(compressed + 1);\n }\n\n /// @notice Flips the initialized state for a given tick from false to true, or vice versa\n /// @param selfResult The result of the mapping in which to flip the tick (Ithil modified)\n /// @param tick The tick to flip\n /// @param tickSpacing The spacing between usable ticks\n function flipTick(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing\n ) internal pure {\n require(tick % tickSpacing == 0); // ensure that the tick is spaced\n (, uint8 bitPos) = position(tick / tickSpacing);\n uint256 mask = 1 << bitPos;\n selfResult ^= mask;\n }\n\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\n /// to the left (less than or equal to) or right (greater than) of the given tick\n /// @param selfResult The result of the mapping in which to compute the next initialized tick (Ithil modified)\n /// @param tick The starting tick\n /// @param tickSpacing The spacing between usable ticks\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\n function nextInitializedTickWithinOneWord(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int24 next, bool initialized) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n if (lte) {\n (, uint8 bitPos) = position(compressed);\n // all the 1s at or to the right of the current bitPos\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed - int24(uint24(bitPos) - uint24(BitMath.mostSignificantBit(masked)))) * tickSpacing\n : (compressed - int24(uint24(bitPos))) * tickSpacing;\n } else {\n // start from the word of the next tick, since the current tick state doesn't matter\n (, uint8 bitPos) = position(compressed + 1);\n // all the 1s at or to the left of the bitPos\n uint256 mask = ~((1 << bitPos) - 1);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed + 1 + int24(uint24(BitMath.leastSignificantBit(masked) - bitPos))) * tickSpacing\n : (compressed + 1 + int24(uint24(type(uint8).max - bitPos))) * tickSpacing;\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/UnsafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math functions that do not check inputs or outputs\n/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks\nlibrary UnsafeMath {\n /// @notice Returns ceil(x / y)\n /// @dev division by 0 has unspecified behavior, and must be checked externally\n /// @param x The dividend\n /// @param y The divisor\n /// @return z The quotient, ceil(x / y)\n function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n z := add(div(x, y), gt(mod(x, y), 0))\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../IUniswapV3Factory.sol\";\nimport \"./interfaces/IQuoter.sol\";\nimport \"./UniswapV3Quoter.sol\";\n\ncontract Quoter is IQuoter, UniswapV3Quoter {\n IUniswapV3Factory internal uniV3Factory; // TODO should it be immutable?\n\n constructor(address _uniV3Factory) {\n uniV3Factory = IUniswapV3Factory(_uniV3Factory);\n }\n\n // This should be equal to quoteExactInputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateOutputSingle(_toToken, _fromToken, _amount, pool);\n }\n\n // This should be equal to quoteExactOutputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateInputSingle(_fromToken, _toToken, _amount, pool);\n }\n\n // todo: add price limit\n function _estimateOutputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken > _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n else amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n }\n\n // todo: add price limit\n function _estimateInputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken < _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n -int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n else amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n }\n\n function doesPoolExist(address _token0, address _token1) external view returns (bool) {\n // try 0.05%\n address pool = uniV3Factory.getPool(_token0, _token1, 500);\n if (pool != address(0)) return true;\n\n // try 0.3%\n pool = uniV3Factory.getPool(_token0, _token1, 3000);\n if (pool != address(0)) return true;\n\n // try 1%\n pool = uniV3Factory.getPool(_token0, _token1, 10000);\n if (pool != address(0)) return true;\n else return false;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/UniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.6;\n\nimport \"./libraries/LowGasSafeMath.sol\";\nimport \"./libraries/SafeCast.sol\";\nimport \"./libraries/Tick.sol\";\nimport \"./libraries/TickBitmap.sol\";\n\nimport \"../FullMath.sol\";\nimport \"../TickMath.sol\";\nimport \"./libraries/LiquidityMath.sol\";\nimport \"./libraries/SqrtPriceMath.sol\";\nimport \"./libraries/SwapMath.sol\";\n\nimport \"./interfaces/IUniswapV3Quoter.sol\";\nimport \"../IUniswapV3Pool.sol\";\nimport \"../IUniswapV3PoolImmutables.sol\";\n\ncontract UniswapV3Quoter {\n using LowGasSafeMath for int256;\n using SafeCast for uint256;\n using Tick for mapping(int24 => Tick.Info);\n\n struct PoolState {\n // the current price\n uint160 sqrtPriceX96;\n // the current tick\n int24 tick;\n // the tick spacing\n int24 tickSpacing;\n // the pool's fee\n uint24 fee;\n // the pool's liquidity\n uint128 liquidity;\n // whether the pool is locked\n bool unlocked;\n }\n\n // accumulated protocol fees in token0/token1 units\n struct ProtocolFees {\n uint128 token0;\n uint128 token1;\n }\n\n // the top level state of the swap, the results of which are recorded in storage at the end\n struct SwapState {\n // the amount remaining to be swapped in/out of the input/output asset\n int256 amountSpecifiedRemaining;\n // the amount already swapped out/in of the output/input asset\n int256 amountCalculated;\n // current sqrt(price)\n uint160 sqrtPriceX96;\n // the tick associated with the current price\n int24 tick;\n // the current liquidity in range\n uint128 liquidity;\n }\n\n struct StepComputations {\n // the price at the beginning of the step\n uint160 sqrtPriceStartX96;\n // the next tick to swap to from the current tick in the swap direction\n int24 tickNext;\n // whether tickNext is initialized or not\n bool initialized;\n // sqrt(price) for the next tick (1/0)\n uint160 sqrtPriceNextX96;\n // how much is being swapped in in this step\n uint256 amountIn;\n // how much is being swapped out\n uint256 amountOut;\n // how much fee is being paid in\n uint256 feeAmount;\n }\n\n struct InitialState {\n address poolAddress;\n PoolState poolState;\n uint256 feeGrowthGlobal0X128;\n uint256 feeGrowthGlobal1X128;\n }\n\n struct NextTickPassage {\n int24 tick;\n int24 tickSpacing;\n }\n\n function fetchState(address _pool) internal view returns (PoolState memory poolState) {\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\n (uint160 sqrtPriceX96, int24 tick, , , , , bool unlocked) = pool.slot0(); // external call\n uint128 liquidity = pool.liquidity(); // external call\n int24 tickSpacing = IUniswapV3PoolImmutables(_pool).tickSpacing(); // external call\n uint24 fee = IUniswapV3PoolImmutables(_pool).fee(); // external call\n poolState = PoolState(sqrtPriceX96, tick, tickSpacing, fee, liquidity, unlocked);\n }\n\n function setInitialState(\n PoolState memory initialPoolState,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n )\n internal\n pure\n returns (\n SwapState memory state,\n uint128 liquidity,\n uint160 sqrtPriceX96\n )\n {\n liquidity = initialPoolState.liquidity;\n\n sqrtPriceX96 = initialPoolState.sqrtPriceX96;\n\n require(\n zeroForOne\n ? sqrtPriceLimitX96 < initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO\n : sqrtPriceLimitX96 > initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,\n \"SPL\"\n );\n\n state = SwapState({\n amountSpecifiedRemaining: amountSpecified,\n amountCalculated: 0,\n sqrtPriceX96: initialPoolState.sqrtPriceX96,\n tick: initialPoolState.tick,\n liquidity: 0 // to be modified after initialization\n });\n }\n\n function getNextTickAndPrice(\n int24 tickSpacing,\n int24 currentTick,\n IUniswapV3Pool pool,\n bool zeroForOne\n )\n internal\n view\n returns (\n int24 tickNext,\n bool initialized,\n uint160 sqrtPriceNextX96\n )\n {\n int24 compressed = currentTick / tickSpacing;\n if (!zeroForOne) compressed++;\n if (currentTick < 0 && currentTick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n uint256 selfResult = pool.tickBitmap(int16(compressed >> 8)); // external call\n\n (tickNext, initialized) = TickBitmap.nextInitializedTickWithinOneWord(\n selfResult,\n currentTick,\n tickSpacing,\n zeroForOne\n );\n\n if (tickNext < TickMath.MIN_TICK) {\n tickNext = TickMath.MIN_TICK;\n } else if (tickNext > TickMath.MAX_TICK) {\n tickNext = TickMath.MAX_TICK;\n }\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\n }\n\n function processSwapWithinTick(\n IUniswapV3Pool pool,\n PoolState memory initialPoolState,\n SwapState memory state,\n uint160 firstSqrtPriceX96,\n uint128 firstLiquidity,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne,\n bool exactAmount\n )\n internal\n view\n returns (\n uint160 sqrtPriceNextX96,\n uint160 finalSqrtPriceX96,\n uint128 finalLiquidity\n )\n {\n StepComputations memory step;\n\n step.sqrtPriceStartX96 = firstSqrtPriceX96;\n\n (step.tickNext, step.initialized, sqrtPriceNextX96) = getNextTickAndPrice(\n initialPoolState.tickSpacing,\n state.tick,\n pool,\n zeroForOne\n );\n\n (finalSqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\n firstSqrtPriceX96,\n (zeroForOne ? sqrtPriceNextX96 < sqrtPriceLimitX96 : sqrtPriceNextX96 > sqrtPriceLimitX96)\n ? sqrtPriceLimitX96\n : sqrtPriceNextX96,\n firstLiquidity,\n state.amountSpecifiedRemaining,\n initialPoolState.fee,\n zeroForOne\n );\n\n if (exactAmount) {\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\n } else {\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\n }\n\n if (finalSqrtPriceX96 == sqrtPriceNextX96) {\n if (step.initialized) {\n (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext);\n if (zeroForOne) liquidityNet = -liquidityNet;\n finalLiquidity = LiquidityMath.addDelta(firstLiquidity, liquidityNet);\n }\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\n } else if (finalSqrtPriceX96 != step.sqrtPriceStartX96) {\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\n state.tick = TickMath.getTickAtSqrtRatio(finalSqrtPriceX96);\n }\n }\n\n function returnedAmount(\n SwapState memory state,\n int256 amountSpecified,\n bool zeroForOne\n ) internal pure returns (int256 amount0, int256 amount1) {\n if (amountSpecified > 0) {\n (amount0, amount1) = zeroForOne\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\n } else {\n (amount0, amount1) = zeroForOne\n ? (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining)\n : (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated);\n }\n }\n\n function quoteSwap(\n address poolAddress,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n ) internal view returns (int256 amount0, int256 amount1) {\n bool exactAmount = amountSpecified > 0;\n\n PoolState memory initialPoolState = fetchState(poolAddress);\n uint160 sqrtPriceNextX96;\n\n (SwapState memory state, uint128 liquidity, uint160 sqrtPriceX96) = setInitialState(\n initialPoolState,\n amountSpecified,\n sqrtPriceLimitX96,\n zeroForOne\n );\n\n while (state.amountSpecifiedRemaining != 0 && sqrtPriceX96 != sqrtPriceLimitX96)\n (sqrtPriceNextX96, sqrtPriceX96, liquidity) = processSwapWithinTick(\n IUniswapV3Pool(poolAddress),\n initialPoolState,\n state,\n sqrtPriceX96,\n liquidity,\n sqrtPriceLimitX96,\n zeroForOne,\n exactAmount\n );\n\n (amount0, amount1) = returnedAmount(state, amountSpecified, zeroForOne);\n }\n}\n" + }, + "contracts/external/uniswap/TickMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Cast MAX_TICK to int256 before casting to uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n int24 internal constant MIN_TICK = -887272;\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n int24 internal constant MAX_TICK = -MIN_TICK;\n\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\n /// @dev Throws if |tick| > max tick\n /// @param tick The input tick for the above formula\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n /// at the given tick\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n unchecked {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n if (tick > 0) ratio = type(uint256).max / ratio;\n\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n }\n }\n\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n /// ever return.\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n unchecked {\n // second inequality must be < because the price can never reach the price at the max tick\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, \"R\");\n uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n uint256 r = ratio;\n uint256 msb = 0;\n\n assembly {\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(5, gt(r, 0xFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(4, gt(r, 0xFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(3, gt(r, 0xFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(2, gt(r, 0xF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(1, gt(r, 0x3))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := gt(r, 0x1)\n msb := or(msb, f)\n }\n\n if (msb >= 128) r = ratio >> (msb - 127);\n else r = ratio << (127 - msb);\n\n int256 log_2 = (int256(msb) - 128) << 64;\n\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(63, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(62, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(61, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(60, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(59, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(58, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(57, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(56, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(55, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(54, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(53, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(52, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(51, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(50, f))\n }\n\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n }\n }\n}\n" + }, + "contracts/external/uniswap/UniswapV2Library.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Pair.sol\";\nimport \"./IUniswapV2Factory.sol\";\n\nlibrary UniswapV2Library {\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, \"UniswapV2Library: IDENTICAL_ADDRESSES\");\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), \"UniswapV2Library: ZERO_ADDRESS\");\n }\n\n function pairFor(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (address pair) {\n return IUniswapV2Factory(factory).getPair(tokenA, tokenB);\n }\n\n // fetches and sorts the reserves for a pair\n function getReserves(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (uint256 reserveA, uint256 reserveB) {\n (address token0, ) = sortTokens(tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n }\n\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) internal pure returns (uint256 amountB) {\n require(amountA > 0, \"UniswapV2Library: INSUFFICIENT_AMOUNT\");\n require(reserveA > 0 && reserveB > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n amountB = (amountA * reserveB) / reserveA;\n }\n\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountOut) {\n require(amountIn > 0, \"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 amountInWithFee = amountIn * (10000 - flashSwapFee);\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = reserveIn * 10000 + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountIn) {\n require(amountOut > 0, \"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 numerator = reserveIn * amountOut * 10000;\n uint256 denominator = (reserveOut - amountOut) * (10000 - flashSwapFee);\n amountIn = numerator / denominator + 1;\n }\n\n // performs chained getAmountOut calculations on any number of pairs\n function getAmountsOut(\n address factory,\n uint256 amountIn,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[0] = amountIn;\n for (uint256 i; i < path.length - 1; i++) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n\n // performs chained getAmountIn calculations on any number of pairs\n function getAmountsIn(\n address factory,\n uint256 amountOut,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[amounts.length - 1] = amountOut;\n for (uint256 i = path.length - 1; i > 0; i--) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n}\n" + }, + "contracts/external/velodrome/IVelodromeRouter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRouter_Velodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidPath();\n error OnlyWETH();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of Velodrome v2 pool factory\n function factory() external view returns (address);\n\n /// @notice Address of Velodrome v2 pool implementation\n function poolImplementation() external view returns (address);\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n}\n" + }, + "contracts/FeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { CErc20Delegator } from \"./compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"./compound/CErc20PluginDelegate.sol\";\nimport { SafeOwnableUpgradeable } from \"./ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { DiamondExtension, DiamondBase } from \"./ionic/DiamondExtension.sol\";\nimport { AuthoritiesRegistry } from \"./ionic/AuthoritiesRegistry.sol\";\n\ncontract FeeDistributorStorage {\n struct CDelegateUpgradeData {\n address implementation;\n bytes becomeImplementationData;\n }\n\n /**\n * @notice Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n * @dev A value of 0 means unset whereas a negative value means 0.\n */\n mapping(address => int256) public customInterestFeeRates;\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n mapping(address => address) internal _latestComptrollerImplementation;\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n mapping(uint8 => CDelegateUpgradeData) internal _latestCErc20Delegate;\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n mapping(address => address) internal _latestPluginImplementation;\n\n mapping(address => DiamondExtension[]) public comptrollerExtensions;\n\n mapping(address => DiamondExtension[]) public cErc20DelegateExtensions;\n\n AuthoritiesRegistry public authoritiesRegistry;\n\n /**\n * @dev used as salt for the creation of new markets\n */\n uint256 public marketsCounter;\n\n /**\n * @dev Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n */\n uint256 public minBorrowEth;\n\n /**\n * @dev Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n * No longer used as of `Rari-Capital/compound-protocol` version `fuse-v1.1.0`.\n */\n uint256 public maxUtilizationRate;\n\n /**\n * @notice The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n uint256 public defaultInterestFeeRate;\n}\n\n/**\n * @title FeeDistributor\n * @author David Lucid (https://github.com/davidlucid)\n * @notice FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\n */\ncontract FeeDistributor is SafeOwnableUpgradeable, FeeDistributorStorage {\n using AddressUpgradeable for address;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Initializer that sets initial values of state variables.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function initialize(uint256 _defaultInterestFeeRate) public initializer {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n __SafeOwnable_init(msg.sender);\n defaultInterestFeeRate = _defaultInterestFeeRate;\n maxUtilizationRate = type(uint256).max;\n }\n\n function reinitialize(AuthoritiesRegistry _ar) public onlyOwnerOrAdmin {\n authoritiesRegistry = _ar;\n }\n\n /**\n * @dev Sets the default proportion of Ionic pool interest taken as a protocol fee.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setDefaultInterestFeeRate(uint256 _defaultInterestFeeRate) external onlyOwner {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n defaultInterestFeeRate = _defaultInterestFeeRate;\n }\n\n /**\n * @dev Withdraws accrued fees on interest.\n * @param erc20Contract The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\n */\n function _withdrawAssets(address erc20Contract) external {\n if (erc20Contract == address(0)) {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No balance available to withdraw.\");\n (bool success, ) = owner().call{ value: balance }(\"\");\n require(success, \"Failed to transfer ETH balance to msg.sender.\");\n } else {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 balance = token.balanceOf(address(this));\n require(balance > 0, \"No token balance available to withdraw.\");\n token.safeTransfer(owner(), balance);\n }\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param _minBorrowEth Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n * @param _maxUtilizationRate Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n */\n function _setPoolLimits(uint256 _minBorrowEth, uint256 _maxUtilizationRate) external onlyOwner {\n minBorrowEth = _minBorrowEth;\n maxUtilizationRate = _maxUtilizationRate;\n }\n\n function getMinBorrowEth(ICErc20 _ctoken) public view returns (uint256) {\n (, , uint256 borrowBalance, ) = _ctoken.getAccountSnapshot(_msgSender());\n if (borrowBalance == 0) return minBorrowEth;\n IonicComptroller comptroller = IonicComptroller(address(_ctoken.comptroller()));\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPriceEth = oracle.price(ICErc20(address(_ctoken)).underlying());\n uint256 underlyingDecimals = _ctoken.decimals();\n uint256 borrowBalanceEth = (underlyingPriceEth * borrowBalance) / 10**underlyingDecimals;\n if (borrowBalanceEth > minBorrowEth) {\n return 0;\n }\n return minBorrowEth - borrowBalanceEth;\n }\n\n /**\n * @dev Receives native fees.\n */\n receive() external payable {}\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes[] calldata data) external onlyOwner {\n require(targets.length > 0 && targets.length == data.length, \"Array lengths must be equal and greater than 0.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data[i]);\n }\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes calldata data) external onlyOwner {\n require(targets.length > 0, \"No target addresses specified.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data);\n }\n\n /**\n * @dev Deploys a CToken for an underlying ERC20\n * @param constructorData Encoded construction data for `CToken initialize()`\n */\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address) {\n // Make sure comptroller == msg.sender\n (address underlying, address comptroller) = abi.decode(constructorData[0:64], (address, address));\n require(comptroller == msg.sender, \"Comptroller is not sender.\");\n\n // Deploy CErc20Delegator using msg.sender, underlying, and block.number as a salt\n bytes32 salt = keccak256(abi.encodePacked(msg.sender, underlying, ++marketsCounter));\n\n bytes memory cErc20DelegatorCreationCode = abi.encodePacked(type(CErc20Delegator).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(0, salt, cErc20DelegatorCreationCode);\n\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n DiamondExtension delegateAsExtension = DiamondExtension(data.implementation);\n // register the first extension\n DiamondBase(proxy)._registerExtension(delegateAsExtension, DiamondExtension(address(0)));\n // derive and configure the other extensions\n DiamondExtension[] memory ctokenExts = cErc20DelegateExtensions[address(delegateAsExtension)];\n for (uint256 i = 0; i < ctokenExts.length; i++) {\n if (ctokenExts[i] == delegateAsExtension) continue;\n DiamondBase(proxy)._registerExtension(ctokenExts[i], DiamondExtension(address(0)));\n }\n CErc20PluginDelegate(address(proxy))._becomeImplementation(becomeImplData);\n\n return proxy;\n }\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n function latestComptrollerImplementation(address oldImplementation) external view returns (address) {\n return\n _latestComptrollerImplementation[oldImplementation] != address(0)\n ? _latestComptrollerImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest `Comptroller` upgrade implementation address.\n * @param oldImplementation The old `Comptroller` implementation address to upgrade from.\n * @param newImplementation Latest `Comptroller` implementation address.\n */\n function _setLatestComptrollerImplementation(address oldImplementation, address newImplementation)\n external\n onlyOwner\n {\n _latestComptrollerImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n function latestCErc20Delegate(uint8 delegateType) external view returns (address, bytes memory) {\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n bytes memory emptyBytes;\n return\n data.implementation != address(0)\n ? (data.implementation, data.becomeImplementationData)\n : (address(0), emptyBytes);\n }\n\n /**\n * @dev Sets the latest `CErc20Delegate` upgrade implementation address and data.\n * @param delegateType The old `CErc20Delegate` implementation address to upgrade from.\n * @param newImplementation Latest `CErc20Delegate` implementation address.\n * @param becomeImplementationData Data passed to the new implementation via `becomeImplementation` after upgrade.\n */\n function _setLatestCErc20Delegate(\n uint8 delegateType,\n address newImplementation,\n bytes calldata becomeImplementationData\n ) external onlyOwner {\n _latestCErc20Delegate[delegateType] = CDelegateUpgradeData(newImplementation, becomeImplementationData);\n }\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n function latestPluginImplementation(address oldImplementation) external view returns (address) {\n return\n _latestPluginImplementation[oldImplementation] != address(0)\n ? _latestPluginImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest plugin upgrade implementation address.\n * @param oldImplementation The old plugin implementation address to upgrade from.\n * @param newImplementation Latest plugin implementation address.\n */\n function _setLatestPluginImplementation(address oldImplementation, address newImplementation) external onlyOwner {\n _latestPluginImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\n * @param cDelegator the proxy address\n * @return if the plugin was upgraded or not\n */\n function _upgradePluginToLatestImplementation(address cDelegator) external onlyOwner returns (bool) {\n CErc20PluginDelegate market = CErc20PluginDelegate(cDelegator);\n\n address oldPluginAddress = address(market.plugin());\n market._updatePlugin(_latestPluginImplementation[oldPluginAddress]);\n address newPluginAddress = address(market.plugin());\n\n return newPluginAddress != oldPluginAddress;\n }\n\n /**\n * @notice Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function interestFeeRate() external view returns (uint256) {\n (bool success, bytes memory data) = msg.sender.staticcall(abi.encodeWithSignature(\"comptroller()\"));\n\n if (success && data.length == 32) {\n address comptroller = abi.decode(data, (address));\n int256 customRate = customInterestFeeRates[comptroller];\n if (customRate > 0) return uint256(customRate);\n if (customRate < 0) return 0;\n }\n\n return defaultInterestFeeRate;\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param comptroller The Unitroller (Comptroller proxy) address.\n * @param rate The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setCustomInterestFeeRate(address comptroller, int256 rate) external onlyOwner {\n require(rate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n customInterestFeeRates[comptroller] = rate;\n }\n\n function getComptrollerExtensions(address comptroller) external view returns (DiamondExtension[] memory) {\n return comptrollerExtensions[comptroller];\n }\n\n function _setComptrollerExtensions(address comptroller, DiamondExtension[] calldata extensions) external onlyOwner {\n comptrollerExtensions[comptroller] = extensions;\n }\n\n function _registerComptrollerExtension(\n address payable pool,\n DiamondExtension extensionToAdd,\n DiamondExtension extensionToReplace\n ) external onlyOwner {\n DiamondBase(pool)._registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (DiamondExtension[] memory) {\n return cErc20DelegateExtensions[cErc20Delegate];\n }\n\n function _setCErc20DelegateExtensions(address cErc20Delegate, DiamondExtension[] calldata extensions)\n external\n onlyOwner\n {\n cErc20DelegateExtensions[cErc20Delegate] = extensions;\n }\n\n function autoUpgradePool(IonicComptroller pool) external onlyOwner {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n // auto upgrade the pool\n pool._upgrade();\n\n for (uint8 i = 0; i < markets.length; i++) {\n // upgrade the market\n markets[i]._upgrade();\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n return authoritiesRegistry.canCall(pool, user, target, functionSig);\n }\n}\n" + }, + "contracts/ILiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\n\ninterface ILiquidator {\n /**\n * borrower The borrower's Ethereum address.\n * repayAmount The amount to repay to liquidate the unhealthy loan.\n * cErc20 The borrowed CErc20 contract to repay.\n * cTokenCollateral The cToken collateral contract to be liquidated.\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\n */\n struct LiquidateToTokensWithFlashSwapVars {\n address borrower;\n uint256 repayAmount;\n ICErc20 cErc20;\n ICErc20 cTokenCollateral;\n address flashSwapContract;\n uint256 minProfitAmount;\n IRedemptionStrategy[] redemptionStrategies;\n bytes[] strategyData;\n IFundsConversionStrategy[] debtFundingStrategies;\n bytes[] debtFundingStrategiesData;\n }\n\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256);\n\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n returns (uint256);\n\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\n\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external;\n\n function setExpressRelay(address _expressRelay) external;\n\n function setPoolLens(address _poolLens) external;\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\n}\n" + }, + "contracts/ionic/AddressesProvider.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title AddressesProvider\n * @notice The Addresses Provider serves as a central storage of system internal and external\n * contract addresses that change between deploys and across chains\n * @author Veliko Minkov \n */\ncontract AddressesProvider is SafeOwnableUpgradeable {\n mapping(string => address) private _addresses;\n mapping(address => Contract) public plugins;\n mapping(address => Contract) public flywheelRewards;\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\n JarvisPool[] public jarvisPoolsConfig;\n CurveSwapPool[] public curveSwapPoolsConfig;\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\n\n /// @dev Initializer to set the admin that can set and change contracts addresses\n function initialize(address owner) public initializer {\n __SafeOwnable_init(owner);\n }\n\n /**\n * @dev The contract address and a string that uniquely identifies the contract's interface\n */\n struct Contract {\n address addr;\n string contractInterface;\n }\n\n struct RedemptionStrategy {\n address addr;\n string contractInterface;\n address outputToken;\n }\n\n struct FundingStrategy {\n address addr;\n string contractInterface;\n address inputToken;\n }\n\n struct JarvisPool {\n address syntheticToken;\n address collateralToken;\n address liquidityPool;\n uint256 expirationTime;\n }\n\n struct CurveSwapPool {\n address poolAddress;\n address[] coins;\n }\n\n /**\n * @dev sets the address and contract interface ID of the flywheel for the reward token\n * @param rewardToken the reward token address\n * @param flywheelRewardsModule the flywheel rewards module address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFlywheelRewards(\n address rewardToken,\n address flywheelRewardsModule,\n string calldata contractInterface\n ) public onlyOwner {\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\n * @param asset the asset address\n * @param plugin the ERC4626 plugin address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setPlugin(\n address asset,\n address plugin,\n string calldata contractInterface\n ) public onlyOwner {\n plugins[asset] = Contract(plugin, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\n * @param asset the asset address\n * @param strategy redemption strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setRedemptionStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address outputToken\n ) public onlyOwner {\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\n }\n\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\n return redemptionStrategiesConfig[asset];\n }\n\n /**\n * @dev sets the address and contract interface ID of the funding strategy for the asset\n * @param asset the asset address\n * @param strategy funding strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFundingStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address inputToken\n ) public onlyOwner {\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\n }\n\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\n return fundingStrategiesConfig[asset];\n }\n\n /**\n * @dev configures the Jarvis pool of a Jarvis synthetic token\n * @param syntheticToken the synthetic token address\n * @param collateralToken the collateral token address\n * @param liquidityPool the liquidity pool address\n * @param expirationTime the operation expiration time\n */\n function setJarvisPool(\n address syntheticToken,\n address collateralToken,\n address liquidityPool,\n uint256 expirationTime\n ) public onlyOwner {\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\n }\n\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\n }\n\n /**\n * @dev Sets an address for an id replacing the address saved in the addresses map\n * @param id The id\n * @param newAddress The address to set\n */\n function setAddress(string calldata id, address newAddress) external onlyOwner {\n _addresses[id] = newAddress;\n }\n\n /**\n * @dev Returns an address by id\n * @return The address\n */\n function getAddress(string calldata id) public view returns (address) {\n return _addresses[id];\n }\n\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\n return curveSwapPoolsConfig;\n }\n\n function getJarvisPools() public view returns (JarvisPool[] memory) {\n return jarvisPoolsConfig;\n }\n\n function setBalancerPoolForTokens(\n address inputToken,\n address outputToken,\n address pool\n ) external onlyOwner {\n balancerPoolForTokens[inputToken][outputToken] = pool;\n }\n\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\n return balancerPoolForTokens[inputToken][outputToken];\n }\n}\n" + }, + "contracts/ionic/AuthoritiesRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\n PoolRolesAuthority public poolAuthLogic;\n address public leveredPositionsFactory;\n bool public noAuthRequired;\n\n function initialize(address _leveredPositionsFactory) public initializer {\n __SafeOwnable_init(msg.sender);\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n }\n\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n // for Neon the auth is not required\n noAuthRequired = block.chainid == 245022934;\n }\n\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\n require(address(poolsAuthorities[pool]) == address(0), \"already created\");\n\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \"\");\n auth = PoolRolesAuthority(address(proxy));\n auth.initialize(address(this));\n poolsAuthorities[pool] = auth;\n\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\n // sets the registry owner as the auth owner\n reconfigureAuthority(pool);\n }\n\n function reconfigureAuthority(address poolAddress) public {\n IonicComptroller pool = IonicComptroller(poolAddress);\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\n\n if (msg.sender != poolAddress || address(auth) != address(0)) {\n require(address(auth) != address(0), \"no such authority\");\n require(msg.sender == owner() || msg.sender == poolAddress, \"not owner or pool\");\n\n auth.configureRegistryCapabilities();\n auth.configurePoolSupplierCapabilities(pool);\n auth.configurePoolBorrowerCapabilities(pool);\n // everyone can be a liquidator\n auth.configureOpenPoolLiquidatorCapabilities(pool);\n auth.configureLeveredPositionCapabilities(pool);\n\n if (auth.owner() != owner()) {\n auth.setOwner(owner());\n }\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\n if (address(authorityForPool) == address(0)) {\n return noAuthRequired;\n } else {\n // allow only if an auth exists and it allows the action\n return authorityForPool.canCall(user, target, functionSig);\n }\n }\n\n function setUserRole(\n address pool,\n address user,\n uint8 role,\n bool enabled\n ) external {\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\n\n require(address(poolAuth) != address(0), \"auth does not exist\");\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \"not owner or factory\");\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \"only lev pos role\");\n\n poolAuth.setUserRole(user, role, enabled);\n }\n}\n" + }, + "contracts/ionic/CollateralSwap.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nimport { IFlashLoanReceiver } from \"./IFlashLoanReceiver.sol\";\nimport { Exponential } from \"../compound/Exponential.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\ncontract CollateralSwap is Ownable2Step, Exponential, IFlashLoanReceiver {\n using SafeERC20 for IERC20;\n\n uint256 public feeBps;\n address public feeRecipient;\n IonicComptroller public comptroller;\n mapping(address => bool) public allowedSwapTargets;\n\n error SwapCollateralFailed();\n error TransferFailed(address market, address user, address target);\n error MintFailed(address market, uint256 errorCode);\n error RedeemFailed(address market, uint256 errorCode);\n error InvalidFlashloanCaller(address caller);\n error InvalidSwapTarget(address target);\n\n constructor(\n uint256 _feeBps,\n address _feeRecipient,\n address _comptroller,\n address[] memory _allowedSwapTargets\n ) Ownable2Step() {\n feeBps = _feeBps;\n feeRecipient = _feeRecipient;\n comptroller = IonicComptroller(_comptroller);\n for (uint256 i = 0; i < _allowedSwapTargets.length; i++) {\n allowedSwapTargets[_allowedSwapTargets[i]] = true;\n }\n }\n\n // ADMIN FUNCTIONS\n\n function setFeeBps(uint256 _feeBps) public onlyOwner {\n feeBps = _feeBps;\n }\n\n function setFeeRecipient(address _feeRecipient) public onlyOwner {\n feeRecipient = _feeRecipient;\n }\n\n function setAllowedSwapTarget(address _target, bool _allowed) public onlyOwner {\n allowedSwapTargets[_target] = _allowed;\n }\n\n function sweep(address token) public onlyOwner {\n IERC20(token).safeTransfer(owner(), IERC20(token).balanceOf(address(this)));\n }\n\n // PUBLIC FUNCTIONS\n\n function swapCollateral(\n uint256 amountUnderlying,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes calldata swapData\n ) public {\n oldCollateralMarket.flash(\n amountUnderlying,\n abi.encode(msg.sender, oldCollateralMarket, newCollateralMarket, swapTarget, swapData)\n );\n }\n\n function receiveFlashLoan(address borrowedAsset, uint256 borrowedAmount, bytes calldata data) external {\n // make sure the caller is a valid market\n {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n bool isAllowed = false;\n for (uint256 i = 0; i < markets.length; i++) {\n if (msg.sender == address(markets[i])) {\n isAllowed = true;\n break;\n }\n }\n if (!isAllowed) {\n revert InvalidFlashloanCaller(msg.sender);\n }\n }\n\n (\n address borrower,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes memory swapData\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes));\n\n // swap the collateral\n {\n if (!allowedSwapTargets[swapTarget]) {\n revert InvalidSwapTarget(swapTarget);\n }\n IERC20(borrowedAsset).approve(swapTarget, borrowedAmount);\n (bool success, ) = swapTarget.call(swapData);\n if (!success) {\n revert SwapCollateralFailed();\n }\n }\n\n // mint the new collateral\n {\n IERC20 newCollateralAsset = IERC20(newCollateralMarket.underlying());\n uint256 outputAmount = newCollateralAsset.balanceOf(address(this));\n uint256 fee = (outputAmount * feeBps) / 10_000;\n outputAmount -= fee;\n if (fee > 0) {\n newCollateralAsset.safeTransfer(feeRecipient, fee);\n }\n newCollateralAsset.approve(address(newCollateralMarket), outputAmount);\n uint256 mintResult = newCollateralMarket.mint(outputAmount);\n if (mintResult != 0) {\n revert MintFailed(address(newCollateralMarket), mintResult);\n }\n }\n\n // transfer the new collateral to the borrower\n {\n uint256 cTokenBalance = IERC20(address(newCollateralMarket)).balanceOf(address(this));\n IERC20(address(newCollateralMarket)).safeTransfer(borrower, cTokenBalance);\n }\n\n // withdraw the old collateral\n {\n (MathError mErr, uint256 amountCTokensToSwap) = divScalarByExpTruncate(\n borrowedAmount,\n Exp({ mantissa: oldCollateralMarket.exchangeRateCurrent() })\n );\n require(mErr == MathError.NO_ERROR, \"exchange rate error\");\n bool transferStatus = oldCollateralMarket.transferFrom(borrower, address(this), amountCTokensToSwap + 1);\n if (!transferStatus) {\n revert TransferFailed(address(oldCollateralMarket), borrower, address(this));\n }\n uint256 redeemResult = oldCollateralMarket.redeemUnderlying(type(uint256).max);\n if (redeemResult != 0) {\n revert RedeemFailed(address(oldCollateralMarket), redeemResult);\n }\n IERC20(borrowedAsset).approve(address(oldCollateralMarket), borrowedAmount);\n }\n // flashloan gets paid back from redeemed collateral\n }\n}\n" + }, + "contracts/ionic/DiamondExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @notice a base contract for logic extensions that use the diamond pattern storage\n * to map the functions when looking up the extension contract to delegate to.\n */\nabstract contract DiamondExtension {\n /**\n * @return a list of all the function selectors that this logic extension exposes\n */\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\n}\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\n// When no extension exists for function called\nerror ExtensionNotFound(bytes4 _functionSelector);\n\n// When the function is already added\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\n\nabstract contract DiamondBase {\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\n\n function _listExtensions() public view returns (address[] memory) {\n return LibDiamond.listExtensions();\n }\n\n fallback() external {\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n\n/**\n * @notice a library to use in a contract, whose logic is extended with diamond extension\n */\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.extensions.diamond.storage\");\n\n struct Function {\n address extension;\n bytes4 selector;\n }\n\n struct LogicStorage {\n Function[] functions;\n address[] extensions;\n }\n\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\n return getExtensionForSelector(msgSig, diamondStorage());\n }\n\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n function listExtensions() internal view returns (address[] memory) {\n return diamondStorage().extensions;\n }\n\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\n if (address(extensionToReplace) != address(0)) {\n removeExtension(extensionToReplace);\n }\n addExtension(extensionToAdd);\n }\n\n function removeExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n // remove all functions of the extension to replace\n removeExtensionFunctions(extension);\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n if (ds.extensions[i] == address(extension)) {\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\n ds.extensions.pop();\n }\n }\n }\n\n function addExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n require(ds.extensions[i] != address(extension), \"extension already added\");\n }\n addExtensionFunctions(extension);\n ds.extensions.push(address(extension));\n }\n\n function removeExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\n bytes4 selectorToRemove = fnsToRemove[i];\n // must never fail\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\n // swap with the last element in the selectorAtIndex array and remove the last element\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\n ds.functions.pop();\n }\n }\n\n function addExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n uint16 functionsCount = uint16(ds.functions.length);\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\n bytes4 selector = fnsToAdd[functionsIndex];\n address oldImplementation = getExtensionForSelector(selector, ds);\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\n ds.functions.push(Function(address(extension), selector));\n functionsCount++;\n }\n }\n\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\n uint256 fnsLen = ds.functions.length;\n for (uint256 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\n }\n\n return address(0);\n }\n\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\n uint16 fnsLen = uint16(ds.functions.length);\n for (uint16 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return i;\n }\n\n return type(uint16).max;\n }\n}\n" + }, + "contracts/ionic/IFlashLoanReceiver.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface IFlashLoanReceiver {\n function receiveFlashLoan(\n address borrowedAsset,\n uint256 borrowedAmount,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/ionic/levered/ILeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILeveredPositionFactoryStorage {\n function feeDistributor() external view returns (IFeeDistributor);\n\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\n\n function blocksPerYear() external view returns (uint256);\n\n function owner() external view returns (address);\n}\n\ninterface ILeveredPositionFactoryBase {\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external;\n}\n\ninterface ILeveredPositionFactoryFirstExtension {\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getMinBorrowNative() external view returns (uint256);\n\n function removeClosedPosition(address closedPosition) external returns (bool removed);\n\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\n\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\n\n function getAccountsWithOpenPositions() external view returns (address[] memory);\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\n}\n\ninterface ILeveredPositionFactorySecondExtension {\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) external returns (LeveredPosition);\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition);\n}\n\ninterface ILeveredPositionFactoryExtension is\n ILeveredPositionFactoryFirstExtension,\n ILeveredPositionFactorySecondExtension\n{}\n\ninterface ILeveredPositionFactory is\n ILeveredPositionFactoryStorage,\n ILeveredPositionFactoryBase,\n ILeveredPositionFactoryExtension\n{}\n" + }, + "contracts/ionic/levered/LeveredPosition.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IFlashLoanReceiver } from \"../IFlashLoanReceiver.sol\";\nimport { IonicFlywheel } from \"../../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { LeveredPositionStorage } from \"./LeveredPositionStorage.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFlywheelLensRouter_LP {\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\n}\n\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error OnlyWhenClosed();\n error NotPositionOwner();\n error OnlyFactoryOwner();\n error AssetNotRescuable();\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\n\n error ConvertFundsFailed();\n error ExitFailed(uint256 errorCode);\n error RedeemFailed(uint256 errorCode);\n error SupplyCollateralFailed(uint256 errorCode);\n error BorrowStableFailed(uint256 errorCode);\n error RepayBorrowFailed(uint256 errorCode);\n error RedeemCollateralFailed(uint256 errorCode);\n error ExtNotFound(bytes4 _functionSelector);\n\n constructor(\n address _positionOwner,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket\n ) LeveredPositionStorage(_positionOwner) {\n IonicComptroller collateralPool = _collateralMarket.comptroller();\n IonicComptroller stablePool = _stableMarket.comptroller();\n require(collateralPool == stablePool, \"markets pools differ\");\n pool = collateralPool;\n\n collateralMarket = _collateralMarket;\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\n stableMarket = _stableMarket;\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\n\n factory = ILeveredPositionFactory(msg.sender);\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\n _supplyCollateral(fundingAsset);\n\n if (!pool.checkMembership(address(this), collateralMarket)) {\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(collateralMarket);\n pool.enterMarkets(cTokens);\n }\n }\n\n function closePosition() public returns (uint256) {\n return closePosition(msg.sender);\n }\n\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n _leverDown(1e18);\n\n // calling accrue and exit allows to redeem the full underlying balance\n collateralMarket.accrueInterest();\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\n if (errorCode != 0) revert ExitFailed(errorCode);\n\n // redeem all cTokens should leave no dust\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\n if (errorCode != 0) revert RedeemFailed(errorCode);\n\n if (stableAsset.balanceOf(address(this)) > 0) {\n // convert all overborrowed leftovers/profits to the collateral asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // withdraw the redeemed collateral\n withdrawAmount = collateralAsset.balanceOf(address(this));\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\n }\n\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n // anything under 1x means removing the leverage\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\n\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\n else _leverDown(targetRatioMantissa);\n\n // return the de facto achieved ratio\n return getCurrentLeverageRatio();\n }\n\n function receiveFlashLoan(\n address assetAddress,\n uint256 borrowedAmount,\n bytes calldata data\n ) external override {\n if (msg.sender == address(collateralMarket)) {\n // increasing the leverage ratio\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\n _leverUpPostFL(stableBorrowAmount);\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\n if (positionCollateralBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\n } else if (msg.sender == address(stableMarket)) {\n // decreasing the leverage ratio\n uint256 amountToRedeem = abi.decode(data, (uint256));\n _leverDownPostFL(borrowedAmount, amountToRedeem);\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\n if (positionStableBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\n } else {\n revert(\"!fl not from either markets\");\n }\n\n // repay FL\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\n }\n\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\n if (msg.sender != positionOwner) revert NotPositionOwner();\n if (!isPositionClosed()) revert OnlyWhenClosed();\n\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\n return stableLeftovers;\n }\n\n function claimRewards() public {\n claimRewards(msg.sender);\n }\n\n function claimRewards(address withdrawTo) public {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n address[] memory flywheels = pool.getRewardsDistributors();\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n fw.claimRewards(address(this));\n ERC20 rewardToken = fw.rewardToken();\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\n if (rewardsAccrued > 0) {\n rewardToken.transfer(withdrawTo, rewardsAccrued);\n }\n }\n }\n\n function rescueTokens(IERC20Upgradeable asset) external {\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\n\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\n }\n\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\n }\n return (rewardTokens, rewards);\n }\n\n fallback() external {\n address extension = factory.getPositionsExtension(msg.sig);\n if (extension == address(0)) revert ExtNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getAccruedRewards()\n external\n returns (\n /*view*/\n ERC20[] memory rewardTokens,\n uint256[] memory amounts\n )\n {\n address[] memory flywheels = pool.getRewardsDistributors();\n\n rewardTokens = new ERC20[](flywheels.length);\n amounts = new uint256[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n rewardTokens[i] = fw.rewardToken();\n amounts[i] = fw.rewardsAccrued(address(this));\n }\n }\n\n function getCurrentLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtValue = 0;\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n if (debtAmount > 0) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n }\n\n // TODO check if positionValue > debtValue\n // s / ( s - b )\n return (positionValue * 1e18) / (positionValue - debtValue);\n }\n\n function getMinLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\n }\n\n function getMaxLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\n }\n\n function _getLeverageRatioAfterBorrow(\n uint256 newBorrowsAmount,\n uint256 positionSupplyAmount,\n uint256 positionBorrowAmount\n ) internal view returns (uint256 r) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\n\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n {\n // add 10 bps just to not go under the min borrow value\n assumedSlippage += 10;\n }\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\n\n int256 s = int256(positionValue);\n int256 b = int256(currentBorrowsValue);\n int256 x = int256(topUpCollateralValue);\n\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\n }\n\n function isPositionClosed() public view returns (bool) {\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\n }\n\n function getEquityAmount() external view returns (uint256 equityAmount) {\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n\n uint256 equityValue = positionValue - debtValue;\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\n }\n\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentRatio = getCurrentLeverageRatio();\n bool up = targetRatio > currentRatio;\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\n }\n\n function _getSupplyAmountDelta(\n bool up,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 assumedSlippage;\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\n\n uint256 supplyValueDeltaAbs;\n {\n // s = supply value before\n // b = borrow value before\n // r = target ratio after\n // c = borrow value coefficient to account for the slippage\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\n int256 r = int256(targetRatio);\n int256 r1 = r - 1e18;\n int256 c = int256(slippageFactor);\n\n // some math magic here\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\n\n // x = supplyValueDelta\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\n }\n\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\n\n if (up) {\n // stables to borrow = c * x\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\n } else {\n // amount to redeem = c * x\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\n }\n }\n\n /*----------------------------------------------------------------\n Internal Functions\n ----------------------------------------------------------------*/\n\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\n // in case the funding is with a different asset\n if (address(collateralAsset) != address(fundingAsset)) {\n // swap for collateral asset\n convertAllTo(fundingAsset, collateralAsset);\n }\n\n // supply the collateral\n amountToSupply = collateralAsset.balanceOf(address(this));\n collateralAsset.approve(address(collateralMarket), amountToSupply);\n uint256 errorCode = collateralMarket.mint(amountToSupply);\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\n }\n\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\n function _leverUp(uint256 targetRatio) internal {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\n true,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n\n // all stables are swapped for collateral to repay the FL\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\n if (collateralLeftovers > 0) {\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\n collateralMarket.mint(collateralLeftovers);\n }\n }\n\n // @dev supply the flash loaned collateral and then borrow stables with it\n function _leverUpPostFL(uint256 stableToBorrow) internal {\n // supply the flash loaned collateral\n _supplyCollateral(collateralAsset);\n\n // borrow stables that will be swapped to repay the FL\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\n function _leverDown(uint256 targetRatio) internal {\n uint256 amountToRedeem;\n uint256 borrowsToRepay;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n if (targetRatio <= 1e18) {\n // if max levering down, then derive the amount to redeem from the debt to be repaid\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\n } else {\n // else derive the debt to be repaid from the amount to redeem\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\n false,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n // the slippage is already accounted for in _getSupplyAmountDelta\n }\n\n if (borrowsToRepay > 0) {\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n }\n\n // all the redeemed collateral is swapped for stables to repay the FL\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n if (stableLeftovers > 0) {\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n if (borrowBalance > 0) {\n // whatever is smaller\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\n stableAsset.approve(address(stableMarket), amountToRepay);\n stableMarket.repayBorrow(amountToRepay);\n }\n }\n }\n\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\n // repay the borrows\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\n stableAsset.approve(address(stableMarket), repayAmount);\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\n\n // redeem the corresponding amount needed to repay the FL\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(collateralAsset, stableAsset);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n private\n returns (uint256 outputAmount)\n {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\n .getRedemptionStrategies(inputToken, outputToken);\n\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\n\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\n inputAmount = outputAmount;\n inputToken = outputToken;\n }\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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" + }, + "contracts/ionic/levered/LeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { DiamondBase, DiamondExtension, LibDiamond } from \"../../ionic/DiamondExtension.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactory is LeveredPositionFactoryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /*----------------------------------------------------------------\n Constructor\n ----------------------------------------------------------------*/\n\n constructor(\n IFeeDistributor _feeDistributor,\n ILiquidatorsRegistry _registry,\n uint256 _blocksPerYear\n ) {\n feeDistributor = _feeDistributor;\n liquidatorsRegistry = _registry;\n blocksPerYear = _blocksPerYear;\n }\n\n /*----------------------------------------------------------------\n Admin Functions\n ----------------------------------------------------------------*/\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external onlyOwner {\n require(_collateralMarket.comptroller() == _stableMarket.comptroller(), \"markets not of the same pool\");\n\n if (_whitelisted) {\n collateralMarkets.add(address(_collateralMarket));\n borrowableMarketsByCollateral[_collateralMarket].add(address(_stableMarket));\n } else {\n borrowableMarketsByCollateral[_collateralMarket].remove(address(_stableMarket));\n if (borrowableMarketsByCollateral[_collateralMarket].length() == 0)\n collateralMarkets.remove(address(_collateralMarket));\n }\n }\n\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external onlyOwner {\n liquidatorsRegistry = _liquidatorsRegistry;\n }\n\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactoryFirstExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactoryFirstExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactoryFirstExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n error NoSuchPosition();\n error PositionNotClosed();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 10;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.removeClosedPosition.selector;\n functionSelectors[--fnsCount] = this.closeAndRemoveUserPosition.selector;\n functionSelectors[--fnsCount] = this.getMinBorrowNative.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getBorrowableMarketsByCollateral.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedCollateralMarkets.selector;\n functionSelectors[--fnsCount] = this.getAccountsWithOpenPositions.selector;\n functionSelectors[--fnsCount] = this.getPositionsByAccount.selector;\n functionSelectors[--fnsCount] = this.getPositionsExtension.selector;\n functionSelectors[--fnsCount] = this._setPositionsExtension.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n // @return true if removed, otherwise false\n function removeClosedPosition(address closedPosition) external returns (bool) {\n return _removeClosedPosition(closedPosition, msg.sender);\n }\n\n function closeAndRemoveUserPosition(LeveredPosition position) external onlyOwner returns (bool) {\n address positionOwner = position.positionOwner();\n position.closePosition(positionOwner);\n return _removeClosedPosition(address(position), positionOwner);\n }\n\n function _removeClosedPosition(address closedPosition, address positionOwner) internal returns (bool removed) {\n EnumerableSet.AddressSet storage userPositions = positionsByAccount[positionOwner];\n if (!userPositions.contains(closedPosition)) revert NoSuchPosition();\n if (!LeveredPosition(closedPosition).isPositionClosed()) revert PositionNotClosed();\n\n removed = userPositions.remove(closedPosition);\n if (userPositions.length() == 0) accountsWithOpenPositions.remove(positionOwner);\n }\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external onlyOwner {\n _positionsExtensions[msgSig] = extension;\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n function getMinBorrowNative() external view returns (uint256) {\n return feeDistributor.minBorrowEth();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n return liquidatorsRegistry.getRedemptionStrategies(inputToken, outputToken);\n }\n\n function getPositionsByAccount(\n address account\n ) external view returns (address[] memory positions, bool[] memory closed) {\n positions = positionsByAccount[account].values();\n closed = new bool[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n closed[i] = LeveredPosition(positions[i]).isPositionClosed();\n }\n }\n\n function getAccountsWithOpenPositions() external view returns (address[] memory) {\n return accountsWithOpenPositions.values();\n }\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory) {\n return collateralMarkets.values();\n }\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory) {\n return borrowableMarketsByCollateral[_collateralMarket].values();\n }\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address) {\n return _positionsExtensions[msgSig];\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactorySecondExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactorySecondExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactorySecondExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 3;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.createPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPositionAtRatio.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) public returns (LeveredPosition) {\n if (!borrowableMarketsByCollateral[_collateralMarket].contains(address(_stableMarket))) revert PairNotWhitelisted();\n\n LeveredPosition position = new LeveredPosition(msg.sender, _collateralMarket, _stableMarket);\n\n accountsWithOpenPositions.add(msg.sender);\n positionsByAccount[msg.sender].add(address(position));\n\n AuthoritiesRegistry authoritiesRegistry = feeDistributor.authoritiesRegistry();\n address poolAddress = address(_collateralMarket.comptroller());\n PoolRolesAuthority poolAuth = authoritiesRegistry.poolsAuthorities(poolAddress);\n if (address(poolAuth) != address(0)) {\n authoritiesRegistry.setUserRole(poolAddress, address(position), poolAuth.LEVERED_POSITION_ROLE(), true);\n }\n\n return position;\n }\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) public returns (LeveredPosition) {\n LeveredPosition position = createPosition(_collateralMarket, _stableMarket);\n _fundingAsset.safeTransferFrom(msg.sender, address(this), _fundingAmount);\n _fundingAsset.approve(address(position), _fundingAmount);\n position.fundPosition(_fundingAsset, _fundingAmount);\n return position;\n }\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition) {\n LeveredPosition position = createAndFundPosition(_collateralMarket, _stableMarket, _fundingAsset, _fundingAmount);\n if (_leverageRatio > 1e18) {\n position.adjustLeverageRatio(_leverageRatio);\n }\n return position;\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\n EnumerableSet.AddressSet internal collateralMarkets;\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\n\n IFeeDistributor public feeDistributor;\n ILiquidatorsRegistry public liquidatorsRegistry;\n uint256 public blocksPerYear;\n\n mapping(bytes4 => address) internal _positionsExtensions;\n}\n" + }, + "contracts/ionic/levered/LeveredPositionsLens.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract LeveredPositionsLens is Initializable {\n ILeveredPositionFactory public factory;\n\n function initialize(ILeveredPositionFactory _factory) external initializer {\n factory = _factory;\n }\n\n function reinitialize(ILeveredPositionFactory _factory) external reinitializer(2) {\n factory = _factory;\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\n function getCollateralMarkets()\n external\n view\n returns (\n address[] memory markets,\n IonicComptroller[] memory poolOfMarket,\n address[] memory underlyings,\n uint256[] memory underlyingPrices,\n string[] memory names,\n string[] memory symbols,\n uint8[] memory decimals,\n uint256[] memory totalUnderlyingSupplied,\n uint256[] memory ratesPerBlock\n )\n {\n markets = factory.getWhitelistedCollateralMarkets();\n poolOfMarket = new IonicComptroller[](markets.length);\n underlyings = new address[](markets.length);\n underlyingPrices = new uint256[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n totalUnderlyingSupplied = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n ratesPerBlock = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n poolOfMarket[i] = market.comptroller();\n underlyingPrices[i] = BasePriceOracle(poolOfMarket[i].oracle()).getUnderlyingPrice(market);\n underlyings[i] = market.underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyings[i]);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n decimals[i] = underlying.decimals();\n totalUnderlyingSupplied[i] = market.getTotalUnderlyingSupplied();\n ratesPerBlock[i] = market.supplyRatePerBlock();\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\n function getBorrowRateAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _equityAmount,\n uint256 _targetLeverageRatio\n ) external view returns (uint256) {\n IonicComptroller pool = IonicComptroller(_stableMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(_stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n uint256 borrowAmount = ((_targetLeverageRatio - 1e18) * _equityAmount * collateralAssetPrice) /\n (stableAssetPrice * 1e18);\n return _stableMarket.borrowRatePerBlockAfterBorrow(borrowAmount) * factory.blocksPerYear();\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\n function getBorrowableMarketsAndRates(ICErc20 _collateralMarket)\n external\n view\n returns (\n address[] memory markets,\n address[] memory underlyings,\n uint256[] memory underlyingsPrices,\n string[] memory names,\n string[] memory symbols,\n uint256[] memory rates,\n uint8[] memory decimals\n )\n {\n markets = factory.getBorrowableMarketsByCollateral(_collateralMarket);\n underlyings = new address[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n rates = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n underlyingsPrices = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n address underlyingAddress = market.underlying();\n underlyings[i] = underlyingAddress;\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyingAddress);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n rates[i] = market.borrowRatePerBlock();\n decimals[i] = underlying.decimals();\n underlyingsPrices[i] = market.comptroller().oracle().getUnderlyingPrice(market);\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getNetAPY(\n uint256 _supplyAPY,\n uint256 _supplyAmount,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _targetLeverageRatio\n ) public view returns (int256 netAPY) {\n if (_supplyAmount == 0 || _targetLeverageRatio <= 1e18) return 0;\n\n IonicComptroller pool = IonicComptroller(_collateralMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n // TODO the calcs can be implemented without using collateralAssetPrice\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n // total collateral = base collateral + levered collateral\n uint256 totalCollateral = (_supplyAmount * _targetLeverageRatio) / 1e18;\n uint256 yieldFromTotalSupplyScaled = _supplyAPY * totalCollateral;\n int256 yieldValueScaled = int256((yieldFromTotalSupplyScaled * collateralAssetPrice) / 1e18);\n\n uint256 borrowedValueScaled = (totalCollateral - _supplyAmount) * collateralAssetPrice;\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n int256 borrowInterestValueScaled = int256((_borrowRate * borrowedValueScaled) / 1e18);\n\n int256 netValueDiffScaled = yieldValueScaled - borrowInterestValueScaled;\n\n netAPY = ((netValueDiffScaled / int256(collateralAssetPrice)) * 1e18) / int256(_supplyAmount);\n }\n\n function getPositionsInfo(LeveredPosition[] calldata positions, uint256[] calldata supplyApys)\n external\n view\n returns (PositionInfo[] memory infos)\n {\n infos = new PositionInfo[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n infos[i] = getPositionInfo(positions[i], supplyApys[i]);\n }\n }\n\n function getLeverageRatioAfterFunding(LeveredPosition pos, uint256 newFunding) public view returns (uint256) {\n uint256 equityAmount = pos.getEquityAmount();\n if (equityAmount == 0 && newFunding == 0) return 0;\n\n uint256 suppliedCollateralCurrent = pos.collateralMarket().balanceOfUnderlying(address(pos));\n return ((suppliedCollateralCurrent + newFunding) * 1e18) / (equityAmount + newFunding);\n }\n\n function getNetApyForPositionAfterFunding(\n LeveredPosition pos,\n uint256 supplyAPY,\n uint256 newFunding\n ) public view returns (int256) {\n return\n getNetAPY(\n supplyAPY,\n pos.getEquityAmount() + newFunding,\n pos.collateralMarket(),\n pos.stableMarket(),\n getLeverageRatioAfterFunding(pos, newFunding)\n );\n }\n\n function getNetApyForPosition(LeveredPosition pos, uint256 supplyAPY) public view returns (int256) {\n return getNetApyForPositionAfterFunding(pos, supplyAPY, 0);\n }\n\n struct PositionInfo {\n uint256 collateralAssetPrice;\n uint256 borrowedAssetPrice;\n uint256 positionSupplyAmount;\n uint256 positionValue;\n uint256 debtAmount;\n uint256 debtValue;\n uint256 equityAmount;\n uint256 equityValue;\n int256 currentApy;\n uint256 debtRatio;\n uint256 liquidationThreshold;\n uint256 safetyBuffer;\n }\n\n function getPositionInfo(LeveredPosition pos, uint256 supplyApy) public view returns (PositionInfo memory info) {\n ICErc20 collateralMarket = pos.collateralMarket();\n IonicComptroller pool = pos.pool();\n info.collateralAssetPrice = pool.oracle().getUnderlyingPrice(collateralMarket);\n {\n info.positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(pos));\n info.positionValue = (info.collateralAssetPrice * info.positionSupplyAmount) / 1e18;\n info.currentApy = getNetApyForPosition(pos, supplyApy);\n }\n\n {\n ICErc20 stableMarket = pos.stableMarket();\n info.borrowedAssetPrice = pool.oracle().getUnderlyingPrice(stableMarket);\n info.debtAmount = stableMarket.borrowBalanceCurrent(address(pos));\n info.debtValue = (info.borrowedAssetPrice * info.debtAmount) / 1e18;\n info.equityValue = info.positionValue - info.debtValue;\n info.debtRatio = info.positionValue == 0 ? 0 : (info.debtValue * 1e18) / info.positionValue;\n info.equityAmount = (info.equityValue * 1e18) / info.collateralAssetPrice;\n }\n\n {\n (, uint256 collateralFactor) = pool.markets(address(collateralMarket));\n info.liquidationThreshold = collateralFactor;\n info.safetyBuffer = collateralFactor - info.debtRatio;\n }\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract LeveredPositionStorage {\n address public immutable positionOwner;\n ILeveredPositionFactory public factory;\n\n ICErc20 public collateralMarket;\n ICErc20 public stableMarket;\n IonicComptroller public pool;\n\n IERC20Upgradeable public collateralAsset;\n IERC20Upgradeable public stableAsset;\n\n constructor(address _positionOwner) {\n positionOwner = _positionOwner;\n }\n}\n" + }, + "contracts/ionic/PoolRolesAuthority.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller, ComptrollerInterface } from \"../compound/ComptrollerInterface.sol\";\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \"../compound/CTokenInterfaces.sol\";\n\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\n constructor() RolesAuthority(address(0), Authority(address(0))) {\n _disableInitializers();\n }\n\n function initialize(address _owner) public initializer {\n owner = _owner;\n authority = this;\n }\n\n // up to 256 roles\n uint8 public constant REGISTRY_ROLE = 0;\n uint8 public constant SUPPLIER_ROLE = 1;\n uint8 public constant BORROWER_ROLE = 2;\n uint8 public constant LIQUIDATOR_ROLE = 3;\n uint8 public constant LEVERED_POSITION_ROLE = 4;\n\n function configureRegistryCapabilities() external requiresAuth {\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\n true\n );\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\n }\n\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, true);\n }\n\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, false);\n }\n\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\n }\n }\n }\n\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\n }\n\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\n uint8 fnsCount = 6;\n selectors = new bytes4[](fnsCount);\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return selectors;\n }\n\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\n }\n }\n }\n\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, true);\n }\n\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, false);\n }\n\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\n }\n }\n\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n // borrowers have the SUPPLIER_ROLE capabilities by default\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n // TODO this leaves redeeming open for everyone\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\n\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n}\n" + }, + "contracts/ionic/SafeOwnable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nabstract contract SafeOwnable is Ownable2Step {\n function renounceOwnership() public override onlyOwner {\n revert(\"renounce ownership not allowed\");\n }\n}\n" + }, + "contracts/ionic/SafeOwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\n/**\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\n * that will shift the other.\n */\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\n /**\n * @notice Pending owner of this contract\n */\n address public pendingOwner;\n\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\n __Ownable_init();\n _transferOwnership(owner_);\n }\n\n struct AddressSlot {\n address value;\n }\n\n modifier onlyOwnerOrAdmin() {\n bool isOwner = owner() == _msgSender();\n if (!isOwner) {\n address admin = _getProxyAdmin();\n bool isAdmin = admin == _msgSender();\n require(isAdmin, \"Ownable: caller is neither the owner nor the admin\");\n }\n _;\n }\n\n /**\n * @notice Emitted when pendingOwner is changed\n */\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\n\n /**\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\n */\n event NewOwner(address oldOwner, address newOwner);\n\n /**\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @param newPendingOwner New pending owner.\n */\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\n // Save current value, if any, for inclusion in log\n address oldPendingOwner = pendingOwner;\n\n // Store pendingOwner with value newPendingOwner\n pendingOwner = newPendingOwner;\n\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\n }\n\n /**\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\n * @dev Owner function for pending owner to accept role and update owner\n */\n function _acceptOwner() public {\n // Check caller is pendingOwner and pendingOwner ≠ address(0)\n require(msg.sender == pendingOwner, \"not the pending owner\");\n\n // Save current values for inclusion in log\n address oldOwner = owner();\n address oldPendingOwner = pendingOwner;\n\n // Store owner with value pendingOwner\n _transferOwnership(pendingOwner);\n\n // Clear the pending value\n pendingOwner = address(0);\n\n emit NewOwner(oldOwner, pendingOwner);\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\n }\n\n function renounceOwnership() public override onlyOwner {\n // do not remove this overriding fn\n revert(\"not used anymore\");\n }\n\n function transferOwnership(address newOwner) public override onlyOwner {\n emit NewPendingOwner(pendingOwner, newOwner);\n pendingOwner = newOwner;\n }\n\n function _getProxyAdmin() internal view returns (address admin) {\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n AddressSlot storage adminSlot;\n assembly {\n adminSlot.slot := _ADMIN_SLOT\n }\n admin = adminSlot.value;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IFlywheelBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/**\n @title Balance Booster Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\n \n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\n\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\n*/\ninterface IFlywheelBooster {\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IIonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ninterface IIonicFlywheel {\n function isRewardsDistributor() external returns (bool);\n\n function isFlywheel() external returns (bool);\n\n function flywheelPreSupplierAction(address market, address supplier) external;\n\n function flywheelPreBorrowerAction(address market, address borrower) external;\n\n function flywheelPreTransferAction(address market, address src, address dst) external;\n\n function compAccrued(address user) external view returns (uint256);\n\n function addMarketForRewards(ERC20 strategy) external;\n\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport \"./IIonicFlywheel.sol\";\n\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\n bool public constant isRewardsDistributor = true;\n bool public constant isFlywheel = true;\n\n function flywheelPreSupplierAction(address market, address supplier) external {\n accrue(ERC20(market), supplier);\n }\n\n function flywheelPreBorrowerAction(address market, address borrower) external {}\n\n function flywheelPreTransferAction(address market, address src, address dst) external {\n accrue(ERC20(market), src, dst);\n }\n\n function compAccrued(address user) external view returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n // TODO remove\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\nimport { SafeCastLib } from \"solmate/utils/SafeCastLib.sol\";\n\nimport { IFlywheelRewards } from \"./rewards/IFlywheelRewards.sol\";\nimport { IFlywheelBooster } from \"./IFlywheelBooster.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n /// @notice How much rewardsToken will be send to treasury\n uint256 public performanceFee;\n\n /// @notice Address that gets rewardsToken accrued by performanceFee\n address public feeRecipient;\n\n /// @notice The token to reward\n ERC20 public rewardToken;\n\n /// @notice append-only list of strategies added\n ERC20[] public allStrategies;\n\n /// @notice the rewards contract for managing streams\n IFlywheelRewards public flywheelRewards;\n\n /// @notice optional booster module for calculating virtual balances on strategies\n IFlywheelBooster public flywheelBooster;\n\n /// @notice The accrued but not yet transferred rewards for each user\n mapping(address => uint256) internal _rewardsAccrued;\n\n /// @notice The strategy index and last updated per strategy\n mapping(ERC20 => RewardsState) internal _strategyState;\n\n /// @notice user index per strategy\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\n\n constructor() {\n // prevents the misusage of the implementation contract\n _disableInitializers();\n }\n\n function initialize(\n ERC20 _rewardToken,\n IFlywheelRewards _flywheelRewards,\n IFlywheelBooster _flywheelBooster,\n address _owner\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n\n rewardToken = _rewardToken;\n flywheelRewards = _flywheelRewards;\n flywheelBooster = _flywheelBooster;\n\n _transferOwnership(_owner);\n\n performanceFee = 10e16; // 10%\n feeRecipient = _owner;\n }\n\n /*----------------------------------------------------------------\n ACCRUE/CLAIM LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a user's rewards accrue to a given strategy.\n @param strategy the updated rewards strategy\n @param user the user of the rewards\n @param rewardsDelta how many new rewards accrued to the user\n @param rewardsIndex the market index for rewards per token accrued\n */\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\n\n /** \n @notice Emitted when a user claims accrued rewards.\n @param user the user of the rewards\n @param amount the amount of rewards claimed\n */\n event ClaimRewards(address indexed user, uint256 amount);\n\n /** \n @notice accrue rewards for a single user on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the user to be accrued\n @return the cumulative amount of rewards accrued to user (including prior)\n */\n function accrue(ERC20 strategy, address user) public returns (uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return 0;\n\n state = accrueStrategy(strategy, state);\n return accrueUser(strategy, user, state);\n }\n\n /** \n @notice accrue rewards for a two users on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the first user to be accrued\n @param user the second user to be accrued\n @return the cumulative amount of rewards accrued to the first user (including prior)\n @return the cumulative amount of rewards accrued to the second user (including prior)\n */\n function accrue(\n ERC20 strategy,\n address user,\n address secondUser\n ) public returns (uint256, uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return (0, 0);\n\n state = accrueStrategy(strategy, state);\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\n }\n\n /** \n @notice claim rewards for a given user\n @param user the user claiming rewards\n @dev this function is public, and all rewards transfer to the user\n */\n function claimRewards(address user) external {\n uint256 accrued = rewardsAccrued(user);\n\n if (accrued != 0) {\n _rewardsAccrued[user] = 0;\n\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\n\n emit ClaimRewards(user, accrued);\n }\n }\n\n /*----------------------------------------------------------------\n ADMIN LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a new strategy is added to flywheel by the admin\n @param newStrategy the new added strategy\n */\n event AddStrategy(address indexed newStrategy);\n\n /// @notice initialize a new strategy\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n function _addStrategyForRewards(ERC20 strategy) internal {\n (uint224 index, ) = strategyState(strategy);\n require(index == 0, \"strategy\");\n _strategyState[strategy] = RewardsState({\n index: (10**rewardToken.decimals()).safeCastTo224(),\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n\n function getAllStrategies() external view returns (ERC20[] memory) {\n return allStrategies;\n }\n\n /** \n @notice Emitted when the rewards module changes\n @param newFlywheelRewards the new rewards module\n */\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\n\n /// @notice swap out the flywheel rewards contract\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\n if (address(flywheelRewards) != address(0)) {\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\n if (oldRewardBalance > 0) {\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\n }\n }\n\n flywheelRewards = newFlywheelRewards;\n\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\n }\n\n /** \n @notice Emitted when the booster module changes\n @param newBooster the new booster module\n */\n event FlywheelBoosterUpdate(address indexed newBooster);\n\n /// @notice swap out the flywheel booster contract\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\n flywheelBooster = newBooster;\n\n emit FlywheelBoosterUpdate(address(newBooster));\n }\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n * @dev Claim rewards first from the previous feeRecipient before changing it\n */\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\n _updateFeeSettings(_performanceFee, _feeRecipient);\n }\n\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\n\n if (feeRecipient != _feeRecipient) {\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\n _rewardsAccrued[feeRecipient] = 0;\n }\n performanceFee = _performanceFee;\n feeRecipient = _feeRecipient;\n }\n\n /*----------------------------------------------------------------\n INTERNAL ACCOUNTING LOGIC\n ----------------------------------------------------------------*/\n\n struct RewardsState {\n /// @notice The strategy's last updated index\n uint224 index;\n /// @notice The timestamp the index was last updated at\n uint32 lastUpdatedTimestamp;\n }\n\n /// @notice accumulate global rewards on a strategy\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\n private\n returns (RewardsState memory rewardsState)\n {\n // calculate accrued rewards through module\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\n\n rewardsState = state;\n\n if (strategyRewardsAccrued > 0) {\n // use the booster or token supply to calculate reward index denominator\n uint256 supplyTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedTotalSupply(strategy)\n : strategy.totalSupply();\n\n // 100% = 100e16\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\n\n _rewardsAccrued[feeRecipient] += accruedFees;\n strategyRewardsAccrued -= accruedFees;\n\n uint224 deltaIndex;\n\n if (supplyTokens != 0)\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\n\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\n rewardsState = RewardsState({\n index: state.index + deltaIndex,\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n _strategyState[strategy] = rewardsState;\n }\n }\n\n /// @notice accumulate rewards on a strategy for a specific user\n function accrueUser(\n ERC20 strategy,\n address user,\n RewardsState memory state\n ) private returns (uint256) {\n // load indices\n uint224 strategyIndex = state.index;\n uint224 supplierIndex = userIndex(strategy, user);\n\n // sync user index to global\n _userIndex[strategy][user] = strategyIndex;\n\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\n // zero balances will have no effect other than syncing to global index\n if (supplierIndex == 0) {\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\n }\n\n uint224 deltaIndex = strategyIndex - supplierIndex;\n // use the booster or token balance to calculate reward balance multiplier\n uint256 supplierTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedBalanceOf(strategy, user)\n : strategy.balanceOf(user);\n\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\n\n _rewardsAccrued[user] = supplierAccrued;\n\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\n\n return supplierAccrued;\n }\n\n function rewardsAccrued(address user) public virtual returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\n return _userIndex[strategy][user];\n }\n\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport { IonicComptroller } from \"../../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { PoolDirectory } from \"../../../PoolDirectory.sol\";\n\ninterface IPriceOracle_IFLR {\n function getUnderlyingPrice(ERC20 cToken) external view returns (uint256);\n\n function price(address underlying) external view returns (uint256);\n}\n\ncontract IonicFlywheelLensRouter {\n PoolDirectory public fpd;\n\n constructor(PoolDirectory _fpd) {\n fpd = _fpd;\n }\n\n struct MarketRewardsInfo {\n /// @dev comptroller oracle price of market underlying\n uint256 underlyingPrice;\n ICErc20 market;\n RewardsInfo[] rewardsInfo;\n }\n\n struct RewardsInfo {\n /// @dev rewards in `rewardToken` paid per underlying staked token in `market` per second\n uint256 rewardSpeedPerSecondPerToken;\n /// @dev comptroller oracle price of reward token\n uint256 rewardTokenPrice;\n /// @dev APR scaled by 1e18. Calculated as rewardSpeedPerSecondPerToken * rewardTokenPrice * 365.25 days / underlyingPrice * 1e18 / market.exchangeRate\n uint256 formattedAPR;\n address flywheel;\n address rewardToken;\n }\n\n function getPoolMarketRewardsInfo(IonicComptroller comptroller) external returns (MarketRewardsInfo[] memory) {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n return _getMarketRewardsInfo(markets, comptroller);\n }\n\n function getMarketRewardsInfo(ICErc20[] memory markets) external returns (MarketRewardsInfo[] memory) {\n IonicComptroller pool;\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 asMarket = ICErc20(address(markets[i]));\n if (address(pool) == address(0)) pool = asMarket.comptroller();\n else require(asMarket.comptroller() == pool);\n }\n return _getMarketRewardsInfo(markets, pool);\n }\n\n function _getMarketRewardsInfo(ICErc20[] memory markets, IonicComptroller comptroller)\n internal\n returns (MarketRewardsInfo[] memory)\n {\n if (address(comptroller) == address(0) || markets.length == 0) return new MarketRewardsInfo[](0);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n address[] memory rewardTokens = new address[](flywheels.length);\n uint256[] memory rewardTokenPrices = new uint256[](flywheels.length);\n uint256[] memory rewardTokenDecimals = new uint256[](flywheels.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n MarketRewardsInfo[] memory infoList = new MarketRewardsInfo[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n RewardsInfo[] memory rewardsInfo = new RewardsInfo[](flywheels.length);\n\n ICErc20 market = ICErc20(address(markets[i]));\n uint256 price = oracle.price(market.underlying()); // scaled to 1e18\n\n if (i == 0) {\n for (uint256 j = 0; j < flywheels.length; j++) {\n ERC20 rewardToken = IonicFlywheelCore(flywheels[j]).rewardToken();\n rewardTokens[j] = address(rewardToken);\n rewardTokenPrices[j] = oracle.price(address(rewardToken)); // scaled to 1e18\n rewardTokenDecimals[j] = uint256(rewardToken.decimals());\n }\n }\n\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n rewardTokenDecimals[j]\n );\n uint256 apr = getApr(\n rewardSpeedPerSecondPerToken,\n rewardTokenPrices[j],\n price, \n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n rewardsInfo[j] = RewardsInfo({\n rewardSpeedPerSecondPerToken: rewardSpeedPerSecondPerToken, // scaled in 1e18\n rewardTokenPrice: rewardTokenPrices[j],\n formattedAPR: apr, // scaled in 1e18\n flywheel: address(flywheel),\n rewardToken: rewardTokens[j]\n });\n }\n\n infoList[i] = MarketRewardsInfo({ market: market, rewardsInfo: rewardsInfo, underlyingPrice: price });\n }\n\n return infoList;\n }\n\n function scaleIndexDiff(uint256 indexDiff, uint256 decimals) internal pure returns (uint256) {\n return decimals <= 18 ? uint256(indexDiff) * (10**(18 - decimals)) : uint256(indexDiff) / (10**(decimals - 18));\n }\n\n function getRewardSpeedPerSecondPerToken(\n IonicFlywheelCore flywheel,\n ICErc20 market,\n uint256 decimals\n ) internal returns (uint256 rewardSpeedPerSecondPerToken) {\n ERC20 strategy = ERC20(address(market));\n (uint224 indexBefore, uint32 lastUpdatedTimestampBefore) = flywheel.strategyState(strategy);\n flywheel.accrue(strategy, address(0));\n (uint224 indexAfter, uint32 lastUpdatedTimestampAfter) = flywheel.strategyState(strategy);\n if (lastUpdatedTimestampAfter > lastUpdatedTimestampBefore) {\n rewardSpeedPerSecondPerToken =\n scaleIndexDiff((indexAfter - indexBefore), decimals) /\n (lastUpdatedTimestampAfter - lastUpdatedTimestampBefore);\n }\n }\n\n function getApr(\n uint256 rewardSpeedPerSecondPerToken,\n uint256 rewardTokenPrice,\n uint256 underlyingPrice,\n uint256 exchangeRate,\n bool isBorrow\n ) internal pure returns (uint256) {\n if (rewardSpeedPerSecondPerToken == 0) return 0;\n uint256 nativeSpeedPerSecondPerCToken = rewardSpeedPerSecondPerToken * rewardTokenPrice; // scaled to 1e36\n uint256 nativeSpeedPerYearPerCToken = nativeSpeedPerSecondPerCToken * 365.25 days; // scaled to 1e36\n uint256 assetSpeedPerYearPerCToken = nativeSpeedPerYearPerCToken / underlyingPrice; // scaled to 1e18\n uint256 assetSpeedPerYearPerCTokenScaled = assetSpeedPerYearPerCToken * 1e18; // scaled to 1e36\n uint256 apr = assetSpeedPerYearPerCTokenScaled;\n if (!isBorrow) {\n // if not borrowing, use exchange rate to scale\n apr = assetSpeedPerYearPerCTokenScaled / exchangeRate; // scaled to 1e18\n } else {\n apr = assetSpeedPerYearPerCTokenScaled / 1e18; // scaled to 1e18\n }\n return apr;\n }\n\n function getRewardsAprForMarket(ICErc20 market) internal returns (int256 totalMarketRewardsApr) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPrice = oracle.getUnderlyingPrice(market);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n ERC20 rewardToken = flywheel.rewardToken();\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n uint256(rewardToken.decimals())\n );\n\n uint256 marketApr = getApr(\n rewardSpeedPerSecondPerToken,\n oracle.price(address(rewardToken)),\n underlyingPrice,\n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n totalMarketRewardsApr += int256(marketApr);\n }\n }\n\n function getUserNetValueDeltaForMarket(\n address user,\n ICErc20 market,\n int256 offchainApr,\n int256 blocksPerYear\n ) internal returns (int256) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n int256 netApr = getRewardsAprForMarket(market) +\n getUserInterestAprForMarket(user, market, blocksPerYear) +\n offchainApr;\n return (netApr * int256(market.balanceOfUnderlying(user)) * int256(oracle.getUnderlyingPrice(market))) / 1e36;\n }\n\n function getUserInterestAprForMarket(\n address user,\n ICErc20 market,\n int256 blocksPerYear\n ) internal returns (int256) {\n uint256 borrows = market.borrowBalanceCurrent(user);\n uint256 supplied = market.balanceOfUnderlying(user);\n uint256 supplyRatePerBlock = market.supplyRatePerBlock();\n uint256 borrowRatePerBlock = market.borrowRatePerBlock();\n\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 assetPrice = oracle.getUnderlyingPrice(market);\n uint256 collateralValue = (supplied * assetPrice) / 1e18;\n uint256 borrowsValue = (borrows * assetPrice) / 1e18;\n\n uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;\n uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;\n\n if (collateralValue == 0) return 0;\n return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);\n }\n\n struct AdjustedUserNetAprVars {\n int256 userNetAssetsValue;\n int256 userNetValueDelta;\n BasePriceOracle oracle;\n ICErc20[] markets;\n IonicComptroller pool;\n }\n\n function getAdjustedUserNetApr(\n address user,\n int256 blocksPerYear,\n address[] memory offchainRewardsAprMarkets,\n int256[] memory offchainRewardsAprs\n ) public returns (int256) {\n AdjustedUserNetAprVars memory vars;\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n vars.oracle = pool.oracle();\n vars.markets = pool.getAllMarkets();\n for (uint256 j = 0; j < vars.markets.length; j++) {\n int256 offchainRewardsApr = 0;\n for (uint256 k = 0; k < offchainRewardsAprMarkets.length; k++) {\n if (offchainRewardsAprMarkets[k] == address(vars.markets[j])) offchainRewardsApr = offchainRewardsAprs[k];\n }\n vars.userNetAssetsValue +=\n int256(vars.markets[j].balanceOfUnderlying(user) * vars.oracle.getUnderlyingPrice(vars.markets[j])) /\n 1e18;\n vars.userNetValueDelta += getUserNetValueDeltaForMarket(\n user,\n vars.markets[j],\n offchainRewardsApr,\n blocksPerYear\n );\n }\n }\n\n if (vars.userNetAssetsValue == 0) return 0;\n else return (vars.userNetValueDelta * 1e18) / vars.userNetAssetsValue;\n }\n\n function getUserNetApr(address user, int256 blocksPerYear) external returns (int256) {\n address[] memory emptyAddrArray = new address[](0);\n int256[] memory emptyIntArray = new int256[](0);\n return getAdjustedUserNetApr(user, blocksPerYear, emptyAddrArray, emptyIntArray);\n }\n\n function getAllRewardTokens() public view returns (address[] memory uniqueRewardTokens) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n uint256 rewardTokensCounter;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n rewardTokensCounter += fws.length;\n }\n\n address[] memory rewardTokens = new address[](rewardTokensCounter);\n\n uint256 uniqueRewardTokensCounter = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n for (uint256 j = 0; j < fws.length; j++) {\n address rwToken = address(IonicFlywheelCore(fws[j]).rewardToken());\n if (rwToken == address(0)) break;\n\n bool added;\n for (uint256 k = 0; k < rewardTokens.length; k++) {\n if (rwToken == rewardTokens[k]) {\n added = true;\n break;\n }\n }\n if (!added) rewardTokens[uniqueRewardTokensCounter++] = rwToken;\n }\n }\n\n uniqueRewardTokens = new address[](uniqueRewardTokensCounter);\n for (uint256 i = 0; i < uniqueRewardTokensCounter; i++) {\n uniqueRewardTokens[i] = rewardTokens[i];\n }\n }\n\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory) {\n address[] memory rewardTokens = getAllRewardTokens();\n uint256[] memory rewardsClaimedForToken = new uint256[](rewardTokens.length);\n\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n rewardsClaimedForToken[i] = claimRewardsOfRewardToken(user, rewardTokens[i]);\n }\n\n return (rewardTokens, rewardsClaimedForToken);\n }\n\n function claimRewardsOfRewardToken(address user, address rewardToken) public returns (uint256 rewardsClaimed) {\n uint256 balanceBefore = ERC20(rewardToken).balanceOf(user);\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ERC20[] memory markets;\n {\n ICErc20[] memory cerc20s = pool.getAllMarkets();\n markets = new ERC20[](cerc20s.length);\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n }\n\n address[] memory flywheelAddresses = pool.getAccruingFlywheels();\n for (uint256 k = 0; k < flywheelAddresses.length; k++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);\n if (address(flywheel.rewardToken()) == rewardToken) {\n for (uint256 m = 0; m < markets.length; m++) {\n flywheel.accrue(markets[m], user);\n }\n flywheel.claimRewards(user);\n }\n }\n }\n\n uint256 balanceAfter = ERC20(rewardToken).balanceOf(user);\n return balanceAfter - balanceBefore;\n }\n\n function claimRewardsForMarket(\n address user,\n ERC20 market,\n IonicFlywheelCore[] calldata flywheels,\n bool[] calldata accrue\n )\n external\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n uint256 size = flywheels.length;\n rewards = new uint256[](size);\n rewardTokens = new address[](size);\n\n for (uint256 i = 0; i < size; i++) {\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n\n function claimRewardsForPool(address user, IonicComptroller comptroller)\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory,\n uint256[] memory\n )\n {\n ICErc20[] memory cerc20s = comptroller.getAllMarkets();\n ERC20[] memory markets = new ERC20[](cerc20s.length);\n address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();\n IonicFlywheelCore[] memory flywheels = new IonicFlywheelCore[](flywheelAddresses.length);\n bool[] memory accrue = new bool[](flywheelAddresses.length);\n\n for (uint256 j = 0; j < flywheelAddresses.length; j++) {\n flywheels[j] = IonicFlywheelCore(flywheelAddresses[j]);\n accrue[j] = true;\n }\n\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n\n return claimRewardsForMarkets(user, markets, flywheels, accrue);\n }\n\n function claimRewardsForMarkets(\n address user,\n ERC20[] memory markets,\n IonicFlywheelCore[] memory flywheels,\n bool[] memory accrue\n )\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n rewards = new uint256[](flywheels.length);\n rewardTokens = new address[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n for (uint256 j = 0; j < markets.length; j++) {\n ERC20 market = markets[j];\n\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n }\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/BaseFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IFlywheelRewards} from \"./IFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Reward Module\n @notice Determines how many rewards accrue to each strategy globally over a given time period.\n @dev approves the flywheel core for the reward token to allow balances to be managed by the module but claimed from core.\n*/\nabstract contract BaseFlywheelRewards is IFlywheelRewards {\n using SafeTransferLib for ERC20;\n\n /// @notice thrown when caller is not the flywheel\n error FlywheelError();\n\n /// @notice the reward token paid\n ERC20 public immutable override rewardToken;\n\n /// @notice the flywheel core contract\n IonicFlywheelCore public immutable override flywheel;\n\n constructor(IonicFlywheelCore _flywheel) {\n flywheel = _flywheel;\n ERC20 _rewardToken = _flywheel.rewardToken();\n rewardToken = _rewardToken;\n\n _rewardToken.safeApprove(address(_flywheel), type(uint256).max);\n }\n\n modifier onlyFlywheel() {\n if (msg.sender != address(flywheel)) revert FlywheelError();\n _;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelDynamicRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {SafeCastLib} from \"solmate/utils/SafeCastLib.sol\";\n\n/** \n @title Flywheel Dynamic Reward Stream\n @notice Determines rewards based on a dynamic reward stream.\n Rewards are transferred linearly over a \"rewards cycle\" to prevent gaming the reward distribution. \n The reward source can be arbitrary logic, but most common is to \"pass through\" rewards from some other source.\n The getNextCycleRewards() hook should also transfer the next cycle's rewards to this contract to ensure proper accounting.\n*/\nabstract contract FlywheelDynamicRewards is BaseFlywheelRewards {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n event NewRewardsCycle(uint32 indexed start, uint32 indexed end, uint192 reward);\n\n /// @notice the length of a rewards cycle\n uint32 public immutable rewardsCycleLength;\n\n struct RewardsCycle {\n uint32 start;\n uint32 end;\n uint192 reward;\n }\n\n mapping(ERC20 => RewardsCycle) public rewardsCycle;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _rewardsCycleLength) BaseFlywheelRewards(_flywheel) {\n rewardsCycleLength = _rewardsCycleLength;\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsCycle memory cycle = rewardsCycle[strategy];\n\n uint32 timestamp = block.timestamp.safeCastTo32();\n\n uint32 latest = timestamp >= cycle.end ? cycle.end : timestamp;\n uint32 earliest = lastUpdatedTimestamp <= cycle.start ? cycle.start : lastUpdatedTimestamp;\n if (cycle.end != 0) {\n amount = (cycle.reward * (latest - earliest)) / (cycle.end - cycle.start);\n assert(amount <= cycle.reward); // should never happen because latest <= cycle.end and earliest >= cycle.start\n }\n // if cycle has ended, reset cycle and transfer all available\n if (timestamp >= cycle.end) {\n uint32 end = ((timestamp + rewardsCycleLength) / rewardsCycleLength) * rewardsCycleLength;\n uint192 rewards = getNextCycleRewards(strategy);\n\n // reset for next cycle\n rewardsCycle[strategy] = RewardsCycle({start: timestamp, end: end, reward: rewards});\n\n emit NewRewardsCycle(timestamp, end, rewards);\n }\n }\n\n function getNextCycleRewards(ERC20 strategy) internal virtual returns (uint192);\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {Auth, Authority} from \"solmate/auth/Auth.sol\";\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Static Reward Stream\n @notice Determines rewards per strategy based on a fixed reward rate per second\n*/\ncontract FlywheelStaticRewards is Auth, BaseFlywheelRewards {\n event RewardsInfoUpdate(ERC20 indexed strategy, uint224 rewardsPerSecond, uint32 rewardsEndTimestamp);\n\n struct RewardsInfo {\n /// @notice Rewards per second\n uint224 rewardsPerSecond;\n /// @notice The timestamp the rewards end at\n /// @dev use 0 to specify no end\n uint32 rewardsEndTimestamp;\n }\n\n /// @notice rewards info per strategy\n mapping(ERC20 => RewardsInfo) public rewardsInfo;\n\n constructor(\n IonicFlywheelCore _flywheel,\n address _owner,\n Authority _authority\n ) Auth(_owner, _authority) BaseFlywheelRewards(_flywheel) {}\n\n /**\n @notice set rewards per second and rewards end time for Fei Rewards\n @param strategy the strategy to accrue rewards for\n @param rewards the rewards info for the strategy\n */\n function setRewardsInfo(ERC20 strategy, RewardsInfo calldata rewards) external requiresAuth {\n rewardsInfo[strategy] = rewards;\n emit RewardsInfoUpdate(strategy, rewards.rewardsPerSecond, rewards.rewardsEndTimestamp);\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @param lastUpdatedTimestamp the last updated time for strategy\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n view\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsInfo memory rewards = rewardsInfo[strategy];\n\n uint256 elapsed;\n if (rewards.rewardsEndTimestamp == 0 || rewards.rewardsEndTimestamp > block.timestamp) {\n elapsed = block.timestamp - lastUpdatedTimestamp;\n } else if (rewards.rewardsEndTimestamp > lastUpdatedTimestamp) {\n elapsed = rewards.rewardsEndTimestamp - lastUpdatedTimestamp;\n }\n\n amount = rewards.rewardsPerSecond * elapsed;\n }\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/**\n @title Rewards Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Rewards module is responsible for:\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\n * actually holding rewards that are yet to be claimed\n\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\n\n Different module strategies include:\n * a static reward rate per second\n * a decaying reward rate\n * a dynamic just-in-time reward stream\n * liquid governance reward delegation (Curve Gauge style)\n\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\n */\ninterface IFlywheelRewards {\n /**\n @notice calculate the rewards amount accrued to a strategy since the last update.\n @param strategy the strategy to accrue rewards for.\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\n @return rewards the amount of rewards accrued to the market\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\n\n /// @notice return the flywheel core address\n function flywheel() external view returns (IonicFlywheelCore);\n\n /// @notice return the reward token associated with flywheel core.\n function rewardToken() external view returns (ERC20);\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport \"./FlywheelDynamicRewards.sol\";\n\ninterface ICERC20 {\n function plugin() external returns (address);\n}\n\ninterface IPlugin_FDR {\n function claimRewards() external;\n}\n\n/** \n @title Ionic Flywheel Dynamic Reward Stream\n @notice Determines rewards based on reward cycle\n Each cycle, claims rewards on the plugin before getting the reward amount\n*/\ncontract IonicFlywheelDynamicRewardsPlugin is FlywheelDynamicRewards {\n using SafeTransferLib for ERC20;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)\n FlywheelDynamicRewards(_flywheel, _cycleLength)\n {}\n\n function getNextCycleRewards(ERC20 strategy)\n internal\n override\n returns (uint192)\n {\n IPlugin_FDR plugin = IPlugin_FDR(ICERC20(address(strategy)).plugin());\n try plugin.claimRewards() {} catch {}\n\n uint256 rewardAmount = rewardToken.balanceOf(address(strategy));\n if (rewardAmount != 0) {\n rewardToken.safeTransferFrom(\n address(strategy),\n address(this),\n rewardAmount\n );\n }\n return uint192(rewardAmount);\n }\n}" + }, + "contracts/ionic/strategies/IonicERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nimport { PausableUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol\";\nimport { ERC4626Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nabstract contract IonicERC4626 is SafeOwnableUpgradeable, PausableUpgradeable, ERC4626Upgradeable {\n using FixedPointMathLib for uint256;\n using SafeERC20Upgradeable for ERC20Upgradeable;\n\n /* ========== STATE VARIABLES ========== */\n\n uint256 public vaultShareHWM;\n uint256 public performanceFee;\n address public feeRecipient;\n\n /* ========== EVENTS ========== */\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /* ========== INITIALIZER ========== */\n\n function __IonicER4626_init(ERC20Upgradeable asset_) internal onlyInitializing {\n __SafeOwnable_init(msg.sender);\n __Pausable_init();\n __Context_init();\n __ERC20_init(\n string(abi.encodePacked(\"Ionic \", asset_.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", asset_.symbol()))\n );\n __ERC4626_init(asset_);\n\n vaultShareHWM = 10**asset_.decimals();\n feeRecipient = msg.sender;\n }\n\n function _asset() internal view returns (ERC20Upgradeable) {\n return ERC20Upgradeable(super.asset());\n }\n\n /* ========== DEPOSIT/WITHDRAW FUNCTIONS ========== */\n\n function deposit(uint256 assets, address receiver) public override whenNotPaused returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public override whenNotPaused returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public override returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public override returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n /* ========== FEE FUNCTIONS ========== */\n\n /**\n * @notice Take the performance fee that has accrued since last fee harvest.\n * @dev Performance fee is based on a vault share high water mark value. If vault share value has increased above the\n * HWM in a fee period, issue fee shares to the vault equal to the performance fee.\n */\n function takePerformanceFee() external onlyOwner {\n require(feeRecipient != address(0), \"fee recipient not initialized\");\n\n uint256 currentAssets = totalAssets();\n uint256 shareValue = convertToAssets(10**_asset().decimals());\n\n require(shareValue > vaultShareHWM, \"shareValue !> vaultShareHWM\");\n // cache value\n uint256 supply = totalSupply();\n\n uint256 accruedPerformanceFee = (performanceFee * (shareValue - vaultShareHWM) * supply) / 1e36;\n _mint(feeRecipient, accruedPerformanceFee.mulDivDown(supply, (currentAssets - accruedPerformanceFee)));\n\n vaultShareHWM = convertToAssets(10**_asset().decimals());\n }\n\n /**\n * @notice Transfer accrued fees to rewards manager contract. Caller must be a registered keeper.\n * @dev We must make sure that feeRecipient is not address(0) before withdrawing fees\n */\n function withdrawAccruedFees() external onlyOwner {\n redeem(balanceOf(feeRecipient), feeRecipient, feeRecipient);\n }\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n */\n function updateFeeSettings(uint256 newPerformanceFee, address newFeeRecipient) external onlyOwner {\n emit UpdatedFeeSettings(performanceFee, newPerformanceFee, feeRecipient, newFeeRecipient);\n\n performanceFee = newPerformanceFee;\n\n if (newFeeRecipient != feeRecipient) {\n if (feeRecipient != address(0)) {\n uint256 oldFees = balanceOf(feeRecipient);\n\n _burn(feeRecipient, oldFees);\n _approve(feeRecipient, owner(), 0);\n _mint(newFeeRecipient, oldFees);\n }\n\n _approve(newFeeRecipient, owner(), type(uint256).max);\n }\n\n feeRecipient = newFeeRecipient;\n }\n\n /* ========== EMERGENCY FUNCTIONS ========== */\n\n // Should withdraw all funds from the strategy and pause the contract\n function emergencyWithdrawAndPause() external virtual;\n\n function unpause() external virtual;\n\n function shutdown(address market) external onlyOwner whenPaused returns (uint256) {\n ERC20Upgradeable theAsset = _asset();\n uint256 endBalance = theAsset.balanceOf(address(this));\n theAsset.transfer(market, endBalance);\n return endBalance;\n }\n\n /* ========== INTERNAL HOOKS LOGIC ========== */\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual;\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual;\n}\n" + }, + "contracts/ionic/strategies/MockERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626 is ERC4626 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /**\n @notice Creates a new Vault that accepts a specific underlying token.\n @param _asset The ERC20 compliant token the Vault should accept.\n */\n constructor(ERC20 _asset)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {}\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/ionic/strategies/MockERC4626Dynamic.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IonicFlywheelCore } from \"./flywheel/IonicFlywheelCore.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626Dynamic is ERC4626 {\n using FixedPointMathLib for uint256;\n\n /* ========== STATE VARIABLES ========== */\n IonicFlywheelCore public immutable flywheel;\n\n /* ========== INITIALIZER ========== */\n\n /**\n @notice Initializes the Vault.\n @param _asset The ERC20 compliant token the Vault should accept.\n @param _flywheel Flywheel to pull in rewardsToken\n */\n constructor(ERC20 _asset, IonicFlywheelCore _flywheel)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {\n flywheel = _flywheel;\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/IonicLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./utils/IW_NATIVE.sol\";\n\nimport \"./external/uniswap/IUniswapV2Router02.sol\";\nimport \"./external/uniswap/IUniswapV2Pair.sol\";\nimport \"./external/uniswap/IUniswapV2Callee.sol\";\nimport \"./external/uniswap/UniswapV2Library.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicLiquidator\n * @author David Lucid (https://github.com/davidlucid)\n * @notice IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).\n * @dev Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.\n */\ncontract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, IExpressRelayFeeReceiver {\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n\n /**\n * @dev W_NATIVE contract address.\n */\n address public W_NATIVE_ADDRESS;\n\n /**\n * @dev UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)\n */\n IUniswapV2Router02 public UNISWAP_V2_ROUTER_02;\n\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n mapping(address => bool) public redemptionStrategiesWhitelist;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n /**\n * @dev Percentage of the flash swap fee, measured in basis points.\n */\n uint8 public flashSwapFee;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(\n address _wtoken,\n address _uniswapV2router,\n uint8 _flashSwapFee\n ) external initializer {\n __Ownable_init();\n require(_uniswapV2router != address(0), \"_uniswapV2router not defined.\");\n W_NATIVE_ADDRESS = _wtoken;\n UNISWAP_V2_ROUTER_02 = IUniswapV2Router02(_uniswapV2router);\n flashSwapFee = _flashSwapFee;\n }\n\n function _becomeImplementation(bytes calldata data) external {}\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @dev Internal function to approve\n */\n function justApprove(\n IERC20Upgradeable token,\n address to,\n uint256 amount\n ) private {\n token.approve(to, amount);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n justApprove(underlying, address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.\n * @param vars @see LiquidateToTokensWithFlashSwapVars.\n */\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n onlyLowHF(vars.borrower, vars.cTokenCollateral)\n returns (uint256)\n {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV2Pair flashSwapPair = IUniswapV2Pair(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPair.token0() == address(fundingToken);\n flashSwapPair.swap(\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n address(this),\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n function uniswapV2Call(\n address,\n uint256,\n uint256,\n bytes calldata data\n ) public override {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars);\n }\n\n /**\n * @dev Callback function for PCS flashloans.\n */\n function pancakeCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n function moraswapCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(LiquidateToTokensWithFlashSwapVars memory vars) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n justApprove(IERC20Upgradeable(underlyingBorrow), address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData\n ) private returns (address) {\n // Calculate flashloan return amount\n uint256 flashSwapReturnAmount = (_flashSwapAmount * 10000) / (10000 - flashSwapFee);\n if ((_flashSwapAmount * 10000) % (10000 - flashSwapFee) > 0) flashSwapReturnAmount++; // Round up if division resulted in a remainder\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n IUniswapV2Pair pair = IUniswapV2Pair(msg.sender);\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pair.token0() || address(underlyingCollateral) == pair.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay amount for the borrow side\n collateralRequired = flashSwapReturnAmount;\n } else {\n // repay amount for the non-borrow side\n collateralRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n _flashSwapAmount, //flashSwapReturnAmount,\n array(address(underlyingCollateral), _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n // Repay flashloan\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n require(\n underlyingCollateral.transfer(msg.sender, collateralRequired),\n \"Failed to repay token flashloan on borrow side.\"\n );\n\n return address(underlyingCollateral);\n } else {\n // exchange the collateral to W_NATIVE to repay the borrow side\n uint256 wethRequired;\n if (_flashSwapToken == W_NATIVE_ADDRESS) {\n wethRequired = flashSwapReturnAmount;\n } else {\n // Get W_NATIVE required to repay flashloan\n wethRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n flashSwapReturnAmount,\n array(W_NATIVE_ADDRESS, _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n if (address(underlyingCollateral) != W_NATIVE_ADDRESS) {\n // Approve to Uniswap router\n justApprove(underlyingCollateral, address(UNISWAP_V2_ROUTER_02), underlyingCollateralSeized);\n\n // Swap collateral tokens for W_NATIVE to be repaid via Uniswap router\n UNISWAP_V2_ROUTER_02.swapTokensForExactTokens(\n wethRequired,\n underlyingCollateralSeized,\n array(address(underlyingCollateral), W_NATIVE_ADDRESS),\n address(this),\n block.timestamp\n );\n }\n\n // Repay flashloan\n require(\n wethRequired <= IERC20Upgradeable(W_NATIVE_ADDRESS).balanceOf(address(this)),\n \"Not enough W_NATIVE exchanged from seized collateral to repay flashloan.\"\n );\n require(\n IW_NATIVE(W_NATIVE_ADDRESS).transfer(msg.sender, wethRequired),\n \"Failed to repay Uniswap flashloan with W_NATIVE exchanged from seized collateral.\"\n );\n\n // Return the profited token (underlying collateral if same as exchangeProfitTo; otherwise, W_NATIVE)\n return address(underlyingCollateral);\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external\n onlyOwner\n {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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 /**\n * @dev Returns an array containing the parameters supplied.\n */\n function array(address a, address b) private pure returns (address[] memory) {\n address[] memory arr = new address[](2);\n arr[0] = a;\n arr[1] = b;\n return arr;\n }\n}\n" + }, + "contracts/IonicUniV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./external/uniswap/IUniswapV3FlashCallback.sol\";\nimport \"./external/uniswap/IUniswapV3Pool.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\nimport { IUniswapV3Quoter } from \"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IFlashLoanReceiver } from \"./ionic/IFlashLoanReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicUniV3Liquidator\n * @author Veliko Minkov (https://github.com/vminkov)\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\n */\ncontract IonicUniV3Liquidator is\n OwnableUpgradeable,\n ILiquidator,\n IUniswapV3FlashCallback,\n IExpressRelayFeeReceiver,\n IFlashLoanReceiver\n{\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n\n address public W_NATIVE_ADDRESS;\n mapping(address => bool) public redemptionStrategiesWhitelist;\n IUniswapV3Quoter public quoter;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(address _wtoken, address _quoter) external initializer {\n __Ownable_init();\n W_NATIVE_ADDRESS = _wtoken;\n quoter = IUniswapV3Quoter(_quoter);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n underlying.approve(address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateToTokensWithFlashLoan(\n LiquidateToTokensWithFlashSwapVars calldata vars\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\n flashSwapPool.flash(\n address(this),\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(\n LiquidateToTokensWithFlashSwapVars memory vars,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\n uint256 flashSwapReturnAmount = _flashSwapAmount;\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\n flashSwapReturnAmount += fee0;\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\n flashSwapReturnAmount += fee1;\n } else {\n revert(\"wrong pool or _flashSwapToken\");\n }\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay the borrowed asset directly\n collateralRequired = flashSwapReturnAmount;\n\n // Repay flashloan\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\n } else {\n // TODO swap within the same pool and then repay the FL to the pool\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\n\n {\n collateralRequired = quoter.quoteExactOutputSingle(\n zeroForOne ? pool.token0() : pool.token1(),\n zeroForOne ? pool.token1() : pool.token0(),\n pool.fee(),\n _flashSwapAmount,\n 0 // sqrtPriceLimitX96\n );\n }\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n\n // Repay flashloan\n pool.swap(\n address(pool),\n zeroForOne,\n int256(collateralRequired),\n 0, // sqrtPriceLimitX96\n \"\"\n );\n }\n\n return address(underlyingCollateral);\n } else {\n revert(\"the redemptions strategy did not swap to the flash swapped pool assets\");\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n bool[] calldata whitelisted\n ) external onlyOwner {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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" + }, + "contracts/liquidators/AerodromeCLLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { ISwapRouter_Aerodrome } from \"../external/aerodrome/IAerodromeSwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\ncontract AerodromeCLLiquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n ,\n address _outputToken,\n ISwapRouter_Aerodrome swapRouter,\n address _unwrappedInput,\n address _unwrappedOutput,\n int24 _tickSpacing\n ) = abi.decode(strategyData, (address, address, ISwapRouter_Aerodrome, address, address, int24));\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(_outputToken);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n ISwapRouter_Aerodrome.ExactInputSingleParams(\n address(inputToken),\n address(outputToken),\n _tickSpacing,\n address(this),\n block.timestamp,\n inputAmount,\n 0,\n 0\n )\n );\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(_outputToken), outputAmount);\n IERC4626(_outputToken).deposit(outputAmount, address(this));\n outputAmount = IERC4626(_unwrappedOutput).balanceOf(address(this));\n outputToken = IERC20Upgradeable(_outputToken);\n }\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"AerodromeCLLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AerodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\n\n/**\n * @title AerodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Aerodrome V2 router for use as a step in a liquidation.\n */\ncontract AerodromeV2Liquidator {\n function _swap(IRouter_Aerodrome router, uint256 inputAmount, IRouter_Aerodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"AerodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Aerodrome router, IRouter_Aerodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Aerodrome, IRouter_Aerodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid AerodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/liquidators/AlgebraSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/algebra/ISwapRouter.sol\";\n\n/**\n * @title AlgebraSwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Algebra router for use as a step in a liquidation.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract AlgebraSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address _outputToken, IAlgebraSwapRouter swapRouter) = abi.decode(strategyData, (address, IAlgebraSwapRouter));\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n IAlgebraSwapRouter.ExactInputSingleParams memory params = IAlgebraSwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n address(this),\n block.timestamp,\n inputAmount,\n 0, // amountOutMinimum\n 0 // limitSqrtPrice\n );\n\n outputAmount = swapRouter.exactInputSingle(params);\n }\n\n function name() public pure returns (string memory) {\n return \"AlgebraSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract BalancerSwapLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address outputTokenAddress, IBalancerPool pool) = abi.decode(strategyData, (address, IBalancerPool));\n\n IBalancerVault vault = pool.getVault();\n bytes32 poolId = pool.getPoolId();\n\n SingleSwap memory singleSwap = SingleSwap(\n poolId,\n SwapKind.GIVEN_IN,\n IAsset(address(inputToken)),\n IAsset(address(outputTokenAddress)),\n inputAmount,\n \"\"\n );\n\n FundManagement memory funds = FundManagement(\n address(this),\n false, // fromInternalBalance\n payable(address(this)),\n false // toInternalBalance\n );\n\n inputToken.approve(address(vault), inputAmount);\n vault.swap(singleSwap, funds, 0, block.timestamp + 10);\n outputAmount = IERC20Upgradeable(outputTokenAddress).balanceOf(address(this));\n return (IERC20Upgradeable(outputTokenAddress), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BaseUniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nabstract contract BaseUniswapV2Liquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2 && swapPath[0] == address(inputToken), \"Invalid UniswapLiquidator swap path.\");\n\n // Swap underlying tokens\n inputToken.approve(address(uniswapV2Router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(uniswapV2Router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1]);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal virtual;\n}\n" + }, + "contracts/liquidators/CurveLpTokenLiquidatorNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\nimport { WETH } from \"solmate/tokens/WETH.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLpTokenLiquidatorNoRegistry\n * @notice Redeems seized Curve LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLpTokenLiquidatorNoRegistry is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // TODO get the curvePool from the strategyData instead of the _oracle\n (address outputTokenAddress, address payable wtoken, address _oracle) = abi.decode(\n strategyData,\n (address, address, address)\n );\n // the oracle contains the pool registry\n CurveLpTokenPriceOracleNoRegistry oracle = CurveLpTokenPriceOracleNoRegistry(_oracle);\n\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(oracle.poolOf(address(inputToken)));\n\n uint8 outputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (outputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == outputTokenAddress) outputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(outputIndex)), 1);\n\n // better safe than sorry\n if (outputTokenAddress == address(0) || outputTokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n WETH(wtoken).deposit{ value: address(this).balance }();\n outputToken = IERC20Upgradeable(wtoken);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n outputAmount = outputToken.balanceOf(address(this));\n\n return (outputToken, outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenLiquidatorNoRegistry\";\n }\n}\n\ncontract CurveLpTokenWrapper is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (ICurvePool curvePool, address _outputTokenAddress) = abi.decode(strategyData, (ICurvePool, address));\n outputToken = IERC20Upgradeable(_outputTokenAddress);\n\n uint8 inputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (inputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == address(inputToken)) inputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n inputToken.approve(address(curvePool), inputAmount);\n uint256[2] memory amounts;\n amounts[inputIndex] = inputAmount;\n curvePool.add_liquidity(amounts, 1);\n\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nimport \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\n/**\n * @title CurveSwapLiquidator\n * @notice Swaps seized token collateral via Curve as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable, uint256) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address outputTokenAddress,\n address _unwrappedInput,\n address _unwrappedOutput\n ) = abi.decode(strategyData, (CurveV2LpTokenPriceOracleNoRegistry, address, address, address));\n\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n address inputTokenAddress = address(inputToken);\n\n ICurvePool curvePool;\n int128 i;\n int128 j;\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, address(outputToken));\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n inputToken.approve(address(curvePool), inputAmount);\n outputAmount = curvePool.exchange(i, j, inputAmount, 0);\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(outputTokenAddress), outputAmount);\n IERC4626(outputTokenAddress).deposit(outputAmount, address(this));\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n outputAmount = outputToken.balanceOf(address(this));\n return (outputToken, outputAmount);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"CurveSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CurveSwapLiquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\n\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract CurveSwapLiquidatorFunder is CurveSwapLiquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable, uint256)\n {\n ICurvePool curvePool;\n int128 i;\n int128 j;\n {\n (\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle,\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address inputTokenAddress,\n address outputTokenAddress,\n\n ) = abi.decode(\n strategyData,\n (CurveLpTokenPriceOracleNoRegistry, CurveV2LpTokenPriceOracleNoRegistry, address, address, address)\n );\n\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n if (address(curvePool) == address(0)) {\n (curvePool, i, j) = curveV1Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n IERC20MetadataUpgradeable inputMetadataToken = IERC20MetadataUpgradeable(curvePool.coins(uint256(int256(i))));\n uint256 inputAmountGuesstimate = guesstimateInputAmount(curvePool, i, j, inputMetadataToken, outputAmount);\n uint256 inputAmount = binSearch(\n curvePool,\n i,\n j,\n (70 * inputAmountGuesstimate) / 100,\n (130 * inputAmountGuesstimate) / 100,\n outputAmount\n );\n\n return (inputMetadataToken, inputAmount);\n }\n\n function guesstimateInputAmount(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n IERC20MetadataUpgradeable inputMetadataToken,\n uint256 outputAmount\n ) internal view returns (uint256) {\n uint256 oneInputToken = 10**inputMetadataToken.decimals();\n uint256 outputTokensForOneInputToken = curvePool.get_dy(i, j, oneInputToken);\n // inputAmount / outputAmount = oneInputToken / outputTokensForOneInputToken\n uint256 inputAmount = (outputAmount * oneInputToken) / outputTokensForOneInputToken;\n return inputAmount;\n }\n\n function binSearch(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n uint256 low,\n uint256 high,\n uint256 value\n ) internal view returns (uint256) {\n if (low >= high) return low;\n\n uint256 mid = (low + high) / 2;\n uint256 outputAmount = curvePool.get_dy(i, j, mid);\n if (outputAmount == 0) revert(\"output amount 0\");\n // output can be up to 10% in excess\n if (outputAmount >= value && outputAmount <= (11 * value) / 10) return mid;\n else if (outputAmount > value) {\n return binSearch(curvePool, i, j, low, mid, value);\n } else {\n return binSearch(curvePool, i, j, mid, high, value);\n }\n }\n\n function name() public pure override(CurveSwapLiquidator, IRedemptionStrategy) returns (string memory) {\n return \"CurveSwapLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/IFundsConversionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFundsConversionStrategy is IRedemptionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\n}\n" + }, + "contracts/liquidators/IRedemptionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\n/**\n * @title IRedemptionStrategy\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function name() external view returns (string memory);\n}\n" + }, + "contracts/liquidators/JarvisLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { ISynthereumLiquidityPool } from \"../external/jarvis/ISynthereumLiquidityPool.sol\";\n\ncontract JarvisLiquidatorFunder is IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n\n // approve so the pool can pull out the input tokens\n inputToken.approve(address(pool), inputAmount);\n\n IERC20Upgradeable collateralToken = pool.collateralToken();\n IERC20Upgradeable syntheticToken = pool.syntheticToken();\n\n if (inputToken == syntheticToken) {\n outputToken = collateralToken;\n\n uint256 shutdownPrice = 0;\n // TODO figure out why this method was removed and what to use instead\n try pool.emergencyShutdownPrice() returns (uint256 price) {\n shutdownPrice = price;\n } catch {}\n\n if (shutdownPrice > 0) {\n // emergency shutdowns cannot be reverted, so this corner case must be covered\n (, uint256 collateralSettled) = pool.settleEmergencyShutdown();\n outputAmount = collateralSettled;\n // outputToken = collateralToken;\n } else {\n // redeem the underlying BUSD\n // fetch the estimated redeemable collateral in BUSD, less the fee paid\n (uint256 redeemableCollateralAmount, ) = pool.getRedeemTradeInfo(inputAmount);\n\n (uint256 collateralAmountReceived, ) = pool.redeem(\n ISynthereumLiquidityPool.RedeemParams(inputAmount, redeemableCollateralAmount, block.timestamp, address(this))\n );\n\n outputAmount = collateralAmountReceived;\n }\n } else if (inputToken == collateralToken) {\n outputToken = syntheticToken;\n\n // mint jBRL from the supplied bUSD\n (uint256 synthTokensReceived, ) = pool.getMintTradeInfo(inputAmount);\n\n (uint256 syntheticTokensMinted, ) = pool.mint(\n ISynthereumLiquidityPool.MintParams(synthTokensReceived, inputAmount, block.timestamp, address(this))\n );\n\n outputAmount = syntheticTokensMinted;\n } else {\n revert(\"unknown input token\");\n }\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address inputTokenAddress, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n\n inputToken = IERC20Upgradeable(inputTokenAddress);\n\n uint8 decimals = 18;\n try IERC20MetadataUpgradeable(inputTokenAddress).decimals() returns (uint8 dec) {\n decimals = dec;\n } catch {}\n uint256 ONE = 10**decimals;\n\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n if (inputToken == pool.syntheticToken()) {\n // collateralAmountReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / collateralAmountReceived\n (uint256 collateralAmountReceived, ) = ISynthereumLiquidityPool(poolAddress).getRedeemTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, collateralAmountReceived);\n } else if (inputToken == pool.collateralToken()) {\n // synthTokensReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / synthTokensReceived\n (uint256 synthTokensReceived, ) = ISynthereumLiquidityPool(poolAddress).getMintTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, synthTokensReceived);\n } else {\n revert(\"unknown input token\");\n }\n }\n\n function name() public pure returns (string memory) {\n return \"JarvisLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/KimUniV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\ncontract KimUniV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(\n inputAmount,\n 0,\n swapPath,\n address(this),\n address(0), // referrer\n block.timestamp\n );\n }\n\n function name() public pure virtual returns (string memory) {\n return \"KimUniV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/registry/ILiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILiquidatorsRegistryStorage {\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\n\n function redemptionStrategiesByTokens(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy);\n\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\n\n function owner() external view returns (address);\n\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\n\n function customUniV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (address);\n}\n\ninterface ILiquidatorsRegistryExtension {\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\n\n function getAllRedemptionStrategies() external view returns (address[] memory);\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage);\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256);\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage);\n}\n\ninterface ILiquidatorsRegistrySecondExtension {\n function getAllPairsStrategies()\n external\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n );\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool);\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool);\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool);\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external;\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external;\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external;\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external;\n\n function optimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IERC20Upgradeable[] memory);\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external;\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\n}\n\ninterface ILiquidatorsRegistry is\n ILiquidatorsRegistryExtension,\n ILiquidatorsRegistrySecondExtension,\n ILiquidatorsRegistryStorage\n{}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\nimport \"./LiquidatorsRegistryExtension.sol\";\n\ncontract LiquidatorsRegistry is LiquidatorsRegistryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n constructor(AddressesProvider _ap) SafeOwnable() {\n ap = _ap;\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function asExtension() public view returns (LiquidatorsRegistryExtension) {\n return LiquidatorsRegistryExtension(address(this));\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../IRedemptionStrategy.sol\";\nimport \"../../ionic/DiamondExtension.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \"../../external/aerodrome/IAerodromeRouter.sol\";\nimport { IRouter_Velodrome as IVelodromeV2Router } from \"../../external/velodrome/IVelodromeRouter.sol\";\nimport { IRouter } from \"../../external/solidly/IRouter.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error NoRedemptionPath();\n error OutputTokenMismatch();\n\n event SlippageUpdated(\n IERC20Upgradeable indexed from,\n IERC20Upgradeable indexed to,\n uint256 prevValue,\n uint256 newValue\n );\n\n // @notice maximum slippage in swaps, in bps\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 7;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\n functionSelectors[--fnsCount] = this.swap.selector;\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\n functionSelectors[--fnsCount] = this.getSlippage.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage) {\n slippage = conversionSlippage[inputToken][outputToken];\n // TODO slippage == 0 should be allowed\n if (slippage == 0) return MAX_SLIPPAGE;\n }\n\n function getAllRedemptionStrategies() public view returns (address[] memory) {\n return redemptionStrategies.values();\n }\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage) {\n if (inputAmount == 0) return (0, 0);\n\n outputAmount = swap(inputToken, inputAmount, outputToken);\n if (outputAmount == 0) return (0, 0);\n\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n uint256 inputTokenPrice = mpo.price(address(inputToken));\n uint256 outputTokenPrice = mpo.price(address(outputToken));\n\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\n\n if (outputTokensValue < inputTokensValue) {\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\n }\n // min slippage should be non-zero\n // just in case of rounding errors\n slippage += 1;\n\n // cache the slippage\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\n\n conversionSlippage[inputToken][outputToken] = slippage;\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\n }\n }\n\n /// @dev returns price scaled to 1e36 - decimals\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\n return\n tokenDecimals <= 18\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\n }\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) public returns (uint256 outputAmount) {\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\n outputAmount = convertAllTo(inputToken, outputToken);\n outputToken.safeTransfer(msg.sender, outputAmount);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\n inputToken,\n outputToken\n );\n\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\n\n IERC20Upgradeable swapInputToken = inputToken;\n uint256 swapInputAmount = inputAmount;\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\n swapInputToken,\n swapInputAmount,\n redemptionStrategy,\n strategyData\n );\n swapInputAmount = swapOutputAmount;\n swapInputToken = swapOutputToken;\n }\n\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\n return outputToken.balanceOf(address(this));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\n return inputTokensByOutputToken[outputToken].values();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n IERC20Upgradeable tokenToRedeem = inputToken;\n IERC20Upgradeable targetOutputToken = outputToken;\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\n bytes[] memory strategiesDataTemp = new bytes[](10);\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\n uint256 optimalPathIterator = 0;\n\n uint256 k = 0;\n while (tokenToRedeem != targetOutputToken) {\n IERC20Upgradeable nextRedeemedToken;\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\n if (address(directStrategy) != address(0)) {\n nextRedeemedToken = targetOutputToken;\n } else {\n // check if an optimal path is preconfigured\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\n }\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\n nextRedeemedToken = optimalPath[optimalPathIterator++];\n } else {\n // else if no optimal path is available, use the default\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\n }\n }\n\n // check if going in an endless loop\n for (uint256 i = 0; i < tokenPath.length; i++) {\n if (nextRedeemedToken == tokenPath[i]) break;\n }\n\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\n tokenToRedeem,\n nextRedeemedToken\n );\n if (address(strategy) == address(0)) break;\n\n strategiesTemp[k] = strategy;\n strategiesDataTemp[k] = strategyData;\n tokenPath[k] = nextRedeemedToken;\n tokenToRedeem = nextRedeemedToken;\n\n k++;\n if (k == 10) break;\n }\n\n strategies = new IRedemptionStrategy[](k);\n strategiesData = new bytes[](k);\n\n for (uint8 i = 0; i < k; i++) {\n strategies[i] = strategiesTemp[i];\n strategiesData[i] = strategiesDataTemp[i];\n }\n }\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\n\n if (isStrategy(strategy, \"UniswapV2LiquidatorFunder\") || isStrategy(strategy, \"KimUniV2Liquidator\")) {\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"UniswapV3LiquidatorFunder\")) {\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AlgebraSwapLiquidator\")) {\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeV2Liquidator\")) {\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeCLLiquidator\")) {\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"CurveSwapLiquidator\")) {\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"VelodromeV2Liquidator\")) {\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\n } else {\n revert(\"no strategy data\");\n }\n }\n\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\n }\n\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\n }\n address wnative = ap.getAddress(\"wtoken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wnative) return wnative;\n }\n address stableToken = ap.getAddress(\"stableToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == stableToken) return stableToken;\n }\n address wbtc = ap.getAddress(\"wBTCToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wbtc) return wbtc;\n }\n return tokens[0];\n }\n\n function getUniswapV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (address) {\n address customRouter = customUniV3Router[inputToken][outputToken];\n if (customRouter == address(0)) {\n customRouter = customUniV3Router[outputToken][inputToken];\n }\n\n if (customRouter != address(0)) {\n return customRouter;\n } else {\n // get asset specific router or default\n return ap.getAddress(\"UNISWAP_V3_ROUTER\");\n }\n }\n\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"IUniswapV2Router02\");\n }\n\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_V2_ROUTER\");\n }\n\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_CL_ROUTER\");\n }\n\n function uniswapV3LiquidatorFunderData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\n if (fee == 0) fee = 500;\n\n address router = getUniswapV3Router(inputToken, outputToken);\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\"Quoter\"));\n }\n\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\n return _wrappedToUnwrapped4626[address(inputToken)];\n }\n\n function getAeroCLTickSpacing(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (int24) {\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\n if (tickSpacing == 0) {\n tickSpacing = 1;\n }\n return tickSpacing;\n }\n\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\n }\n\n function uniswapV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\n swapPath[0] = inputToken;\n swapPath[1] = outputToken;\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\n }\n\n function aerodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\n swapPath[0] = IAerodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken),\n factory: ap.getAddress(\"AERODROME_V2_FACTORY\")\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n\n function aerodromeCLLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n inputToken,\n outputToken,\n getAerodromeCLRouter(inputToken),\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken),\n getAeroCLTickSpacing(inputToken, outputToken)\n );\n }\n\n function algebraSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(outputToken, ap.getAddress(\"ALGEBRA_SWAP_ROUTER\"));\n }\n\n function curveSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n ap.getAddress(\"CURVE_V2_ORACLE_NO_REGISTRY\"),\n outputToken,\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken)\n );\n }\n\n function velodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\n swapPath[0] = IVelodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken)\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../../ionic/DiamondExtension.sol\";\n\ncontract LiquidatorsRegistrySecondExtension is\n LiquidatorsRegistryStorage,\n DiamondExtension,\n ILiquidatorsRegistrySecondExtension\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 20;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getAllPairsStrategies.selector;\n functionSelectors[--fnsCount] = this.pairsStrategiesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsFeesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsRoutersMatch.selector;\n functionSelectors[--fnsCount] = this._setSlippages.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Fees.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Routers.selector;\n functionSelectors[--fnsCount] = this._setDefaultOutputToken.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this._removeRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._resetRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.optimalSwapPath.selector;\n functionSelectors[--fnsCount] = this._setOptimalSwapPath.selector;\n functionSelectors[--fnsCount] = this.wrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this.aeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this.aeroV2IsStable.selector;\n functionSelectors[--fnsCount] = this._setWrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this._setAeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this._setAeroV2IsStable.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external onlyOwner {\n require(slippages.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < slippages.length; i++) {\n conversionSlippage[inputTokens[i]][outputTokens[i]] = slippages[i];\n }\n }\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external onlyOwner {\n require(fees.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < fees.length; i++) {\n uniswapV3Fees[inputTokens[i]][outputTokens[i]] = fees[i];\n }\n }\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external onlyOwner {\n require(routers.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < routers.length; i++) {\n customUniV3Router[inputTokens[i]][outputTokens[i]] = routers[i];\n }\n }\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external onlyOwner {\n defaultOutputToken[inputToken] = outputToken;\n }\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public onlyOwner {\n string memory name = strategy.name();\n IRedemptionStrategy oldStrategy = redemptionStrategiesByName[name];\n\n redemptionStrategiesByTokens[inputToken][outputToken] = strategy;\n redemptionStrategiesByName[name] = strategy;\n\n redemptionStrategies.remove(address(oldStrategy));\n redemptionStrategies.add(address(strategy));\n\n if (defaultOutputToken[inputToken] == IERC20Upgradeable(address(0))) {\n defaultOutputToken[inputToken] = outputToken;\n }\n inputTokensByOutputToken[outputToken].add(address(inputToken));\n outputTokensSet.add(address(outputToken));\n }\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n // empty the input/output token mappings/sets\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n outputTokensSet.remove(_outputTokens[i]);\n }\n\n // empty the strategies mappings/sets\n address[] memory _currentStrategies = redemptionStrategies.values();\n for (uint256 i = 0; i < _currentStrategies.length; i++) {\n IRedemptionStrategy _currentStrategy = IRedemptionStrategy(_currentStrategies[i]);\n string memory _name = _currentStrategy.name();\n redemptionStrategiesByName[_name] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(_currentStrategies[i]);\n }\n\n // write the new strategies and their tokens configs\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external onlyOwner {\n // check all the input/output tokens if they match the strategy to remove\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n IRedemptionStrategy _currentStrategy = redemptionStrategiesByTokens[_inputToken][_outputToken];\n\n // only nullify the input/output tokens config if the strategy matches\n if (_currentStrategy == strategyToRemove) {\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n if (defaultOutputToken[_inputToken] == _outputToken) {\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n }\n }\n if (inputTokensByOutputToken[_outputToken].length() == 0) {\n outputTokensSet.remove(address(_outputToken));\n }\n }\n\n redemptionStrategiesByName[strategyToRemove.name()] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(address(strategyToRemove));\n }\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool) {\n // find a match for each config fee\n for (uint256 i = 0; i < configFees.length; i++) {\n if (uniswapV3Fees[configInputTokens[i]][configOutputTokens[i]] != configFees[i]) return false;\n }\n\n return true;\n }\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool) {\n // find a match for each config router\n for (uint256 i = 0; i < configRouters.length; i++) {\n if (customUniV3Router[configInputTokens[i]][configOutputTokens[i]] != configRouters[i]) return false;\n }\n\n return true;\n }\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool) {\n (\n IRedemptionStrategy[] memory onChainStrategies,\n IERC20Upgradeable[] memory onChainInputTokens,\n IERC20Upgradeable[] memory onChainOutputTokens\n ) = getAllPairsStrategies();\n // find a match for each config strategy\n for (uint256 i = 0; i < configStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < onChainStrategies.length; j++) {\n if (\n onChainStrategies[j] == configStrategies[i] &&\n onChainInputTokens[j] == configInputTokens[i] &&\n onChainOutputTokens[j] == configOutputTokens[i]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n // find a match for each on-chain strategy\n for (uint256 i = 0; i < onChainStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < configStrategies.length; j++) {\n if (\n onChainStrategies[i] == configStrategies[j] &&\n onChainInputTokens[i] == configInputTokens[j] &&\n onChainOutputTokens[i] == configOutputTokens[j]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n return true;\n }\n\n function getAllPairsStrategies()\n public\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n )\n {\n address[] memory _outputTokens = outputTokensSet.values();\n uint256 pairsCounter = 0;\n\n {\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n pairsCounter += _inputTokens.length;\n }\n\n strategies = new IRedemptionStrategy[](pairsCounter);\n inputTokens = new IERC20Upgradeable[](pairsCounter);\n outputTokens = new IERC20Upgradeable[](pairsCounter);\n }\n\n pairsCounter = 0;\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n strategies[pairsCounter] = redemptionStrategiesByTokens[_inputToken][_outputToken];\n inputTokens[pairsCounter] = _inputToken;\n outputTokens[pairsCounter] = _outputToken;\n pairsCounter++;\n }\n }\n }\n\n function optimalSwapPath(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IERC20Upgradeable[] memory)\n {\n return _optimalSwapPath[inputToken][outputToken];\n }\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external onlyOwner {\n _optimalSwapPath[inputToken][outputToken] = optimalPath;\n }\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address) {\n return _wrappedToUnwrapped4626[wrapped];\n }\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24) {\n return _aeroCLTickSpacings[inputToken][outputToken];\n }\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool) {\n return _aeroV2IsStable[inputToken][outputToken];\n }\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external onlyOwner {\n _wrappedToUnwrapped4626[wrapped] = unwrapped;\n }\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external onlyOwner {\n _aeroCLTickSpacings[inputToken][outputToken] = tickSpacing;\n }\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external onlyOwner {\n _aeroV2IsStable[inputToken][outputToken] = isStable;\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../IRedemptionStrategy.sol\";\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\n AddressesProvider public ap;\n\n EnumerableSet.AddressSet internal redemptionStrategies;\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\n EnumerableSet.AddressSet internal outputTokensSet;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\n mapping(address => address) internal _wrappedToUnwrapped4626;\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\n}\n" + }, + "contracts/liquidators/SolidlyLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/solidly/IRouter.sol\";\nimport \"../external/solidly/IPair.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlyLpTokenLiquidator\n * @notice Exchanges seized Solidly LP token collateral for underlying tokens for use as a step in a liquidation.\n */\ncontract SolidlyLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) internal {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Uniswap pool\n IPair pair = IPair(address(inputToken));\n bool stable = pair.stable();\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n pair.transfer(address(pair), inputAmount);\n (uint256 amount0, uint256 amount1) = pair.burn(address(this));\n\n // Swap underlying tokens\n (IRouter solidlyRouter, address tokenTo) = abi.decode(strategyData, (IRouter, address));\n\n if (tokenTo != token0) {\n safeApprove(IERC20Upgradeable(token0), address(solidlyRouter), amount0);\n solidlyRouter.swapExactTokensForTokensSimple(amount0, 0, token0, tokenTo, stable, address(this), block.timestamp);\n } else {\n safeApprove(IERC20Upgradeable(token1), address(solidlyRouter), amount1);\n solidlyRouter.swapExactTokensForTokensSimple(amount1, 0, token1, tokenTo, stable, address(this), block.timestamp);\n }\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenLiquidator\";\n }\n}\n\ncontract SolidlyLpTokenWrapper is IRedemptionStrategy {\n struct WrapSolidlyLpTokenVars {\n uint256 amountToSwapOfToken0ForToken1;\n uint256 amountToSwapOfToken1ForToken0;\n IRouter solidlyRouter;\n IERC20Upgradeable token0;\n IERC20Upgradeable token1;\n bool stable;\n IPair pair;\n IRouter.Route[] swapPath0;\n IRouter.Route[] swapPath1;\n uint256 ratio;\n }\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n WrapSolidlyLpTokenVars memory vars;\n (vars.solidlyRouter, vars.pair, vars.swapPath0, vars.swapPath1) = abi.decode(\n strategyData,\n (IRouter, IPair, IRouter.Route[], IRouter.Route[])\n );\n vars.token0 = IERC20Upgradeable(vars.pair.token0());\n vars.token1 = IERC20Upgradeable(vars.pair.token1());\n vars.stable = vars.pair.stable();\n\n // calculate the amount for token0 or token1 that needs to be swapped for the other\n {\n vars.amountToSwapOfToken1ForToken0 = inputAmount / 2;\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n if (vars.token0 == inputToken) {\n uint256 out1 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken0ForToken1, vars.swapPath0)[\n vars.swapPath0.length\n ];\n // price1For0 is scaled to 18 + token1.decimals - token0.decimals\n uint256 price1For0 = (out1 * 1e18) / vars.amountToSwapOfToken0ForToken1;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n vars.amountToSwapOfToken1ForToken0,\n out1\n );\n\n vars.ratio = (amount1 * 1e36) / (amount0 * price1For0);\n }\n\n if (vars.token1 == inputToken) {\n uint256 out0 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken1ForToken0, vars.swapPath1)[\n vars.swapPath1.length\n ];\n // price0For1 is scaled to 18 + token0.decimals - token1.decimals\n uint256 price0For1 = (out0 * 1e18) / vars.amountToSwapOfToken1ForToken0;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n out0,\n vars.amountToSwapOfToken0ForToken1\n );\n\n vars.ratio = (amount1 * price0For1) / amount0;\n }\n\n // recalculate the amounts to swap based on the ratio of the value of the required input amounts\n vars.amountToSwapOfToken1ForToken0 = (inputAmount * 1e18) / (vars.ratio + 1e18);\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n }\n\n // swap a part of the input token amount for the other token\n if (vars.token0 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken0ForToken1);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken0ForToken1,\n 0,\n vars.swapPath0,\n address(this),\n block.timestamp\n );\n }\n if (vars.token1 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken1ForToken0);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken1ForToken0,\n 0,\n vars.swapPath1,\n address(this),\n block.timestamp\n );\n }\n\n // provide the liquidity\n uint256 token0Balance = vars.token0.balanceOf(address(this));\n uint256 token1Balance = vars.token1.balanceOf(address(this));\n\n vars.token0.approve(address(vars.solidlyRouter), token0Balance);\n vars.token1.approve(address(vars.solidlyRouter), token1Balance);\n vars.solidlyRouter.addLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n token0Balance,\n token1Balance,\n 1,\n 1,\n address(this),\n block.timestamp\n );\n\n outputToken = IERC20Upgradeable(address(vars.pair));\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/SolidlySwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { IRouter } from \"../external/solidly/IRouter.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlySwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Solidly router for use as a step in a liquidation.\n */\ncontract SolidlySwapLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Solidly router and path\n (IRouter solidlyRouter, address tokenTo, bool stable) = abi.decode(strategyData, (IRouter, address, bool));\n\n // Swap underlying tokens\n inputToken.approve(address(solidlyRouter), inputAmount);\n solidlyRouter.swapExactTokensForTokensSimple(\n inputAmount,\n 0,\n address(inputToken),\n tokenTo,\n stable,\n address(this),\n block.timestamp\n );\n\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlySwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\n/**\n * @title UniswapV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Uniswap V2 router for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"UniswapV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { UniswapV2Liquidator } from \"./UniswapV2Liquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\ncontract UniswapV2LiquidatorFunder is UniswapV2Liquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2, \"Invalid UniswapLiquidator swap path.\");\n\n uint256[] memory amounts = uniswapV2Router.getAmountsIn(outputAmount, swapPath);\n\n inputAmount = amounts[0];\n inputToken = IERC20Upgradeable(swapPath[0]);\n }\n\n function name() public pure override(UniswapV2Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV2LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { IV3SwapRouter } from \"../external/uniswap/IV3SwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract UniswapV3Liquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address _outputToken, uint24 fee, IV3SwapRouter swapRouter, ) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, address)\n );\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n IV3SwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n fee,\n address(this),\n inputAmount,\n 0,\n 0\n )\n );\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"UniswapV3Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport \"./UniswapV3Liquidator.sol\";\n\nimport { Quoter } from \"../external/uniswap/quoter/Quoter.sol\";\n\ncontract UniswapV3LiquidatorFunder is UniswapV3Liquidator, IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address _inputToken, address _outputToken, uint24 fee, , Quoter quoter) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, Quoter)\n );\n\n inputAmount = quoter.estimateMinSwapUniswapV3(_inputToken, _outputToken, outputAmount, fee);\n inputToken = IERC20Upgradeable(_inputToken);\n }\n\n function name() public pure override(UniswapV3Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV3LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/VelodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\n\n/**\n * @title VelodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Velodrome V2 router for use as a step in a liquidation.\n */\ncontract VelodromeV2Liquidator {\n function _swap(IRouter_Velodrome router, uint256 inputAmount, IRouter_Velodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"VelodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Velodrome router, IRouter_Velodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Velodrome, IRouter_Velodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid VelodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/oracles/1337/MockPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/chainlink/AggregatorV3Interface.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title MockPriceOracle\n * @notice Returns mocked prices from a Chainlink-like oracle. Used for local dev only\n * @dev Implements `PriceOracle`.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract MockPriceOracle is BasePriceOracle {\n /**\n * @notice The maximum number of seconds elapsed since the round was last updated before the price is considered stale. If set to 0, no limit is enforced.\n */\n uint256 public maxSecondsBeforePriceIsStale;\n\n /**\n * @dev Constructor to set `maxSecondsBeforePriceIsStale` as well as all Chainlink price feeds.\n */\n constructor(uint256 _maxSecondsBeforePriceIsStale) {\n // Set maxSecondsBeforePriceIsStale\n maxSecondsBeforePriceIsStale = _maxSecondsBeforePriceIsStale;\n }\n\n /**\n * @dev Returns a boolean indicating if a price feed exists for the underlying asset.\n */\n\n function hasPriceFeed(address underlying) external pure returns (bool) {\n return true;\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n */\n\n function random() private view returns (uint256) {\n uint256 r = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 99;\n r = r + 1;\n return r;\n }\n\n function _price(address underlying) internal view returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) return 1e18;\n\n int256 tokenEthPrice = 1;\n uint256 r = random();\n\n return ((uint256(tokenEthPrice) * 1e18) / r) / 1e18;\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n return 1e18;\n }\n}\n" + }, + "contracts/oracles/BasePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../compound/CTokenInterfaces.sol\";\n\n/**\n * @title BasePriceOracle\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\n * @dev Implements the `PriceOracle` interface.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface BasePriceOracle {\n /**\n * @notice Get the price of an underlying asset.\n * @param underlying The underlying asset to get the price of.\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function price(address underlying) external view returns (uint256);\n\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\n}\n" + }, + "contracts/oracles/default/CurveLpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/curve/ICurvePool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracleNoRegistry\n * @author David Lucid (https://github.com/davidlucid)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract CurveLpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Curve LP token addresses to underlying token addresses.\n */\n mapping(address => address[]) public underlyingTokens;\n\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n * @param _poolUnderlyings The underlying token addresses of a pool\n */\n function initialize(\n address[] memory _lpTokens,\n address[] memory _pools,\n address[][] memory _poolUnderlyings\n ) public initializer {\n require(\n _lpTokens.length == _pools.length && _lpTokens.length == _poolUnderlyings.length,\n \"No LP tokens supplied or array lengths not equal.\"\n );\n\n __SafeOwnable_init(msg.sender);\n for (uint256 i = 0; i < _lpTokens.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n underlyingTokens[_lpTokens[i]] = _poolUnderlyings[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), 0, 0);\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Curve, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/CurveOracle.sol\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(pool != address(0), \"LP token is not registered.\");\n address[] memory tokens = underlyingTokens[lpToken];\n uint256 minPx = type(uint256).max;\n uint256 n = tokens.length;\n\n for (uint256 i = 0; i < n; i++) {\n address ulToken = tokens[i];\n uint256 tokenPx = BasePriceOracle(msg.sender).price(ulToken);\n if (tokenPx < minPx) minPx = tokenPx;\n }\n\n require(minPx != type(uint256).max, \"No minimum underlying token price found.\");\n return (minPx * ICurvePool(pool).get_virtual_price()) / 1e18; // Use min underlying token prices\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n * @param _underlyings Underlying addresses.\n */\n function registerPool(\n address _lpToken,\n address _pool,\n address[] memory _underlyings\n ) external onlyOwner {\n poolOf[_lpToken] = _pool;\n underlyingTokens[_lpToken] = _underlyings;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n\n /**\n * @dev getter for the underlying tokens\n * @param lpToken the LP token address.\n * @return _underlyings Underlying addresses.\n */\n function getUnderlyingTokens(address lpToken) public view returns (address[] memory) {\n return underlyingTokens[lpToken];\n }\n}\n" + }, + "contracts/oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\nimport \"../../external/curve/ICurveV2Pool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve V2 LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract CurveV2LpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n address public usdToken;\n MasterPriceOracle public masterPriceOracle;\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n */\n function initialize(address[] memory _lpTokens, address[] memory _pools) public initializer {\n require(_lpTokens.length == _pools.length, \"No LP tokens supplied or array lengths not equal.\");\n __SafeOwnable_init(msg.sender);\n\n for (uint256 i = 0; i < _pools.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), int128(0), int128(0));\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token price from Curve, with 18 decimals of precision.\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(address(pool) != address(0), \"LP token is not registered.\");\n\n address baseToken = ICurvePool(pool).coins(0);\n uint256 lpPrice = ICurveV2Pool(pool).lp_price();\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n return (lpPrice * baseTokenPrice) / 10**18;\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n */\n function registerPool(address _lpToken, address _pool) external onlyOwner {\n address pool = poolOf[_lpToken];\n require(pool == address(0), \"This LP token is already registered.\");\n poolOf[_lpToken] = _pool;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracle is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWeETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWeETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A) {\n underlying = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWrsETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWrsETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd) {\n underlying = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/MasterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BasePriceOracle } from \"./BasePriceOracle.sol\";\n\n/**\n * @title MasterPriceOracle\n * @notice Use a combination of price oracles.\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public oracles;\n\n /**\n * @dev Default/fallback `PriceOracle`.\n */\n BasePriceOracle public defaultOracle;\n\n /**\n * @dev The administrator of this `MasterPriceOracle`.\n */\n address public admin;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool internal noAdminOverwrite;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public wtoken;\n\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public fallbackOracles;\n\n /**\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n function canAdminOverwrite() external view returns (bool) {\n return !noAdminOverwrite;\n }\n\n /**\n * @dev Event emitted when `admin` is changed.\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @dev Event emitted when the default oracle is changed.\n */\n event NewDefaultOracle(address oldOracle, address newOracle);\n\n /**\n * @dev Event emitted when an underlying token's oracle is changed.\n */\n event NewOracle(address underlying, address oldOracle, address newOracle);\n\n /**\n * @dev Initialize state variables.\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\n * @param _defaultOracle The default `PriceOracle` contract to use.\n * @param _admin The admin who can assign oracles to underlying tokens.\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n * @param _wtoken The Wrapped native asset address\n */\n function initialize(\n address[] memory underlyings,\n BasePriceOracle[] memory _oracles,\n BasePriceOracle _defaultOracle,\n address _admin,\n bool _canAdminOverwrite,\n address _wtoken\n ) external initializer {\n // Input validation\n require(underlyings.length == _oracles.length, \"Lengths of both arrays must be equal.\");\n\n // Initialize state variables\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, address(0), address(newOracle));\n }\n\n defaultOracle = _defaultOracle;\n admin = _admin;\n noAdminOverwrite = !_canAdminOverwrite;\n wtoken = _wtoken;\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(oracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(fallbackOracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n fallbackOracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Changes the default price oracle\n */\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\n BasePriceOracle oldOracle = defaultOracle;\n defaultOracle = newOracle;\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\n }\n\n /**\n * @dev Changes the admin and emits an event.\n */\n function changeAdmin(address newAdmin) external onlyAdmin {\n address oldAdmin = admin;\n admin = newAdmin;\n emit NewAdmin(oldAdmin, newAdmin);\n }\n\n /**\n * @dev Modifier that checks if `msg.sender == admin`.\n */\n modifier onlyAdmin() {\n require(msg.sender == admin, \"Sender is not the admin.\");\n _;\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = address(ICErc20(address(cToken)).underlying());\n\n if (underlying == wtoken) return 1e18;\n\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n\n /**\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) public view override returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == wtoken) return 1e18;\n\n // Get underlying price from assigned oracle\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n}\n" + }, + "contracts/PoolDirectory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./compound/Unitroller.sol\";\nimport \"./ionic/SafeOwnableUpgradeable.sol\";\nimport \"./ionic/DiamondExtension.sol\";\n\n/**\n * @title PoolDirectory\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\n */\ncontract PoolDirectory is SafeOwnableUpgradeable {\n /**\n * @dev Initializes a deployer whitelist if desired.\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\n */\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\n __SafeOwnable_init(msg.sender);\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\n }\n\n /**\n * @dev Struct for a Ionic interest rate pool.\n */\n struct Pool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n /**\n * @dev Array of Ionic interest rate pools.\n */\n Pool[] public pools;\n\n /**\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\n */\n mapping(address => uint256[]) private _poolsByAccount;\n\n /**\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\n */\n mapping(address => bool) public poolExists;\n\n /**\n * @dev Emitted when a new Ionic pool is added to the directory.\n */\n event PoolRegistered(uint256 index, Pool pool);\n\n /**\n * @dev Booleans indicating if the deployer whitelist is enforced.\n */\n bool public enforceDeployerWhitelist;\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\n */\n mapping(address => bool) public deployerWhitelist;\n\n /**\n * @dev Controls if the deployer whitelist is to be enforced.\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\n */\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\n enforceDeployerWhitelist = enforce;\n }\n\n /**\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\n * @param deployers Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\n require(deployers.length > 0, \"No deployers supplied.\");\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\n }\n\n /**\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\n * @param name The name of the pool.\n * @param comptroller The pool's Comptroller proxy contract address.\n * @return The index of the registered Ionic pool.\n */\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\n require(!poolExists[comptroller], \"Pool already exists in the directory.\");\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \"Sender is not on deployer whitelist.\");\n require(bytes(name).length <= 100, \"No pool name supplied.\");\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\n pools.push(pool);\n _poolsByAccount[msg.sender].push(pools.length - 1);\n poolExists[comptroller] = true;\n emit PoolRegistered(pools.length - 1, pool);\n return pools.length - 1;\n }\n\n function _deprecatePool(address comptroller) external onlyOwner {\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller == comptroller) {\n _deprecatePool(i);\n break;\n }\n }\n }\n\n function _deprecatePool(uint256 index) public onlyOwner {\n Pool storage ionicPool = pools[index];\n\n require(ionicPool.comptroller != address(0), \"pool already deprecated\");\n\n // swap with the last pool of the creator and delete\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\n for (uint256 i = 0; i < creatorPools.length; i++) {\n if (creatorPools[i] == index) {\n creatorPools[i] = creatorPools[creatorPools.length - 1];\n creatorPools.pop();\n break;\n }\n }\n\n // leave it to true to deny the re-registering of the same pool\n poolExists[ionicPool.comptroller] = true;\n\n // nullify the storage\n ionicPool.comptroller = address(0);\n ionicPool.creator = address(0);\n ionicPool.name = \"\";\n ionicPool.blockPosted = 0;\n ionicPool.timestampPosted = 0;\n }\n\n /**\n * @dev Deploys a new Ionic pool and adds to the directory.\n * @param name The name of the pool.\n * @param implementation The Comptroller implementation contract address.\n * @param constructorData Encoded construction data for `Unitroller constructor()`\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\n * @param closeFactor The pool's close factor (scaled by 1e18).\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\n * @param priceOracle The pool's PriceOracle contract address.\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\n */\n function deployPool(\n string memory name,\n address implementation,\n bytes calldata constructorData,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive,\n address priceOracle\n ) external returns (uint256, address) {\n // Input validation\n require(implementation != address(0), \"No Comptroller implementation contract address specified.\");\n require(priceOracle != address(0), \"No PriceOracle contract address specified.\");\n\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(\n 0,\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\n unitrollerCreationCode\n );\n\n // Setup the pool\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\n // Set up the extensions\n comptrollerProxy._upgrade();\n\n // Set pool parameters\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \"Failed to set pool close factor.\");\n require(\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\n \"Failed to set pool liquidation incentive.\"\n );\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \"Failed to set pool price oracle.\");\n\n // Whitelist\n if (enforceWhitelist)\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \"Failed to enforce supplier/borrower whitelist.\");\n\n // Make msg.sender the admin\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \"Failed to set pending admin on Unitroller.\");\n\n // Register the pool with this PoolDirectory\n return (_registerPool(name, proxy), proxy);\n }\n\n /**\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory activePools = new Pool[](count);\n uint256[] memory poolIds = new uint256[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n poolIds[index] = i;\n activePools[index] = pools[i];\n index++;\n }\n }\n\n return (poolIds, activePools);\n }\n\n /**\n * @notice Returns arrays of all Ionic pools' data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getAllPools() public view returns (Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory result = new Pool[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n result[index++] = pools[i];\n }\n }\n\n return result;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n indexes[index] = i;\n poolsOfUser[index] = activePools[i];\n index++;\n }\n\n return (indexes, poolsOfUser);\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\n */\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\n (, Pool[] memory activePools) = getActivePools();\n\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\n indexes[i] = _poolsByAccount[account][i];\n accountPools[i] = activePools[_poolsByAccount[account][i]];\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Modify existing Ionic pool name.\n */\n function setPoolName(uint256 index, string calldata name) external {\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\n require(\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\n \"!permission\"\n );\n pools[index].name = name;\n }\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\n */\n mapping(address => bool) public adminWhitelist;\n\n /**\n * @dev used as salt for the creation of new pools\n */\n uint256 public poolsCounter;\n\n /**\n * @dev Event emitted when the admin whitelist is updated.\n */\n event AdminWhitelistUpdated(address[] admins, bool status);\n\n /**\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\n * @param admins Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\n require(admins.length > 0, \"No admins supplied.\");\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\n emit AdminWhitelistUpdated(admins, status);\n }\n\n /**\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getVerifiedPoolsOfWhitelistedAccount(address account)\n external\n view\n returns (uint256[] memory, Pool[] memory)\n {\n uint256 arrayLength = 0;\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n indexes[index] = i;\n accountWhitelistedPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, accountWhitelistedPools);\n }\n}\n" + }, + "contracts/PoolLens.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"./oracles/MasterPriceOracle.sol\";\n\n/**\n * @title PoolLens\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLens is Initializable {\n error ComptrollerError(uint256 errCode);\n\n /**\n * @notice Initialize the `PoolDirectory` contract object.\n * @param _directory The PoolDirectory\n * @param _name Name for the nativeToken\n * @param _symbol Symbol for the nativeToken\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\n * @param _hardcodedNames Harcoded name for these tokens\n * @param _hardcodedSymbols Harcoded symbol for these tokens\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\n */\n function initialize(\n PoolDirectory _directory,\n string memory _name,\n string memory _symbol,\n address[] memory _hardcodedAddresses,\n string[] memory _hardcodedNames,\n string[] memory _hardcodedSymbols,\n string[] memory _uniswapLPTokenNames,\n string[] memory _uniswapLPTokenSymbols,\n string[] memory _uniswapLPTokenDisplayNames\n ) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n require(\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\n \"Hardcoded addresses lengths not equal.\"\n );\n require(\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\n \"Uniswap LP token names lengths not equal.\"\n );\n\n directory = _directory;\n name = _name;\n symbol = _symbol;\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\n }\n\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\n uniswapData.push(\n UniswapData({\n name: _uniswapLPTokenNames[i],\n symbol: _uniswapLPTokenSymbols[i],\n displayName: _uniswapLPTokenDisplayNames[i]\n })\n );\n }\n }\n\n string public name;\n string public symbol;\n\n struct TokenData {\n string name;\n string symbol;\n }\n mapping(address => TokenData) hardcoded;\n\n struct UniswapData {\n string name; // ie \"Uniswap V2\" or \"SushiSwap LP Token\"\n string symbol; // ie \"UNI-V2\" or \"SLP\"\n string displayName; // ie \"SushiSwap\" or \"Uniswap\"\n }\n UniswapData[] uniswapData;\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @dev Struct for Ionic pool summary data.\n */\n struct IonicPoolData {\n uint256 totalSupply;\n uint256 totalBorrow;\n address[] underlyingTokens;\n string[] underlyingSymbols;\n bool whitelistedAdmin;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsWithData()\n external\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\n {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsByVerificationWithData(\n bool whitelistedAdmin\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\n whitelistedAdmin\n );\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsOIonicrWithData(\n address user\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\n return (indexes, userPools, data, errored);\n }\n\n /**\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\n bool[] memory errored = new bool[](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\n uint256 _totalSupply,\n uint256 _totalBorrow,\n address[] memory _underlyingTokens,\n string[] memory _underlyingSymbols,\n bool _whitelistedAdmin\n ) {\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\n } catch {\n errored[i] = true;\n }\n }\n\n return (data, errored);\n }\n\n /**\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\n */\n function getPoolSummary(\n IonicComptroller comptroller\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\n uint256 totalBorrow = 0;\n uint256 totalSupply = 0;\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n address[] memory underlyingTokens = new address[](cTokens.length);\n string[] memory underlyingSymbols = new string[](cTokens.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n cToken.accrueInterest();\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\n uint256 assetTotalSupply = cToken.getCash() +\n assetTotalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\n\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\n }\n\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\n }\n\n /**\n * @dev Struct for a Ionic pool asset.\n */\n struct PoolAsset {\n address cToken;\n address underlyingToken;\n string underlyingName;\n string underlyingSymbol;\n uint256 underlyingDecimals;\n uint256 underlyingBalance;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 totalSupply;\n uint256 totalBorrow;\n uint256 supplyBalance;\n uint256 borrowBalance;\n uint256 liquidity;\n bool membership;\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\n address oracle;\n uint256 collateralFactor;\n uint256 reserveFactor;\n uint256 adminFee;\n uint256 ionicFee;\n bool borrowGuardianPaused;\n bool mintGuardianPaused;\n }\n\n /**\n * @notice Returns data on the specified assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\n * @param cTokens The cToken contract addresses of the assets to query.\n * @param user The user for which to get account data.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(\n IonicComptroller comptroller,\n ICErc20[] memory cTokens,\n address user\n ) internal returns (PoolAsset[] memory) {\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\n if (isListed) arrayLength++;\n }\n\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\n uint256 index = 0;\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n // Check if market is listed and get collateral factor\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\n if (!isListed) continue;\n\n // Start adding data to PoolAsset\n PoolAsset memory asset;\n ICErc20 cToken = cTokens[i];\n asset.cToken = address(cToken);\n\n cToken.accrueInterest();\n\n // Get underlying asset data\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\n asset.underlyingDecimals = underlying.decimals();\n asset.underlyingBalance = underlying.balanceOf(user);\n\n // Get cToken data\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\n asset.liquidity = cToken.getCash();\n asset.totalBorrow = cToken.totalBorrowsCurrent();\n asset.totalSupply =\n asset.liquidity +\n asset.totalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\n asset.membership = comptroller.checkMembership(user, cToken);\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\n\n // Get oracle for this cToken\n asset.oracle = address(oracle);\n\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\n asset.oracle = address(_oracle);\n } catch {}\n\n // More cToken data\n asset.collateralFactor = collateralFactorMantissa;\n asset.reserveFactor = cToken.reserveFactorMantissa();\n asset.adminFee = cToken.adminFeeMantissa();\n asset.ionicFee = cToken.ionicFeeMantissa();\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\n\n // Add to assets array and increment index\n detailedAssets[index] = asset;\n index++;\n }\n\n return (detailedAssets);\n }\n\n function getBorrowCapsPerCollateral(\n ICErc20 borrowedAsset,\n IonicComptroller comptroller\n )\n internal\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsAgainstCollateral,\n bool[] memory borrowingBlacklistedAgainstCollateral\n )\n {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n collateral = new address[](poolMarkets.length);\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\n\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n address collateralAddress = address(poolMarkets[i]);\n if (collateralAddress != address(borrowedAsset)) {\n collateral[i] = collateralAddress;\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\n address(borrowedAsset),\n collateralAddress\n );\n }\n }\n }\n\n /**\n * @notice Returns the `name` and `symbol` of `token`.\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\n * @param token An ERC20 token contract object.\n * @return The `name` and `symbol`.\n */\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\n // i.e. MKR is a DSToken and uses bytes32\n if (bytes(hardcoded[token].symbol).length != 0) {\n return (hardcoded[token].name, hardcoded[token].symbol);\n }\n\n // Get name and symbol from token contract\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\n string memory _name = tokenContract.name();\n string memory _symbol = tokenContract.symbol();\n\n return (_name, _symbol);\n }\n\n /**\n * @notice Returns the assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\n }\n\n /**\n * @dev Struct for a Ionic pool user.\n */\n struct IonicPoolUser {\n address account;\n uint256 totalBorrow;\n uint256 totalCollateral;\n uint256 health;\n }\n\n /**\n * @notice Returns arrays of PoolAsset for a specific user\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\n return assets;\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n }\n\n return (assets, supplyCapsPerAsset);\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsDataForPool(\n IonicComptroller comptroller\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\n }\n\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\n }\n\n /**\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n }\n\n /**\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsDataForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap,\n uint256 nonWhitelistedTotalBorrows\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n uint256 totalBorrows = asset.totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\n * Note that the whitelist does not have to be enforced.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getWhitelistedPoolsByAccount(\n address account\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) {\n indexes[index] = i;\n accountPools[index] = pools[i];\n index++;\n break;\n }\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getWhitelistedPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\n }\n\n function getHealthFactorHypothetical(\n IonicComptroller pool,\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\n account,\n cTokenModify,\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n\n if (err != 0) revert ComptrollerError(err);\n\n if (shortfall > 0) {\n // HF < 1.0\n return (collateralValue * 1e18) / (collateralValue + shortfall);\n } else {\n // HF >= 1.0\n if (collateralValue <= liquidity) return type(uint256).max;\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\n }\n }\n}\n" + }, + "contracts/PoolLensSecondary.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"./external/uniswap/IUniswapV2Pair.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\n\ninterface IRewardsDistributor_PLS {\n function rewardToken() external view returns (address);\n\n function compSupplySpeeds(address) external view returns (uint256);\n\n function compBorrowSpeeds(address) external view returns (uint256);\n\n function compAccrued(address) external view returns (uint256);\n\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n}\n\n/**\n * @title PoolLensSecondary\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLensSecondary is Initializable {\n /**\n * @notice Constructor to set the `PoolDirectory` contract object.\n */\n function initialize(PoolDirectory _directory) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n directory = _directory;\n }\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @notice Struct for ownership over a CToken.\n */\n struct CTokenOwnership {\n address cToken;\n address admin;\n bool adminHasRights;\n bool ionicAdminHasRights;\n }\n\n /**\n * @notice Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolOwnership(IonicComptroller comptroller)\n external\n view\n returns (\n address,\n bool,\n bool,\n CTokenOwnership[] memory\n )\n {\n // Get pool ownership\n address comptrollerAdmin = comptroller.admin();\n bool comptrollerAdminHasRights = comptroller.adminHasRights();\n bool comptrollerIonicAdminHasRights = comptroller.ionicAdminHasRights();\n\n // Get cToken ownership\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) arrayLength++;\n }\n\n CTokenOwnership[] memory outliers = new CTokenOwnership[](arrayLength);\n uint256 arrayIndex = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array and increment array index\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) {\n outliers[arrayIndex] = CTokenOwnership(\n address(cToken),\n cTokenAdmin,\n cTokenAdminHasRights,\n cTokenIonicAdminHasRights\n );\n arrayIndex++;\n }\n }\n\n return (comptrollerAdmin, comptrollerAdminHasRights, comptrollerIonicAdminHasRights, outliers);\n }\n\n /**\n * @notice Determine the maximum redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum redeem amount.\n */\n function getMaxRedeem(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, false);\n }\n\n /**\n * @notice Determine the maximum borrow amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow amount.\n */\n function getMaxBorrow(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, true);\n }\n\n /**\n * @dev Internal function to determine the maximum borrow/redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow/redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow/redeem amount.\n */\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal returns (uint256) {\n IonicComptroller comptroller = IonicComptroller(cTokenModify.comptroller());\n return comptroller.getMaxRedeemOrBorrow(account, cTokenModify, isBorrow);\n }\n\n /**\n * @notice Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptroller The Ionic pool Comptroller to check.\n */\n function getRewardSpeedsByPool(IonicComptroller comptroller)\n public\n view\n returns (\n ICErc20[] memory,\n address[] memory,\n address[] memory,\n uint256[][] memory,\n uint256[][] memory\n )\n {\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n address[] memory distributors;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors = _distributors;\n } catch {\n distributors = new address[](0);\n }\n\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[][] memory supplySpeeds = new uint256[][](allMarkets.length);\n uint256[][] memory borrowSpeeds = new uint256[][](allMarkets.length);\n\n // Get reward tokens for each distributor\n for (uint256 i = 0; i < distributors.length; i++) {\n rewardTokens[i] = IRewardsDistributor_PLS(distributors[i]).rewardToken();\n }\n\n // Get reward speeds for each market for each distributor\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address cToken = address(allMarkets[i]);\n supplySpeeds[i] = new uint256[](distributors.length);\n borrowSpeeds[i] = new uint256[](distributors.length);\n\n for (uint256 j = 0; j < distributors.length; j++) {\n IRewardsDistributor_PLS distributor = IRewardsDistributor_PLS(distributors[j]);\n supplySpeeds[i][j] = distributor.compSupplySpeeds(cToken);\n borrowSpeeds[i][j] = distributor.compBorrowSpeeds(cToken);\n }\n }\n\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptrollers The Ionic pool Comptrollers to check.\n */\n function getRewardSpeedsByPools(IonicComptroller[] memory comptrollers)\n external\n view\n returns (\n ICErc20[][] memory,\n address[][] memory,\n address[][] memory,\n uint256[][][] memory,\n uint256[][][] memory\n )\n {\n ICErc20[][] memory allMarkets = new ICErc20[][](comptrollers.length);\n address[][] memory distributors = new address[][](comptrollers.length);\n address[][] memory rewardTokens = new address[][](comptrollers.length);\n uint256[][][] memory supplySpeeds = new uint256[][][](comptrollers.length);\n uint256[][][] memory borrowSpeeds = new uint256[][][](comptrollers.length);\n for (uint256 i = 0; i < comptrollers.length; i++)\n (allMarkets[i], distributors[i], rewardTokens[i], supplySpeeds[i], borrowSpeeds[i]) = getRewardSpeedsByPool(\n comptrollers[i]\n );\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice Returns unaccrued rewards by `holder` from `cToken` on `distributor`.\n * @param holder The address to check.\n * @param distributor The RewardsDistributor to check.\n * @param cToken The CToken to check.\n * @return Unaccrued (unclaimed) supply-side rewards and unaccrued (unclaimed) borrow-side rewards.\n */\n function getUnaccruedRewards(\n address holder,\n IRewardsDistributor_PLS distributor,\n ICErc20 cToken\n ) internal returns (uint256, uint256) {\n // Get unaccrued supply rewards\n uint256 compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreSupplierAction(address(cToken), holder);\n uint256 supplyRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Get unaccrued borrow rewards\n compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreBorrowerAction(address(cToken), holder);\n uint256 borrowRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Return both\n return (supplyRewardsUnaccrued, borrowRewardsUnaccrued);\n }\n\n /**\n * @notice Returns all unclaimed rewards accrued by the `holder` on `distributors`.\n * @param holder The address to check.\n * @param distributors The `RewardsDistributor` contracts to check.\n * @return For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\n */\n function getUnclaimedRewardsByDistributors(address holder, IRewardsDistributor_PLS[] memory distributors)\n external\n returns (\n address[] memory,\n uint256[] memory,\n ICErc20[][] memory,\n uint256[2][][] memory,\n uint256[] memory\n )\n {\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[] memory compUnclaimedTotal = new uint256[](distributors.length);\n ICErc20[][] memory allMarkets = new ICErc20[][](distributors.length);\n uint256[2][][] memory rewardsUnaccrued = new uint256[2][][](distributors.length);\n uint256[] memory distributorFunds = new uint256[](distributors.length);\n\n for (uint256 i = 0; i < distributors.length; i++) {\n IRewardsDistributor_PLS distributor = distributors[i];\n rewardTokens[i] = distributor.rewardToken();\n allMarkets[i] = distributor.getAllMarkets();\n rewardsUnaccrued[i] = new uint256[2][](allMarkets[i].length);\n for (uint256 j = 0; j < allMarkets[i].length; j++)\n (rewardsUnaccrued[i][j][0], rewardsUnaccrued[i][j][1]) = getUnaccruedRewards(\n holder,\n distributor,\n allMarkets[i][j]\n );\n compUnclaimedTotal[i] = distributor.compAccrued(holder);\n distributorFunds[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(distributor));\n }\n\n return (rewardTokens, compUnclaimedTotal, allMarkets, rewardsUnaccrued, distributorFunds);\n }\n\n /**\n * @notice Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getRewardsDistributorsBySupplier(address supplier)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n // Get array length\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n try IonicComptroller(pools[i].comptroller).suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) arrayLength++;\n } catch {}\n }\n\n // Build array\n uint256[] memory indexes = new uint256[](arrayLength);\n IonicComptroller[] memory comptrollers = new IonicComptroller[](arrayLength);\n address[][] memory distributors = new address[][](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n try comptroller.suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) {\n indexes[index] = i;\n comptrollers[index] = comptroller;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors[index] = _distributors;\n } catch {}\n\n index++;\n }\n } catch {}\n }\n\n // Return distributors\n return (indexes, comptrollers, distributors);\n }\n\n /**\n * @notice The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getFlywheelsToClaim(address user)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n\n IonicComptroller[] memory comptrollers = new IonicComptroller[](pools.length);\n address[][] memory distributors = new address[][](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n comptrollers[i] = comptroller;\n distributors[i] = flywheelsWithRewardsForPoolUser(user, _distributors);\n } catch {}\n }\n\n return (poolIds, comptrollers, distributors);\n }\n\n function flywheelsWithRewardsForPoolUser(address user, address[] memory _distributors)\n internal\n view\n returns (address[] memory)\n {\n address[] memory distributors = new address[](_distributors.length);\n for (uint256 j = 0; j < _distributors.length; j++) {\n if (IRewardsDistributor_PLS(_distributors[j]).compAccrued(user) > 0) {\n distributors[j] = _distributors[j];\n }\n }\n\n return distributors;\n }\n}\n" + }, + "contracts/test/abstracts/AbstractAssetTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { AbstractERC4626Test } from \"./AbstractERC4626Test.sol\";\nimport { ITestConfigStorage } from \"./ITestConfigStorage.sol\";\n\ncontract AbstractAssetTest is BaseTest {\n AbstractERC4626Test public test;\n ITestConfigStorage public testConfigStorage;\n\n function setUpTestContract(bytes calldata testConfig) public virtual {\n // test._setUp(MockERC20(address(IBeefyVault(testConfig.beefyVault).want())).symbol(), testConfig);\n }\n\n function runTest(function() external testFn) public {\n if (shouldRunForChain(block.chainid)) {\n for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n this.setUpTestContract(testConfigStorage.getTestConfig(i));\n testFn();\n }\n }\n }\n\n function testInitializedValues() public virtual {\n // for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n // this.setUpTestContract(testConfigs[i]);\n // test.testInitializedValues(asset.name(), asset.symbol());\n // }\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n this.runTest(test.testPreviewDepositAndMintReturnTheSameValue);\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n this.runTest(test.testPreviewWithdrawAndRedeemReturnTheSameValue);\n }\n\n function testDeposit() public {\n this.runTest(test.testDeposit);\n }\n\n function testDepositWithIncreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithIncreasedVaultValue);\n }\n\n function testDepositWithDecreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithDecreasedVaultValue);\n }\n\n function testMultipleDeposit() public {\n this.runTest(test.testMultipleDeposit);\n }\n\n function testMint() public {\n this.runTest(test.testMint);\n }\n\n function testMultipleMint() public {\n this.runTest(test.testMultipleMint);\n }\n\n function testWithdraw() public {\n this.runTest(test.testWithdraw);\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithIncreasedVaultValue);\n }\n\n function testWithdrawWithDecreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithDecreasedVaultValue);\n }\n\n function testMultipleWithdraw() public {\n this.runTest(test.testMultipleWithdraw);\n }\n\n function testRedeem() public {\n this.runTest(test.testRedeem);\n }\n\n function testMultipleRedeem() public {\n this.runTest(test.testMultipleRedeem);\n }\n\n function testPauseContract() public {\n this.runTest(test.testPauseContract);\n }\n\n function testEmergencyWithdrawAndPause() public {\n this.runTest(test.testEmergencyWithdrawAndPause);\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n this.runTest(test.testEmergencyWithdrawAndRedeem);\n }\n}\n" + }, + "contracts/test/abstracts/AbstractERC4626Test.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../helpers/WithPool.sol\";\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { IonicERC4626 } from \"../../ionic/strategies/IonicERC4626.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Authority } from \"solmate/auth/Auth.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nabstract contract AbstractERC4626Test is WithPool {\n using FixedPointMathLib for uint256;\n\n IonicERC4626 plugin;\n\n string testPreFix;\n\n uint256 public depositAmount = 100e18;\n uint256 BPS_DENOMINATOR = 10_000;\n\n uint256 initialStrategyBalance;\n uint256 initialStrategySupply;\n\n constructor() {\n _forkAtBlock(uint128(block.chainid), block.number);\n }\n\n function _setUp(string memory _testPreFix, bytes calldata data) public virtual;\n\n function deposit(address _owner, uint256 amount) public {\n vm.startPrank(_owner);\n underlyingToken.approve(address(plugin), amount);\n plugin.deposit(amount, _owner);\n vm.stopPrank();\n }\n\n function sendUnderlyingToken(uint256 amount, address recipient) public {\n deal(address(underlyingToken), recipient, amount);\n }\n\n function increaseAssetsInVault() public virtual {}\n\n function decreaseAssetsInVault() public virtual {}\n\n function getDepositShares() public view virtual returns (uint256);\n\n function getStrategyBalance() public view virtual returns (uint256);\n\n function getExpectedDepositShares() public view virtual returns (uint256);\n\n function testInitializedValues(string memory assetName, string memory assetSymbol) public virtual {\n assertEq(\n plugin.name(),\n string(abi.encodePacked(\"Midas \", assetName, \" Vault\")),\n string(abi.encodePacked(\"!name \", testPreFix))\n );\n assertEq(\n plugin.symbol(),\n string(abi.encodePacked(\"mv\", assetSymbol)),\n string(abi.encodePacked(\"!symbol \", testPreFix))\n );\n assertEq(address(plugin.asset()), address(underlyingToken), string(abi.encodePacked(\"!asset \", testPreFix)));\n // assertEq(\n // address(BeefyERC4626(address(plugin)).beefyVault()),\n // address(beefyVault),\n // string(abi.encodePacked(\"!beefyVault \", testPreFix))\n // );\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n uint256 returnedShares = plugin.previewDeposit(depositAmount);\n assertApproxEqAbs(\n plugin.previewMint(returnedShares),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewMint \", testPreFix))\n );\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 reqShares = plugin.previewWithdraw(withdrawalAmount);\n assertApproxEqAbs(\n plugin.previewRedeem(reqShares),\n withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewRedeem \", testPreFix))\n );\n }\n\n function testDeposit() public virtual {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShares \", testPreFix))\n );\n }\n\n function testDepositWithIncreasedVaultValue() public {\n // lpDepositor just mints the exact amount of depositShares as the user deposits in assets\n uint256 oldExpectedDepositShare = this.getExpectedDepositShares();\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n oldExpected4626Shares + previewErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == oldExpectedShares \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n previewErc4626Shares,\n oldExpected4626Shares,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n assertApproxEqAbs(\n previewErc4626Shares,\n expected4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == expectedShares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n oldExpectedDepositShare + expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n }\n\n function testDepositWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n uint256 oldExpecteDepositShares = depositAmount;\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n deposit(address(this), depositAmount);\n // Decrease the share price\n decreaseAssetsInVault();\n uint256 expectedDepositShare = depositAmount;\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n // Test that we minted the correct amount of token\n assertApproxEqAbs(plugin.balanceOf(address(this)), oldExpected4626Shares + previewErc4626Shares);\n // Test that we got less shares on the second mint after assets in the vault increased\n assertGt(previewErc4626Shares, oldExpected4626Shares, \"!new shares > old Shares\");\n assertApproxEqAbs(previewErc4626Shares, expected4626Shares, \"!previewShares == expectedShares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(this.getDepositShares(), oldExpecteDepositShares + expectedDepositShare);\n */\n }\n\n function testMultipleDeposit() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount * 2,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount * 2,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"Total Assets should be same as sum of deposited amounts \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(this) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(1) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares * 2,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n // DotDot ERC4626 should not have underlyingToken after deposit\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testMultipleMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n vm.startPrank(address(1));\n underlyingToken.approve(address(plugin), depositAmount);\n sendUnderlyingToken(depositAmount, address(1));\n plugin.mint(mintAmount, address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount + depositAmount,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"!2.totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"!2.balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount + mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!2.depositShare \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n uint256(2),\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n vm.stopPrank();\n }\n\n function testWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n assertTrue(underlyingToken.balanceOf(address(plugin)) <= 1, string(abi.encodePacked(\"!0 \", testPreFix)));\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n uint256 depositShareBal = this.getExpectedDepositShares();\n\n deposit(address(this), depositAmount);\n\n uint256 withdrawalAmount = 10e18;\n\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n expectedErc4626SharesNeeded,\n oldExpectedErc4626SharesNeeded,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + ExpectedDepositSharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testWithdrawWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n sendUnderlyingToken(depositAmount, address(this));\n uint256 depositShares = this.getExpectedDepositShares();\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Increase the share price\n decreaseAssetsInVault();\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded)\n );\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(expectedErc4626SharesNeeded, oldExpectedErc4626SharesNeeded, \"!new shares < old Shares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + expectedDepositSharesNeeded)\n );\n */\n }\n\n function testMultipleWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal\", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n depositAmount * 2 - expectedErc4626SharesNeeded,\n plugin.totalSupply(),\n 10,\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 1,\n 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - expectedErc4626SharesNeeded;\n depositShares = depositShares - ExpectedDepositSharesNeeded;\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testMultipleRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount * 2 - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - redeemAmount;\n depositShares -= ExpectedDepositSharesNeeded;\n redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testPauseContract() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n underlyingToken.approve(address(plugin), depositAmount);\n vm.expectRevert(\"Pausable: paused\");\n plugin.deposit(depositAmount, address(this));\n\n vm.expectRevert(\"Pausable: paused\");\n plugin.mint(depositAmount, address(this));\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndPause() public virtual {\n deposit(address(this), depositAmount);\n\n uint256 expectedBal = plugin.previewRedeem(depositAmount);\n assertEq(underlyingToken.balanceOf(address(plugin)), 0, string(abi.encodePacked(\"!init 0 \", testPreFix)));\n\n plugin.emergencyWithdrawAndPause();\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!withdraws underlying \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalAssets(),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets == expectedBal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n}\n" + }, + "contracts/test/abstracts/ITestConfigStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface ITestConfigStorage {\n function getTestConfig(uint256 i) external view returns (bytes memory);\n\n function getTestConfigLength() external view returns (uint256);\n}\n" + }, + "contracts/test/AccountLiquidityTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract AccountLiquidityTest is UpgradesBaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n } else {\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testUserMaxWithdraw() public debuggingOnly forkAtBlock(MODE_MAINNET, 5890823) {\n address user = 0xBf891E7eFCC98A8239385D3172bA10AD593c7886;\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n _upgradePoolWithExtension(asUnitroller);\n\n {\n _testAccountLiquidity(user);\n\n uint256 maxRedeem = lens2.getMaxRedeem(user, wethMarket);\n emit log_named_uint(\"maxRedeem\", maxRedeem);\n\n bool isMember = pool.checkMembership(user, wethMarket);\n emit log(isMember ? \"is member\" : \"NOT A MEMBER\");\n }\n //vm.rollFork(5891795);\n // redeemed before liquidation at 5890822\n\n // before withdraw call at block 5890821\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 156238264982770748812\n // liquidity: 16428491404549045373\n // maxRedeem: 23469273435070064818\n // is member\n\n // user calls withdraw with max(uint256) at block 5890822\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 139809773853485792955\n // SHORTFALL: 257892668904\n // maxRedeem: 0\n // is member\n\n // liquidated at 5890902\n // https://explorer.mode.network/tx/0x424fd0504e7afb00382c6dcd25a2efdefd96c005c2333112be450fc7bd98cc88\n }\n}\n" + }, + "contracts/test/AccrueInterestTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\n\nstruct AccrualDiff {\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n}\n\ncontract AccrueInterestTest is UpgradesBaseTest {\n // fork before the accrue interest refactoring\n function testAccrueInterest() public debuggingOnly forkAtBlock(BSC_MAINNET, 26032460) {\n address busdMarketAddress = 0xa7213deB44f570646Ea955771Cc7f39B58841363;\n address wbnbMarketAddress = 0x57a64a77f8E4cFbFDcd22D5551F52D675cc5A956;\n\n _testAccrueInterest(wbnbMarketAddress);\n }\n\n function _testAccrueInterest(address marketAddress) internal {\n //CErc20Delegate market = CErc20Delegate(marketAddress);\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(marketAddress);\n ICErc20 market = ICErc20(marketAddress);\n\n uint256 adminFeeMantissa = market.adminFeeMantissa();\n uint256 ionicFeeMantissa = market.ionicFeeMantissa();\n uint256 reserveFactorMantissa = market.reserveFactorMantissa();\n\n // test with the logic before the refactoring\n\n AccrualDiff memory diffBefore;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index old impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows old impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves old impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees old impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees old impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply old impl\");\n\n diffBefore.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffBefore.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffBefore.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffBefore.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffBefore.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n // test with the logic after the refactoring\n vm.rollFork(26032460);\n afterForkSetUp();\n _upgradeMarketWithExtension(market);\n\n AccrualDiff memory diffAfter;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index new impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows new impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves new impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees new impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees new impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply new impl\");\n\n diffAfter.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffAfter.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffAfter.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffAfter.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffAfter.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n assertEq(diffBefore.borrowIndex, diffAfter.borrowIndex, \"!borrowIndexDiff\");\n assertEq(diffBefore.totalBorrows, diffAfter.totalBorrows, \"!totalBorrowsDiff\");\n assertEq(diffBefore.totalReserves, diffAfter.totalReserves, \"!totalReservesDiff\");\n assertEq(diffBefore.totalIonicFees, diffAfter.totalIonicFees, \"!totalIonicFeesDiff\");\n assertEq(diffBefore.totalAdminFees, diffAfter.totalAdminFees, \"!totalAdminFeesDiff\");\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testMintGated() public fork(POLYGON_MAINNET) {\n address newMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address assetWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n // approve spending\n vm.startPrank(assetWhale);\n IERC20Upgradeable(CErc20Delegate(newMarket).underlying()).approve(newMarket, 1e6);\n require(CErc20Delegate(newMarket).mint(1e6) == 0, \"!mint failed\");\n vm.stopPrank();\n }\n\n function testDeployCToken() public debuggingOnly fork(POLYGON_MAINNET) {\n CErc20Delegate cErc20Delegate = new CErc20Delegate();\n IonicComptroller pool = IonicComptroller(0x69617fE545804BcDfE853626B4C8EF23475Ac54B);\n emit log_named_address(\"admin\", pool.admin());\n pool.adminHasRights();\n vm.startPrank(0x9308dddeC9B5cCd8a2685A46E913C892FE31C826);\n pool._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(0xb5DFABd7fF7F83BAB83995E72A52B97ABb7bcf63),\n 0x69617fE545804BcDfE853626B4C8EF23475Ac54B,\n payable(address(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c)),\n InterestRateModel(address(0xA433B7d3a8A87D8fd40dA68A424007Dd8a21Ce41)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(0),\n uint256(0)\n ),\n \"\",\n 0.72e18\n );\n vm.stopPrank();\n // _functionCall(0xC40119C7269A5FA813d878BF83d14E3462fC8Fde, hex\"8f93bfba\", \"raw liquidation failed\");\n }\n\n function testDeployNeonPool() public debuggingOnly fork(NEON_MAINNET) {\n PoolDirectory poolDirectory = PoolDirectory(0x297a15F615aCdf87580af1Fc497EE57424975Dae);\n FeeDistributor ionicAdmin = FeeDistributor(payable(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c));\n Comptroller tempComptroller = new Comptroller();\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n vm.prank(ionicAdmin.owner());\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))), // FD\n false,\n 0.1e18,\n 1.1e18,\n 0xBAAb9986A7002ad67cb5a9C1761210C2Cdd98BFa // MPO\n );\n }\n}\n" + }, + "contracts/test/AuthoritiesRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport \"../ionic/AuthoritiesRegistry.sol\";\nimport \"./helpers/WithPool.sol\";\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\ncontract AuthoritiesRegistryTest is WithPool {\n AuthoritiesRegistry registry;\n\n function afterForkSetUp() internal override {\n registry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n if (address(registry) == address(0)) {\n address proxyAdmin = address(999);\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), proxyAdmin, \"\");\n registry = AuthoritiesRegistry(address(proxy));\n registry.initialize(address(1023));\n }\n\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n setUpPool(\"auth-reg-test\", false, 0.1e18, 1.1e18);\n }\n\n function testRegistry() public fork(POLYGON_MAINNET) {\n PoolRolesAuthority auth;\n\n vm.prank(address(555));\n vm.expectRevert(\"Ownable: caller is not the owner\");\n auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n auth = registry.createPoolAuthority(address(comptroller));\n\n assertEq(auth.owner(), registry.owner(), \"!same owner\");\n }\n\n function testAuthReconfigurePermissions() public fork(POLYGON_MAINNET) {\n vm.prank(registry.owner());\n PoolRolesAuthority auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(address(8283));\n vm.expectRevert(\"not owner or pool\");\n registry.reconfigureAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n registry.reconfigureAuthority(address(comptroller));\n }\n\n function upgradeRegistry() internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(registry)));\n AuthoritiesRegistry newImpl = new AuthoritiesRegistry();\n vm.startPrank(dpa.owner());\n dpa.upgradeAndCall(\n proxy,\n address(newImpl),\n abi.encodeWithSelector(AuthoritiesRegistry.reinitialize.selector, registry.leveredPositionsFactory())\n );\n vm.stopPrank();\n }\n\n function upgradeAuth(PoolRolesAuthority auth) internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n PoolRolesAuthority newImpl = new PoolRolesAuthority();\n vm.prank(dpa.owner());\n dpa.upgrade(proxy, address(newImpl));\n }\n\n function testAuthPermissions() public debuggingOnly fork(BSC_CHAPEL) {\n address pool = 0xa4bc2fCF2F9d87EB349f74f8729024F92A030330;\n registry = AuthoritiesRegistry(0xa5E190Fa38F325617381e835da8b2DB2D12cE5eb);\n //upgradeRegistry();\n\n PoolRolesAuthority auth = PoolRolesAuthority(0xFe5AfFFC8b55A2d139cb2ef76699C8B58c1EA299);\n //upgradeAuth(auth);\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n\n vm.prank(address(dpa));\n emit log_named_address(\"proxy.implementation\", proxy.implementation());\n\n emit log_named_address(\"registry.poolAuthLogic\", address(registry.poolAuthLogic()));\n //vm.prank(registry.owner());\n //registry.reconfigureAuthority(pool);\n\n bool isReg = auth.doesUserHaveRole(address(registry), auth.REGISTRY_ROLE());\n assertEq(isReg, true, \"!not registry role\");\n\n bool canCall = auth.canCall(address(registry), address(auth), RolesAuthority.setUserRole.selector);\n assertEq(canCall, true, \"!cannot call setUserRol\");\n }\n}\n" + }, + "contracts/test/caps/AdrastiaPrudentiaCapsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { ComptrollerPrudentiaCapsExt, DiamondExtension } from \"../../compound/ComptrollerPrudentiaCapsExt.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { ComptrollerV4Storage } from \"../../compound/ComptrollerStorage.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\nimport { PrudentiaLib } from \"../../adrastia/PrudentiaLib.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MockPriceOracle } from \"../../oracles/1337/MockPriceOracle.sol\";\n\nimport \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\nabstract contract HistoricalRates is IHistoricalRates {\n struct BufferMetadata {\n uint8 start;\n uint8 end;\n uint8 size;\n uint8 maxSize;\n bool pauseUpdates; // Note: this is left for extentions, but is not used in this contract.\n }\n\n /// @notice Event emitted when a rate buffer's capacity is increased past the initial capacity.\n /// @dev Buffer initialization does not emit an event.\n /// @param token The token for which the rate buffer's capacity was increased.\n /// @param oldCapacity The previous capacity of the rate buffer.\n /// @param newCapacity The new capacity of the rate buffer.\n event RatesCapacityIncreased(address indexed token, uint256 oldCapacity, uint256 newCapacity);\n\n /// @notice Event emitted when a rate buffer's capacity is initialized.\n /// @param token The token for which the rate buffer's capacity was initialized.\n /// @param capacity The capacity of the rate buffer.\n event RatesCapacityInitialized(address indexed token, uint256 capacity);\n\n /// @notice Event emitted when a new rate is pushed to the rate buffer.\n /// @param token The token for which the rate was pushed.\n /// @param target The target rate.\n /// @param current The current rate, which may be different from the target rate if the rate change is capped.\n /// @param timestamp The timestamp at which the rate was pushed.\n event RateUpdated(address indexed token, uint256 target, uint256 current, uint256 timestamp);\n\n /// @notice An error that is thrown if we try to initialize a rate buffer that has already been initialized.\n /// @param token The token for which we tried to initialize the rate buffer.\n error BufferAlreadyInitialized(address token);\n\n /// @notice An error that is thrown if we try to retrieve a rate at an invalid index.\n /// @param token The token for which we tried to retrieve the rate.\n /// @param index The index of the rate that we tried to retrieve.\n /// @param size The size of the rate buffer.\n error InvalidIndex(address token, uint256 index, uint256 size);\n\n /// @notice An error that is thrown if we try to decrease the capacity of a rate buffer.\n /// @param token The token for which we tried to decrease the capacity of the rate buffer.\n /// @param amount The capacity that we tried to decrease the rate buffer to.\n /// @param currentCapacity The current capacity of the rate buffer.\n error CapacityCannotBeDecreased(address token, uint256 amount, uint256 currentCapacity);\n\n /// @notice An error that is thrown if we try to increase the capacity of a rate buffer past the maximum capacity.\n /// @param token The token for which we tried to increase the capacity of the rate buffer.\n /// @param amount The capacity that we tried to increase the rate buffer to.\n /// @param maxCapacity The maximum capacity of the rate buffer.\n error CapacityTooLarge(address token, uint256 amount, uint256 maxCapacity);\n\n /// @notice An error that is thrown if we try to retrieve more rates than are available in the rate buffer.\n /// @param token The token for which we tried to retrieve the rates.\n /// @param size The size of the rate buffer.\n /// @param minSizeRequired The minimum size of the rate buffer that we require.\n error InsufficientData(address token, uint256 size, uint256 minSizeRequired);\n\n /// @notice The initial capacity of the rate buffer.\n uint8 internal immutable initialBufferCardinality;\n\n /// @notice Maps a token to its metadata.\n mapping(address => BufferMetadata) internal rateBufferMetadata;\n\n /// @notice Maps a token to a buffer of rates.\n mapping(address => RateLibrary.Rate[]) internal rateBuffers;\n\n /**\n * @notice Constructs the HistoricalRates contract with a specified initial buffer capacity.\n * @param initialBufferCardinality_ The initial capacity of the rate buffer.\n */\n constructor(uint8 initialBufferCardinality_) {\n initialBufferCardinality = initialBufferCardinality_;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRateAt(address token, uint256 index) external view virtual override returns (RateLibrary.Rate memory) {\n BufferMetadata memory meta = rateBufferMetadata[token];\n\n if (index >= meta.size) {\n revert InvalidIndex(token, index, meta.size);\n }\n\n uint256 bufferIndex = meta.end < index ? meta.end + meta.size - index : meta.end - index;\n\n return rateBuffers[token][bufferIndex];\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(address token, uint256 amount) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, 0, 1);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, offset, increment);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCount(address token) external view override returns (uint256) {\n return rateBufferMetadata[token].size;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCapacity(address token) external view virtual override returns (uint256) {\n uint256 maxSize = rateBufferMetadata[token].maxSize;\n if (maxSize == 0) return initialBufferCardinality;\n\n return maxSize;\n }\n\n /// @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n /// less than 256.\n /// @inheritdoc IHistoricalRates\n function setRatesCapacity(address token, uint256 amount) external virtual {\n _setRatesCapacity(token, amount);\n }\n\n /**\n * @dev Internal function to set the capacity of the rate buffer for a token.\n * @param token The token for which to set the new capacity.\n * @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n * less than 256.\n */\n function _setRatesCapacity(address token, uint256 amount) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (amount < meta.maxSize) revert CapacityCannotBeDecreased(token, amount, meta.maxSize);\n if (amount > type(uint8).max) revert CapacityTooLarge(token, amount, type(uint8).max);\n\n RateLibrary.Rate[] storage rateBuffer = rateBuffers[token];\n\n // Add new slots to the buffer\n uint256 capacityToAdd = amount - meta.maxSize;\n for (uint256 i = 0; i < capacityToAdd; ++i) {\n // Push a dummy rate with non-zero values to put most of the gas cost on the caller\n rateBuffer.push(RateLibrary.Rate({ target: 1, current: 1, timestamp: 1 }));\n }\n\n if (meta.maxSize != amount) {\n emit RatesCapacityIncreased(token, meta.maxSize, amount);\n\n // Update the metadata\n meta.maxSize = uint8(amount);\n }\n }\n\n /**\n * @dev Internal function to get historical rates with specified amount, offset, and increment.\n * @param token The token for which to retrieve the rates.\n * @param amount The number of historical rates to retrieve.\n * @param offset The number of rates to skip before starting to collect the rates.\n * @param increment The step size between the rates to collect.\n * @return observations An array of Rate structs containing the retrieved historical rates.\n */\n function _getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) internal view virtual returns (RateLibrary.Rate[] memory) {\n if (amount == 0) return new RateLibrary.Rate[](0);\n\n BufferMetadata memory meta = rateBufferMetadata[token];\n if (meta.size <= (amount - 1) * increment + offset)\n revert InsufficientData(token, meta.size, (amount - 1) * increment + offset + 1);\n\n RateLibrary.Rate[] memory observations = new RateLibrary.Rate[](amount);\n\n uint256 count = 0;\n\n for (\n uint256 i = meta.end < offset ? meta.end + meta.size - offset : meta.end - offset;\n count < amount;\n i = (i < increment) ? (i + meta.size) - increment : i - increment\n ) {\n observations[count++] = rateBuffers[token][i];\n }\n\n return observations;\n }\n\n /**\n * @dev Internal function to initialize rate buffers for a token.\n * @param token The token for which to initialize the rate buffer.\n */\n function initializeBuffers(address token) internal virtual {\n if (rateBuffers[token].length != 0) {\n revert BufferAlreadyInitialized(token);\n }\n\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n // Initialize the buffers\n RateLibrary.Rate[] storage observationBuffer = rateBuffers[token];\n\n for (uint256 i = 0; i < initialBufferCardinality; ++i) {\n observationBuffer.push();\n }\n\n // Initialize the metadata\n meta.start = 0;\n meta.end = 0;\n meta.size = 0;\n meta.maxSize = initialBufferCardinality;\n meta.pauseUpdates = false;\n\n emit RatesCapacityInitialized(token, meta.maxSize);\n }\n\n /**\n * @dev Internal function to push a new rate data into the rate buffer and update metadata accordingly.\n * @param token The token for which to push the new rate data.\n * @param rate The Rate struct containing target rate, current rate, and timestamp data to be pushed.\n */\n function push(address token, RateLibrary.Rate memory rate) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (meta.size == 0) {\n if (meta.maxSize == 0) {\n // Initialize the buffers\n initializeBuffers(token);\n }\n } else {\n meta.end = (meta.end + 1) % meta.maxSize;\n }\n\n rateBuffers[token][meta.end] = rate;\n\n emit RateUpdated(token, rate.target, rate.current, block.timestamp);\n\n if (meta.size < meta.maxSize && meta.end == meta.size) {\n // We are at the end of the array and we have not yet filled it\n meta.size++;\n } else {\n // start was just overwritten\n meta.start = (meta.start + 1) % meta.size;\n }\n }\n}\n\ncontract PrudentiaStub is HistoricalRates {\n constructor() HistoricalRates(2) {}\n\n function stubPush(address underlyingToken, uint64 rate) public {\n push(underlyingToken, RateLibrary.Rate({ target: rate, current: rate, timestamp: uint32(block.timestamp) }));\n }\n}\n\ncontract AdrastiaPrudentiaCapsTest is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicComptroller comptroller;\n\n InterestRateModel interestModel;\n MockPriceOracle priceOracle;\n\n MockERC20 underlyingToken1;\n ICErc20 cToken1;\n\n MockERC20 underlyingToken2;\n ICErc20 cToken2;\n\n MockERC20 underlyingToken3;\n ICErc20 cToken3;\n\n CErc20Delegate cErc20Delegate;\n\n PrudentiaStub prudentia;\n\n function setUp() public {\n // Deploy admin contracts\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n // Deploy comptroller logic\n Comptroller comptrollerLogic = new Comptroller();\n\n // Deploy underlying tokens\n underlyingToken1 = new MockERC20(\"UnderlyingToken1\", \"UT1\", 18);\n underlyingToken1.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken2 = new MockERC20(\"UnderlyingToken2\", \"UT2\", 18);\n underlyingToken2.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken3 = new MockERC20(\"UnderlyingToken3\", \"UT3\", 6);\n underlyingToken3.mint(address(this), 1000000e6); // 1M tokens\n\n // Deploy cToken delegates\n cErc20Delegate = new CErc20Delegate();\n\n // Deploy price oracle\n priceOracle = new MockPriceOracle(10);\n\n // Deploy IRM\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n\n // Deploy comptroller\n address[] memory unitroller = new address[](1);\n unitroller[0] = address(comptrollerLogic);\n address[] memory addressZero = new address[](1);\n addressZero[0] = address(0);\n bool[] memory boolTrue = new bool[](1);\n boolTrue[0] = true;\n bool[] memory boolFalse = new bool[](1);\n boolFalse[0] = false;\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(comptrollerLogic));\n DiamondExtension[] memory extensions = new DiamondExtension[](3);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = new ComptrollerPrudentiaCapsExt();\n extensions[2] = comptrollerLogic;\n ionicAdmin._setComptrollerExtensions(address(comptrollerLogic), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\", // name\n address(comptrollerLogic), // implementation address\n abi.encode(payable(address(ionicAdmin))), // constructor args\n false, // whitelist enforcement\n 0.1e18, // close factor = 10%\n 1.1e18, // liquidation incentive = 110%\n address(priceOracle) // price oracle\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n\n // Setup CErc20Delegate whitelist\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](1);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n address[] memory oldCErc20Implementations = new address[](1);\n oldCErc20Implementations[0] = address(0);\n address[] memory newCErc20Implementations = new address[](1);\n newCErc20Implementations[0] = address(cErc20Delegate);\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n // Deploy cToken1\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken1), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 1\", // cToken name\n \"CT1\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken2\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken2), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 2\", // cToken name\n \"CT2\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken3\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken3), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 3\", // cToken name\n \"CT3\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Store the cToken addresses\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n assertEq(allMarkets.length, 3);\n cToken1 = allMarkets[0];\n cToken2 = allMarkets[1];\n cToken3 = allMarkets[2];\n\n // Deploy Prudentia\n prudentia = new PrudentiaStub();\n }\n\n function test_NativeCaps_UnrestrictedSupply() public {\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), 0); // No supply cap set (unrestricted)\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n }\n\n function test_NativeCaps_RestrictedSupply() public {\n uint256 cap = 9999e18; // supply cap of 9,999\n uint256 mintAmount = 10000e18; // mint of 10,000\n\n // Set a native supply cap for cToken1\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = cap;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cTokens[0])), supplyCaps[0]);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_NativeCaps_UnrestrictedBorrow() public {\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // No borrow cap set (unrestricted)\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n cToken2.borrow(1000e18); // Borrow 1,000 cToken2\n }\n\n function test_NativeCaps_RestrictedBorrow() public {\n uint256 cap = 999e18; // borrow cap of 999\n uint256 borrowAmount = 1000e18; // borrow of 1,000\n\n // Set a native borrow cap for cToken2\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = cap;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cTokens[0])), borrowCaps[0]);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0\n */\n\n function test_Prudentia_Supply_Unrestricted() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Supply cap\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken2\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted supply cap for cToken2\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken2)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken1\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted borrow cap for cToken1\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftPos1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftNeg1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and using a cToken with the underlying token having 6 decimals\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // Unrestricted cap at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_Offset1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_Offset1() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n Additional ComptrollerPrudentiaCapsExt tests\n */\n\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n function test_Prudentia_SupplyCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewSupplyCapConfig(oldConfig, newConfig);\n\n // Set supply cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n\n // Get the supply cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getSupplyCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_BorrowCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewBorrowCapConfig(oldConfig, newConfig);\n\n // Set borrow cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n\n // Get the borrow cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getBorrowCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_SetSupplyCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n }\n\n function test_Prudentia_SetBorrowCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n }\n}\n" + }, + "contracts/test/CollateralSwapTest.t.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CollateralSwap } from \"../ionic/CollateralSwap.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\n\ncontract CollateralSwapTest is UpgradesBaseTest {\n ICErc20 wethMarket = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3);\n ICErc20 usdcMarket = ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0);\n ICErc20 ezETHMarket = ICErc20(0x079f84161642D81aaFb67966123C9949F9284bf5);\n ICErc20 cbETHMarket = ICErc20(0x9c201024A62466F9157b2dAaDda9326207ADDd29);\n PoolLens lens = PoolLens(0x6ec80f9aCd960b568932696C0F0bE06FBfCd175a);\n CollateralSwap swap;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n _upgradeMarketWithExtension(wethMarket);\n _upgradeMarketWithExtension(ezETHMarket);\n _upgradeMarketWithExtension(cbETHMarket);\n _upgradeMarketWithExtension(usdcMarket);\n swap = new CollateralSwap(0, msg.sender, address(wethMarket.comptroller()), new address[](0));\n emit log_named_address(\"swap address: \", address(swap));\n }\n\n function test_collateralSwap_works_noBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20754244) {\n address ionwethWhale = 0x753E909D68921388b8fB4E471D155ff73c735ebC;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n uint256 healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n bytes memory swapData = abi.encodePacked(\n hex\"5fd9ae2ea41bd686f6e5326450d10ac2dc733b837ae20fb0aaf871e87b4a9227171918ab00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0cb889707d426a7a386870a03bc70d1b0697598000000000000000000000000000000000000000000000000000000001d42cce300000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000005696f6e6963000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000002d02dd2e34e182400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000084eedd56e100000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000b85da6a0970f0000000000000000000000000000000000000000000000000001ccea209179a9000000000000000000000000d5ee82d18f63f0b82df91a6ae73b74cfda57144e000000000000000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000002cda88b1c1c076b00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000000000000000000000000000000000001d42cce3000000000000000000000000000000000000000000000000000000001d68714c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004d69971ccd4a636c403a3c1b00c85e99bb9b5606000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e4200000000000000000000000000000000000006000064b79dd08ea68a908a97220c76d19a6aa9cbde437600002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000000c1a09d5d0445047da3ab4994262b22404288a3b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002eb79dd08ea68a908a97220c76d19a6aa9cbde4376000001833589fcd6edb6e08f4c7c32d4f71b54bda029130000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a0000000000000000000000000000000000000000000000000000000001d68714c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n vm.startPrank(ionwethWhale);\n wethMarket.approve(address(swap), 1e18);\n swap.swapCollateral(1e18, wethMarket, usdcMarket, swapTarget, swapData);\n vm.stopPrank();\n healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n }\n\n function test_collateralSwap_worksWithBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20874971) {\n address ionezEthWhale = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n bytes memory swapData = abi.encodePacked(\n hex\"4666fc80a7f78b3a1e00f74ab91e766714a7b7390c173e43f2f65d7c74bda18ff1e067dd00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000d6bbde9174b1cdaa358d2cf4d57d1a9f7178fbff000000000000000000000000000000000000000000000000003625685b773877000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000000000000000000000000000000039afc19de8c3ba00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000000000000000000000000000003625685b77387700000000000000000000000000000000000000000000000000366b101e2d34e40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004c98e9c2439c0d4621c62fee2fed6d042fa8c57000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e2416092f143378750bb29b79ed961ab195cceea5000064420000000000000000000000000000000000000600000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000257fcbae4ac6b26a02e4fc5e1a11e4174b5ce39500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e42000000000000000000000000000000000000060000642ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a000000000000000000000000000000000000000000000000000366b101e2d34e400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f8654220000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec2200000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f990000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n (uint256 error, uint256 balance, uint256 borrowBalance, uint256 exchangeRateMantissa) = ezETHMarket\n .getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n vm.startPrank(ionezEthWhale);\n ezETHMarket.approve(address(swap), type(uint256).max);\n uint256 healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n swap.swapCollateral(16237319785333690, ezETHMarket, cbETHMarket, swapTarget, swapData);\n healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n vm.stopPrank();\n\n (error, balance, borrowBalance, exchangeRateMantissa) = ezETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n }\n}\n" + }, + "contracts/test/ComptrollerTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract ComptrollerTest is BaseTest {\n IonicComptroller internal comptroller;\n IonicFlywheel internal flywheel;\n address internal nonOwner = address(0x2222);\n\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n function setUp() public {\n {\n Unitroller proxy = new Unitroller(payable(address(this)));\n proxy._registerExtension(new Comptroller(), DiamondExtension(address(0)));\n comptroller = IonicComptroller(address(proxy));\n }\n {\n ERC20 rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, IFlywheelRewards(address(2)), IFlywheelBooster(address(3)), address(this));\n }\n }\n\n function test__setFlywheel() external {\n vm.prank(comptroller.admin());\n comptroller._addRewardsDistributor(address(flywheel));\n assertEq(comptroller.rewardsDistributors(0), address(flywheel));\n }\n\n function test__setFlywheelRevertsIfNonOwner() external {\n vm.startPrank(nonOwner);\n vm.expectRevert(\"!admin\");\n comptroller._addRewardsDistributor(address(flywheel));\n }\n\n function testBscInflationProtection() public debuggingOnly fork(BSC_MAINNET) {\n _testInflationProtection();\n }\n\n function testPolygonInflationProtection() public debuggingOnly fork(POLYGON_MAINNET) {\n _testInflationProtection();\n }\n\n function testModeInflationProtection() public debuggingOnly fork(MODE_MAINNET) {\n _testInflationProtection();\n }\n\n function _testInflationProtection() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n PoolDirectory.Pool[] memory pools = fpd.getAllPools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n uint256 totalSupply = market.totalSupply();\n if (totalSupply > 0) {\n if (totalSupply < 1000) {\n emit log_named_address(\"low ts market\", address(markets[j]));\n emit log_named_uint(\"ts\", totalSupply);\n } else {\n assertEq(\n pool.redeemAllowed(address(markets[j]), address(0), totalSupply - 980),\n uint256(ComptrollerErrorReporter.Error.REJECTION),\n \"low ts not rejected\"\n );\n }\n }\n }\n }\n }\n}\n" + }, + "contracts/test/config/BaseTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\nimport \"forge-std/Test.sol\";\nimport \"forge-std/console.sol\";\n\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\nabstract contract BaseTest is Test {\n uint128 constant ETHEREUM_MAINNET = 1;\n uint128 constant BSC_MAINNET = 56;\n uint128 constant POLYGON_MAINNET = 137;\n uint128 constant ARBITRUM_ONE = 42161;\n\n uint128 constant BSC_CHAPEL = 97;\n uint128 constant NEON_MAINNET = 245022934;\n uint128 constant LINEA_MAINNET = 59144;\n uint128 constant ZKEVM_MAINNET = 1101;\n uint128 constant MODE_MAINNET = 34443;\n uint128 constant BASE_MAINNET = 8453;\n\n // taken from ERC1967Upgrade\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n AddressesProvider public ap;\n ProxyAdmin public dpa;\n\n mapping(uint128 => uint256) private forkIds;\n\n constructor() {\n configureAddressesProvider(0);\n }\n\n uint256 constant CRITICAL = 100;\n uint256 constant NORMAL = 90;\n uint256 constant LOW = 80;\n\n modifier importance(uint256 testImportance) {\n uint256 runLevel = NORMAL;\n\n try vm.envUint(\"TEST_RUN_LEVEL\") returns (uint256 level) {\n runLevel = level;\n } catch {\n emit log(\"failed to get env param TEST_RUN_LEVEL\");\n }\n\n if (testImportance >= runLevel) {\n _;\n } else {\n emit log(\"not running the test\");\n }\n }\n\n modifier debuggingOnly() {\n try vm.envBool(\"LOCAL_FORGE_ENV\") returns (bool run) {\n if (run) _;\n } catch {\n emit log(\"skipping this test in the CI/CD - add LOCAL_FORGE_ENV=true to your .env file to run locally\");\n }\n }\n\n modifier fork(uint128 chainid) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, 0);\n _;\n }\n }\n\n modifier forkAtBlock(uint128 chainid, uint256 blockNumber) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, blockNumber);\n _;\n }\n }\n\n modifier whenForking() {\n try vm.activeFork() returns (uint256) {\n _;\n } catch {}\n }\n\n function shouldRunForChain(uint256 chainid) internal returns (bool) {\n bool run = true;\n try vm.envUint(\"TEST_RUN_CHAINID\") returns (uint256 envChainId) {\n run = envChainId == chainid;\n } catch {\n emit log(\"failed to get env param TEST_RUN_CHAINID\");\n }\n return run;\n }\n\n function _forkAtBlock(uint128 chainid, uint256 blockNumber) internal {\n if (block.chainid != chainid) {\n if (blockNumber != 0) {\n vm.selectFork(getArchiveForkId(chainid));\n vm.rollFork(blockNumber);\n } else {\n vm.selectFork(getForkId(chainid));\n }\n }\n configureAddressesProvider(chainid);\n afterForkSetUp();\n }\n\n function getForkId(uint128 chainid, bool archive) private returns (uint256) {\n return archive ? getForkId(chainid) : getArchiveForkId(chainid);\n }\n\n function getForkId(uint128 chainid) private returns (uint256) {\n if (forkIds[chainid] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc_chapel\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"polygon\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"neon\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"arbitrum\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"ethereum\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"linea\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"zkevm\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"mode\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"base\")) + 100;\n }\n }\n\n return forkIds[chainid] - 100;\n }\n\n function getArchiveForkId(uint128 chainid) private returns (uint256) {\n // store the archive rpc urls in the forkIds mapping at an offset\n uint128 chainidWithOffset = chainid + type(uint64).max;\n if (forkIds[chainidWithOffset] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_archive\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_chapel_archive\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"polygon_archive\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"neon_archive\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"arbitrum_archive\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"ethereum_archive\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"linea_archive\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"zkevm_archive\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"mode_archive\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"base_archive\")) + 100;\n }\n }\n return forkIds[chainidWithOffset] - 100;\n }\n\n function afterForkSetUp() internal virtual {}\n\n function configureAddressesProvider(uint128 chainid) private {\n if (chainid == BSC_MAINNET) {\n ap = AddressesProvider(address(0));\n } else if (chainid == BSC_CHAPEL) {\n ap = AddressesProvider(0x3dc8CE9f581e49B9E5304CF580940ad341F64c3f);\n } else if (block.chainid == POLYGON_MAINNET) {\n ap = AddressesProvider(0xE31baC0B582AA248c0017F87F24087cEa7A55E26);\n } else if (chainid == NEON_MAINNET) {\n ap = AddressesProvider(0xF4C60F6ac6b3AF54044757a1a54D76EEe28244CE);\n } else if (chainid == ARBITRUM_ONE) {\n ap = AddressesProvider(0x3B12BA992259Fb3855C4E1D452a754dCa2E276fC);\n } else if (chainid == LINEA_MAINNET) {\n ap = AddressesProvider(0x914694DA0bED80e74ef1a28029f016119782C0f1);\n } else if (chainid == ZKEVM_MAINNET) {\n ap = AddressesProvider(0x27aA55A3D55959261e119d75256aadAB79aE897C);\n } else if (chainid == MODE_MAINNET) {\n ap = AddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n } else if (chainid == BASE_MAINNET) {\n ap = AddressesProvider(0xcD4D7c8e2bA627684a9B18F7fe88239341D3ba5c);\n } else {\n dpa = new ProxyAdmin();\n AddressesProvider logic = new AddressesProvider();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(logic),\n address(dpa),\n abi.encodeWithSelector(ap.initialize.selector, address(this))\n );\n ap = AddressesProvider(address(proxy));\n ap.setAddress(\"DefaultProxyAdmin\", address(dpa));\n }\n dpa = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n if (ap.owner() == address(0)) {\n ap.initialize(address(this));\n }\n if (ap.getAddress(\"deployer\") == address(0)) {\n vm.prank(ap.owner());\n ap.setAddress(\"deployer\", 0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n }\n\n function diff(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n } else {\n return b - a;\n }\n }\n\n function compareStrings(string memory a, string memory b) public pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function asArray(address value) public pure returns (address[] memory) {\n address[] memory array = new address[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(address value0, address value1) public pure returns (address[] memory) {\n address[] memory array = new address[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n address value0,\n address value1,\n address value2\n ) public pure returns (address[] memory) {\n address[] memory array = new address[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function asArray(bool value) public pure returns (bool[] memory) {\n bool[] memory array = new bool[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(uint256 value0, uint256 value1) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(uint256 value) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value0, bytes memory value1) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n bytes memory value0,\n bytes memory value1,\n bytes memory value2\n ) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function sqrt(uint256 x) public pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n}\n" + }, + "contracts/test/config/MarketsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./BaseTest.t.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../../compound/CErc20RewardsDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { DiamondExtension } from \"../../ionic/DiamondExtension.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MarketsTest is BaseTest {\n FeeDistributor internal ffd;\n\n CErc20Delegate internal cErc20Delegate;\n CErc20PluginDelegate internal cErc20PluginDelegate;\n CErc20RewardsDelegate internal cErc20RewardsDelegate;\n CErc20PluginRewardsDelegate internal cErc20PluginRewardsDelegate;\n CTokenFirstExtension internal newCTokenExtension;\n\n address payable internal latestComptrollerImplementation;\n ComptrollerFirstExtension internal comptrollerExtension;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n upgradeFfd();\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20RewardsDelegate = new CErc20RewardsDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n newCTokenExtension = new CTokenFirstExtension();\n\n comptrollerExtension = new ComptrollerFirstExtension();\n Comptroller newComptrollerImplementation = new Comptroller();\n latestComptrollerImplementation = payable(address(newComptrollerImplementation));\n }\n\n function upgradeFfd() internal {\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffd)));\n bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n if (address(ffd.authoritiesRegistry()) == address(0)) {\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n vm.prank(ffd.owner());\n ffd.reinitialize(newAr);\n }\n }\n\n function _prepareCTokenUpgrade(ICErc20 market) internal returns (address) {\n address implBefore = market.implementation();\n //emit log(\"implementation before\");\n //emit log_address(implBefore);\n\n CErc20Delegate newImpl;\n if (market.delegateType() == 1) {\n newImpl = cErc20Delegate;\n } else if (market.delegateType() == 2) {\n newImpl = cErc20PluginDelegate;\n } else if (market.delegateType() == 3) {\n newImpl = cErc20RewardsDelegate;\n } else {\n newImpl = cErc20PluginRewardsDelegate;\n }\n\n // set the new ctoken delegate as the latest\n uint8 delegateType = market.delegateType();\n vm.prank(ffd.owner());\n ffd._setLatestCErc20Delegate(delegateType, address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = DiamondExtension(newImpl);\n cErc20DelegateExtensions[1] = newCTokenExtension;\n vm.prank(ffd.owner());\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n\n return address(newImpl);\n }\n\n function _upgradeMarket(ICErc20 market) internal {\n address newDelegate = _prepareCTokenUpgrade(market);\n\n bytes memory becomeImplData = (address(newDelegate) == address(cErc20Delegate))\n ? bytes(\"\")\n : abi.encode(address(0));\n vm.prank(market.ionicAdmin());\n market._setImplementationSafe(newDelegate, becomeImplData);\n }\n\n function _prepareComptrollerUpgrade(address oldCompImpl) internal {\n vm.startPrank(ffd.owner());\n ffd._setLatestComptrollerImplementation(oldCompImpl, latestComptrollerImplementation);\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = comptrollerExtension;\n extensions[1] = Comptroller(latestComptrollerImplementation);\n ffd._setComptrollerExtensions(latestComptrollerImplementation, extensions);\n vm.stopPrank();\n }\n\n function _upgradeExistingPool(address poolAddress) internal {\n Unitroller asUnitroller = Unitroller(payable(poolAddress));\n // change the implementation to the new that can add extensions\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n _prepareComptrollerUpgrade(oldComptrollerImplementation);\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n}\n" + }, + "contracts/test/ContractsUpgradesTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ComptrollerFirstExtension, DiamondExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract ContractsUpgradesTest is BaseTest {\n function testPoolDirectoryUpgrade() public fork(BSC_MAINNET) {\n address contractToTest = ap.getAddress(\"PoolDirectory\"); // PoolDirectory proxy\n\n // before upgrade\n PoolDirectory fpdBefore = PoolDirectory(contractToTest);\n PoolDirectory.Pool[] memory poolsBefore = fpdBefore.getAllPools();\n address ownerBefore = fpdBefore.owner();\n emit log_address(ownerBefore);\n\n uint256 lenBefore = poolsBefore.length;\n emit log_uint(lenBefore);\n\n // upgrade\n {\n PoolDirectory newImpl = new PoolDirectory();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(contractToTest));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n PoolDirectory fpd = PoolDirectory(contractToTest);\n address ownerAfter = fpd.owner();\n emit log_address(ownerAfter);\n\n (, PoolDirectory.Pool[] memory poolsAfter) = fpd.getActivePools();\n uint256 lenAfter = poolsAfter.length;\n emit log_uint(poolsAfter.length);\n\n assertEq(lenBefore, lenAfter, \"pools count does not match\");\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testFeeDistributorUpgrade() public fork(BSC_MAINNET) {\n // TODO use an already deployed market\n CErc20Delegate oldCercDelegate = new CErc20Delegate();\n\n // before upgrade\n FeeDistributor ffdProxy = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n uint256 marketsCounterBefore = ffdProxy.marketsCounter();\n address ownerBefore = ffdProxy.owner();\n\n (address latestCErc20DelegateBefore, ) = ffdProxy.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterBefore);\n emit log_address(ownerBefore);\n\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffdProxy)));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n FeeDistributor ffd = FeeDistributor(payable(address(ffdProxy)));\n\n uint256 marketsCounterAfter = ffd.marketsCounter();\n address ownerAfter = ffd.owner();\n (address latestCErc20DelegateAfter, ) = ffd.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterAfter);\n emit log_address(ownerAfter);\n\n assertEq(latestCErc20DelegateBefore, latestCErc20DelegateAfter, \"latest delegates do not match\");\n assertEq(marketsCounterBefore, marketsCounterAfter, \"markets counter does not match\");\n\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testMarketsLatestImplementationsChapel() public fork(BSC_CHAPEL) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsBsc() public fork(BSC_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsPolygon() public fork(POLYGON_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsArbitrum() public fork(ARBITRUM_ONE) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsEth() public fork(ETHEREUM_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function _testMarketsLatestImplementations() internal {\n FeeDistributor ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n if (address(fpd) != address(0)) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n\n uint8 currentDelegateType = market.delegateType();\n (address upgradeToImpl, ) = ffd.latestCErc20Delegate(currentDelegateType);\n\n address currentImpl = market.implementation();\n if (currentImpl != upgradeToImpl) emit log_address(address(market));\n assertEq(currentImpl, upgradeToImpl, \"market needs to be upgraded\");\n\n DiamondBase asBase = DiamondBase(address(markets[j]));\n try asBase._listExtensions() returns (address[] memory extensions) {\n assertEq(extensions.length, 2, \"market is missing an extension\");\n } catch {\n emit log(\"market that is not yet upgraded to the extensions upgrade\");\n emit log_address(address(market));\n emit log(\"implementation\");\n emit log_address(currentImpl);\n emit log(\"pool\");\n emit log_address(pools[i].comptroller);\n emit log(\"\");\n }\n }\n }\n }\n }\n\n function testPauseGuardiansBsc() public debuggingOnly fork(BSC_MAINNET) {\n _testPauseGuardians();\n }\n\n // TODO redeploy to polygon to fix\n function testPauseGuardiansPolygon() public debuggingOnly fork(POLYGON_MAINNET) {\n _testPauseGuardians();\n }\n\n function _testPauseGuardians() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n address deployer = ap.getAddress(\"deployer\");\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address pauseGuardian = pool.pauseGuardian();\n if (pauseGuardian != address(0) && pauseGuardian != deployer) {\n emit log_named_address(\"pool\", address(pool));\n emit log_named_address(\"unknown pause guardian\", pauseGuardian);\n emit log(\"\");\n }\n }\n }\n}\n" + }, + "contracts/test/DeployMarkets.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Test.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { IonicFlywheelDynamicRewardsPlugin } from \"../ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20, ICErc20Plugin, ICErc20PluginRewards } from \"../compound/CTokenInterfaces.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { MockERC4626 } from \"../ionic/strategies/MockERC4626.sol\";\nimport { MockERC4626Dynamic } from \"../ionic/strategies/MockERC4626Dynamic.sol\";\n\ncontract DeployMarketsTest is Test {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n MockERC4626 mockERC4626;\n MockERC4626Dynamic mockERC4626Dynamic;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheelDynamicRewardsPlugin rewards;\n\n address[] markets;\n bool[] t;\n bool[] f;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts() public {\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", 18);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n }\n\n function setUpExtensions() public {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = cErc20Delegate;\n cErc20DelegateExtensions[1] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(0), cErc20DelegateExtensions);\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n }\n\n function setUpPool() public {\n underlyingToken.mint(address(this), 100e36);\n\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n }\n\n function setUp() public {\n setUpBaseContracts();\n setUpPool();\n setUpExtensions();\n vm.roll(1);\n }\n\n function testDeployCErc20Delegate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n require(cToken.mint(10e18) == 0, \"mint failed\");\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(underlyingToken.balanceOf(address(cToken)), 10e18);\n }\n\n function testDeployCErc20PluginDelegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10e18);\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(mockERC4626.balanceOf(address(cToken)), 10e18);\n assertEq(underlyingToken.balanceOf(address(mockERC4626)), 10e18);\n }\n\n function testDeployCErc20PluginRewardsDelegate() public {\n IonicFlywheelCore impl = new IonicFlywheelCore();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n IonicFlywheelCore flywheel = IonicFlywheelCore(address(proxy));\n flywheel.initialize(underlyingToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n IonicFlywheelCore asFlywheelCore = IonicFlywheelCore(address(flywheel));\n rewards = new IonicFlywheelDynamicRewardsPlugin(asFlywheelCore, 1);\n flywheel.setFlywheelRewards(rewards);\n\n mockERC4626Dynamic = new MockERC4626Dynamic(ERC20(address(underlyingToken)), asFlywheelCore);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(address(mockERC4626Dynamic), address(flywheel), address(underlyingToken)),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20PluginRewards cToken = ICErc20PluginRewards(address(allMarkets[allMarkets.length - 1]));\n\n flywheel.addStrategyForRewards(ERC20(address(cToken)));\n\n assertEq(address(cToken.plugin()), address(mockERC4626Dynamic), \"!plugin == erc4626\");\n assertEq(underlyingToken.allowance(address(cToken), address(mockERC4626Dynamic)), type(uint256).max);\n assertEq(underlyingToken.allowance(address(cToken), address(flywheel)), 0);\n\n cToken.approve(address(rewardToken), address(flywheel));\n assertEq(rewardToken.allowance(address(cToken), address(flywheel)), type(uint256).max);\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10000000);\n assertEq(cToken.totalSupply(), 10000000 * 5);\n assertEq(mockERC4626Dynamic.balanceOf(address(cToken)), 10000000);\n assertEq(underlyingToken.balanceOf(address(mockERC4626Dynamic)), 10000000);\n }\n\n function testAutoImplementationCErc20Delegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n address implBefore = cToken.implementation();\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n cToken.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address implAfter = cToken.implementation();\n\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testAutoImplementationPlugin() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n ionicAdmin._upgradePluginToLatestImplementation(address(cToken));\n address pluginImplAfter = address(cToken.plugin());\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n }\n\n function testAutoImplementationCErc20PluginDelegate() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n address implBefore = cToken.implementation();\n uint8 delegateType = cToken.delegateType();\n\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n delegateType,\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address pluginImplAfter = address(cToken.plugin());\n address implAfter = cToken.implementation();\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testInflateExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint just 2 wei\n underlyingToken.approve(address(cToken), 1e36);\n cToken.mint(2);\n assertEq(cToken.totalSupply(), 10);\n assertEq(underlyingToken.balanceOf(address(cToken)), 2, \"!total supply 2\");\n\n uint256 exchRateBefore = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate\", exchRateBefore);\n assertEq(exchRateBefore, 2e17, \"!default exch rate\");\n\n // donate\n underlyingToken.transfer(address(cToken), 1e36);\n\n uint256 exchRateAfter = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate after\", exchRateAfter);\n assertGt(exchRateAfter, 1e30, \"!inflated exch rate\");\n\n // the market should own 1e36 + 2 underlying assets\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e36 + 2, \"!total underlying\");\n\n // 50% + 1\n uint256 errCode = cToken.redeemUnderlying(0.5e36 + 2);\n assertEq(errCode, 0, \"!redeem underlying\");\n\n assertEq(cToken.totalSupply(), 0, \"!should have redeemed all ctokens for 50% + 1 of the underlying\");\n }\n\n function testSupplyCapInflatedExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint 1e18\n underlyingToken.approve(address(cToken), 1e18);\n cToken.mint(1e18);\n assertEq(cToken.totalSupply(), 5 * 1e18, \"!total supply 5\");\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e18, \"!market underlying balance 1\");\n\n (, , uint256 liqBefore, uint256 sfBefore) = comptroller.getAccountLiquidity(address(this));\n\n uint256[] memory caps = new uint256[](1);\n caps[0] = 25e18;\n ICErc20[] memory marketArray = new ICErc20[](1);\n marketArray[0] = cToken;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(marketArray, caps);\n\n // donate 100e18\n underlyingToken.transfer(address(cToken), 100e18);\n assertEq(underlyingToken.balanceOf(address(cToken)), 101e18, \"!market balance 101\");\n assertEq(cToken.balanceOfUnderlying(address(this)), 101e18, \"!user balance 101\");\n\n (, , uint256 liqAfter, uint256 sfAfter) = comptroller.getAccountLiquidity(address(this));\n emit log_named_uint(\"liqBefore\", liqBefore);\n emit log_named_uint(\"liqAfter\", liqAfter);\n\n assertEq(liqAfter / liqBefore, 25, \"liquidity should increase only 25x\");\n }\n}\n" + }, + "contracts/test/DevTesting.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport \"./config/BaseTest.t.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ISwapRouter } from \"../external/uniswap/ISwapRouter.sol\";\nimport { RedstoneAdapterPriceOracle } from \"../oracles/default/RedstoneAdapterPriceOracle.sol\";\nimport { RedstoneAdapterPriceOracleWrsETH } from \"../oracles/default/RedstoneAdapterPriceOracleWrsETH.sol\";\nimport { RedstoneAdapterPriceOracleWeETH } from \"../oracles/default/RedstoneAdapterPriceOracleWeETH.sol\";\nimport { MasterPriceOracle, BasePriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { LeveredPositionFactory } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { LeveredPositionStorage } from \"../ionic/levered/LeveredPositionStorage.sol\";\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle_IFLR } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { CurveSwapLiquidator } from \"../liquidators/CurveSwapLiquidator.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\nimport { VelodromeV2Liquidator } from \"../liquidators/VelodromeV2Liquidator.sol\";\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport \"forge-std/console.sol\";\n\nstruct HealthFactorVars {\n uint256 usdcSupplied;\n uint256 wethSupplied;\n uint256 ezEthSuppled;\n uint256 stoneSupplied;\n uint256 wbtcSupplied;\n uint256 weEthSupplied;\n uint256 merlinBTCSupplied;\n uint256 usdcBorrowed;\n uint256 wethBorrowed;\n uint256 ezEthBorrowed;\n uint256 stoneBorrowed;\n uint256 wbtcBorrowed;\n uint256 weEthBorrowed;\n uint256 merlinBTCBorrowed;\n ICErc20 testCToken;\n address testUnderlying;\n uint256 amountBorrow;\n}\n\ncontract DevTesting is BaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n LeveredPositionsLens levPosLens;\n\n address deployer = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n ICErc20 ezEthMarket;\n ICErc20 stoneMarket;\n ICErc20 weEthMarket;\n ICErc20 merlinBTCMarket;\n\n // mode mainnet assets\n address WETH = 0x4200000000000000000000000000000000000006;\n address USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address USDT = 0xf0F161fDA2712DB8b566946122a5af183995e2eD;\n address WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;\n address UNI = 0x3e7eF8f50246f725885102E8238CBba33F276747;\n address SNX = 0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3;\n address LINK = 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb;\n address DAI = 0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea;\n address BAL = 0xD08a2917653d4E460893203471f0000826fb4034;\n address AAVE = 0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2;\n address weETH = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n address merlinBTC = 0x59889b7021243dB5B1e065385F918316cD90D46c;\n IERC20Upgradeable wsuperOETH = IERC20Upgradeable(0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6);\n IERC20Upgradeable superOETH = IERC20Upgradeable(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n ezEthMarket = ICErc20(0x59e710215d45F584f44c0FEe83DA6d43D762D857);\n stoneMarket = ICErc20(0x959FA710CCBb22c7Ce1e59Da82A247e686629310);\n weEthMarket = ICErc20(0xA0D844742B4abbbc43d8931a6Edb00C56325aA18);\n merlinBTCMarket = ICErc20(0x19F245782b1258cf3e11Eda25784A378cC18c108);\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n } else {}\n levPosLens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testModePoolBorrowers() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_array(\"borrowers\", pool.getAllBorrowers());\n }\n\n function testModeLiquidationShortfall() public debuggingOnly fork(MODE_MAINNET) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(\n 0xa75F9C8246f7269279bE4c969e7Bc6Eb619cC204\n );\n\n emit log_named_uint(\"err\", err);\n emit log_named_uint(\"collateralValue\", collateralValue);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n }\n\n function testModeHealthFactor() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n\n uint256 wethSupplied = wethMarket.balanceOfUnderlying(rahul);\n uint256 usdcSupplied = usdcMarket.balanceOfUnderlying(rahul);\n uint256 usdtSupplied = usdtMarket.balanceOfUnderlying(rahul);\n uint256 wbtcSupplied = wbtcMarket.balanceOfUnderlying(rahul);\n // emit log_named_uint(\"wethSupplied\", wethSupplied);\n emit log_named_uint(\"usdcSupplied\", usdcSupplied);\n emit log_named_uint(\"usdtSupplied\", usdtSupplied);\n emit log_named_uint(\"wbtcSupplied\", wbtcSupplied);\n emit log_named_uint(\"value of wethSupplied\", wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n emit log_named_uint(\"value of usdcSupplied\", usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n emit log_named_uint(\"value of usdtSupplied\", usdtSupplied * pool.oracle().getUnderlyingPrice(usdtMarket));\n emit log_named_uint(\"value of wbtcSupplied\", wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n PoolLens newImpl = new PoolLens();\n // TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(lens)));\n // vm.prank(dpa.owner());\n // proxy.upgradeTo(address(newImpl));\n\n uint256 hf = newImpl.getHealthFactor(rahul, pool);\n\n emit log_named_uint(\"hf\", hf);\n }\n\n function testNetAprMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 8479829) {\n address user = 0x30D5047e839f079bDE1Ab16b34668f57391DacB3;\n int256 blocks = 30 * 24 * 365 * 60;\n IonicFlywheelLensRouter lensRouter = new IonicFlywheelLensRouter(\n PoolDirectory(0x39C353Cf9041CcF467A04d0e78B63d961E81458a)\n );\n int256 apr = lensRouter.getUserNetApr(user, blocks);\n\n emit log_named_int(\"apr\", apr);\n }\n\n function testModeUsdcBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdcMarket);\n }\n\n function testHypotheticalPosition() public debuggingOnly forkAtBlock(MODE_MAINNET, 8028296) {\n HealthFactorVars memory vars;\n\n address wolfy = 0x7d922bf0975424b3371074f54cC784AF738Dac0D;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n address wbtcWhale = 0xBD8CCf3ebE4CC2D57962cdC2756B143ce0135a6B;\n address wethWhale = 0xD746A2a6048C5D3AFF5766a8c4A0C8cFD2311745;\n\n address whale = wbtcWhale;\n vars.testCToken = wethMarket;\n vars.testUnderlying = WETH;\n vars.amountBorrow = 1e18 / 2;\n\n address[] memory cTokens = new address[](1);\n\n vm.startPrank(usdcWhale);\n ERC20(USDC).transfer(wolfy, ERC20(USDC).balanceOf(usdcWhale));\n vm.stopPrank();\n\n vm.startPrank(wbtcWhale);\n ERC20(WBTC).transfer(wolfy, ERC20(WBTC).balanceOf(wbtcWhale));\n vm.stopPrank();\n\n vm.startPrank(wethWhale);\n ERC20(WETH).transfer(wolfy, ERC20(WETH).balanceOf(wethWhale));\n vm.stopPrank();\n\n // emit log_named_uint(\"USDC balance\", ERC20(USDC).balanceOf(wolfy));\n // emit log_named_uint(\"WBTC balance\", ERC20(WBTC).balanceOf(wolfy));\n // emit log_named_uint(\"WETH balance\", ERC20(WETH).balanceOf(wolfy));\n\n vm.startPrank(wolfy);\n\n ERC20(USDC).approve(address(usdcMarket), ERC20(USDC).balanceOf(wolfy));\n usdcMarket.mint(ERC20(USDC).balanceOf(wolfy));\n cTokens[0] = address(usdcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WBTC).approve(address(wbtcMarket), ERC20(WBTC).balanceOf(wolfy));\n wbtcMarket.mint(ERC20(WBTC).balanceOf(wolfy));\n cTokens[0] = address(wbtcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WETH).approve(address(wethMarket), ERC20(WETH).balanceOf(wolfy));\n wethMarket.mint(ERC20(WETH).balanceOf(wolfy));\n cTokens[0] = address(wethMarket);\n pool.enterMarkets(cTokens);\n\n wethMarket.borrow(1e18);\n\n vm.stopPrank();\n\n vars.usdcSupplied = usdcMarket.balanceOfUnderlying(wolfy);\n vars.wethSupplied = wethMarket.balanceOfUnderlying(wolfy);\n vars.ezEthSuppled = ezEthMarket.balanceOfUnderlying(wolfy);\n vars.stoneSupplied = stoneMarket.balanceOfUnderlying(wolfy);\n vars.wbtcSupplied = wbtcMarket.balanceOfUnderlying(wolfy);\n vars.weEthSupplied = weEthMarket.balanceOfUnderlying(wolfy);\n vars.merlinBTCSupplied = merlinBTCMarket.balanceOfUnderlying(wolfy);\n\n vars.usdcBorrowed = usdcMarket.borrowBalanceCurrent(wolfy);\n vars.wethBorrowed = wethMarket.borrowBalanceCurrent(wolfy);\n vars.ezEthBorrowed = ezEthMarket.borrowBalanceCurrent(wolfy);\n vars.stoneBorrowed = stoneMarket.borrowBalanceCurrent(wolfy);\n vars.wbtcBorrowed = wbtcMarket.borrowBalanceCurrent(wolfy);\n vars.weEthBorrowed = weEthMarket.borrowBalanceCurrent(wolfy);\n vars.merlinBTCBorrowed = merlinBTCMarket.borrowBalanceCurrent(wolfy);\n\n emit log_named_uint(\"usdcSupplied\", vars.usdcSupplied);\n emit log_named_uint(\"wethSupplied\", vars.wethSupplied);\n emit log_named_uint(\"ezEthSupplied\", vars.ezEthSuppled);\n emit log_named_uint(\"stoneSupplied\", vars.stoneSupplied);\n emit log_named_uint(\"wbtcSupplied\", vars.wbtcSupplied);\n emit log_named_uint(\"weEthSupplied\", vars.weEthSupplied);\n emit log_named_uint(\"merlinBTCSupplied\", vars.merlinBTCSupplied);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"usdcBorrowed\", vars.usdcBorrowed);\n emit log_named_uint(\"wethBorrowed\", vars.wethBorrowed);\n emit log_named_uint(\"ezEthBorrowed\", vars.ezEthBorrowed);\n emit log_named_uint(\"stoneBorrowed\", vars.stoneBorrowed);\n emit log_named_uint(\"wbtcBorrowed\", vars.wbtcBorrowed);\n emit log_named_uint(\"weEthBorrowed\", vars.weEthBorrowed);\n emit log_named_uint(\"merlinBTCBorrowed\", vars.merlinBTCBorrowed);\n\n // emit log_named_uint(\"value of usdcSupplied\", vars.usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethSupplied\", vars.wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthSupplied\", vars.ezEthSuppled * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneSupplied\", vars.stoneSupplied * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcSupplied\", vars.wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n // emit log_named_uint(\"value of usdcBorrowed\", vars.usdcBorrowed * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethBorrowed\", vars.wethBorrowed * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthBorrowed\", vars.ezEthBorrowed * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneBorrowed\", vars.stoneBorrowed * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcBorrowed\", vars.wbtcBorrowed * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n vm.startPrank(whale);\n ERC20(vars.testUnderlying).transfer(wolfy, ERC20(vars.testUnderlying).balanceOf(whale));\n vm.stopPrank();\n\n uint256 hf = lens.getHealthFactor(wolfy, pool);\n uint256 hypothetical = lens.getHealthFactorHypothetical(\n pool,\n wolfy,\n address(vars.testCToken),\n 0,\n 0,\n vars.amountBorrow\n );\n\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value Before\", collateralValue);\n emit log_named_uint(\"Liquidity Before\", liquidity);\n emit log_named_uint(\"hf before\", hf);\n emit log_named_uint(\"hypothetical hf\", hypothetical);\n\n vm.startPrank(wolfy);\n ERC20(vars.testUnderlying).approve(address(vars.testCToken), vars.amountBorrow);\n vars.testCToken.repayBorrow(vars.amountBorrow);\n vm.stopPrank();\n\n uint256 hfAfter = lens.getHealthFactor(wolfy, pool);\n (err, collateralValue, liquidity, shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value After\", collateralValue);\n emit log_named_uint(\"Liquidity After\", liquidity);\n emit log_named_uint(\"hf after\", hfAfter);\n emit log_named_uint(\"user balance after\", ERC20(vars.testUnderlying).balanceOf(wolfy));\n emit log_named_uint(\"new borrow balance after repay\", vars.testCToken.borrowBalanceCurrent(wolfy));\n }\n\n function testModeUsdtBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdtMarket);\n }\n\n function testModeWethBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(wethMarket);\n wethMarket.accrueInterest();\n _testModeBorrowCaps(wethMarket);\n }\n\n function _testModeBorrowCaps(ICErc20 market) internal {\n uint256 borrowCapUsdc = pool.borrowCaps(address(market));\n uint256 totalBorrowsCurrent = market.totalBorrowsCurrent();\n\n uint256 wethBorrowAmount = 154753148031252;\n console.log(\"borrowCapUsdc %e\", borrowCapUsdc);\n console.log(\"totalBorrowsCurrent %e\", totalBorrowsCurrent);\n console.log(\"new totalBorrowsCurrent %e\", totalBorrowsCurrent + wethBorrowAmount);\n }\n\n function testMarketMember() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; i++) {\n if (pool.checkMembership(rahul, markets[i])) {\n emit log(\"is a member\");\n } else {\n emit log(\"NOT a member\");\n }\n }\n }\n\n function testGetCashError() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20 market = ICErc20(0x49950319aBE7CE5c3A6C90698381b45989C99b46);\n market.getCash();\n }\n\n function testWrsEthBalanceOfError() public debuggingOnly fork(MODE_MAINNET) {\n address wrsEthMarketAddress = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ERC20 wrsEth = ERC20(0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd);\n wrsEth.balanceOf(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n\n function testModeRepay() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0x1A3C4E9B49e4fc595fB7e5f723159bA73a9426e7;\n ICErc20 market = usdcMarket;\n ERC20 asset = ERC20(market.underlying());\n\n uint256 borrowBalance = market.borrowBalanceCurrent(user);\n emit log_named_uint(\"borrowBalance\", borrowBalance);\n\n vm.startPrank(user);\n asset.approve(address(market), borrowBalance);\n uint256 err = market.repayBorrow(borrowBalance / 2);\n\n emit log_named_uint(\"error\", err);\n }\n\n function testAssetsPrices() public debuggingOnly fork(MODE_MAINNET) {\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n emit log_named_uint(\"WETH price\", mpo.price(WETH));\n emit log_named_uint(\"USDC price\", mpo.price(USDC));\n emit log_named_uint(\"USDT price\", mpo.price(USDT));\n emit log_named_uint(\"UNI price\", mpo.price(UNI));\n emit log_named_uint(\"SNX price\", mpo.price(SNX));\n emit log_named_uint(\"LINK price\", mpo.price(LINK));\n emit log_named_uint(\"DAI price\", mpo.price(DAI));\n emit log_named_uint(\"BAL price\", mpo.price(BAL));\n emit log_named_uint(\"AAVE price\", mpo.price(AAVE));\n emit log_named_uint(\"WBTC price\", mpo.price(WBTC));\n }\n\n function testDeployedMarkets() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n emit log_named_address(\"market\", address(markets[i]));\n emit log(markets[i].symbol());\n emit log(markets[i].name());\n }\n }\n\n function testDisableCollateralUsdc() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0xF70CBE91fB1b1AfdeB3C45Fb8CDD2E1249b5b75E;\n address usdcMarketAddr = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n\n vm.startPrank(user);\n\n uint256 borrowed = ICErc20(usdcMarketAddr).borrowBalanceCurrent(user);\n\n emit log_named_uint(\"borrowed\", borrowed);\n\n pool.exitMarket(usdcMarketAddr);\n }\n\n function testBorrowRateAtRatio() public debuggingOnly fork(MODE_MAINNET) {\n uint256 rate = levPosLens.getBorrowRateAtRatio(wethMarket, ezEthMarket, 9988992945501686, 2e18);\n emit log_named_uint(\"borrow rate at ratio\", rate);\n }\n\n function testAssetAsCollateralCap() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ezEthWhale = 0x2344F131B07E6AFd943b0901C55898573F0d1561;\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_EZETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Renzo Restaked ETH\",\n \"ionezETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 ezEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(ezEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(ezEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(ezEthWhale);\n ERC20(MODE_EZETH).approve(address(ezEthMarket), 1e36);\n errCode = ezEthMarket.mint(1e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testNewStoneMarketCapped() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_STONE = 0x80137510979822322193FC997d400D5A6C747bf7;\n address stoneWhale = 0x76486cbED5216C82d26Ee60113E48E06C189541A;\n\n address redstoneOracleAddress = 0x63A1531a06F0Ac597a0DfA5A516a37073c3E1e0a;\n RedstoneAdapterPriceOracle oracle = RedstoneAdapterPriceOracle(redstoneOracleAddress);\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(mpo.admin());\n mpo.add(asArray(MODE_STONE), oracles);\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_STONE,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic StakeStone Ether\",\n \"ionSTONE\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 stoneMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(stoneMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(stoneMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(stoneWhale);\n ERC20(MODE_STONE).approve(address(stoneMarket), 1e36);\n vm.expectRevert(\"not authorized\");\n errCode = stoneMarket.mint(1e18);\n //require(errCode != 0, \"should be unable to supply\");\n }\n\n function testRegisterSFS() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_address(\"pool admin\", pool.admin());\n\n vm.startPrank(multisig);\n pool.registerInSFS();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n markets[i].registerInSFS();\n }\n }\n\n function upgradePool() internal {\n ComptrollerFirstExtension newComptrollerExtension = new ComptrollerFirstExtension();\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n\n // upgrade to the new comptroller extension\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(newComptrollerExtension, DiamondExtension(asUnitroller._listExtensions()[1]));\n\n //asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function testModeBorrowRate() public fork(MODE_MAINNET) {\n //ICErc20[] memory markets = pool.getAllMarkets();\n\n IonicComptroller pool = ezEthMarket.comptroller();\n vm.prank(pool.admin());\n ezEthMarket._setInterestRateModel(JumpRateModel(0x413aD59b80b1632988d478115a466bdF9B26743a));\n\n JumpRateModel discRateModel = JumpRateModel(ezEthMarket.interestRateModel());\n\n uint256 borrows = 200e18;\n uint256 cash = 5000e18 - borrows;\n uint256 reserves = 1e18;\n uint256 rate = discRateModel.getBorrowRate(cash, borrows, reserves);\n\n emit log_named_uint(\"rate per year %e\", rate * discRateModel.blocksPerYear());\n }\n\n function testModeFetchBorrowers() public fork(MODE_MAINNET) {\n // address[] memory borrowers = pool.getAllBorrowers();\n // emit log_named_uint(\"borrowers.len\", borrowers.length);\n\n //upgradePool();\n\n (uint256 totalPages, address[] memory borrowersPage) = pool.getPaginatedBorrowers(1, 0);\n\n emit log_named_uint(\"total pages with 300 size (default)\", totalPages);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(totalPages - 1, 50);\n emit log_named_array(\"last page of 300 borrowers\", borrowersPage);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(1, 50);\n emit log_named_uint(\"total pages with 50 size\", totalPages);\n emit log_named_array(\"page of 50 borrowers\", borrowersPage);\n\n // for (uint256 i = 0; i < borrowers.length; i++) {\n // (\n // uint256 error,\n // uint256 collateralValue,\n // uint256 liquidity,\n // uint256 shortfall\n // ) = pool.getAccountLiquidity(borrowers[i]);\n //\n // emit log(\"\");\n // emit log_named_address(\"user\", borrowers[i]);\n // emit log_named_uint(\"collateralValue\", collateralValue);\n // if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n // if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n // }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testModeDeployMarket() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n address weEthWhale = 0x6e55a90772B92f17f87Be04F9562f3faafd0cc38;\n\n vm.startPrank(pool.admin());\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_WEETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Wrapped eETH\",\n \"ionweETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 weEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(weEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(weEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(weEthWhale);\n ERC20(MODE_WEETH).approve(address(weEthMarket), 1e36);\n errCode = weEthMarket.mint(0.01e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testModeWrsETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6635923) {\n address wrsEth = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n RedstoneAdapterPriceOracleWrsETH oracle = new RedstoneAdapterPriceOracleWrsETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(wrsEth), oracles);\n\n uint256 price = mpo.price(wrsEth);\n emit log_named_uint(\"price of wrsEth\", price);\n }\n\n function testModeWeETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6861468) {\n address weEth = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n RedstoneAdapterPriceOracleWeETH oracle = new RedstoneAdapterPriceOracleWeETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(weEth), oracles);\n\n uint256 price = mpo.price(weEth);\n emit log_named_uint(\"price of weEth\", price);\n assertEq(price, 1036212437077011599);\n }\n\n function testPERLiquidation() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n vm.prank(0x5Cc070844E98F4ceC5f2fBE1592fB1ed73aB7b48);\n _functionCall(\n 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A,\n hex\"20b72325000000000000000000000000f28570694a6c9cd0494955966ae75af61abf5a0700000000000000000000000000000000000000000000000001bc1214ed792fbb0000000000000000000000004341620757bee7eb4553912fafc963e59c949147000000000000000000000000c53edeafb6d502daec5a7015d67936cea0cd0f520000000000000000000000000000000000000000000000000000000000000000\",\n \"error in call\"\n );\n }\n\n function testCtokenUpgrade() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n CErc20PluginRewardsDelegate newImpl = new CErc20PluginRewardsDelegate();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(wethMarket)));\n\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = PoolDirectory(\n 0x39C353Cf9041CcF467A04d0e78B63d961E81458a\n ).getActivePools();\n\n emit log_named_uint(\"First Pool ID\", poolIds[0]);\n emit log_named_uint(\"First Pool ID\", poolIds[1]);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_address(\"First Pool Address\", pools[0].creator);\n emit log_named_address(\"First Pool Address\", pools[1].creator);\n emit log_named_address(\"First Pool Address\", pools[0].comptroller);\n emit log_named_address(\"First Pool Address\", pools[1].comptroller);\n //bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n //address admin = address(uint160(uint256(bytesAtSlot)));\n //vm.prank(admin);\n //proxy.upgradeTo(address(newImpl));\n\n //vm.prank(dpa.owner());\n //proxy.upgradeTo(address(newImpl));\n }\n\n function testAerodromeV2Liquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeV2Liquidator liquidator = new AerodromeV2Liquidator();\n IERC20Upgradeable hyUSD = IERC20Upgradeable(0xCc7FF230365bD730eE4B352cC2492CEdAC49383e);\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n IERC20Upgradeable usdc = IERC20Upgradeable(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);\n address hyusdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0xaac391f166f33CdaEfaa4AfA6616A3BEA66B694d;\n address eusdWhale = 0xEE8Bd6594E046d72D592ac0e278E3CA179b8f189;\n address aerodromeV2Router = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;\n\n vm.startPrank(eusdWhale);\n eUSD.transfer(address(liquidator), 1000 ether);\n IRouter_Aerodrome.Route[] memory path = new IRouter_Aerodrome.Route[](1);\n path[0] = IRouter_Aerodrome.Route({\n from: address(eUSD),\n to: address(usdc),\n stable: true,\n factory: 0x420DD381b31aEf6683db6B902084cB0FFECe40Da\n });\n liquidator.redeem(eUSD, 1000 ether, abi.encode(aerodromeV2Router, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address superOETHWhale = 0xF1010eE787Ee588766b441d7cC397b40DdFB17a3;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n vm.startPrank(superOETHWhale);\n superOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(superOETH, 1 ether, abi.encode(address(superOETH), address(weth), int24(1), aerodromeCLRouter));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorWrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 20203998) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wethWhale = 0x751b77C43643a63362Ab024d466fcC1d75354295;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = AerodromeCLLiquidator(0xb50De36105F6053006306553AB54e77224818B9B);\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n weth,\n 1 ether,\n abi.encode(address(weth), address(wsuperOETH), aerodromeCLRouter, address(0), address(superOETH), 1)\n );\n emit log_named_uint(\"wsuperOETH received\", wsuperOETH.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorUnwrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wsuperOethWhale = 0x0EEaCD4c475040463389d15EAd034d1291b008b1;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n\n vm.startPrank(wsuperOethWhale);\n wsuperOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n wsuperOETH,\n 1 ether,\n abi.encode(address(wsuperOETH), address(weth), aerodromeCLRouter, address(superOETH), address(0), 1)\n );\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testCurveSwapLiquidatorUSDCtowUSDM() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address usdcWhale = 0x134575ff75F9882ca905EE1D78C9340C091d6056;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n vm.prank(usdcWhale);\n IERC20Upgradeable(usdc).transfer(address(liquidator), 100e6);\n liquidator.redeem(IERC20Upgradeable(usdc), 100e6, abi.encode(oracle, wUSDM, address(0), usdm));\n emit log_named_uint(\"wUSDM received\", IERC20Upgradeable(wUSDM).balanceOf(address(liquidator)));\n }\n\n function testCurveSwapLiquidatorwUSDMtoUSDC() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address wusdmWhale = 0x9b8b04B6f82cD5e1dae58cA3614d445F93DeFc5c;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n\n vm.startPrank(wusdmWhale);\n IERC20Upgradeable(wUSDM).transfer(address(liquidator), 30 ether);\n liquidator.redeem(IERC20Upgradeable(wUSDM), 30 ether, abi.encode(oracle, usdc, usdm, address(0)));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testKimLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 13579406) {\n address weth = 0x4200000000000000000000000000000000000006;\n address usdc = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address kimRouter = 0xAc48FcF1049668B285f3dC72483DF5Ae2162f7e8;\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n AlgebraSwapLiquidator liquidator = AlgebraSwapLiquidator(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vm.startPrank(wethWhale);\n IERC20Upgradeable(weth).transfer(address(liquidator), 2018770577362160);\n liquidator.redeem(IERC20Upgradeable(weth), 2018770577362160, abi.encode(usdc, kimRouter));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testVelodromeV2Liquidator_mode_usdcToWeth() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address usdcWhale = 0xFd1D36995d76c0F75bbe4637C84C06E4A68bBB3a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(usdcWhale);\n usdc.transfer(address(liquidator), 1000 * 10e6);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(usdc), to: address(weth), stable: false });\n liquidator.redeem(usdc, 1000 * 10e6, abi.encode(veloRouter, path));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testVelodromeV2Liquidator_mode_wethToUSDC() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(weth), to: address(usdc), stable: false });\n\n liquidator.redeem(weth, 1 ether, abi.encode(veloRouter, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function test_claimRewardFromLeveredPosition() public debuggingOnly fork(BASE_MAINNET) {\n LeveredPosition position = LeveredPosition(\n 0x3a0eA2C577b0e0f2CAaEcC2b8fF8fF1850267ba2 // 20 days old\n );\n ILeveredPositionFactory factory = position.factory();\n\n vm.prank(address(factory));\n LeveredPosition dummy = new LeveredPosition(\n msg.sender,\n ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3),\n ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0)\n );\n emit log_named_address(\"dummy\", address(dummy));\n\n vm.startPrank(factory.owner());\n DiamondBase(address(factory))._registerExtension(\n new LeveredPositionFactoryFirstExtension(),\n DiamondExtension(0x115455f15ef67e298F012F225B606D3c4Daa1d60)\n );\n factory._setPositionsExtension(LeveredPosition.claimRewardsFromRouter.selector, address(dummy));\n vm.stopPrank();\n\n {\n // mock the usdz call\n vm.mockCall(\n 0x04D5ddf5f3a8939889F11E97f8c4BB48317F1938,\n abi.encodeWithSelector(IERC20Upgradeable.balanceOf.selector),\n abi.encode(53307671999615298341926)\n );\n }\n\n vm.startPrank(0xC13110d04f22ed464Cb72A620fF8163585358Ff9);\n (address[] memory rewardTokens, uint256[] memory rewards) = position.claimRewardsFromRouter(\n 0xB1402333b12fc066C3D7F55d37944D5e281a3e8B\n );\n emit log_named_uint(\"reward tokens\", rewardTokens.length);\n emit log_named_uint(\"rewards\", rewards.length);\n vm.stopPrank();\n }\n\n function test_liquidateWithAggregator() public debuggingOnly forkAtBlock(MODE_MAINNET, 15407774) {\n IonicUniV3Liquidator liquidator = new IonicUniV3Liquidator();\n emit log_named_address(\"liquidator\", address(liquidator));\n address cErc20 = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18; // weEth\n address cTokenCollateral = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3; // usdt\n uint256 repayAmount = 872134153950744;\n address borrower = 0xb1f81c88eDB20344447db66340240F00862c3280;\n address aggregatorTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE; // lifi\n // 0xf0F161fDA2712DB8b566946122a5af183995e2eD usdt\n // 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A weeth\n bytes memory aggregatorData = vm.parseBytes(\n \"0x4666fc80a5f4cf3239cc70f0640a4afa0cf877ea4f7530171a84309a4335f821ea9b2a5500000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9000000000000000000000000000000000000000000000000000319339a1f6f55000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e64000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a00000000000000000000000000000000000000000000000000000000002770c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000082490411a320000000000000000000000002d6b88e2b1f8f69c039375fcea4deb0f5cbe3a71000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a000000000000000000000000e1b9041bc284651bbb7a8bd0b2edbfbdf56d2fdc0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000002770c0000000000000000000000000000000000000000000000000000319339a1f6f5500000000000000000000000000000000000000000000000000031d30008681e70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064cac460ee80000000000000003b963620e1b9041bc284651bbb7a8bd0b2edbfbdf56d2fdc000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000053e85d00f2c6578a1205b842255ab9df9d05374400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000643afe5f0080000000000000000271000553e85d00f2c6578a1205b842255ab9df9d05374400000000000000000000000042000000000000000000000000000000000000060000000000000000000000002d6b88e2b1f8f69c039375fcea4deb0f5cbe3a7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e8500000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a000000000000000000000000000000000000000000000000000031d30008681e700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f86542200000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f9900000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n emit log_named_uint(\n \"before collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"before borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n liquidator.safeLiquidateWithAggregator(\n borrower,\n repayAmount,\n ICErc20(cErc20),\n ICErc20(cTokenCollateral),\n aggregatorTarget,\n aggregatorData\n );\n\n emit log_named_uint(\n \"profit collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"profit borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testRawCall() public debuggingOnly forkAtBlock(BASE_MAINNET, 20569373) {\n address caller = 0xC13110d04f22ed464Cb72A620fF8163585358Ff9;\n address target = 0x180272dDf5767C771b3a8d37A2DC6cA507aaa1d9;\n\n ILeveredPositionFactory factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(WETH);\n IERC20Upgradeable outputToken = wsuperOETH;\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(aerodomeClLiquidator, inputToken, outputToken);\n registry._setRedemptionStrategy(aerodomeClLiquidator, outputToken, inputToken);\n vm.stopPrank();\n\n bytes memory data = hex\"c393d0e3\";\n vm.prank(caller);\n _functionCall(target, data, \"raw call failed\");\n\n uint256 superOETHBalance = superOETH.balanceOf(target);\n emit log_named_uint(\"balance of levered position\", superOETHBalance);\n }\n}\n" + }, + "contracts/test/ExtensionsTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MockComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFirstMarketSymbol() public view returns (string memory) {\n return allMarkets[0].symbol();\n }\n\n function _setTransferPaused(bool) public returns (bool) {\n return false;\n }\n\n function _setSeizePaused(bool) public returns (bool) {\n return false;\n }\n\n // a dummy fn to test if the replacement of extension fns works\n function getSecondMarketSymbol() public view returns (string memory) {\n return allMarkets[1].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this.getFirstMarketSymbol.selector;\n functionSelectors[--fnsCount] = this.getSecondMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockSecondComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getThirdMarketSymbol() public view returns (string memory) {\n return allMarkets[2].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getThirdMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockThirdComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFourthMarketSymbol() public view returns (string memory) {\n return allMarkets[3].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getFourthMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract ExtensionsTest is MarketsTest {\n MockComptrollerExtension internal mockExtension;\n MockSecondComptrollerExtension internal second;\n MockThirdComptrollerExtension internal third;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n mockExtension = new MockComptrollerExtension();\n second = new MockSecondComptrollerExtension();\n third = new MockThirdComptrollerExtension();\n }\n\n function testExtensionReplace() public debuggingOnly fork(BSC_MAINNET) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n _upgradeExistingPool(jFiatPoolAddress);\n\n // replace the first extension with the mock\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, mockExtension, comptrollerExtension);\n\n // assert that the replacement worked\n MockComptrollerExtension asMockExtension = MockComptrollerExtension(jFiatPoolAddress);\n emit log(asMockExtension.getSecondMarketSymbol());\n assertEq(asMockExtension.getSecondMarketSymbol(), \"fETH-1\", \"market symbol does not match\");\n\n // add a second mock extension\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, second, DiamondExtension(address(0)));\n\n // add again the third, removing the second\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, third, second);\n\n // assert that it worked\n DiamondBase asBase = DiamondBase(jFiatPoolAddress);\n address[] memory currentExtensions = asBase._listExtensions();\n assertEq(currentExtensions.length, 2, \"extensions count does not match\");\n assertEq(currentExtensions[0], address(mockExtension), \"!first\");\n assertEq(currentExtensions[1], address(third), \"!second\");\n }\n\n function testNewPoolExtensions() public fork(BSC_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n _prepareComptrollerUpgrade(address(0));\n\n // deploy a pool that will have an extension registered automatically\n {\n (, address poolAddress) = fpd.deployPool(\n \"just-a-test2\",\n latestComptrollerImplementation,\n abi.encode(payable(address(ffd))),\n false,\n 0.1e18,\n 1.1e18,\n ap.getAddress(\"MasterPriceOracle\")\n );\n\n address[] memory initExtensionsAfter = DiamondBase(payable(poolAddress))._listExtensions();\n assertEq(initExtensionsAfter.length, 1, \"remove this if the ffd config is set up\");\n assertEq(initExtensionsAfter[0], address(comptrollerExtension), \"first extension is not the CFE\");\n }\n }\n\n function testMulticallMarket() public fork(BSC_MAINNET) {\n uint8 random = uint8(block.timestamp % 256);\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(pools[random % pools.length].comptroller);\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n ICErc20 someMarket = markets[random % markets.length];\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n vm.roll(block.number + 1);\n\n bytes memory blockNumberBeforeCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes memory accrueInterestCall = abi.encodeWithSelector(someMarket.accrueInterest.selector);\n bytes memory blockNumberAfterCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes[] memory results = someMarket.multicall(\n asArray(blockNumberBeforeCall, accrueInterestCall, blockNumberAfterCall)\n );\n uint256 blockNumberBefore = abi.decode(results[0], (uint256));\n uint256 blockNumberAfter = abi.decode(results[2], (uint256));\n\n assertGt(blockNumberAfter, blockNumberBefore, \"did not accrue?\");\n }\n\n function testBscExistingCTokenExtensionUpgrade() public fork(BSC_MAINNET) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function testArbitrumExistingCTokenExtensionUpgrade() public fork(ARBITRUM_ONE) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function _testAllPoolsAllMarketsCTokenExtensionUpgrade() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n _testPoolAllMarketsExtensionUpgrade(pools[i].comptroller);\n }\n }\n\n function _testPoolAllMarketsExtensionUpgrade(address poolAddress) internal {\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(poolAddress);\n\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 someMarket = markets[j];\n CErc20Delegator asDelegator = CErc20Delegator(address(someMarket));\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n try this._testExistingCTokenExtensionUpgrade(asDelegator) {} catch Error(string memory reason) {\n address plugin = address(CErc20PluginDelegate(address(asDelegator)).plugin());\n emit log(\"plugin\");\n emit log_address(plugin);\n\n address latestPlugin = ffd.latestPluginImplementation(plugin);\n emit log(\"latest plugin impl\");\n emit log_address(latestPlugin);\n\n revert(reason);\n }\n }\n }\n\n function _testExistingCTokenExtensionUpgrade(CErc20Delegator asDelegator) public {\n uint256 totalSupplyBefore = asDelegator.totalSupply();\n if (totalSupplyBefore == 0) return; // total supply should be non-zero\n\n // TODO\n _upgradeMarket(ICErc20(address(asDelegator)));\n\n // check if the extension was added\n address[] memory extensions = asDelegator._listExtensions();\n assertEq(extensions.length, 1, \"the first extension should be added\");\n assertEq(extensions[0], address(newCTokenExtension), \"the first extension should be the only extension\");\n\n // check if the storage is read from the same place\n uint256 totalSupplyAfter = asDelegator.totalSupply();\n assertGt(totalSupplyAfter, 0, \"total supply should be non-zero\");\n assertEq(totalSupplyAfter, totalSupplyBefore, \"total supply should be the same\");\n }\n\n function testBscComptrollerExtensions() public debuggingOnly fork(BSC_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testPolygonComptrollerExtensions() public debuggingOnly fork(POLYGON_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testChapelComptrollerExtensions() public debuggingOnly fork(BSC_CHAPEL) {\n _testComptrollersExtensions();\n }\n\n function testArbitrumComptrollerExtensions() public debuggingOnly fork(ARBITRUM_ONE) {\n _testComptrollersExtensions();\n }\n\n function _testComptrollersExtensions() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n address payable asPayable = payable(pools[i].comptroller);\n DiamondBase asBase = DiamondBase(asPayable);\n address[] memory extensions = asBase._listExtensions();\n assertEq(extensions.length, 1, \"each pool should have the first extension\");\n }\n }\n\n function testBulkAutoUpgrade() public debuggingOnly fork(POLYGON_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n vm.prank(ffd.owner());\n ffd.autoUpgradePool(IonicComptroller(pools[i].comptroller));\n }\n }\n\n function testPolygonTotalUnderlyingSupplied() public debuggingOnly fork(POLYGON_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function testBscTotalUnderlyingSupplied() public debuggingOnly fork(BSC_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function _testTotalUnderlyingSupplied() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n // if (pools[i].comptroller == 0x5373C052Df65b317e48D6CAD8Bb8AC50995e9459) continue;\n // if (pools[i].comptroller == 0xD265ff7e5487E9DD556a4BB900ccA6D087Eb3AD2) continue;\n ComptrollerFirstExtension poolExt = ComptrollerFirstExtension(pools[i].comptroller);\n\n ICErc20[] memory markets = poolExt.getAllMarkets();\n for (uint8 k = 0; k < markets.length; k++) {\n CErc20Delegate market = CErc20Delegate(address(markets[k]));\n // emit log(market.contractType());\n // emit log_named_address(\"impl\", market.implementation());\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(address(markets[k]));\n marketAsExt.getTotalUnderlyingSupplied();\n }\n }\n }\n\n function testDelegateType() public debuggingOnly fork(POLYGON_MAINNET) {\n emit log(CErc20Delegate(0x587906620D627fe75C4d1288C6A584089780959c).contractType());\n }\n}\n" + }, + "contracts/test/helpers/WithPool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.4.23;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\n\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract WithPool is BaseTest {\n ERC20Upgradeable public underlyingToken;\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n IonicComptroller comptroller;\n Comptroller newComptroller;\n JumpRateModel interestModel;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n MasterPriceOracle priceOracle;\n PoolLens poolLens;\n\n address[] markets;\n bool[] t;\n bool[] f;\n address[] newImplementation;\n address[] hardcodedAddresses;\n string[] hardcodedNames;\n\n function setUpWithPool(MasterPriceOracle _masterPriceOracle, ERC20Upgradeable _underlyingToken) public {\n priceOracle = _masterPriceOracle;\n underlyingToken = _underlyingToken;\n\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n if (address(ionicAdmin) != address(0)) {\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ionicAdmin)));\n bytes32 bytesAtSlot = vm.load(\n address(proxy),\n 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n );\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n } else {\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n }\n\n {\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setPendingOwner(address(this));\n ionicAdmin._acceptOwner();\n }\n setUpBaseContracts();\n setUpExtensions();\n }\n\n function setUpExtensions() internal {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n }\n\n function setUpBaseContracts() internal {\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n poolLens = new PoolLens();\n poolLens.initialize(\n poolDirectory,\n \"Pool\",\n \"lens\",\n hardcodedAddresses,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames\n );\n }\n\n function setUpPool(\n string memory name,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive\n ) public {\n Comptroller newComptrollerImplementation = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(newComptrollerImplementation));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = newComptrollerImplementation;\n ionicAdmin._setComptrollerExtensions(address(newComptrollerImplementation), extensions);\n\n (, address comptrollerAddress) = poolDirectory.deployPool(\n name,\n address(newComptrollerImplementation),\n abi.encode(payable(address(ionicAdmin))),\n enforceWhitelist,\n closeFactor,\n liquidationIncentive,\n address(priceOracle)\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n }\n\n function upgradePool(address pool) internal {\n Comptroller newComptrollerImplementation = new Comptroller();\n\n Unitroller asUnitroller = Unitroller(payable(pool));\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n newComptrollerImplementation,\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function deployCErc20Delegate(\n address _underlyingToken,\n bytes memory name,\n bytes memory symbol,\n uint256 _collateralFactorMantissa\n ) public {\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n _underlyingToken,\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n name,\n symbol,\n uint256(1),\n uint256(0)\n ),\n \"\",\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginDelegate(address _erc4626, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_erc4626),\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginRewardsDelegate(address _mockERC4626Dynamic, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_mockERC4626Dynamic),\n _collateralFactorMantissa\n );\n }\n}\n" + }, + "contracts/test/LatestImplementationWhitelisted.t.sol": { + "content": "pragma solidity ^0.8.0;\n\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LatestImplementationWhitelisted is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n address[] poolsImplementationsSet;\n address[] marketsImplementationsSet;\n address[] pluginsSet;\n\n function testBscImplementations() public fork(BSC_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function testPolygonImplementations() public fork(POLYGON_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function afterForkSetUp() internal override {\n poolDirectory = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testPoolImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n address implementation = comptroller.comptrollerImplementation();\n\n bool added = false;\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n if (poolsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) poolsImplementationsSet.push(implementation);\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n emit log_address(poolsImplementationsSet[k]);\n\n address latestImpl = ionicAdmin.latestComptrollerImplementation(poolsImplementationsSet[k]);\n assertTrue(poolsImplementationsSet[k] == latestImpl, \"some pool is not upgraded the latest impl\");\n }\n }\n\n function testMarketImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n address implementation = market.implementation();\n\n bool added = false;\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n if (marketsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) marketsImplementationsSet.push(implementation);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n emit log_address(marketsImplementationsSet[k]);\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = ionicAdmin.latestCErc20Delegate(\n CErc20Delegate(marketsImplementationsSet[k]).delegateType()\n );\n\n assertTrue(marketsImplementationsSet[k] == latestCErc20Delegate, \"some markets need to be upgraded\");\n }\n }\n\n function testPluginImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n CErc20PluginDelegate delegate = CErc20PluginDelegate(address(markets[j]));\n\n address plugin;\n try delegate.plugin() returns (IERC4626 _plugin) {\n plugin = address(_plugin);\n } catch {\n continue;\n }\n\n bool added = false;\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n if (pluginsSet[k] == plugin) {\n added = true;\n }\n }\n\n if (!added) pluginsSet.push(plugin);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n address latestPluginImpl = ionicAdmin.latestPluginImplementation(pluginsSet[k]);\n\n emit log_address(pluginsSet[k]);\n\n assertTrue(pluginsSet[k] == latestPluginImpl, \"some plugin is not upgraded to the latest impl\");\n }\n }\n}\n" + }, + "contracts/test/LeveredPositionTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest, BaseTest } from \"./config/MarketsTest.t.sol\";\nimport { DiamondBase, DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { LeveredPositionFactory, IFeeDistributor } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { JarvisLiquidatorFunder } from \"../liquidators/JarvisLiquidatorFunder.sol\";\nimport { BalancerSwapLiquidator } from \"../liquidators/BalancerSwapLiquidator.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { SolidlyLpTokenLiquidator, SolidlyLpTokenWrapper } from \"../liquidators/SolidlyLpTokenLiquidator.sol\";\nimport { SolidlySwapLiquidator } from \"../liquidators/SolidlySwapLiquidator.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\n\nimport { CurveLpTokenLiquidatorNoRegistry } from \"../liquidators/CurveLpTokenLiquidatorNoRegistry.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { LiquidatorsRegistry } from \"../liquidators/registry/LiquidatorsRegistry.sol\";\nimport { LiquidatorsRegistryExtension } from \"../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { SafeOwnable } from \"../ionic/SafeOwnable.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract LeveredPositionLensTest is BaseTest {\n LeveredPositionsLens lens;\n ILeveredPositionFactory factory;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n emit log_named_address(\"factory\", address(factory));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n // lens = new LeveredPositionsLens();\n // lens.initialize(factory);\n }\n\n function testLPLens() public debuggingOnly fork(BSC_CHAPEL) {\n _testLPLens();\n }\n\n function _testLPLens() internal {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(0xb6c11605e971ab46B9BE4fDC48C9650A257075db);\n\n // address[] memory accounts = factory.getAccountsWithOpenPositions();\n // for (uint256 i = 0; i < accounts.length; i++) {\n // (positions, closed) = factory.getPositionsByAccount(accounts[i]);\n // if (positions.length > 0) break;\n // }\n\n uint256[] memory apys = new uint256[](positions.length);\n LeveredPosition[] memory pos = new LeveredPosition[](positions.length);\n for (uint256 j = 0; j < positions.length; j++) {\n apys[j] = 1e17;\n\n if (address(0) == positions[j]) revert(\"zero pos address\");\n pos[j] = LeveredPosition(positions[j]);\n }\n\n LeveredPositionsLens.PositionInfo[] memory infos = lens.getPositionsInfo(pos, apys);\n\n for (uint256 k = 0; k < infos.length; k++) {\n emit log_named_address(\"address\", address(pos[k]));\n emit log_named_uint(\"positionSupplyAmount\", infos[k].positionSupplyAmount);\n emit log_named_uint(\"positionValue\", infos[k].positionValue);\n emit log_named_uint(\"debtAmount\", infos[k].debtAmount);\n emit log_named_uint(\"debtValue\", infos[k].debtValue);\n emit log_named_uint(\"equityValue\", infos[k].equityValue);\n emit log_named_uint(\"equityAmount\", infos[k].equityAmount);\n emit log_named_int(\"currentApy\", infos[k].currentApy);\n emit log_named_uint(\"debtRatio\", infos[k].debtRatio);\n emit log_named_uint(\"liquidationThreshold\", infos[k].liquidationThreshold);\n emit log_named_uint(\"safetyBuffer\", infos[k].safetyBuffer);\n\n emit log(\"\");\n }\n }\n\n function testPrintLeveredPositions() public debuggingOnly fork(POLYGON_MAINNET) {\n address[] memory accounts = factory.getAccountsWithOpenPositions();\n\n emit log_named_array(\"accounts\", accounts);\n\n for (uint256 j = 0; j < accounts.length; j++) {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(accounts[j]);\n emit log_named_array(\"positions\", positions);\n //emit log_named_array(\"closed\", closed);\n }\n }\n\n function testScenarioLeverageFailed() public debuggingOnly forkAtBlock(MODE_MAINNET, 10672173) {\n address USER = 0x95Ce459B20586cf44ee6d295C4f28e1a134CF529;\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006).approve(\n // address(factory),\n // 100000 ether\n // );\n vm.prank(ap.owner());\n ap.setAddress(\"IUniswapV2Router02\", 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45);\n vm.startPrank(USER);\n LeveredPosition position = factory.createAndFundPositionAtRatio(\n ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n IERC20Upgradeable(0x4200000000000000000000000000000000000006),\n 16754252276537996590,\n 3000000000000000000\n );\n emit log_named_address(\"position\", address(position));\n\n // vm.stopPrank();\n // ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n // vm.startPrank(registry.owner());\n // registry._setRedemptionStrategy(\n // new UniswapV3LiquidatorFunder(),\n // IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f),\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006)\n // );\n // vm.stopPrank();\n // vm.startPrank(USER);\n\n vm.roll(10673509);\n position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(10852409);\n // position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(11268772);\n // position.adjustLeverageRatio(3000000000000000000);\n vm.stopPrank();\n }\n}\n\ncontract LeveredPositionFactoryTest is BaseTest {\n ILeveredPositionFactory factory;\n LeveredPositionsLens lens;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testChapelNetApy() public debuggingOnly fork(BSC_CHAPEL) {\n ICErc20 _stableMarket = ICErc20(address(1)); // DAI\n\n uint256 borrowRate = 5.2e16; // 5.2%\n vm.mockCall(\n address(_stableMarket),\n abi.encodeWithSelector(_stableMarket.borrowRatePerBlock.selector),\n abi.encode(borrowRate / factory.blocksPerYear())\n );\n\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n emit log_named_uint(\"_borrowRate\", _borrowRate);\n\n int256 netApy = lens.getNetAPY(\n 2.7e16, // 2.7%\n 1e18, // supply amount\n ICErc20(address(0)), // BOMB\n _stableMarket,\n 2e18 // ratio\n );\n\n emit log_named_int(\"net apy\", netApy);\n\n // boosted APY = 2x 2.7% = 5.4 % of the equity\n // borrow APR = 5.2%\n // diff = 5.4 - 5.2 = 0.2%\n assertApproxEqRel(netApy, 0.2e16, 1e12, \"!net apy\");\n }\n}\n\nabstract contract LeveredPositionTest is MarketsTest {\n ICErc20 collateralMarket;\n ICErc20 stableMarket;\n ILeveredPositionFactory factory;\n ILiquidatorsRegistry registry;\n LeveredPosition position;\n LeveredPositionsLens lens;\n\n uint256 minLevRatio;\n uint256 maxLevRatio;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n registry = factory.liquidatorsRegistry();\n {\n // upgrade the registry\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n\n vm.startPrank(registry.owner());\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory oldExts = asBase._listExtensions();\n\n if (oldExts.length == 1) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(address(0)));\n } else if (oldExts.length == 2) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(oldExts[1]));\n }\n vm.stopPrank();\n }\n\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function upgradePoolAndMarkets() internal {\n _upgradeExistingPool(address(collateralMarket.comptroller()));\n _upgradeMarket(collateralMarket);\n _upgradeMarket(stableMarket);\n }\n\n function _unpauseMarkets(address collat, address stable) internal {\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(address(ICErc20(stable).comptroller()));\n vm.startPrank(asExtension.admin());\n asExtension._setMintPaused(ICErc20(collat), false);\n asExtension._setMintPaused(ICErc20(stable), false);\n asExtension._setBorrowPaused(ICErc20(stable), false);\n vm.stopPrank();\n }\n\n function _configurePairAndLiquidator(address _collat, address _stable, IRedemptionStrategy _liquidator) internal {\n _configurePair(_collat, _stable);\n _configureTwoWayLiquidator(_collat, _stable, _liquidator);\n }\n\n function _configurePair(address _collat, address _stable) internal {\n collateralMarket = ICErc20(_collat);\n stableMarket = ICErc20(_stable);\n\n //upgradePoolAndMarkets();\n //_unpauseMarkets(_collat, _stable);\n vm.prank(factory.owner());\n factory._setPairWhitelisted(collateralMarket, stableMarket, true);\n }\n\n function _whitelistTestUser(address user) internal {\n address pool = address(collateralMarket.comptroller());\n PoolRolesAuthority pra = ffd.authoritiesRegistry().poolsAuthorities(pool);\n\n vm.startPrank(pra.owner());\n pra.setUserRole(user, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n }\n\n function _configureTwoWayLiquidator(\n address inputMarket,\n address outputMarket,\n IRedemptionStrategy strategy\n ) internal {\n IERC20Upgradeable inputToken = underlying(inputMarket);\n IERC20Upgradeable outputToken = underlying(outputMarket);\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(strategy, inputToken, outputToken);\n registry._setRedemptionStrategy(strategy, outputToken, inputToken);\n vm.stopPrank();\n }\n\n function underlying(address market) internal view returns (IERC20Upgradeable) {\n return IERC20Upgradeable(ICErc20(market).underlying());\n }\n\n struct Liquidator {\n IERC20Upgradeable inputToken;\n IERC20Upgradeable outputToken;\n IRedemptionStrategy strategy;\n }\n\n function _configureMultipleLiquidators(Liquidator[] memory liquidators) internal {\n IRedemptionStrategy[] memory strategies = new IRedemptionStrategy[](liquidators.length);\n IERC20Upgradeable[] memory inputTokens = new IERC20Upgradeable[](liquidators.length);\n IERC20Upgradeable[] memory outputTokens = new IERC20Upgradeable[](liquidators.length);\n for (uint256 i = 0; i < liquidators.length; i++) {\n strategies[i] = liquidators[i].strategy;\n inputTokens[i] = liquidators[i].inputToken;\n outputTokens[i] = liquidators[i].outputToken;\n }\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategies(strategies, inputTokens, outputTokens);\n vm.stopPrank();\n }\n\n function _fundMarketAndSelf(ICErc20 market, address whale) internal {\n IERC20Upgradeable token = IERC20Upgradeable(market.underlying());\n\n if (whale == address(0)) {\n whale = address(911);\n //vm.deal(address(token), whale, 100e18);\n }\n\n uint256 allTokens = token.balanceOf(whale);\n vm.prank(whale);\n token.transfer(address(this), allTokens / 20);\n\n if (market.getCash() < allTokens / 2) {\n _whitelistTestUser(whale);\n vm.startPrank(whale);\n token.approve(address(market), allTokens / 2);\n market.mint(allTokens / 2);\n vm.stopPrank();\n }\n }\n\n function _openLeveredPosition(\n address _positionOwner,\n uint256 _depositAmount\n ) internal returns (LeveredPosition _position, uint256 _maxRatio, uint256 _minRatio) {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(_positionOwner, _depositAmount);\n\n vm.startPrank(_positionOwner);\n collateralToken.approve(address(factory), _depositAmount);\n _position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, _depositAmount);\n vm.stopPrank();\n\n _maxRatio = _position.getMaxLeverageRatio();\n emit log_named_uint(\"max ratio\", _maxRatio);\n _minRatio = _position.getMinLeverageRatio();\n emit log_named_uint(\"min ratio\", _minRatio);\n\n assertGt(_maxRatio, _minRatio, \"max ratio <= min ratio\");\n }\n\n function testOpenLeveredPosition() public virtual whenForking {\n assertApproxEqRel(position.getCurrentLeverageRatio(), 1e18, 4e16, \"initial leverage ratio should be 1.0 (1e18)\");\n }\n\n function testAnyLeverageRatio(uint64 ratioDiff) public debuggingOnly whenForking {\n // ratioDiff is between 0 and 2^64 ~= 18.446e18\n uint256 targetLeverageRatio = 1e18 + uint256(ratioDiff);\n emit log_named_uint(\"fuzz max ratio\", maxLevRatio);\n emit log_named_uint(\"fuzz min ratio\", minLevRatio);\n emit log_named_uint(\"target ratio\", targetLeverageRatio);\n vm.assume(targetLeverageRatio < maxLevRatio);\n vm.assume(minLevRatio < targetLeverageRatio);\n\n uint256 borrowedAssetPrice = stableMarket.comptroller().oracle().getUnderlyingPrice(stableMarket);\n (uint256 sd, uint256 bd) = position.getSupplyAmountDelta(targetLeverageRatio);\n emit log_named_uint(\"borrows delta val\", (bd * borrowedAssetPrice) / 1e18);\n emit log_named_uint(\"min borrow value\", ffd.getMinBorrowEth(stableMarket));\n\n uint256 equityAmount = position.getEquityAmount();\n emit log_named_uint(\"equity amount\", equityAmount);\n\n uint256 currentLeverageRatio = position.getCurrentLeverageRatio();\n emit log_named_uint(\"current ratio\", currentLeverageRatio);\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(targetLeverageRatio);\n emit log_named_uint(\"equity amount\", position.getEquityAmount());\n assertApproxEqRel(leverageRatioRealized, targetLeverageRatio, 4e16, \"target ratio not matching\");\n }\n\n function testMinMaxLeverageRatio() public whenForking {\n assertGt(maxLevRatio, minLevRatio, \"max ratio <= min ratio\");\n\n // attempting to adjust to minLevRatio - 0.01 should fail\n vm.expectRevert(abi.encodeWithSelector(LeveredPosition.BorrowStableFailed.selector, 0x3fa));\n position.adjustLeverageRatio((minLevRatio + 1e18) / 2);\n // just testing\n position.adjustLeverageRatio(maxLevRatio);\n // but adjusting to the minLevRatio + 0.01 should succeed\n position.adjustLeverageRatio(minLevRatio + 0.01e18);\n }\n\n function testMaxLeverageRatio() public whenForking {\n uint256 _equityAmount = position.getEquityAmount();\n uint256 rate = lens.getBorrowRateAtRatio(collateralMarket, stableMarket, _equityAmount, maxLevRatio);\n emit log_named_uint(\"borrow rate at max ratio\", rate);\n\n position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(position.getCurrentLeverageRatio(), maxLevRatio, 4e16, \"target max ratio not matching\");\n }\n\n function testRewardsAccruedClaimed() public whenForking {\n address[] memory flywheels = position.pool().getRewardsDistributors();\n if (flywheels.length > 0) {\n vm.warp(block.timestamp + 60 * 60 * 24);\n vm.roll(block.number + 10000);\n\n (ERC20[] memory rewardTokens, uint256[] memory amounts) = position.getAccruedRewards();\n\n ERC20 rewardToken;\n bool atLeastOneAccrued = false;\n for (uint256 i = 0; i < amounts.length; i++) {\n atLeastOneAccrued = amounts[i] > 0;\n if (atLeastOneAccrued) {\n rewardToken = rewardTokens[i];\n emit log_named_address(\"accrued from reward token\", address(rewardTokens[i]));\n break;\n }\n }\n\n assertEq(atLeastOneAccrued, true, \"!should have accrued at least one reward token\");\n\n if (atLeastOneAccrued) {\n uint256 rewardsBalanceBefore = rewardToken.balanceOf(address(this));\n position.claimRewards();\n uint256 rewardsBalanceAfter = rewardToken.balanceOf(address(this));\n assertGt(rewardsBalanceAfter - rewardsBalanceBefore, 0, \"should have claimed some rewards\");\n }\n } else {\n emit log(\"no flywheels/rewards for the pair pool\");\n }\n }\n\n function testLeverMaxDown() public whenForking {\n IERC20Upgradeable stableAsset = IERC20Upgradeable(stableMarket.underlying());\n IERC20Upgradeable collateralAsset = IERC20Upgradeable(collateralMarket.underlying());\n uint256 startingEquity = position.getEquityAmount();\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(leverageRatioRealized, maxLevRatio, 4e16, \"target ratio not matching\");\n\n // decrease the ratio in 10 equal steps\n uint256 ratioDiffStep = (maxLevRatio - 1e18) / 9;\n while (leverageRatioRealized > 1e18) {\n uint256 targetLeverDownRatio = leverageRatioRealized - ratioDiffStep;\n if (targetLeverDownRatio < minLevRatio) targetLeverDownRatio = 1e18;\n leverageRatioRealized = position.adjustLeverageRatio(targetLeverDownRatio);\n assertApproxEqRel(leverageRatioRealized, targetLeverDownRatio, 3e16, \"target lever down ratio not matching\");\n }\n\n uint256 withdrawAmount = position.closePosition();\n emit log_named_uint(\"withdraw amount\", withdrawAmount);\n assertApproxEqRel(startingEquity, withdrawAmount, 5e16, \"!withdraw amount\");\n\n assertEq(position.getEquityAmount(), 0, \"!nonzero equity amount\");\n assertEq(position.getCurrentLeverageRatio(), 0, \"!nonzero leverage ratio\");\n }\n}\n\ncontract WmaticMaticXLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 500e18;\n\n address wmaticMarket = 0xCb8D7c2690536d3444Da3d207f62A939483c8A93;\n address maticxMarket = 0x6ebdbEe1a509247B4A3ac3b73a43bd434C52C7c2;\n address wmaticWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;\n address maticxWhale = 0x72f0275444F2aF8dBf13F78D54A8D3aD7b6E68db;\n\n _configurePair(wmaticMarket, maticxMarket);\n _fundMarketAndSelf(ICErc20(wmaticMarket), wmaticWhale);\n _fundMarketAndSelf(ICErc20(maticxMarket), maticxWhale);\n\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n\n vm.startPrank(wmaticWhale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 100e18, stableToken);\n vm.stopPrank();\n vm.startPrank(maticxWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 100e18, collateralToken);\n vm.stopPrank();\n\n emit log_named_uint(\"slippage coll->stable\", registry.getSlippage(collateralToken, stableToken));\n emit log_named_uint(\"slippage stable->coll\", registry.getSlippage(stableToken, collateralToken));\n }\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract StkBnbWBnbLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 2e18;\n\n address stkBnbMarket = 0xAcfbf93d8fD1A9869bAb2328669dDba33296a421;\n address wbnbMarket = 0x3Af258d24EBdC03127ED6cEb8e58cA90835fbca5;\n address stkBnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n address wbnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n\n AlgebraSwapLiquidator liquidator = new AlgebraSwapLiquidator();\n _configurePairAndLiquidator(stkBnbMarket, wbnbMarket, liquidator);\n _fundMarketAndSelf(ICErc20(stkBnbMarket), stkBnbWhale);\n _fundMarketAndSelf(ICErc20(wbnbMarket), wbnbWhale);\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(address(this), depositAmount);\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, depositAmount);\n }\n}\n\ninterface TwoBrl {\n function minter() external view returns (address);\n\n function mint(address payable _to, uint256 _value) external returns (bool);\n}\n\ncontract Jbrl2BrlLeveredPositionTest is LeveredPositionTest {\n IonicComptroller pool;\n ComptrollerFirstExtension asExtension;\n\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1000e18;\n\n address twoBrlMarket = 0xf0a2852958aD041a9Fb35c312605482Ca3Ec17ba; // 2brl as collateral\n address jBrlMarket = 0x82A3103bc306293227B756f7554AfAeE82F8ab7a; // jbrl as borrowable\n address payable twoBrlWhale = payable(address(177)); // empty account\n address jBrlWhale = 0xA0695f78AF837F570bcc50f53e58Cda300798B65; // solidly pair BRZ-JBRL\n\n TwoBrl twoBrl = TwoBrl(ICErc20(twoBrlMarket).underlying());\n vm.prank(twoBrl.minter());\n twoBrl.mint(twoBrlWhale, depositAmount * 100);\n\n _configurePair(twoBrlMarket, jBrlMarket);\n _fundMarketAndSelf(ICErc20(twoBrlMarket), twoBrlWhale);\n _fundMarketAndSelf(ICErc20(jBrlMarket), jBrlWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract BombWbnbLeveredPositionTest is LeveredPositionTest {\n uint256 depositAmount = 100e18;\n address whale = 0xe7B7dF67C1fe053f1C6B965826d3bFF19603c482;\n address wbnbWhale = 0x57E30beb8054B248CE301FeabfD0c74677Fa40f0;\n uint256 ratioOnCreation = 1.0e18;\n uint256 minBorrowNative = 1e17;\n\n function setUp() public fork(BSC_CHAPEL) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n vm.mockCall(\n address(ffd),\n abi.encodeWithSelector(IFeeDistributor.minBorrowEth.selector),\n abi.encode(minBorrowNative)\n );\n\n address xMarket = 0x9B6E1039103812E0dcC1100a158e4a68014b2571; // BOMB\n address yMarket = 0x9dD00920f5B74A31177cbaB834AB0904703c31B1; // WBNB\n\n collateralMarket = ICErc20(xMarket);\n stableMarket = ICErc20(yMarket);\n\n //upgradePoolAndMarkets();\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n vm.startPrank(whale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 1e18, stableToken);\n collateralToken.transfer(address(this), depositAmount);\n vm.stopPrank();\n\n vm.startPrank(wbnbWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 1e18, collateralToken);\n vm.stopPrank();\n }\n\n vm.prank(whale);\n collateralToken.transfer(address(this), depositAmount);\n\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPositionAtRatio(\n collateralMarket,\n stableMarket,\n collateralToken,\n depositAmount,\n ratioOnCreation\n );\n\n maxLevRatio = position.getMaxLeverageRatio();\n minLevRatio = position.getMinLeverageRatio();\n\n vm.label(address(position), \"Levered Position\");\n }\n}\n\ncontract PearlWUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address wusdrMarket = 0x26EA46e975778662f98dAa0E7a12858dA9139262;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address wUsdrWhale = 0x8711a1a52c34EDe8E61eF40496ab2618a8F6EA4B;\n\n _configurePair(lpTokenMarket, wusdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wusdrMarket), wUsdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdrLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 800e9;\n\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n IRedemptionStrategy liquidator = new SolidlySwapLiquidator();\n _configurePairAndLiquidator(usdrMarket, usdcMarket, liquidator);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrDaiUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 2e18;\n\n // LP token underlying 0xBD02973b441Aa83c8EecEA158b98B5984bb1036E\n address lpTokenMarket = 0xBcE30B4D78cEb9a75A1Aa62156529c3592b3F08b;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x85Fa2331040933A02b154579fAbE6A6a5A765279; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrTngblUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.02e18;\n\n // LP token underlying 0x0Edc235693C20943780b76D79DD763236E94C751\n address lpTokenMarket = 0x2E870Aeee3D9d1eA29Ec93d2c0A99A4e0D5EB697;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdaeF32cA8D699015fcFB2884F6902fFCebE51c5b; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWbtcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.000000071325342755e18;\n\n // LP token underlying 0xb95E1C22dd965FafE926b2A793e9D6757b6613F4\n address lpTokenMarket = 0xffc8c8d747E52fAfbf973c64Bab10d38A6902c46;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x39976f6328ebA2a3C860b7DE5cF2c1bB41581FB8; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWethUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.004081e18;\n\n // LP token underlying 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127\n address lpTokenMarket = 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x7D02A8b758791A03319102f81bF61E220F73e43D; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrMaticUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.05e18;\n\n // LP token underlying vAMM-WMATIC/USDR\n address lpTokenMarket = 0xfacEdA4f9731797102f040380aD5e234c92d1942;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdA0AfBeEEBef6dA2F060237D35cab759b99B13B6; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 300e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 700e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashUsdcLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 300e18;\n\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(cashMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroWethAWbtcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xWBTC-WETH05\n address lpTokenMarket = 0xCB1a06eff3459078c26516ae3a1dB44A61D2DbCA;\n address wethMarket = 0x2469B23354cb7cA50b798663Ec5812Bf28d15e9e;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n\n _configurePair(lpTokenMarket, wethMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract DavosUsdcDusdLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 500e18;\n\n address dusdMarket = 0xE70d09dA78900A0429ee70b35200F70A30d7d2B9;\n address usdcMarket = 0x14787e50578d8c606C3d57bDbA53dD65Fd665449;\n address dusdWhale = 0xE69a1876bdACfa7A7a4F6D531BE2FDE843D2165C;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(dusdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(dusdMarket), dusdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e17;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wethWhale = 0x7380511493DD4c2f1dD75E9CCe5bD52C787D4B51;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wethMarket, USDCMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDCMarket), USDCWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wethWhale = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n\n _configurePair(wethMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wbtcWhale = 0x3f3429D28438Cc14133966820b8A9Ea61Cf1D4F0;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n IERC20Upgradeable token = IERC20Upgradeable(ICErc20(wbtcMarket).underlying());\n\n _configurePair(wbtcMarket, USDCMarket);\n\n uint256 allTokens = token.balanceOf(wbtcWhale);\n\n vm.prank(wbtcWhale);\n token.transfer(address(this), allTokens);\n vm.stopPrank();\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wbtcWhale = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wbtcMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wbtcMarket), wbtcWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address usdcMarket = 0xa900A17a49Bc4D442bA7F72c39FA2108865671f0;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n\n {\n IERC20Upgradeable x = IERC20Upgradeable(ICErc20(hyUsdMarket).underlying());\n IERC20Upgradeable y = IERC20Upgradeable(ICErc20(usdcMarket).underlying());\n IERC20Upgradeable[] memory xToYPath = new IERC20Upgradeable[](2);\n IERC20Upgradeable[] memory yToXPath = new IERC20Upgradeable[](2);\n\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n xToYPath[0] = eUSD;\n yToXPath[0] = eUSD;\n xToYPath[1] = y;\n yToXPath[1] = x;\n\n vm.startPrank(registry.owner());\n registry._setOptimalSwapPath(IERC20Upgradeable(x), IERC20Upgradeable(y), xToYPath);\n registry._setOptimalSwapPath(IERC20Upgradeable(y), IERC20Upgradeable(x), yToXPath);\n vm.stopPrank();\n }\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePair(hyUsdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDeUSDLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address eUsdMarket = 0x9c2A4f9c5471fd36bE3BBd8437A33935107215A1;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address eUsdWhale = 0xa9E0588E82E9Ee1440f7e5375970a429D09646c1;\n AerodromeV2Liquidator aerodomeV2Liquidator = AerodromeV2Liquidator(0xD46b85409C43571145206B11D370A62AaeB22475);\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(hyUsdMarket, eUsdMarket, IRedemptionStrategy(address(aerodomeV2Liquidator)));\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(eUsdMarket), eUsdWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract WSuperOETHWETHLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n address wsuperOeth = 0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6;\n address weth = 0x4200000000000000000000000000000000000006;\n\n uint256 depositAmount = 1e18;\n\n address wsuperOethMarket = 0xC462eb5587062e2f2391990b8609D2428d8Cf598;\n address wethMarket = 0x49420311B518f3d0c94e897592014de53831cfA3;\n address wsuperOethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address wethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(wethMarket);\n\n uint256[] memory newSupplyCaps = new uint256[](1);\n newSupplyCaps[0] = 1e36;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(cTokens, newSupplyCaps);\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n vm.prank(registry.owner());\n registry._setWrappedToUnwrapped4626(address(wsuperOeth), address(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3));\n // vm.prank(aerodomeClLiquidator.owner());\n // emit log_named_address(\"wsuperOeth\", address(wsuperOeth));\n // aerodomeClLiquidator.setWrappedToUnwrapped(\n // address(wsuperOeth),\n // 0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3\n // );\n _configurePairAndLiquidator(wsuperOethMarket, wethMarket, IRedemptionStrategy(address(aerodomeClLiquidator)));\n _fundMarketAndSelf(ICErc20(wsuperOethMarket), wsuperOethWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\n/*\ncontract XYLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(X_CHAIN_ID) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address xMarket = 0x...1;\n address yMarket = 0x...2;\n address xWhale = 0x...3;\n address yWhale = 0x...4;\n\n IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(xMarket, yMarket, liquidator);\n _fundMarketAndSelf(ICErc20(xMarket), xWhale);\n _fundMarketAndSelf(ICErc20(yMarket), yWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n*/\n" + }, + "contracts/test/liquidators/IonicLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\nimport { IonicLiquidator, ILiquidator } from \"../../IonicLiquidator.sol\";\nimport { IonicUniV3Liquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport { ICurvePool } from \"../../external/curve/ICurvePool.sol\";\nimport { CurveSwapLiquidatorFunder } from \"../../liquidators/CurveSwapLiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport \"../../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { UpgradesBaseTest } from \"../UpgradesBaseTest.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { ProxyAdmin } from \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\n\ncontract MockRedemptionStrategy is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable,\n uint256,\n bytes memory\n ) external returns (IERC20Upgradeable, uint256) {\n return (IERC20Upgradeable(address(0)), 1);\n }\n\n function name() public pure returns (string memory) {\n return \"MockRedemptionStrategy\";\n }\n}\n\ncontract IonicLiquidatorTest is UpgradesBaseTest {\n ILiquidator liquidator;\n address uniswapRouter;\n address swapRouter;\n IUniswapV3Quoter quoter;\n address usdcWhale;\n address wethWhale;\n address poolAddress;\n address uniV3PooForFlash;\n uint256 usdcMarketIndex;\n uint256 wethMarketIndex;\n\n AuthoritiesRegistry authRegistry;\n ILiquidatorsRegistry liquidatorsRegistry;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == BSC_MAINNET) {\n uniswapRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E;\n } else if (block.chainid == POLYGON_MAINNET) {\n uniswapRouter = 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff;\n swapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n quoter = IUniswapV3Quoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);\n usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD; // aave reserve\n wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n poolAddress = 0x22A705DEC988410A959B8b17C8c23E33c121580b; // Retro stables pool\n uniV3PooForFlash = 0xA374094527e1673A86dE625aa59517c5dE346d32; // usdc-wmatic\n usdcMarketIndex = 3;\n wethMarketIndex = 5;\n } else if (block.chainid == MODE_MAINNET) {\n uniswapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n // uniswapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n // swapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n swapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n //quoter = IUniswapV3Quoter(0x7Fd569b2021850fbA53887dd07736010aCBFc787); // other sup quoter?\n quoter = IUniswapV3Quoter(0x5E6AEbab1AD525f5336Bd12E6847b851531F72ba); // sup quoter\n usdcWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79; // vault\n wethWhale = 0xF4C85269240C1D447309fA602A90ac23F1CB0Dc0;\n poolAddress = 0xFB3323E24743Caf4ADD0fDCCFB268565c0685556;\n //uniV3PooForFlash = 0x293f2B2c17f8cEa4db346D87Ef5712C9dd0491EF; // kim weth-usdc pool\n uniV3PooForFlash = 0x047CF4b081ee80d2928cb2ce3F3C4964e26eB0B9; // kim usdt-usdc pool\n // uniV3PooForFlash = 0xf2e9C024F1C0B7a2a4ea11243C2D86A7b38DD72f; // sup univ2 0x34a1E3Db82f669f8cF88135422AfD80e4f70701A\n usdcMarketIndex = 1;\n wethMarketIndex = 0;\n // weth 0x4200000000000000000000000000000000000006\n // usdc 0xd988097fb8612cc24eeC14542bC03424c656005f\n }\n\n // vm.prank(ap.owner());\n // ap.setAddress(\"IUniswapV2Router02\", uniswapRouter);\n vm.prank(ap.owner());\n ap.setAddress(\"UNISWAP_V3_ROUTER\", uniswapRouter);\n\n authRegistry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n liquidatorsRegistry = ILiquidatorsRegistry(ap.getAddress(\"LiquidatorsRegistry\"));\n liquidator = IonicLiquidator(payable(ap.getAddress(\"IonicLiquidator\")));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(liquidatorsRegistry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function testBsc() public fork(BSC_MAINNET) {\n testUpgrade();\n }\n\n function testPolygon() public fork(POLYGON_MAINNET) {\n testUpgrade();\n }\n\n function testUpgrade() internal {\n // in case these slots start to get used, please redeploy the FSL\n // with a larger storage gap to protect the owner variable of OwnableUpgradeable\n // from being overwritten by the IonicLiquidator storage\n for (uint256 i = 40; i < 51; i++) {\n address atSloti = address(uint160(uint256(vm.load(address(liquidator), bytes32(i)))));\n assertEq(\n atSloti,\n address(0),\n \"replace the FSL proxy/storage contract with a new one before the owner variable is overwritten\"\n );\n }\n }\n\n function testSpecificLiquidation() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0x5834a3AAFA83A53822B313994Bb554d8E8c215dF;\n address debtMarketAddr = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address collateralMarketAddr = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n liquidator = ILiquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars;\n vars.borrower = borrower;\n vars.cErc20 = ICErc20(debtMarketAddr);\n vars.cTokenCollateral = ICErc20(collateralMarketAddr);\n vars.repayAmount = 0x408c7a4d7c4092;\n vars.flashSwapContract = 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc;\n vars.minProfitAmount = 0;\n vars.redemptionStrategies = new IRedemptionStrategy[](1);\n vars.strategyData = new bytes[](1);\n vars.debtFundingStrategies = new IFundsConversionStrategy[](0);\n vars.debtFundingStrategiesData = new bytes[](0);\n\n vars.redemptionStrategies[0] = IFundsConversionStrategy(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vars.strategyData[\n 0\n ] = hex\"0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8\";\n\n liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n }\n\n function testWithdrawalLiquidator() public debuggingOnly fork(MODE_MAINNET) {\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.prank(0x4200000000000000000000000000000000000016);\n (bool success, ) = address(liquidatorV3).call{ value: 1 ether }(\"\");\n require(success, \"transfer of funds failed\");\n\n uint256 beforeBalance = liquidatorV3.owner().balance;\n\n vm.prank(liquidatorV3.owner());\n liquidatorV3.withdrawAll();\n\n emit log_named_uint(\"balance of liquidator\", liquidatorV3.owner().balance);\n\n assertEq(liquidatorV3.owner().balance, beforeBalance + 1 ether);\n assertEq(address(liquidatorV3).balance, 0);\n }\n\n function testLiquidateAfterUpgradeLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(1e18);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: 0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n function testLiquidateAfterUpgradeLiquidatorExpressRelay() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n address expressRelay = makeAddr(\"expressRelay\");\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(95e16);\n liquidatorV3.setExpressRelay(expressRelay);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n address borrower = address(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: borrower,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(false) \n );\n vm.expectRevert(\"invalid liquidation\");\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(true) \n );\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n // TODO test with marginal shortfall for liquidation penalty errors\n function _testLiquidatorLiquidate(address contractForFlashSwap) internal {\n IonicComptroller pool = IonicComptroller(poolAddress);\n // _upgradePoolWithExtension(Unitroller(payable(poolAddress)));\n //upgradeRegistry();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.prank(pool.admin());\n pool._setBorrowCapForCollateral(address(usdcMarket), address(wethMarket), 1e36);\n }\n\n {\n vm.prank(pool.admin());\n pool._borrowCapWhitelist(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038, address(this), true);\n }\n\n {\n vm.prank(wethWhale);\n weth.transfer(address(this), 0.1e18);\n\n weth.approve(address(wethMarket), 1e36);\n require(wethMarket.mint(0.1e18) == 0, \"mint weth failed\");\n pool.enterMarkets(asArray(address(usdcMarket), address(wethMarket)));\n }\n\n {\n vm.startPrank(usdcWhale);\n usdc.approve(address(usdcMarket), 2e36);\n require(usdcMarket.mint(70e6) == 0, \"mint usdc failed\");\n vm.stopPrank();\n }\n\n {\n require(usdcMarket.borrow(50e6) == 0, \"borrow usdc failed\");\n\n // the collateral prices change\n BasePriceOracle mpo = pool.oracle();\n uint256 priceCollateral = mpo.getUnderlyingPrice(wethMarket);\n vm.mockCall(\n address(mpo),\n abi.encodeWithSelector(mpo.getUnderlyingPrice.selector, wethMarket),\n abi.encode(priceCollateral / 10)\n );\n }\n\n (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) = liquidatorsRegistry\n .getRedemptionStrategies(weth, usdc);\n\n uint256 seizedAmount = liquidator.safeLiquidateToTokensWithFlashLoan(\n ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: address(this),\n repayAmount: 10e6,\n cErc20: usdcMarket,\n cTokenCollateral: wethMarket,\n flashSwapContract: contractForFlashSwap,\n minProfitAmount: 6,\n redemptionStrategies: strategies,\n strategyData: strategiesData,\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n })\n );\n\n emit log_named_uint(\"seized amount\", seizedAmount);\n require(seizedAmount > 0, \"didn't seize any assets\");\n }\n}\n" + }, + "contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IonicUniV3Liquidator, IUniswapV3Pool, ILiquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\nimport { IUniswapV3Factory } from \"../../external/uniswap/IUniswapV3Factory.sol\";\nimport { UniswapV2LiquidatorFunder } from \"../../liquidators/UniswapV2LiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { KimUniV2Liquidator } from \"../../liquidators/KimUniV2Liquidator.sol\";\n\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport \"./IonicLiquidatorTest.sol\";\n\ncontract UniswapV3LiquidatorTest is IonicLiquidatorTest {\n function testPolygonUniV3LiquidatorLiquidate() public fork(POLYGON_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeUniV3LiquidatorLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = new UniswapV3LiquidatorFunder();\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n vm.prank(OwnableUpgradeable(address(liquidator)).owner());\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeKimUniV2Liquidator() public fork(MODE_MAINNET) {\n IonicLiquidator _liquidator = new IonicLiquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), ap.getAddress(\"IUniswapV2Router02\"), 30);\n liquidator = _liquidator;\n liquidator.setPoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n liquidator.setHealthFactorThreshold(1e18);\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = KimUniV2Liquidator(0x6aC17D406a820fa464fFdc0940FCa7E60b3b36B7);\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testUniV3PoolForFee() public debuggingOnly fork(MODE_MAINNET) {\n address wethAddr = 0x4200000000000000000000000000000000000006;\n address usdcAddr = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcAddr);\n IERC20Upgradeable weth = IERC20Upgradeable(wethAddr);\n\n IUniswapV2Router02 kimRouter = IUniswapV2Router02(0x5D61c537393cf21893BE619E36fC94cd73C77DD3);\n address factoryAddress;\n //factory = kimRouter.factory();\n factoryAddress = 0xC33Ce0058004d44E7e1F366E5797A578fDF38584;\n IUniswapV3Factory factory = IUniswapV3Factory(factoryAddress);\n address pool;\n\n uint256 feeConfig = liquidatorsRegistry.uniswapV3Fees(usdc, weth);\n emit log_named_uint(\"feeConfig\", feeConfig);\n\n if (feeConfig == 0) {\n pool = factory.getPool(wethAddr, usdcAddr, uint24(feeConfig));\n emit log_named_address(\"Pool at fee 0\", pool);\n }\n\n pool = factory.getPool(wethAddr, usdcAddr, 500);\n emit log_named_address(\"Pool at fee 500\", pool);\n }\n}\n" + }, + "contracts/test/LiquidityMining.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { FlywheelStaticRewards } from \"../ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { IonicFlywheelLensRouter } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LiquidityMiningTest is BaseTest {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n CErc20Delegate cErc20Delegate;\n ICErc20 cErc20;\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheel flywheel;\n FlywheelStaticRewards rewards;\n IonicFlywheelLensRouter flywheelClaimer;\n\n address user = address(1337);\n\n uint8 baseDecimal;\n uint8 rewardDecimal;\n\n address[] markets;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts(uint8 _baseDecimal, uint8 _rewardDecimal) public {\n baseDecimal = _baseDecimal;\n rewardDecimal = _rewardDecimal;\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", baseDecimal);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", rewardDecimal);\n interestModel = new JumpRateModel(2343665, 1 * 10**baseDecimal, 1 * 10**baseDecimal, 4 * 10**baseDecimal, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1 * 10**(baseDecimal - 2));\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n cErc20Delegate = new CErc20Delegate();\n // set the new delegate as the latest\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), abi.encode(address(0)));\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n }\n\n function setUpPoolAndMarket() public {\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, user, poolAuth.BORROWER_ROLE(), true);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"CUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n cErc20 = allMarkets[allMarkets.length - 1];\n }\n\n function setUpFlywheel() public {\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, FlywheelStaticRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n rewards = new FlywheelStaticRewards(IonicFlywheelCore(address(flywheel)), address(this), Authority(address(0)));\n flywheel.setFlywheelRewards(rewards);\n\n flywheelClaimer = new IonicFlywheelLensRouter(poolDirectory);\n\n flywheel.addStrategyForRewards(ERC20(address(cErc20)));\n\n // add flywheel as rewardsDistributor to call flywheelPreBorrowAction / flywheelPreSupplyAction\n require(comptroller._addRewardsDistributor(address(flywheel)) == 0);\n\n // seed rewards to flywheel\n rewardToken.mint(address(rewards), 100 * 10**rewardDecimal);\n\n // Start reward distribution at 1 token per second\n rewards.setRewardsInfo(\n ERC20(address(cErc20)),\n FlywheelStaticRewards.RewardsInfo({ rewardsPerSecond: uint224(1 * 10**rewardDecimal), rewardsEndTimestamp: 0 })\n );\n\n // preparation for a later call\n flywheelsToClaim.push(IonicFlywheelCore(address(flywheel)));\n }\n\n function _initialize(uint8 _baseDecimal, uint8 _rewardDecimal) internal {\n setUpBaseContracts(_baseDecimal, _rewardDecimal);\n setUpPoolAndMarket();\n setUpFlywheel();\n deposit(1 * 10**_baseDecimal);\n vm.warp(block.timestamp + 1);\n }\n\n function deposit(uint256 _amount) public {\n underlyingToken.mint(user, _amount);\n vm.startPrank(user);\n underlyingToken.approve(address(cErc20), _amount);\n comptroller.enterMarkets(markets);\n cErc20.mint(_amount);\n vm.stopPrank();\n }\n\n function _testIntegration() internal {\n uint256 percentFee = flywheel.performanceFee();\n uint224 percent100 = 100e16; //flywheel.ONE();\n\n // store expected rewards per token (1 token per second over total supply)\n uint256 rewardsPerTokenPlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerTokenForFee = (rewardsPerTokenPlusFee * percentFee) / percent100;\n uint256 rewardsPerToken = rewardsPerTokenPlusFee - rewardsPerTokenForFee;\n\n // store expected user rewards (user balance times reward per second over 1 token)\n uint256 userRewards = (rewardsPerToken * cErc20.balanceOf(user)) / (1 * 10**baseDecimal);\n\n ERC20 asErc20 = ERC20(address(cErc20));\n // accrue rewards and check against expected\n assertEq(flywheel.accrue(asErc20, user), userRewards, \"!accrue amount\");\n\n // check market index\n (uint224 index, ) = flywheel.strategyState(asErc20);\n assertEq(index, 10**rewardDecimal + rewardsPerToken, \"!index\");\n\n // claim and check user balance\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n assertEq(rewardToken.balanceOf(user), userRewards, \"!user rewards\");\n\n // mint more tokens by user and rerun test\n deposit(1 * 10**baseDecimal);\n\n // for next test, advance 10 seconds instead of 1 (multiply expectations by 10)\n vm.warp(block.timestamp + 10);\n\n uint256 rewardsPerToken2PlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerToken2ForFee = (rewardsPerToken2PlusFee * percentFee) / percent100;\n uint256 rewardsPerToken2 = rewardsPerToken2PlusFee - rewardsPerToken2ForFee;\n\n uint256 userRewards2 = (10 * (rewardsPerToken2 * cErc20.balanceOf(user))) / (1 * 10**baseDecimal);\n\n // accrue all unclaimed rewards and claim them\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n\n emit log_named_uint(\"userRewards\", userRewards);\n emit log_named_uint(\"userRewards2\", userRewards2);\n // user balance should accumulate from both rewards\n assertEq(rewardToken.balanceOf(user), userRewards + userRewards2, \"balance mismatch\");\n }\n\n function testIntegrationRewardStandard(uint8 i, uint8 j) public {\n vm.assume(i > 1);\n vm.assume(j > 1);\n vm.assume(i < 19);\n vm.assume(j < 19);\n\n _initialize(i, j);\n _testIntegration();\n }\n}\n" + }, + "contracts/test/MaxBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./helpers/WithPool.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract MockAsset is MockERC20 {\n constructor() MockERC20(\"test\", \"test\", 8) {}\n\n function deposit() external payable {}\n}\n\ncontract MaxBorrowTest is WithPool {\n address usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD;\n address daiWhale = 0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B;\n\n struct LiquidationData {\n address[] cTokens;\n ICErc20[] allMarkets;\n MockAsset usdc;\n MockAsset dai;\n }\n\n function afterForkSetUp() internal override {\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n if (block.chainid == POLYGON_MAINNET) {\n vm.prank(0x369582d2010B6eD950B571F4101e3bB9b554876F); // SAND/WMATIC\n MockERC20(address(underlyingToken)).transfer(address(this), 100e18);\n setUpPool(\"polygon-test\", false, 0.1e18, 1.1e18);\n } else if (block.chainid == BSC_MAINNET) {\n deal(address(underlyingToken), address(this), 100e18);\n setUpPool(\"bsc-test\", false, 0.1e18, 1.1e18);\n }\n }\n\n // TODO redeploy to polygon to fix\n function testMaxBorrow() public fork(POLYGON_MAINNET) {\n PoolLensSecondary poolLensSecondary = new PoolLensSecondary();\n poolLensSecondary.initialize(poolDirectory);\n\n LiquidationData memory vars;\n vm.roll(1);\n vars.usdc = MockAsset(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n vars.dai = MockAsset(0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063);\n\n deployCErc20Delegate(address(vars.usdc), \"USDC\", \"usdc\", 0.9e18);\n deployCErc20Delegate(address(vars.dai), \"DAI\", \"dai\", 0.9e18);\n\n vars.allMarkets = comptroller.getAllMarkets();\n\n CErc20Delegate cToken = CErc20Delegate(address(vars.allMarkets[0]));\n\n CErc20Delegate cDaiToken = CErc20Delegate(address(vars.allMarkets[1]));\n\n vars.cTokens = new address[](1);\n\n address accountOne = address(1);\n PoolRolesAuthority pra = ionicAdmin.authoritiesRegistry().poolsAuthorities(address(comptroller));\n\n vm.startPrank(pra.owner());\n pra.setUserRole(accountOne, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n\n vm.prank(usdcWhale);\n MockERC20(address(vars.usdc)).transfer(accountOne, 10000e6);\n\n vm.prank(daiWhale);\n MockERC20(address(vars.dai)).transfer(accountOne, 10000e18);\n\n // Account One Supply\n {\n emit log(\"Account One Supply\");\n vm.startPrank(accountOne);\n vars.usdc.approve(address(cToken), 1e36);\n cToken.mint(1e6);\n vars.cTokens[0] = address(cToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vars.dai.approve(address(cDaiToken), 1e36);\n cDaiToken.mint(1e18);\n vars.cTokens[0] = address(cDaiToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vm.stopPrank();\n assertEq(cToken.totalSupply(), 1e6 * 5);\n assertEq(cDaiToken.totalSupply(), 1e18 * 5);\n\n uint256 maxBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n uint256 maxDaiBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cDaiToken)));\n assertApproxEqAbs((maxBorrow * 1e18) / 10**cToken.decimals(), maxDaiBorrow, uint256(1e16), \"!max borrow\");\n }\n\n // borrow cap for collateral test\n {\n vm.prank(comptroller.admin());\n comptroller._setBorrowCapForCollateral(address(cToken), address(cDaiToken), 0.5e6);\n }\n\n uint256 maxBorrowAfterBorrowCap = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertApproxEqAbs(maxBorrowAfterBorrowCap, 0.5e6, uint256(1e5), \"!max borrow\");\n\n // blacklist\n {\n vm.prank(comptroller.admin());\n comptroller._blacklistBorrowingAgainstCollateral(address(cToken), address(cDaiToken), true);\n }\n\n uint256 maxBorrowAfterBlacklist = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertEq(maxBorrowAfterBlacklist, 0, \"!blacklist\");\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapPerCollateral() public debuggingOnly forkAtBlock(BSC_MAINNET, 23761190) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n\n address poolAddress = jFiatPoolAddress;\n Comptroller pool = Comptroller(poolAddress);\n\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(poolAddress);\n address[] memory borrowers = asExtension.getAllBorrowers();\n address someBorrower = borrowers[1];\n\n ICErc20[] memory markets = asExtension.getAllMarkets();\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = markets[i];\n uint256 borrowed = market.borrowBalanceCurrent(someBorrower);\n if (borrowed > 0) {\n emit log(\"borrower has borrowed\");\n emit log_uint(borrowed);\n emit log(\"from market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n\n uint256 collateral = market.balanceOf(someBorrower);\n if (collateral > 0) {\n emit log(\"has collateral\");\n emit log_uint(collateral);\n emit log(\"in market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n }\n\n ICErc20 marketToBorrow = markets[0];\n ICErc20 cappedCollateralMarket = markets[6];\n uint256 borrowAmount = marketToBorrow.borrowBalanceCurrent(someBorrower);\n\n {\n (uint256 errBefore, , uint256 liquidityBefore, uint256 shortfallBefore) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errBefore\");\n emit log_uint(errBefore);\n emit log(\"liquidityBefore\");\n emit log_uint(liquidityBefore);\n emit log(\"shortfallBefore\");\n emit log_uint(shortfallBefore);\n\n assertGt(liquidityBefore, 0, \"expected positive liquidity\");\n }\n\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(marketToBorrow), address(cappedCollateralMarket), 1);\n emit log(\"\");\n\n (uint256 errAfter, , uint256 liquidityAfter, uint256 shortfallAfter) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errAfter\");\n emit log_uint(errAfter);\n emit log(\"liquidityAfter\");\n emit log_uint(liquidityAfter);\n emit log(\"shortfallAfter\");\n emit log_uint(shortfallAfter);\n\n assertGt(shortfallAfter, 0, \"expected some shortfall\");\n }\n}\n" + }, + "contracts/test/MinBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract MinBorrowTest is BaseTest {\n FeeDistributor ffd;\n\n function afterForkSetUp() internal override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testMinBorrow() public fork(BSC_MAINNET) {\n IERC20Upgradeable usdc = IERC20Upgradeable(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);\n IERC20Upgradeable busd = IERC20Upgradeable(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);\n\n ICErc20 usdcMarket = ICErc20(0x16B8da195CdC7F380B333bf6cF2f0f33c1061755);\n ICErc20 busdMarket = ICErc20(0x3BCb7dbBe729B24bE6c660B3e8ADD1Cb352e371D);\n IonicComptroller comptroller = usdcMarket.comptroller();\n deal(address(usdc), address(this), 10000e18);\n deal(address(busd), address(1), 10000e18);\n\n usdc.approve(address(usdcMarket), 1e36);\n usdcMarket.mint(1000e18);\n\n vm.startPrank(address(1));\n busd.approve(address(busdMarket), 1e36);\n busdMarket.mint(1000e18);\n vm.stopPrank();\n\n // the 0 liquidity base min borrow amount\n uint256 baseMinBorrowEth = ffd.minBorrowEth();\n\n address[] memory cTokens = new address[](2);\n cTokens[0] = address(usdcMarket);\n cTokens[1] = address(busdMarket);\n comptroller.enterMarkets(cTokens);\n\n uint256 minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, baseMinBorrowEth, \"!minBorrowEth for default min borrow eth\");\n\n busdMarket.borrow(300e18);\n\n minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, 0, \"!minBorrowEth after borrowing less amount than min amount\");\n }\n}\n" + }, + "contracts/test/PermissionedLiquidationsMarketTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ILiquidator } from \"../ILiquidator.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../liquidators/IFundsConversionStrategy.sol\";\n\ncontract PermissionedLiquidationsMarketTest is MarketsTest {\n ICErc20 wethMarket;\n ICErc20 usdtMarket;\n\n ICErc20 wethNativeMarket;\n ICErc20 usdcNativeMarket;\n ICErc20 usdtNativeMarket;\n ICErc20 modeNativeMarket;\n\n IonicComptroller pool;\n PoolLens lens;\n address borrower;\n address liquidator;\n IonicUniV3Liquidator uniV3liquidator;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n\n wethNativeMarket = ICErc20(0xDb8eE6D1114021A94A045956BBeeCF35d13a30F2);\n usdcNativeMarket = ICErc20(0xc53edEafb6D502DAEC5A7015D67936CEa0cD0F52);\n usdtNativeMarket = ICErc20(0x3120B4907851cc9D780eef9aF88ae4d5360175Fd);\n modeNativeMarket = ICErc20(0x4341620757Bee7EB4553912FaFC963e59C949147);\n\n pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n borrower = 0xcE6cEFa163468F730206688665516952bcf83B74;\n liquidator = 0xE000008459b74a91e306a47C808061DFA372000E;\n uniV3liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n vm.prank(ap.owner());\n ap.setAddress(\"PoolLens\", address(lens));\n }\n\n function testLiquidateNoThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateThresholdActive() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n vm.expectRevert(\"Health factor not low enough for non-permissioned liquidations\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n vm.stopPrank();\n }\n\n function testLiquidateHealthFactorLowerThanThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n // fast forward until position unhealthy enough\n vm.roll(block.number + 10000000);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPythShouldRevert() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPyth() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.mockCall(\n address(uniV3liquidator.expressRelay()),\n abi.encodeWithSelector(\n bytes4(keccak256(\"isPermissioned(address,bytes)\")),\n address(uniV3liquidator),\n abi.encode(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6)\n ),\n abi.encode(false)\n );\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testPostUpgradeLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0xE10B38bbe359656066b3c4648DfEa7018711c35f;\n PoolLens.PoolAsset[] memory assets = lens.getPoolAssetsByUser(pool, borrower);\n\n for (uint i; i < assets.length; i++) {\n emit log_named_string(\"Asset Named\", assets[i].underlyingName);\n emit log_named_uint(\"Supply Balance\", assets[i].supplyBalance);\n emit log_named_uint(\"Borrow Balance\", assets[i].borrowBalance);\n emit log_named_uint(\"Liquidity\", assets[i].liquidity);\n emit log(\"----------------------------------------------------\");\n }\n\n emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n\n // vm.startPrank(0x344d9C4f488bb5519D390304457D64034618145C);\n\n // ERC20(0xd988097fb8612cc24eeC14542bC03424c656005f).approve(address(uniV3liquidator), 4000);\n\n // // ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n // // borrower: borrower,\n // // repayAmount: 4000,\n // // cErc20: ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n // // cTokenCollateral: wethMarket,\n // // flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n // // minProfitAmount: 0,\n // // redemptionStrategies: new IRedemptionStrategy[](0),\n // // strategyData: new bytes[](0),\n // // debtFundingStrategies: new IFundsConversionStrategy[](0),\n // // debtFundingStrategiesData: new bytes[](0)\n // // });\n // // uniV3liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n\n // uniV3liquidator.safeLiquidate(borrower, 4000, ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038), wethMarket, 0);\n\n // vm.stopPrank();\n\n // emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n }\n\n function testUpgradeNativeMarket() public debuggingOnly fork(MODE_MAINNET) {\n _upgradeMarket(wethNativeMarket);\n _upgradeMarket(usdcNativeMarket);\n _upgradeMarket(usdtNativeMarket);\n _upgradeMarket(modeNativeMarket);\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n }\n\n struct CErc20StorageStruct {\n address ionicAdmin;\n string name;\n string symbol;\n uint8 decimals;\n address comptroller;\n address interestRateModel;\n uint256 adminFeeMantissa;\n uint256 ionicFeeMantissa;\n uint256 reserveFactorMantissa;\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalAdminFees;\n uint256 totalIonicFees;\n uint256 totalSupply;\n uint256 protocolSeizeShareMantissa;\n uint256 feeSeizeShareMantissa;\n address underlying;\n address ap;\n uint256 cash;\n uint256 totalBorrowsCurrent;\n uint256 balanceOfUnderlying;\n uint256 borrowBalanceCurrent;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 exchangeRateCurrent;\n uint256 totalUnderlyingSupplied;\n uint256 allowance;\n uint256 balanceOf;\n }\n\n function testStorageLayoutSafe() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n // Capture storage layout before upgrade\n CErc20StorageStruct memory storageDataBefore;\n CErc20StorageStruct memory storageDataAfter;\n\n address owner = 0xbF86588d7e20502f1b250561da775343Dfdb3250; // Use a valid spender address as needed\n\n storageDataBefore.ionicAdmin = wethMarket.ionicAdmin();\n storageDataBefore.name = wethMarket.name();\n storageDataBefore.symbol = wethMarket.symbol();\n storageDataBefore.decimals = wethMarket.decimals();\n storageDataBefore.comptroller = address(wethMarket.comptroller());\n storageDataBefore.interestRateModel = address(wethMarket.interestRateModel());\n storageDataBefore.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataBefore.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataBefore.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataBefore.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataBefore.borrowIndex = wethMarket.borrowIndex();\n storageDataBefore.totalBorrows = wethMarket.totalBorrows();\n storageDataBefore.totalReserves = wethMarket.totalReserves();\n storageDataBefore.totalAdminFees = wethMarket.totalAdminFees();\n storageDataBefore.totalIonicFees = wethMarket.totalIonicFees();\n storageDataBefore.totalSupply = wethMarket.totalSupply();\n storageDataBefore.underlying = wethMarket.underlying();\n storageDataBefore.cash = wethMarket.getCash();\n storageDataBefore.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataBefore.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataBefore.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataBefore.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataBefore.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataBefore.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataBefore.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataBefore.balanceOf = wethMarket.balanceOf(owner);\n storageDataBefore.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataBefore.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n // Upgrade the market\n _upgradeMarket(wethMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n storageDataAfter.ionicAdmin = wethMarket.ionicAdmin();\n storageDataAfter.name = wethMarket.name();\n storageDataAfter.symbol = wethMarket.symbol();\n storageDataAfter.decimals = wethMarket.decimals();\n storageDataAfter.comptroller = address(wethMarket.comptroller());\n storageDataAfter.interestRateModel = address(wethMarket.interestRateModel());\n storageDataAfter.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataAfter.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataAfter.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataAfter.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataAfter.borrowIndex = wethMarket.borrowIndex();\n storageDataAfter.totalBorrows = wethMarket.totalBorrows();\n storageDataAfter.totalReserves = wethMarket.totalReserves();\n storageDataAfter.totalAdminFees = wethMarket.totalAdminFees();\n storageDataAfter.totalIonicFees = wethMarket.totalIonicFees();\n storageDataAfter.totalSupply = wethMarket.totalSupply();\n storageDataAfter.underlying = wethMarket.underlying();\n storageDataAfter.cash = wethMarket.getCash();\n storageDataAfter.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataAfter.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataAfter.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataAfter.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataAfter.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataAfter.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataAfter.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataAfter.balanceOf = wethMarket.balanceOf(owner);\n storageDataAfter.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataAfter.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n emit log_named_address(\"Storage ionicAdmin (before)\", storageDataBefore.ionicAdmin);\n emit log_named_address(\"Storage ionicAdmin (after)\", storageDataAfter.ionicAdmin);\n\n emit log_named_string(\"Storage name (before)\", storageDataBefore.name);\n emit log_named_string(\"Storage name (after)\", storageDataAfter.name);\n\n emit log_named_string(\"Storage symbol (before)\", storageDataBefore.symbol);\n emit log_named_string(\"Storage symbol (after)\", storageDataAfter.symbol);\n\n emit log_named_uint(\"Storage decimals (before)\", storageDataBefore.decimals);\n emit log_named_uint(\"Storage decimals (after)\", storageDataAfter.decimals);\n\n emit log_named_address(\"Storage comptroller (before)\", storageDataBefore.comptroller);\n emit log_named_address(\"Storage comptroller (after)\", storageDataAfter.comptroller);\n\n emit log_named_address(\"Storage interestRateModel (before)\", storageDataBefore.interestRateModel);\n emit log_named_address(\"Storage interestRateModel (after)\", storageDataAfter.interestRateModel);\n\n emit log_named_uint(\"Storage adminFeeMantissa (before)\", storageDataBefore.adminFeeMantissa);\n emit log_named_uint(\"Storage adminFeeMantissa (after)\", storageDataAfter.adminFeeMantissa);\n\n emit log_named_uint(\"Storage ionicFeeMantissa (before)\", storageDataBefore.ionicFeeMantissa);\n emit log_named_uint(\"Storage ionicFeeMantissa (after)\", storageDataAfter.ionicFeeMantissa);\n\n emit log_named_uint(\"Storage reserveFactorMantissa (before)\", storageDataBefore.reserveFactorMantissa);\n emit log_named_uint(\"Storage reserveFactorMantissa (after)\", storageDataAfter.reserveFactorMantissa);\n\n emit log_named_uint(\"Storage accrualBlockNumber (before)\", storageDataBefore.accrualBlockNumber);\n emit log_named_uint(\"Storage accrualBlockNumber (after)\", storageDataAfter.accrualBlockNumber);\n\n emit log_named_uint(\"Storage borrowIndex (before)\", storageDataBefore.borrowIndex);\n emit log_named_uint(\"Storage borrowIndex (after)\", storageDataAfter.borrowIndex);\n\n emit log_named_uint(\"Storage totalBorrows (before)\", storageDataBefore.totalBorrows);\n emit log_named_uint(\"Storage totalBorrows (after)\", storageDataAfter.totalBorrows);\n\n emit log_named_uint(\"Storage totalReserves (before)\", storageDataBefore.totalReserves);\n emit log_named_uint(\"Storage totalReserves (after)\", storageDataAfter.totalReserves);\n\n emit log_named_uint(\"Storage totalAdminFees (before)\", storageDataBefore.totalAdminFees);\n emit log_named_uint(\"Storage totalAdminFees (after)\", storageDataAfter.totalAdminFees);\n\n emit log_named_uint(\"Storage totalIonicFees (before)\", storageDataBefore.totalIonicFees);\n emit log_named_uint(\"Storage totalIonicFees (after)\", storageDataAfter.totalIonicFees);\n\n emit log_named_uint(\"Storage totalSupply (before)\", storageDataBefore.totalSupply);\n emit log_named_uint(\"Storage totalSupply (after)\", storageDataAfter.totalSupply);\n\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (before)\", storageDataBefore.protocolSeizeShareMantissa);\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (after)\", storageDataAfter.protocolSeizeShareMantissa);\n\n emit log_named_uint(\"Storage feeSeizeShareMantissa (before)\", storageDataBefore.feeSeizeShareMantissa);\n emit log_named_uint(\"Storage feeSeizeShareMantissa (after)\", storageDataAfter.feeSeizeShareMantissa);\n\n emit log_named_address(\"Storage underlying (before)\", storageDataBefore.underlying);\n emit log_named_address(\"Storage underlying (after)\", storageDataAfter.underlying);\n\n emit log_named_uint(\"Storage cash (before)\", storageDataBefore.cash);\n emit log_named_uint(\"Storage cash (after)\", storageDataAfter.cash);\n\n emit log_named_uint(\"Storage totalBorrowsCurrent (before)\", storageDataBefore.totalBorrowsCurrent);\n emit log_named_uint(\"Storage totalBorrowsCurrent (after)\", storageDataAfter.totalBorrowsCurrent);\n\n emit log_named_uint(\"Storage balanceOfUnderlying (before)\", storageDataBefore.balanceOfUnderlying);\n emit log_named_uint(\"Storage balanceOfUnderlying (after)\", storageDataAfter.balanceOfUnderlying);\n\n emit log_named_uint(\"Storage borrowBalanceCurrent (before)\", storageDataBefore.borrowBalanceCurrent);\n emit log_named_uint(\"Storage borrowBalanceCurrent (after)\", storageDataAfter.borrowBalanceCurrent);\n\n emit log_named_uint(\"Storage supplyRatePerBlock (before)\", storageDataBefore.supplyRatePerBlock);\n emit log_named_uint(\"Storage supplyRatePerBlock (after)\", storageDataAfter.supplyRatePerBlock);\n\n emit log_named_uint(\"Storage borrowRatePerBlock (before)\", storageDataBefore.borrowRatePerBlock);\n emit log_named_uint(\"Storage borrowRatePerBlock (after)\", storageDataAfter.borrowRatePerBlock);\n\n emit log_named_uint(\"Storage exchangeRateCurrent (before)\", storageDataBefore.exchangeRateCurrent);\n emit log_named_uint(\"Storage exchangeRateCurrent (after)\", storageDataAfter.exchangeRateCurrent);\n\n emit log_named_uint(\"Storage totalUnderlyingSupplied (before)\", storageDataBefore.totalUnderlyingSupplied);\n emit log_named_uint(\"Storage totalUnderlyingSupplied (after)\", storageDataAfter.totalUnderlyingSupplied);\n\n emit log_named_uint(\"Storage allowance (before)\", storageDataBefore.allowance);\n emit log_named_uint(\"Storage allowance (after)\", storageDataAfter.allowance);\n\n emit log_named_uint(\"Storage balanceOf (before)\", storageDataBefore.balanceOf);\n emit log_named_uint(\"Storage balanceOf (after)\", storageDataAfter.balanceOf);\n\n emit log_named_address(\"Storage ap (before)\", storageDataBefore.ap);\n emit log_named_address(\"Storage ap (after)\", storageDataAfter.ap);\n\n assertEq(storageDataBefore.ionicAdmin, storageDataAfter.ionicAdmin, \"Mismatch in ionicAdmin\");\n assertEq(storageDataBefore.name, storageDataAfter.name, \"Mismatch in name\");\n assertEq(storageDataBefore.symbol, storageDataAfter.symbol, \"Mismatch in symbol\");\n assertEq(storageDataBefore.decimals, storageDataAfter.decimals, \"Mismatch in decimals\");\n assertEq(storageDataBefore.comptroller, storageDataAfter.comptroller, \"Mismatch in comptroller\");\n assertEq(storageDataBefore.interestRateModel, storageDataAfter.interestRateModel, \"Mismatch in interestRateModel\");\n assertEq(storageDataBefore.adminFeeMantissa, storageDataAfter.adminFeeMantissa, \"Mismatch in adminFeeMantissa\");\n assertEq(storageDataBefore.ionicFeeMantissa, storageDataAfter.ionicFeeMantissa, \"Mismatch in ionicFeeMantissa\");\n assertEq(\n storageDataBefore.reserveFactorMantissa,\n storageDataAfter.reserveFactorMantissa,\n \"Mismatch in reserveFactorMantissa\"\n );\n assertEq(\n storageDataBefore.accrualBlockNumber,\n storageDataAfter.accrualBlockNumber,\n \"Mismatch in accrualBlockNumber\"\n );\n assertEq(storageDataBefore.borrowIndex, storageDataAfter.borrowIndex, \"Mismatch in borrowIndex\");\n assertEq(storageDataBefore.totalBorrows, storageDataAfter.totalBorrows, \"Mismatch in totalBorrows\");\n assertEq(storageDataBefore.totalReserves, storageDataAfter.totalReserves, \"Mismatch in totalReserves\");\n assertEq(storageDataBefore.totalAdminFees, storageDataAfter.totalAdminFees, \"Mismatch in totalAdminFees\");\n assertEq(storageDataBefore.totalIonicFees, storageDataAfter.totalIonicFees, \"Mismatch in totalIonicFees\");\n assertEq(storageDataBefore.totalSupply, storageDataAfter.totalSupply, \"Mismatch in totalSupply\");\n assertEq(storageDataBefore.underlying, storageDataAfter.underlying, \"Mismatch in underlying\");\n assertEq(storageDataBefore.cash, storageDataAfter.cash, \"Mismatch in cash\");\n assertEq(\n storageDataBefore.totalBorrowsCurrent,\n storageDataAfter.totalBorrowsCurrent,\n \"Mismatch in totalBorrowsCurrent\"\n );\n assertEq(\n storageDataBefore.balanceOfUnderlying,\n storageDataAfter.balanceOfUnderlying,\n \"Mismatch in balanceOfUnderlying\"\n );\n assertEq(\n storageDataBefore.borrowBalanceCurrent,\n storageDataAfter.borrowBalanceCurrent,\n \"Mismatch in borrowBalanceCurrent\"\n );\n assertEq(\n storageDataBefore.supplyRatePerBlock,\n storageDataAfter.supplyRatePerBlock,\n \"Mismatch in supplyRatePerBlock\"\n );\n assertEq(\n storageDataBefore.borrowRatePerBlock,\n storageDataAfter.borrowRatePerBlock,\n \"Mismatch in borrowRatePerBlock\"\n );\n assertEq(\n storageDataBefore.exchangeRateCurrent,\n storageDataAfter.exchangeRateCurrent,\n \"Mismatch in exchangeRateCurrent\"\n );\n assertEq(\n storageDataBefore.totalUnderlyingSupplied,\n storageDataAfter.totalUnderlyingSupplied,\n \"Mismatch in totalUnderlyingSupplied\"\n );\n assertEq(storageDataBefore.balanceOf, storageDataAfter.balanceOf, \"Mismatch in balanceOf\");\n assertEq(\n storageDataBefore.protocolSeizeShareMantissa,\n storageDataAfter.protocolSeizeShareMantissa,\n \"Mismatch in protocolSeizeShareMantissa\"\n );\n assertEq(\n storageDataBefore.feeSeizeShareMantissa,\n storageDataAfter.feeSeizeShareMantissa,\n \"Mismatch in feeSeizeShareMantissa\"\n );\n }\n\n function testCurrentMarkets() public debuggingOnly forkAtBlock(MODE_MAINNET, 10785800) {\n address[] memory ionAddresses = new address[](10);\n\n _upgradeMarket(wethMarket);\n\n ionAddresses[0] = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n ionAddresses[1] = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n ionAddresses[2] = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n ionAddresses[3] = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n ionAddresses[4] = 0x59e710215d45F584f44c0FEe83DA6d43D762D857;\n ionAddresses[5] = 0x959FA710CCBb22c7Ce1e59Da82A247e686629310;\n ionAddresses[6] = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ionAddresses[7] = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18;\n ionAddresses[8] = 0x9a9072302B775FfBd3Db79a7766E75Cf82bcaC0A;\n ionAddresses[9] = 0x19F245782b1258cf3e11Eda25784A378cC18c108;\n\n address ap;\n for (uint i = 0; i < ionAddresses.length; i++) {\n // ap = address(CTokenFirstExtension(ionAddresses[i]).ap());\n ap = address(CTokenFirstExtension(address(wethMarket)).ap());\n emit log_named_address(\"ap\", ap);\n }\n }\n}\n" + }, + "contracts/test/PoolCapsAndBlacklistsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./config/MarketsTest.t.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract PoolCapsAndBlacklistsTest is MarketsTest {\n Comptroller pool;\n ComptrollerFirstExtension asExtension;\n address borrower = 0x28C0208b7144B511C73586Bb07dE2100495e92f3; // ANKR account\n address otherSupplier = 0x2924973E3366690eA7aE3FCdcb2b4e136Cf7f8Cc; // Supplier of ankrBNBAnkrMkt\n ICErc20 ankrBNBAnkrMkt = ICErc20(0x71693C84486B37096192c9942852f542543639Bf);\n ICErc20 ankrBNBMkt = ICErc20(0xb2b01D6f953A28ba6C8f9E22986f5bDDb7653aEa);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n // ankr pool\n pool = Comptroller(payable(0x1851e32F34565cb95754310b031C5a2Fc0a8a905));\n asExtension = ComptrollerFirstExtension(address(pool));\n _upgradeExistingPool(address(pool));\n\n _upgradeMarket(ankrBNBMkt);\n _upgradeMarket(ankrBNBAnkrMkt);\n\n // just some logging\n {\n uint256 borrowedAnkr = ankrBNBMkt.borrowBalanceCurrent(borrower);\n emit log_named_uint(\"ankrBnb borrow balance\", borrowedAnkr);\n uint256 collateralAnkr = ankrBNBAnkrMkt.balanceOf(borrower);\n emit log_named_uint(\"ankrBnb collateral balance of ankrBNB-ANKR\", collateralAnkr);\n\n uint256 borrowedOther = ankrBNBMkt.borrowBalanceCurrent(otherSupplier);\n emit log_named_uint(\"Other supplier borrower balance\", borrowedOther);\n uint256 collateralOther = ankrBNBAnkrMkt.balanceOf(otherSupplier);\n emit log_named_uint(\"Other supplier collateral balance of ankrBNB-ANKR\", collateralOther);\n\n emit log(\"\");\n emit log(\"Before collateral caps\");\n {\n (, , uint256 liq, uint256 sf) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 before setting BC\", liq); // 1366119859198693075092\n emit log_named_uint(\"Shortfall for account 1 before setting BC\", sf); // 0\n emit log(\"\");\n (, , uint256 liq1, uint256 sf1) = pool.getAccountLiquidity(otherSupplier);\n emit log_named_uint(\"Liq for account 2 before setting BC\", liq1); // 24108891649595017\n emit log_named_uint(\"Shortfall for account 2 before setting BC\", sf1); // 0\n\n assertGt(liq, 0, \"expected positive liquidity\");\n assertGt(liq1, 0, \"expected positive liquidity\");\n emit log(\"\");\n }\n }\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapForCollateralWhitelist() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n emit log(\"\");\n emit log(\"Borrow Caps Set\");\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), 1);\n (, , uint256 liqAfter, uint256 sfAfter) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 after setting BC\", liqAfter);\n emit log_named_uint(\"Shortfall for account 1 after setting BC\", sfAfter);\n (, , uint256 liq1After, uint256 sf1After) = pool.getAccountLiquidity(otherSupplier);\n emit log(\"\");\n emit log_named_uint(\"Liq for account 2 after setting BC\", liq1After);\n emit log_named_uint(\"Shortfall for account 2 after setting BC\", sf1After);\n emit log(\"\");\n\n assertGt(sfAfter, 0, \"expected some shortfall for ankr\");\n assertEq(liq1After, 24108891649595017, \"expected liquidity for account 2 to decrease\");\n }\n\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateralWhitelist(address(ankrBNBMkt), address(ankrBNBAnkrMkt), borrower, true);\n\n emit log(\"\");\n (, , uint256 liqAfterWl, uint256 sfAfterWl) = pool.getAccountLiquidity(borrower);\n (, , uint256 liq1AfterWl, uint256 sf1AfterWl) = pool.getAccountLiquidity(otherSupplier);\n assertEq(sfAfterWl, 0, \"expected shortfall to go back to 0\");\n assertEq(liqAfterWl, 1366119859198693075092, \"expected liq to go back to original\");\n\n // expect liq for second (not whitelisted) account to stay reduced\n assertEq(liq1AfterWl, 24108891649595017, \"expected liq to go back to prev value\");\n }\n }\n\n function testBlacklistBorrowingAgainstCollateralWhitelist() public debuggingOnly fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), true);\n\n (, , uint256 liquidityAfterBlacklist, uint256 shortFallAfterBlacklist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertGt(liquidityBefore - liquidityAfterBlacklist, 0, \"should have lower liquidity after bl\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateralWhitelist(\n address(ankrBNBMkt),\n address(ankrBNBAnkrMkt),\n borrower,\n true\n );\n\n (, , uint256 liquidityAfterWhitelist, uint256 shortFallWhitelist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallWhitelist, shortFallBefore, \"should have the same sf after wl\");\n assertEq(liquidityAfterWhitelist, liquidityBefore, \"should have the same liquidity after wl\");\n }\n\n function testSupplyCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.startPrank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n asExtension._setMintPaused(ankrBNBMkt, false);\n asExtension._setMintPaused(ankrBNBAnkrMkt, false);\n vm.stopPrank();\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!supply cap\");\n pool.mintAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.mintAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"mint not allowed after cap whitelist\");\n }\n\n function testBorrowCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketBorrowCaps(markets, asArray(1, 1));\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!borrow:cap\");\n pool.borrowAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._borrowCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.borrowAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"borrow not allowed after cap whitelist\");\n }\n\n function testSupplyCapValue() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, 0, \"should have no liquidity after\");\n assertGt(shortFallAfterCap, 0, \"should have positive shortfall after\");\n }\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[0]), borrower, true);\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[1]), borrower, true);\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, liquidityBefore, \"liquidity after whitelist should match before\");\n assertEq(shortFallAfterCap, shortFallBefore, \"shortfall after whitelist should match before\");\n }\n }\n}\n" + }, + "contracts/test/UpgradesBaseTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../compound/CErc20RewardsDelegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nabstract contract UpgradesBaseTest is BaseTest {\n FeeDistributor internal ffd;\n ComptrollerFirstExtension internal poolExt;\n CTokenFirstExtension internal marketExt;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n poolExt = new ComptrollerFirstExtension();\n marketExt = new CTokenFirstExtension();\n }\n\n function _upgradePoolWithExtension(Unitroller asUnitroller) internal {\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n // instantiate the new implementation\n Comptroller newComptrollerImplementation = new Comptroller();\n vm.startPrank(ffd.owner());\n address comptrollerImplementationAddress = address(newComptrollerImplementation);\n ffd._setLatestComptrollerImplementation(address(0), comptrollerImplementationAddress);\n // add the extension to the auto upgrade config\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = poolExt;\n extensions[1] = newComptrollerImplementation;\n ffd._setComptrollerExtensions(comptrollerImplementationAddress, extensions);\n vm.stopPrank();\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n DiamondExtension(comptrollerImplementationAddress),\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function _upgradeMarketWithExtension(ICErc20 market) internal {\n address implBefore = market.implementation();\n\n // instantiate the new implementation\n CErc20Delegate newImpl;\n bytes memory becomeImplData = \"\";\n if (compareStrings(\"CErc20Delegate\", market.contractType())) {\n newImpl = new CErc20Delegate();\n } else if (compareStrings(\"CErc20PluginDelegate\", market.contractType())) {\n newImpl = new CErc20PluginDelegate();\n becomeImplData = abi.encode(address(0));\n } else if (compareStrings(\"CErc20RewardsDelegate\", market.contractType())) {\n newImpl = new CErc20RewardsDelegate();\n becomeImplData = abi.encode(address(0));\n } else {\n newImpl = new CErc20PluginRewardsDelegate();\n becomeImplData = abi.encode(address(0));\n }\n\n // set the new delegate as the latest\n vm.startPrank(ffd.owner());\n ffd._setLatestCErc20Delegate(newImpl.delegateType(), address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = marketExt;\n cErc20DelegateExtensions[1] = newImpl;\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n vm.stopPrank();\n\n // upgrade to the new delegate\n vm.prank(address(ffd));\n market._setImplementationSafe(address(newImpl), becomeImplData);\n }\n}\n" + }, + "contracts/utils/IMulticall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Multicall interface\n/// @notice Enables calling multiple methods in a single call to the contract\ninterface IMulticall {\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n /// @param data The encoded function data for each of the calls to make to this contract\n /// @return results The results from each of the calls passed in via data\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n}\n" + }, + "contracts/utils/IW_NATIVE.sol": { + "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity >=0.8.0;\n\ninterface IW_NATIVE {\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n function balanceOf(address) external view returns (uint256);\n}\n" + }, + "contracts/utils/Multicall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./IMulticall.sol\";\n\n/// @title Multicall\n/// @notice Enables calling multiple methods in a single call to the contract\nabstract contract Multicall is IMulticall {\n /// @inheritdoc IMulticall\n function multicall(bytes[] calldata data) public payable virtual override returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n if (!success) {\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n if (result.length < 68) revert();\n assembly {\n result := add(result, 0x04)\n }\n revert(abi.decode(result, (string)));\n }\n\n results[i] = result;\n }\n }\n}\n" + }, + "ds-test/test.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.5.0;\n\ncontract DSTest {\n event log (string);\n event logs (bytes);\n\n event log_address (address);\n event log_bytes32 (bytes32);\n event log_int (int);\n event log_uint (uint);\n event log_bytes (bytes);\n event log_string (string);\n\n event log_named_address (string key, address val);\n event log_named_bytes32 (string key, bytes32 val);\n event log_named_decimal_int (string key, int val, uint decimals);\n event log_named_decimal_uint (string key, uint val, uint decimals);\n event log_named_int (string key, int val);\n event log_named_uint (string key, uint val);\n event log_named_bytes (string key, bytes val);\n event log_named_string (string key, string val);\n\n bool public IS_TEST = true;\n bool private _failed;\n\n address constant HEVM_ADDRESS =\n address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));\n\n modifier mayRevert() { _; }\n modifier testopts(string memory) { _; }\n\n function failed() public returns (bool) {\n if (_failed) {\n return _failed;\n } else {\n bool globalFailed = false;\n if (hasHEVMContext()) {\n (, bytes memory retdata) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"load(address,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"))\n )\n );\n globalFailed = abi.decode(retdata, (bool));\n }\n return globalFailed;\n }\n }\n\n function fail() internal virtual {\n if (hasHEVMContext()) {\n (bool status, ) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"store(address,bytes32,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"), bytes32(uint256(0x01)))\n )\n );\n status; // Silence compiler warnings\n }\n _failed = true;\n }\n\n function hasHEVMContext() internal view returns (bool) {\n uint256 hevmCodeSize = 0;\n assembly {\n hevmCodeSize := extcodesize(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D)\n }\n return hevmCodeSize > 0;\n }\n\n modifier logs_gas() {\n uint startGas = gasleft();\n _;\n uint endGas = gasleft();\n emit log_named_uint(\"gas\", startGas - endGas);\n }\n\n function assertTrue(bool condition) internal {\n if (!condition) {\n emit log(\"Error: Assertion Failed\");\n fail();\n }\n }\n\n function assertTrue(bool condition, string memory err) internal {\n if (!condition) {\n emit log_named_string(\"Error\", err);\n assertTrue(condition);\n }\n }\n\n function assertEq(address a, address b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [address]\");\n emit log_named_address(\" Left\", a);\n emit log_named_address(\" Right\", b);\n fail();\n }\n }\n function assertEq(address a, address b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes32 a, bytes32 b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bytes32]\");\n emit log_named_bytes32(\" Left\", a);\n emit log_named_bytes32(\" Right\", b);\n fail();\n }\n }\n function assertEq(bytes32 a, bytes32 b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq32(bytes32 a, bytes32 b) internal {\n assertEq(a, b);\n }\n function assertEq32(bytes32 a, bytes32 b, string memory err) internal {\n assertEq(a, b, err);\n }\n\n function assertEq(int a, int b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n fail();\n }\n }\n function assertEq(int a, int b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq(uint a, uint b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n fail();\n }\n }\n function assertEq(uint a, uint b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEqDecimal(int a, int b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n\n function assertGt(uint a, uint b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGt(uint a, uint b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGt(int a, int b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGt(int a, int b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGtDecimal(int a, int b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n\n function assertGe(uint a, uint b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGe(uint a, uint b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGe(int a, int b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGe(int a, int b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGeDecimal(int a, int b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n\n function assertLt(uint a, uint b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLt(uint a, uint b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLt(int a, int b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLt(int a, int b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLtDecimal(int a, int b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n\n function assertLe(uint a, uint b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLe(uint a, uint b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLe(int a, int b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLe(int a, int b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLeDecimal(int a, int b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n\n function assertEq(string memory a, string memory b) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log(\"Error: a == b not satisfied [string]\");\n emit log_named_string(\" Left\", a);\n emit log_named_string(\" Right\", b);\n fail();\n }\n }\n function assertEq(string memory a, string memory b, string memory err) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function checkEq0(bytes memory a, bytes memory b) internal pure returns (bool ok) {\n ok = true;\n if (a.length == b.length) {\n for (uint i = 0; i < a.length; i++) {\n if (a[i] != b[i]) {\n ok = false;\n }\n }\n } else {\n ok = false;\n }\n }\n function assertEq0(bytes memory a, bytes memory b) internal {\n if (!checkEq0(a, b)) {\n emit log(\"Error: a == b not satisfied [bytes]\");\n emit log_named_bytes(\" Left\", a);\n emit log_named_bytes(\" Right\", b);\n fail();\n }\n }\n function assertEq0(bytes memory a, bytes memory b, string memory err) internal {\n if (!checkEq0(a, b)) {\n emit log_named_string(\"Error\", err);\n assertEq0(a, b);\n }\n }\n}\n" + }, + "forge-std/Base.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {StdStorage} from \"./StdStorage.sol\";\nimport {Vm, VmSafe} from \"./Vm.sol\";\n\nabstract contract CommonBase {\n // Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.\n address internal constant VM_ADDRESS = address(uint160(uint256(keccak256(\"hevm cheat code\"))));\n // console.sol and console2.sol work by executing a staticcall to this address.\n address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;\n // Default address for tx.origin and msg.sender, 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38.\n address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256(\"foundry default caller\"))));\n // Address of the test contract, deployed by the DEFAULT_SENDER.\n address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;\n // Deterministic deployment address of the Multicall3 contract.\n address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;\n\n uint256 internal constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n Vm internal constant vm = Vm(VM_ADDRESS);\n StdStorage internal stdstore;\n}\n\nabstract contract TestBase is CommonBase {}\n\nabstract contract ScriptBase is CommonBase {\n // Used when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);\n}\n" + }, + "forge-std/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n }\n\n function logUint(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n }\n\n function log(uint p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n }\n\n function log(uint p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n }\n\n function log(uint p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n }\n\n function log(string memory p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/console2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\n/// @dev The original console.sol uses `int` and `uint` for computing function selectors, but it should\n/// use `int256` and `uint256`. This modified version fixes that. This version is recommended\n/// over `console.sol` if you don't need compatibility with Hardhat as the logs will show up in\n/// forge stack traces. If you do need compatibility with Hardhat, you must use `console.sol`.\n/// Reference: https://github.com/NomicFoundation/hardhat/issues/2178\nlibrary console2 {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, int256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,int256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/interfaces/IMulticall3.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ninterface IMulticall3 {\n struct Call {\n address target;\n bytes callData;\n }\n\n struct Call3 {\n address target;\n bool allowFailure;\n bytes callData;\n }\n\n struct Call3Value {\n address target;\n bool allowFailure;\n uint256 value;\n bytes callData;\n }\n\n struct Result {\n bool success;\n bytes returnData;\n }\n\n function aggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes[] memory returnData);\n\n function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);\n\n function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);\n\n function blockAndAggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n\n function getBasefee() external view returns (uint256 basefee);\n\n function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);\n\n function getBlockNumber() external view returns (uint256 blockNumber);\n\n function getChainId() external view returns (uint256 chainid);\n\n function getCurrentBlockCoinbase() external view returns (address coinbase);\n\n function getCurrentBlockDifficulty() external view returns (uint256 difficulty);\n\n function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);\n\n function getCurrentBlockTimestamp() external view returns (uint256 timestamp);\n\n function getEthBalance(address addr) external view returns (uint256 balance);\n\n function getLastBlockHash() external view returns (bytes32 blockHash);\n\n function tryAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (Result[] memory returnData);\n\n function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n}\n" + }, + "forge-std/StdAssertions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {DSTest} from \"ds-test/test.sol\";\nimport {stdMath} from \"./StdMath.sol\";\n\nabstract contract StdAssertions is DSTest {\n event log_array(uint256[] val);\n event log_array(int256[] val);\n event log_array(address[] val);\n event log_named_array(string key, uint256[] val);\n event log_named_array(string key, int256[] val);\n event log_named_array(string key, address[] val);\n\n function fail(string memory err) internal virtual {\n emit log_named_string(\"Error\", err);\n fail();\n }\n\n function assertFalse(bool data) internal virtual {\n assertTrue(!data);\n }\n\n function assertFalse(bool data, string memory err) internal virtual {\n assertTrue(!data, err);\n }\n\n function assertEq(bool a, bool b) internal virtual {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bool]\");\n emit log_named_string(\" Left\", a ? \"true\" : \"false\");\n emit log_named_string(\" Right\", b ? \"true\" : \"false\");\n fail();\n }\n }\n\n function assertEq(bool a, bool b, string memory err) internal virtual {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes memory a, bytes memory b) internal virtual {\n assertEq0(a, b);\n }\n\n function assertEq(bytes memory a, bytes memory b, string memory err) internal virtual {\n assertEq0(a, b, err);\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [uint[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [int[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(address[] memory a, address[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [address[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(address[] memory a, address[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n // Legacy helper\n function assertEqUint(uint256 a, uint256 b) internal virtual {\n assertEq(uint256(a), uint256(b));\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100%\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals,\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta, string memory err) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual {\n assertEqCall(target, callDataA, target, callDataB, true);\n }\n\n function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)\n internal\n virtual\n {\n assertEqCall(targetA, callDataA, targetB, callDataB, true);\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)\n internal\n virtual\n {\n assertEqCall(target, callDataA, target, callDataB, strictRevertData);\n }\n\n function assertEqCall(\n address targetA,\n bytes memory callDataA,\n address targetB,\n bytes memory callDataB,\n bool strictRevertData\n ) internal virtual {\n (bool successA, bytes memory returnDataA) = address(targetA).call(callDataA);\n (bool successB, bytes memory returnDataB) = address(targetB).call(callDataB);\n\n if (successA && successB) {\n assertEq(returnDataA, returnDataB, \"Call return data does not match\");\n }\n\n if (!successA && !successB && strictRevertData) {\n assertEq(returnDataA, returnDataB, \"Call revert data does not match\");\n }\n\n if (!successA && successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call revert data\", returnDataA);\n emit log_named_bytes(\" Right call return data\", returnDataB);\n fail();\n }\n\n if (successA && !successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call return data\", returnDataA);\n emit log_named_bytes(\" Right call revert data\", returnDataB);\n fail();\n }\n }\n}\n" + }, + "forge-std/StdChains.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n/**\n * StdChains provides information about EVM compatible chains that can be used in scripts/tests.\n * For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are\n * identified by their alias, which is the same as the alias in the `[rpc_endpoints]` section of\n * the `foundry.toml` file. For best UX, ensure the alias in the `foundry.toml` file match the\n * alias used in this contract, which can be found as the first argument to the\n * `setChainWithDefaultRpcUrl` call in the `initialize` function.\n *\n * There are two main ways to use this contract:\n * 1. Set a chain with `setChain(string memory chainAlias, ChainData memory chain)` or\n * `setChain(string memory chainAlias, Chain memory chain)`\n * 2. Get a chain with `getChain(string memory chainAlias)` or `getChain(uint256 chainId)`.\n *\n * The first time either of those are used, chains are initialized with the default set of RPC URLs.\n * This is done in `initialize`, which uses `setChainWithDefaultRpcUrl`. Defaults are recorded in\n * `defaultRpcUrls`.\n *\n * The `setChain` function is straightforward, and it simply saves off the given chain data.\n *\n * The `getChain` methods use `getChainWithUpdatedRpcUrl` to return a chain. For example, let's say\n * we want to retrieve `mainnet`'s RPC URL:\n * - If you haven't set any mainnet chain info with `setChain`, you haven't specified that\n * chain in `foundry.toml` and no env var is set, the default data and RPC URL will be returned.\n * - If you have set a mainnet RPC URL in `foundry.toml` it will return that, if valid (e.g. if\n * a URL is given or if an environment variable is given and that environment variable exists).\n * Otherwise, the default data is returned.\n * - If you specified data with `setChain` it will return that.\n *\n * Summarizing the above, the prioritization hierarchy is `setChain` -> `foundry.toml` -> environment variable -> defaults.\n */\nabstract contract StdChains {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private initialized;\n\n struct ChainData {\n string name;\n uint256 chainId;\n string rpcUrl;\n }\n\n struct Chain {\n // The chain name.\n string name;\n // The chain's Chain ID.\n uint256 chainId;\n // The chain's alias. (i.e. what gets specified in `foundry.toml`).\n string chainAlias;\n // A default RPC endpoint for this chain.\n // NOTE: This default RPC URL is included for convenience to facilitate quick tests and\n // experimentation. Do not use this RPC URL for production test suites, CI, or other heavy\n // usage as you will be throttled and this is a disservice to others who need this endpoint.\n string rpcUrl;\n }\n\n // Maps from the chain's alias (matching the alias in the `foundry.toml` file) to chain data.\n mapping(string => Chain) private chains;\n // Maps from the chain's alias to it's default RPC URL.\n mapping(string => string) private defaultRpcUrls;\n // Maps from a chain ID to it's alias.\n mapping(uint256 => string) private idToAlias;\n\n bool private fallbackToDefaultRpcUrls = true;\n\n // The RPC URL will be fetched from config or defaultRpcUrls if possible.\n function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {\n require(bytes(chainAlias).length != 0, \"StdChains getChain(string): Chain alias cannot be the empty string.\");\n\n initialize();\n chain = chains[chainAlias];\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(string): Chain with alias \\\"\", chainAlias, \"\\\" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {\n require(chainId != 0, \"StdChains getChain(uint256): Chain ID cannot be 0.\");\n initialize();\n string memory chainAlias = idToAlias[chainId];\n\n chain = chains[chainAlias];\n\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(uint256): Chain with ID \", vm.toString(chainId), \" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, ChainData memory chain) internal virtual {\n require(\n bytes(chainAlias).length != 0,\n \"StdChains setChain(string,ChainData): Chain alias cannot be the empty string.\"\n );\n\n require(chain.chainId != 0, \"StdChains setChain(string,ChainData): Chain ID cannot be 0.\");\n\n initialize();\n string memory foundAlias = idToAlias[chain.chainId];\n\n require(\n bytes(foundAlias).length == 0 || keccak256(bytes(foundAlias)) == keccak256(bytes(chainAlias)),\n string(\n abi.encodePacked(\n \"StdChains setChain(string,ChainData): Chain ID \",\n vm.toString(chain.chainId),\n \" already used by \\\"\",\n foundAlias,\n \"\\\".\"\n )\n )\n );\n\n uint256 oldChainId = chains[chainAlias].chainId;\n delete idToAlias[oldChainId];\n\n chains[chainAlias] =\n Chain({name: chain.name, chainId: chain.chainId, chainAlias: chainAlias, rpcUrl: chain.rpcUrl});\n idToAlias[chain.chainId] = chainAlias;\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, Chain memory chain) internal virtual {\n setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));\n }\n\n function _toUpper(string memory str) private pure returns (string memory) {\n bytes memory strb = bytes(str);\n bytes memory copy = new bytes(strb.length);\n for (uint256 i = 0; i < strb.length; i++) {\n bytes1 b = strb[i];\n if (b >= 0x61 && b <= 0x7A) {\n copy[i] = bytes1(uint8(b) - 32);\n } else {\n copy[i] = b;\n }\n }\n return string(copy);\n }\n\n // lookup rpcUrl, in descending order of priority:\n // current -> config (foundry.toml) -> environment variable -> default\n function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private returns (Chain memory) {\n if (bytes(chain.rpcUrl).length == 0) {\n try vm.rpcUrl(chainAlias) returns (string memory configRpcUrl) {\n chain.rpcUrl = configRpcUrl;\n } catch (bytes memory err) {\n string memory envName = string(abi.encodePacked(_toUpper(chainAlias), \"_RPC_URL\"));\n if (fallbackToDefaultRpcUrls) {\n chain.rpcUrl = vm.envOr(envName, defaultRpcUrls[chainAlias]);\n } else {\n chain.rpcUrl = vm.envString(envName);\n }\n // distinguish 'not found' from 'cannot read'\n bytes memory notFoundError =\n abi.encodeWithSignature(\"CheatCodeError\", string(abi.encodePacked(\"invalid rpc url \", chainAlias)));\n if (keccak256(notFoundError) != keccak256(err) || bytes(chain.rpcUrl).length == 0) {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, err), mload(err))\n }\n }\n }\n }\n return chain;\n }\n\n function setFallbackToDefaultRpcUrls(bool useDefault) internal {\n fallbackToDefaultRpcUrls = useDefault;\n }\n\n function initialize() private {\n if (initialized) return;\n\n initialized = true;\n\n // If adding an RPC here, make sure to test the default RPC URL in `testRpcs`\n setChainWithDefaultRpcUrl(\"anvil\", ChainData(\"Anvil\", 31337, \"http://127.0.0.1:8545\"));\n setChainWithDefaultRpcUrl(\n \"mainnet\", ChainData(\"Mainnet\", 1, \"https://mainnet.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"goerli\", ChainData(\"Goerli\", 5, \"https://goerli.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"sepolia\", ChainData(\"Sepolia\", 11155111, \"https://sepolia.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\"optimism\", ChainData(\"Optimism\", 10, \"https://mainnet.optimism.io\"));\n setChainWithDefaultRpcUrl(\"optimism_goerli\", ChainData(\"Optimism Goerli\", 420, \"https://goerli.optimism.io\"));\n setChainWithDefaultRpcUrl(\"arbitrum_one\", ChainData(\"Arbitrum One\", 42161, \"https://arb1.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\n \"arbitrum_one_goerli\", ChainData(\"Arbitrum One Goerli\", 421613, \"https://goerli-rollup.arbitrum.io/rpc\")\n );\n setChainWithDefaultRpcUrl(\"arbitrum_nova\", ChainData(\"Arbitrum Nova\", 42170, \"https://nova.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\"polygon\", ChainData(\"Polygon\", 137, \"https://polygon-rpc.com\"));\n setChainWithDefaultRpcUrl(\n \"polygon_mumbai\", ChainData(\"Polygon Mumbai\", 80001, \"https://rpc-mumbai.maticvigil.com\")\n );\n setChainWithDefaultRpcUrl(\"avalanche\", ChainData(\"Avalanche\", 43114, \"https://api.avax.network/ext/bc/C/rpc\"));\n setChainWithDefaultRpcUrl(\n \"avalanche_fuji\", ChainData(\"Avalanche Fuji\", 43113, \"https://api.avax-test.network/ext/bc/C/rpc\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain\", ChainData(\"BNB Smart Chain\", 56, \"https://bsc-dataseed1.binance.org\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain_testnet\",\n ChainData(\"BNB Smart Chain Testnet\", 97, \"https://rpc.ankr.com/bsc_testnet_chapel\")\n );\n setChainWithDefaultRpcUrl(\"gnosis_chain\", ChainData(\"Gnosis Chain\", 100, \"https://rpc.gnosischain.com\"));\n }\n\n // set chain info, with priority to chainAlias' rpc url in foundry.toml\n function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private {\n string memory rpcUrl = chain.rpcUrl;\n defaultRpcUrls[chainAlias] = rpcUrl;\n chain.rpcUrl = \"\";\n setChain(chainAlias, chain);\n chain.rpcUrl = rpcUrl; // restore argument\n }\n}\n" + }, + "forge-std/StdCheats.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {Vm} from \"./Vm.sol\";\n\nabstract contract StdCheatsSafe {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private gasMeteringOff;\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawTx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n // json value name = function\n string functionSig;\n bytes32 hash;\n // json value name = tx\n RawTx1559Detail txDetail;\n // json value name = type\n string opcode;\n }\n\n struct RawTx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n bytes gas;\n bytes nonce;\n address to;\n bytes txType;\n bytes value;\n }\n\n struct Tx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n bytes32 hash;\n Tx1559Detail txDetail;\n string opcode;\n }\n\n struct Tx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n uint256 gas;\n uint256 nonce;\n address to;\n uint256 txType;\n uint256 value;\n }\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that DO NOT conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct TxLegacy {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n string hash;\n string opcode;\n TxDetailLegacy transaction;\n }\n\n struct TxDetailLegacy {\n AccessList[] accessList;\n uint256 chainId;\n bytes data;\n address from;\n uint256 gas;\n uint256 gasPrice;\n bytes32 hash;\n uint256 nonce;\n bytes1 opcode;\n bytes32 r;\n bytes32 s;\n uint256 txType;\n address to;\n uint8 v;\n uint256 value;\n }\n\n struct AccessList {\n address accessAddress;\n bytes32[] storageKeys;\n }\n\n // Data structures to parse Receipt objects from the broadcast artifact.\n // The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawReceipt {\n bytes32 blockHash;\n bytes blockNumber;\n address contractAddress;\n bytes cumulativeGasUsed;\n bytes effectiveGasPrice;\n address from;\n bytes gasUsed;\n RawReceiptLog[] logs;\n bytes logsBloom;\n bytes status;\n address to;\n bytes32 transactionHash;\n bytes transactionIndex;\n }\n\n struct Receipt {\n bytes32 blockHash;\n uint256 blockNumber;\n address contractAddress;\n uint256 cumulativeGasUsed;\n uint256 effectiveGasPrice;\n address from;\n uint256 gasUsed;\n ReceiptLog[] logs;\n bytes logsBloom;\n uint256 status;\n address to;\n bytes32 transactionHash;\n uint256 transactionIndex;\n }\n\n // Data structures to parse the entire broadcast artifact, assuming the\n // transactions conform to EIP1559.\n\n struct EIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n Receipt[] receipts;\n uint256 timestamp;\n Tx1559[] transactions;\n TxReturn[] txReturns;\n }\n\n struct RawEIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n RawReceipt[] receipts;\n TxReturn[] txReturns;\n uint256 timestamp;\n RawTx1559[] transactions;\n }\n\n struct RawReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n bytes blockNumber;\n bytes data;\n bytes logIndex;\n bool removed;\n bytes32[] topics;\n bytes32 transactionHash;\n bytes transactionIndex;\n bytes transactionLogIndex;\n }\n\n struct ReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n uint256 blockNumber;\n bytes data;\n uint256 logIndex;\n bytes32[] topics;\n uint256 transactionIndex;\n uint256 transactionLogIndex;\n bool removed;\n }\n\n struct TxReturn {\n string internalType;\n string value;\n }\n\n function assumeNoPrecompiles(address addr) internal virtual {\n // Assembly required since `block.chainid` was introduced in 0.8.0.\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n assumeNoPrecompiles(addr, chainId);\n }\n\n function assumeNoPrecompiles(address addr, uint256 chainId) internal pure virtual {\n // Note: For some chains like Optimism these are technically predeploys (i.e. bytecode placed at a specific\n // address), but the same rationale for excluding them applies so we include those too.\n\n // These should be present on all EVM-compatible chains.\n vm.assume(addr < address(0x1) || addr > address(0x9));\n\n // forgefmt: disable-start\n if (chainId == 10 || chainId == 420) {\n // https://github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.go#L6-L21\n vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));\n } else if (chainId == 42161 || chainId == 421613) {\n // https://developer.arbitrum.io/useful-addresses#arbitrum-precompiles-l2-same-on-all-arb-chains\n vm.assume(addr < address(0x0000000000000000000000000000000000000064) || addr > address(0x0000000000000000000000000000000000000068));\n } else if (chainId == 43114 || chainId == 43113) {\n // https://github.com/ava-labs/subnet-evm/blob/47c03fd007ecaa6de2c52ea081596e0a88401f58/precompile/params.go#L18-L59\n vm.assume(addr < address(0x0100000000000000000000000000000000000000) || addr > address(0x01000000000000000000000000000000000000ff));\n vm.assume(addr < address(0x0200000000000000000000000000000000000000) || addr > address(0x02000000000000000000000000000000000000FF));\n vm.assume(addr < address(0x0300000000000000000000000000000000000000) || addr > address(0x03000000000000000000000000000000000000Ff));\n }\n // forgefmt: disable-end\n }\n\n function readEIP1559ScriptArtifact(string memory path)\n internal\n view\n virtual\n returns (EIP1559ScriptArtifact memory)\n {\n string memory data = vm.readFile(path);\n bytes memory parsedData = vm.parseJson(data);\n RawEIP1559ScriptArtifact memory rawArtifact = abi.decode(parsedData, (RawEIP1559ScriptArtifact));\n EIP1559ScriptArtifact memory artifact;\n artifact.libraries = rawArtifact.libraries;\n artifact.path = rawArtifact.path;\n artifact.timestamp = rawArtifact.timestamp;\n artifact.pending = rawArtifact.pending;\n artifact.txReturns = rawArtifact.txReturns;\n artifact.receipts = rawToConvertedReceipts(rawArtifact.receipts);\n artifact.transactions = rawToConvertedEIPTx1559s(rawArtifact.transactions);\n return artifact;\n }\n\n function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory) {\n Tx1559[] memory txs = new Tx1559[](rawTxs.length);\n for (uint256 i; i < rawTxs.length; i++) {\n txs[i] = rawToConvertedEIPTx1559(rawTxs[i]);\n }\n return txs;\n }\n\n function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory) {\n Tx1559 memory transaction;\n transaction.arguments = rawTx.arguments;\n transaction.contractName = rawTx.contractName;\n transaction.functionSig = rawTx.functionSig;\n transaction.hash = rawTx.hash;\n transaction.txDetail = rawToConvertedEIP1559Detail(rawTx.txDetail);\n transaction.opcode = rawTx.opcode;\n return transaction;\n }\n\n function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)\n internal\n pure\n virtual\n returns (Tx1559Detail memory)\n {\n Tx1559Detail memory txDetail;\n txDetail.data = rawDetail.data;\n txDetail.from = rawDetail.from;\n txDetail.to = rawDetail.to;\n txDetail.nonce = _bytesToUint(rawDetail.nonce);\n txDetail.txType = _bytesToUint(rawDetail.txType);\n txDetail.value = _bytesToUint(rawDetail.value);\n txDetail.gas = _bytesToUint(rawDetail.gas);\n txDetail.accessList = rawDetail.accessList;\n return txDetail;\n }\n\n function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".transactions\");\n RawTx1559[] memory rawTxs = abi.decode(parsedDeployData, (RawTx1559[]));\n return rawToConvertedEIPTx1559s(rawTxs);\n }\n\n function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".transactions[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawTx1559 memory rawTx = abi.decode(parsedDeployData, (RawTx1559));\n return rawToConvertedEIPTx1559(rawTx);\n }\n\n // Analogous to readTransactions, but for receipts.\n function readReceipts(string memory path) internal view virtual returns (Receipt[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".receipts\");\n RawReceipt[] memory rawReceipts = abi.decode(parsedDeployData, (RawReceipt[]));\n return rawToConvertedReceipts(rawReceipts);\n }\n\n function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".receipts[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawReceipt memory rawReceipt = abi.decode(parsedDeployData, (RawReceipt));\n return rawToConvertedReceipt(rawReceipt);\n }\n\n function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory) {\n Receipt[] memory receipts = new Receipt[](rawReceipts.length);\n for (uint256 i; i < rawReceipts.length; i++) {\n receipts[i] = rawToConvertedReceipt(rawReceipts[i]);\n }\n return receipts;\n }\n\n function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory) {\n Receipt memory receipt;\n receipt.blockHash = rawReceipt.blockHash;\n receipt.to = rawReceipt.to;\n receipt.from = rawReceipt.from;\n receipt.contractAddress = rawReceipt.contractAddress;\n receipt.effectiveGasPrice = _bytesToUint(rawReceipt.effectiveGasPrice);\n receipt.cumulativeGasUsed = _bytesToUint(rawReceipt.cumulativeGasUsed);\n receipt.gasUsed = _bytesToUint(rawReceipt.gasUsed);\n receipt.status = _bytesToUint(rawReceipt.status);\n receipt.transactionIndex = _bytesToUint(rawReceipt.transactionIndex);\n receipt.blockNumber = _bytesToUint(rawReceipt.blockNumber);\n receipt.logs = rawToConvertedReceiptLogs(rawReceipt.logs);\n receipt.logsBloom = rawReceipt.logsBloom;\n receipt.transactionHash = rawReceipt.transactionHash;\n return receipt;\n }\n\n function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)\n internal\n pure\n virtual\n returns (ReceiptLog[] memory)\n {\n ReceiptLog[] memory logs = new ReceiptLog[](rawLogs.length);\n for (uint256 i; i < rawLogs.length; i++) {\n logs[i].logAddress = rawLogs[i].logAddress;\n logs[i].blockHash = rawLogs[i].blockHash;\n logs[i].blockNumber = _bytesToUint(rawLogs[i].blockNumber);\n logs[i].data = rawLogs[i].data;\n logs[i].logIndex = _bytesToUint(rawLogs[i].logIndex);\n logs[i].topics = rawLogs[i].topics;\n logs[i].transactionIndex = _bytesToUint(rawLogs[i].transactionIndex);\n logs[i].transactionLogIndex = _bytesToUint(rawLogs[i].transactionLogIndex);\n logs[i].removed = rawLogs[i].removed;\n }\n return logs;\n }\n\n // Deploy a contract by fetching the contract bytecode from\n // the artifacts directory\n // e.g. `deployCode(code, abi.encode(arg1,arg2,arg3))`\n function deployCode(string memory what, bytes memory args) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes): Deployment failed.\");\n }\n\n function deployCode(string memory what) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string): Deployment failed.\");\n }\n\n /// @dev deploy contract with value on construction\n function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes,uint256): Deployment failed.\");\n }\n\n function deployCode(string memory what, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,uint256): Deployment failed.\");\n }\n\n // creates a labeled address and the corresponding private key\n function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey) {\n privateKey = uint256(keccak256(abi.encodePacked(name)));\n addr = vm.addr(privateKey);\n vm.label(addr, name);\n }\n\n // creates a labeled address\n function makeAddr(string memory name) internal virtual returns (address addr) {\n (addr,) = makeAddrAndKey(name);\n }\n\n function deriveRememberKey(string memory mnemonic, uint32 index)\n internal\n virtual\n returns (address who, uint256 privateKey)\n {\n privateKey = vm.deriveKey(mnemonic, index);\n who = vm.rememberKey(privateKey);\n }\n\n function _bytesToUint(bytes memory b) private pure returns (uint256) {\n require(b.length <= 32, \"StdCheats _bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n function isFork() internal view virtual returns (bool status) {\n try vm.activeFork() {\n status = true;\n } catch (bytes memory) {}\n }\n\n modifier skipWhenForking() {\n if (!isFork()) {\n _;\n }\n }\n\n modifier skipWhenNotForking() {\n if (isFork()) {\n _;\n }\n }\n\n modifier noGasMetering() {\n vm.pauseGasMetering();\n // To prevent turning gas monitoring back on with nested functions that use this modifier,\n // we check if gasMetering started in the off position. If it did, we don't want to turn\n // it back on until we exit the top level function that used the modifier\n //\n // i.e. funcA() noGasMetering { funcB() }, where funcB has noGasMetering as well.\n // funcA will have `gasStartedOff` as false, funcB will have it as true,\n // so we only turn metering back on at the end of the funcA\n bool gasStartedOff = gasMeteringOff;\n gasMeteringOff = true;\n\n _;\n\n // if gas metering was on when this modifier was called, turn it back on at the end\n if (!gasStartedOff) {\n gasMeteringOff = false;\n vm.resumeGasMetering();\n }\n }\n\n // a cheat for fuzzing addresses that are payable only\n // see https://github.com/foundry-rs/foundry/issues/3631\n function assumePayable(address addr) internal virtual {\n (bool success,) = payable(addr).call{value: 0}(\"\");\n vm.assume(success);\n }\n}\n\n// Wrappers around cheatcodes to avoid footguns\nabstract contract StdCheats is StdCheatsSafe {\n using stdStorage for StdStorage;\n\n StdStorage private stdstore;\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n // Skip forward or rewind time by the specified number of seconds\n function skip(uint256 time) internal virtual {\n vm.warp(block.timestamp + time);\n }\n\n function rewind(uint256 time) internal virtual {\n vm.warp(block.timestamp - time);\n }\n\n // Setup a prank from an address that has some ether\n function hoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender, origin);\n }\n\n function hoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender, origin);\n }\n\n // Start perpetual prank from an address that has some ether\n function startHoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender);\n }\n\n function startHoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender);\n }\n\n // Start perpetual prank from an address that has some ether\n // tx.origin is set to the origin parameter\n function startHoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender, origin);\n }\n\n function startHoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender, origin);\n }\n\n function changePrank(address msgSender) internal virtual {\n vm.stopPrank();\n vm.startPrank(msgSender);\n }\n\n // The same as Vm's `deal`\n // Use the alternative signature for ERC20 tokens\n function deal(address to, uint256 give) internal virtual {\n vm.deal(to, give);\n }\n\n // Set the balance of an account for any ERC20 token\n // Use the alternative signature to update `totalSupply`\n function deal(address token, address to, uint256 give) internal virtual {\n deal(token, to, give, false);\n }\n\n // Set the balance of an account for any ERC1155 token\n // Use the alternative signature to update `totalSupply`\n function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual {\n dealERC1155(token, to, id, give, false);\n }\n\n function deal(address token, address to, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0x18160ddd));\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0x18160ddd).checked_write(totSup);\n }\n }\n\n function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x00fdd58e, to, id));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0xbd85b039, id));\n require(\n totSupData.length != 0,\n \"StdCheats deal(address,address,uint,uint,bool): target contract is not ERC1155Supply.\"\n );\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);\n }\n }\n\n function dealERC721(address token, address to, uint256 id) internal virtual {\n // check if token id is already minted and the actual owner.\n (bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id));\n require(successMinted, \"StdCheats deal(address,address,uint,bool): id not minted.\");\n\n // get owner current balance\n (, bytes memory fromBalData) = token.call(abi.encodeWithSelector(0x70a08231, abi.decode(ownerData, (address))));\n uint256 fromPrevBal = abi.decode(fromBalData, (uint256));\n\n // get new user current balance\n (, bytes memory toBalData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 toPrevBal = abi.decode(toBalData, (uint256));\n\n // update balances\n stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);\n\n // update owner\n stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);\n }\n}\n" + }, + "forge-std/StdError.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Panics work for versions >=0.8.0, but we lowered the pragma to make this compatible with Test\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdError {\n bytes public constant assertionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x01);\n bytes public constant arithmeticError = abi.encodeWithSignature(\"Panic(uint256)\", 0x11);\n bytes public constant divisionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x12);\n bytes public constant enumConversionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x21);\n bytes public constant encodeStorageError = abi.encodeWithSignature(\"Panic(uint256)\", 0x22);\n bytes public constant popError = abi.encodeWithSignature(\"Panic(uint256)\", 0x31);\n bytes public constant indexOOBError = abi.encodeWithSignature(\"Panic(uint256)\", 0x32);\n bytes public constant memOverflowError = abi.encodeWithSignature(\"Panic(uint256)\", 0x41);\n bytes public constant zeroVarError = abi.encodeWithSignature(\"Panic(uint256)\", 0x51);\n}\n" + }, + "forge-std/StdInvariant.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ncontract StdInvariant {\n struct FuzzSelector {\n address addr;\n bytes4[] selectors;\n }\n\n address[] private _excludedContracts;\n address[] private _excludedSenders;\n address[] private _targetedContracts;\n address[] private _targetedSenders;\n\n string[] private _excludedArtifacts;\n string[] private _targetedArtifacts;\n\n FuzzSelector[] private _targetedArtifactSelectors;\n FuzzSelector[] private _targetedSelectors;\n\n // Functions for users:\n // These are intended to be called in tests.\n\n function excludeContract(address newExcludedContract_) internal {\n _excludedContracts.push(newExcludedContract_);\n }\n\n function excludeSender(address newExcludedSender_) internal {\n _excludedSenders.push(newExcludedSender_);\n }\n\n function excludeArtifact(string memory newExcludedArtifact_) internal {\n _excludedArtifacts.push(newExcludedArtifact_);\n }\n\n function targetArtifact(string memory newTargetedArtifact_) internal {\n _targetedArtifacts.push(newTargetedArtifact_);\n }\n\n function targetArtifactSelector(FuzzSelector memory newTargetedArtifactSelector_) internal {\n _targetedArtifactSelectors.push(newTargetedArtifactSelector_);\n }\n\n function targetContract(address newTargetedContract_) internal {\n _targetedContracts.push(newTargetedContract_);\n }\n\n function targetSelector(FuzzSelector memory newTargetedSelector_) internal {\n _targetedSelectors.push(newTargetedSelector_);\n }\n\n function targetSender(address newTargetedSender_) internal {\n _targetedSenders.push(newTargetedSender_);\n }\n\n // Functions for forge:\n // These are called by forge to run invariant tests and don't need to be called in tests.\n\n function excludeArtifacts() public view returns (string[] memory excludedArtifacts_) {\n excludedArtifacts_ = _excludedArtifacts;\n }\n\n function excludeContracts() public view returns (address[] memory excludedContracts_) {\n excludedContracts_ = _excludedContracts;\n }\n\n function excludeSenders() public view returns (address[] memory excludedSenders_) {\n excludedSenders_ = _excludedSenders;\n }\n\n function targetArtifacts() public view returns (string[] memory targetedArtifacts_) {\n targetedArtifacts_ = _targetedArtifacts;\n }\n\n function targetArtifactSelectors() public view returns (FuzzSelector[] memory targetedArtifactSelectors_) {\n targetedArtifactSelectors_ = _targetedArtifactSelectors;\n }\n\n function targetContracts() public view returns (address[] memory targetedContracts_) {\n targetedContracts_ = _targetedContracts;\n }\n\n function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_) {\n targetedSelectors_ = _targetedSelectors;\n }\n\n function targetSenders() public view returns (address[] memory targetedSenders_) {\n targetedSenders_ = _targetedSenders;\n }\n}\n" + }, + "forge-std/StdJson.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n// Helpers for parsing and writing JSON files\n// To parse:\n// ```\n// using stdJson for string;\n// string memory json = vm.readFile(\"some_peth\");\n// json.parseUint(\"\");\n// ```\n// To write:\n// ```\n// using stdJson for string;\n// string memory json = \"deploymentArtifact\";\n// Contract contract = new Contract();\n// json.serialize(\"contractAddress\", address(contract));\n// json = json.serialize(\"deploymentTimes\", uint(1));\n// // store the stringified JSON to the 'json' variable we have been using as a key\n// // as we won't need it any longer\n// string memory json2 = \"finalArtifact\";\n// string memory final = json2.serialize(\"depArtifact\", json);\n// final.write(\"\");\n// ```\n\nlibrary stdJson {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {\n return vm.parseJson(json, key);\n }\n\n function readUint(string memory json, string memory key) internal returns (uint256) {\n return vm.parseJsonUint(json, key);\n }\n\n function readUintArray(string memory json, string memory key) internal returns (uint256[] memory) {\n return vm.parseJsonUintArray(json, key);\n }\n\n function readInt(string memory json, string memory key) internal returns (int256) {\n return vm.parseJsonInt(json, key);\n }\n\n function readIntArray(string memory json, string memory key) internal returns (int256[] memory) {\n return vm.parseJsonIntArray(json, key);\n }\n\n function readBytes32(string memory json, string memory key) internal returns (bytes32) {\n return vm.parseJsonBytes32(json, key);\n }\n\n function readBytes32Array(string memory json, string memory key) internal returns (bytes32[] memory) {\n return vm.parseJsonBytes32Array(json, key);\n }\n\n function readString(string memory json, string memory key) internal returns (string memory) {\n return vm.parseJsonString(json, key);\n }\n\n function readStringArray(string memory json, string memory key) internal returns (string[] memory) {\n return vm.parseJsonStringArray(json, key);\n }\n\n function readAddress(string memory json, string memory key) internal returns (address) {\n return vm.parseJsonAddress(json, key);\n }\n\n function readAddressArray(string memory json, string memory key) internal returns (address[] memory) {\n return vm.parseJsonAddressArray(json, key);\n }\n\n function readBool(string memory json, string memory key) internal returns (bool) {\n return vm.parseJsonBool(json, key);\n }\n\n function readBoolArray(string memory json, string memory key) internal returns (bool[] memory) {\n return vm.parseJsonBoolArray(json, key);\n }\n\n function readBytes(string memory json, string memory key) internal returns (bytes memory) {\n return vm.parseJsonBytes(json, key);\n }\n\n function readBytesArray(string memory json, string memory key) internal returns (bytes[] memory) {\n return vm.parseJsonBytesArray(json, key);\n }\n\n function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory) {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bool[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory) {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory) {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory) {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory) {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory) {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function write(string memory jsonKey, string memory path) internal {\n vm.writeJson(jsonKey, path);\n }\n\n function write(string memory jsonKey, string memory path, string memory valueKey) internal {\n vm.writeJson(jsonKey, path, valueKey);\n }\n}\n" + }, + "forge-std/StdMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdMath {\n int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;\n\n function abs(int256 a) internal pure returns (uint256) {\n // Required or it will fail when `a = type(int256).min`\n if (a == INT256_MIN) {\n return 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n }\n\n return uint256(a > 0 ? a : -a);\n }\n\n function delta(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : b - a;\n }\n\n function delta(int256 a, int256 b) internal pure returns (uint256) {\n // a and b are of the same sign\n // this works thanks to two's complement, the left-most bit is the sign bit\n if ((a ^ b) > -1) {\n return delta(abs(a), abs(b));\n }\n\n // a and b are of opposite signs\n return abs(a) + abs(b);\n }\n\n function percentDelta(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n\n return absDelta * 1e18 / b;\n }\n\n function percentDelta(int256 a, int256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n uint256 absB = abs(b);\n\n return absDelta * 1e18 / absB;\n }\n}\n" + }, + "forge-std/StdStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nstruct StdStorage {\n mapping(address => mapping(bytes4 => mapping(bytes32 => uint256))) slots;\n mapping(address => mapping(bytes4 => mapping(bytes32 => bool))) finds;\n bytes32[] _keys;\n bytes4 _sig;\n uint256 _depth;\n address _target;\n bytes32 _set;\n}\n\nlibrary stdStorageSafe {\n event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);\n event WARNING_UninitedSlot(address who, uint256 slot);\n\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return bytes4(keccak256(bytes(sigStr)));\n }\n\n /// @notice find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against\n // slot complexity:\n // if flat, will be bytes32(uint256(uint));\n // if map, will be keccak256(abi.encode(key, uint(slot)));\n // if deep map, will be keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))));\n // if map struct, will be bytes32(uint256(keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))))) + structFieldDepth);\n function find(StdStorage storage self) internal returns (uint256) {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n // calldata to test against\n if (self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n vm.record();\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n (bytes32[] memory reads,) = vm.accesses(address(who));\n if (reads.length == 1) {\n bytes32 curr = vm.load(who, reads[0]);\n if (curr == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[0]));\n }\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[0]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[0]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n } else if (reads.length > 1) {\n for (uint256 i = 0; i < reads.length; i++) {\n bytes32 prev = vm.load(who, reads[i]);\n if (prev == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[i]));\n }\n // store\n vm.store(who, reads[i], bytes32(hex\"1337\"));\n bool success;\n bytes memory rdat;\n {\n (success, rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n if (success && fdat == bytes32(hex\"1337\")) {\n // we found which of the slots is the actual one\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[i]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[i]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n vm.store(who, reads[i], prev);\n break;\n }\n vm.store(who, reads[i], prev);\n }\n } else {\n revert(\"stdStorage find(StdStorage): No storage use detected for target.\");\n }\n\n require(\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))],\n \"stdStorage find(StdStorage): Slot(s) not found.\"\n );\n\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n self._target = _target;\n return self;\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n self._sig = _sig;\n return self;\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n self._sig = sigs(_sig);\n return self;\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n self._keys.push(bytes32(uint256(uint160(who))));\n return self;\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n self._keys.push(bytes32(amt));\n return self;\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n self._keys.push(key);\n return self;\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n self._depth = _depth;\n return self;\n }\n\n function read(StdStorage storage self) private returns (bytes memory) {\n address t = self._target;\n uint256 s = find(self);\n return abi.encode(vm.load(t, bytes32(s)));\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return abi.decode(read(self), (bytes32));\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n int256 v = read_int(self);\n if (v == 0) return false;\n if (v == 1) return true;\n revert(\"stdStorage read_bool(StdStorage): Cannot decode. Make sure you are reading a bool.\");\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return abi.decode(read(self), (address));\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return abi.decode(read(self), (uint256));\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return abi.decode(read(self), (int256));\n }\n\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n\nlibrary stdStorage {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return stdStorageSafe.sigs(sigStr);\n }\n\n function find(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.find(self);\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n return stdStorageSafe.target(self, _target);\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, who);\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, amt);\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, key);\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n return stdStorageSafe.depth(self, _depth);\n }\n\n function checked_write(StdStorage storage self, address who) internal {\n checked_write(self, bytes32(uint256(uint160(who))));\n }\n\n function checked_write(StdStorage storage self, uint256 amt) internal {\n checked_write(self, bytes32(amt));\n }\n\n function checked_write(StdStorage storage self, bool write) internal {\n bytes32 t;\n /// @solidity memory-safe-assembly\n assembly {\n t := write\n }\n checked_write(self, t);\n }\n\n function checked_write(StdStorage storage self, bytes32 set) internal {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n if (!self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n find(self);\n }\n bytes32 slot = bytes32(self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]);\n\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n bytes32 curr = vm.load(who, slot);\n\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n vm.store(who, slot, set);\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return stdStorageSafe.read_bytes32(self);\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n return stdStorageSafe.read_bool(self);\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return stdStorageSafe.read_address(self);\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.read_uint(self);\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return stdStorageSafe.read_int(self);\n }\n\n // Private function so needs to be copied over\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n // Private function so needs to be copied over\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n" + }, + "forge-std/StdStyle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nlibrary StdStyle {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n string constant RED = \"\\u001b[91m\";\n string constant GREEN = \"\\u001b[92m\";\n string constant YELLOW = \"\\u001b[93m\";\n string constant BLUE = \"\\u001b[94m\";\n string constant MAGENTA = \"\\u001b[95m\";\n string constant CYAN = \"\\u001b[96m\";\n string constant BOLD = \"\\u001b[1m\";\n string constant DIM = \"\\u001b[2m\";\n string constant ITALIC = \"\\u001b[3m\";\n string constant UNDERLINE = \"\\u001b[4m\";\n string constant INVERSE = \"\\u001b[7m\";\n string constant RESET = \"\\u001b[0m\";\n\n function styleConcat(string memory style, string memory self) private pure returns (string memory) {\n return string(abi.encodePacked(style, self, RESET));\n }\n\n function red(string memory self) internal pure returns (string memory) {\n return styleConcat(RED, self);\n }\n\n function red(uint256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(int256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(address self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(bool self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes(bytes memory self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes32(bytes32 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function green(string memory self) internal pure returns (string memory) {\n return styleConcat(GREEN, self);\n }\n\n function green(uint256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(int256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(address self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(bool self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes(bytes memory self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes32(bytes32 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function yellow(string memory self) internal pure returns (string memory) {\n return styleConcat(YELLOW, self);\n }\n\n function yellow(uint256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(int256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(address self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(bool self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes(bytes memory self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes32(bytes32 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function blue(string memory self) internal pure returns (string memory) {\n return styleConcat(BLUE, self);\n }\n\n function blue(uint256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(int256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(address self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(bool self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes(bytes memory self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes32(bytes32 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function magenta(string memory self) internal pure returns (string memory) {\n return styleConcat(MAGENTA, self);\n }\n\n function magenta(uint256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(int256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(address self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(bool self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes(bytes memory self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes32(bytes32 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function cyan(string memory self) internal pure returns (string memory) {\n return styleConcat(CYAN, self);\n }\n\n function cyan(uint256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(int256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(address self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(bool self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes(bytes memory self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes32(bytes32 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function bold(string memory self) internal pure returns (string memory) {\n return styleConcat(BOLD, self);\n }\n\n function bold(uint256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(int256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(address self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(bool self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes(bytes memory self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes32(bytes32 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function dim(string memory self) internal pure returns (string memory) {\n return styleConcat(DIM, self);\n }\n\n function dim(uint256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(int256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(address self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(bool self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes(bytes memory self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes32(bytes32 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function italic(string memory self) internal pure returns (string memory) {\n return styleConcat(ITALIC, self);\n }\n\n function italic(uint256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(int256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(address self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(bool self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes(bytes memory self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes32(bytes32 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function underline(string memory self) internal pure returns (string memory) {\n return styleConcat(UNDERLINE, self);\n }\n\n function underline(uint256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(int256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(address self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(bool self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes(bytes memory self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes32(bytes32 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function inverse(string memory self) internal pure returns (string memory) {\n return styleConcat(INVERSE, self);\n }\n\n function inverse(uint256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(int256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(address self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(bool self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes(bytes memory self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes32(bytes32 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n}\n" + }, + "forge-std/StdUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {IMulticall3} from \"./interfaces/IMulticall3.sol\";\n// TODO Remove import.\nimport {VmSafe} from \"./Vm.sol\";\n\nabstract contract StdUtils {\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n //////////////////////////////////////////////////////////////////////////*/\n\n IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;\n uint256 private constant INT256_MIN_ABS =\n 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n uint256 private constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n // Used by default when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n /*//////////////////////////////////////////////////////////////////////////\n INTERNAL FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result) {\n require(min <= max, \"StdUtils bound(uint256,uint256,uint256): Max is less than min.\");\n // If x is between min and max, return x directly. This is to ensure that dictionary values\n // do not get shifted if the min is nonzero. More info: https://github.com/foundry-rs/forge-std/issues/188\n if (x >= min && x <= max) return x;\n\n uint256 size = max - min + 1;\n\n // If the value is 0, 1, 2, 3, warp that to min, min+1, min+2, min+3. Similarly for the UINT256_MAX side.\n // This helps ensure coverage of the min/max values.\n if (x <= 3 && size > x) return min + x;\n if (x >= UINT256_MAX - 3 && size > UINT256_MAX - x) return max - (UINT256_MAX - x);\n\n // Otherwise, wrap x into the range [min, max], i.e. the range is inclusive.\n if (x > max) {\n uint256 diff = x - max;\n uint256 rem = diff % size;\n if (rem == 0) return max;\n result = min + rem - 1;\n } else if (x < min) {\n uint256 diff = min - x;\n uint256 rem = diff % size;\n if (rem == 0) return min;\n result = max - rem + 1;\n }\n }\n\n function bound(uint256 x, uint256 min, uint256 max) internal view virtual returns (uint256 result) {\n result = _bound(x, min, max);\n console2_log(\"Bound Result\", result);\n }\n\n function bound(int256 x, int256 min, int256 max) internal view virtual returns (int256 result) {\n require(min <= max, \"StdUtils bound(int256,int256,int256): Max is less than min.\");\n\n // Shifting all int256 values to uint256 to use _bound function. The range of two types are:\n // int256 : -(2**255) ~ (2**255 - 1)\n // uint256: 0 ~ (2**256 - 1)\n // So, add 2**255, INT256_MIN_ABS to the integer values.\n //\n // If the given integer value is -2**255, we cannot use `-uint256(-x)` because of the overflow.\n // So, use `~uint256(x) + 1` instead.\n uint256 _x = x < 0 ? (INT256_MIN_ABS - ~uint256(x) - 1) : (uint256(x) + INT256_MIN_ABS);\n uint256 _min = min < 0 ? (INT256_MIN_ABS - ~uint256(min) - 1) : (uint256(min) + INT256_MIN_ABS);\n uint256 _max = max < 0 ? (INT256_MIN_ABS - ~uint256(max) - 1) : (uint256(max) + INT256_MIN_ABS);\n\n uint256 y = _bound(_x, _min, _max);\n\n // To move it back to int256 value, subtract INT256_MIN_ABS at here.\n result = y < INT256_MIN_ABS ? int256(~(INT256_MIN_ABS - y) + 1) : int256(y - INT256_MIN_ABS);\n console2_log(\"Bound result\", vm.toString(result));\n }\n\n function bytesToUint(bytes memory b) internal pure virtual returns (uint256) {\n require(b.length <= 32, \"StdUtils bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n /// @dev Compute the address a contract will be deployed at for a given deployer address and nonce\n /// @notice adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)\n function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address) {\n // forgefmt: disable-start\n // The integer zero is treated as an empty byte string, and as a result it only has a length prefix, 0x80, computed via 0x80 + 0.\n // A one byte integer uses its own value as its length prefix, there is no additional \"0x80 + length\" prefix that comes before it.\n if (nonce == 0x00) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, bytes1(0x80))));\n if (nonce <= 0x7f) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, uint8(nonce))));\n\n // Nonces greater than 1 byte all follow a consistent encoding scheme, where each value is preceded by a prefix of 0x80 + length.\n if (nonce <= 2**8 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd7), bytes1(0x94), deployer, bytes1(0x81), uint8(nonce))));\n if (nonce <= 2**16 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd8), bytes1(0x94), deployer, bytes1(0x82), uint16(nonce))));\n if (nonce <= 2**24 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd9), bytes1(0x94), deployer, bytes1(0x83), uint24(nonce))));\n // forgefmt: disable-end\n\n // More details about RLP encoding can be found here: https://eth.wiki/fundamentals/rlp\n // 0xda = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x84 ++ nonce)\n // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex)\n // 0x84 = 0x80 + 0x04 (0x04 = the bytes length of the nonce, 4 bytes, in hex)\n // We assume nobody can have a nonce large enough to require more than 32 bytes.\n return addressFromLast20Bytes(\n keccak256(abi.encodePacked(bytes1(0xda), bytes1(0x94), deployer, bytes1(0x84), uint32(nonce)))\n );\n }\n\n function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)\n internal\n pure\n virtual\n returns (address)\n {\n return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, initcodeHash)));\n }\n\n /// @dev returns the address of a contract created with CREATE2 using the default CREATE2 deployer\n function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address) {\n return computeCreate2Address(salt, initCodeHash, CREATE2_FACTORY);\n }\n\n /// @dev returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n function hashInitCode(bytes memory creationCode) internal pure returns (bytes32) {\n return hashInitCode(creationCode, \"\");\n }\n\n /// @dev returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n /// @param args the ABI-encoded arguments to the constructor of C\n function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(creationCode, args));\n }\n\n // Performs a single call with Multicall3 to query the ERC-20 token balances of the given addresses.\n function getTokenBalances(address token, address[] memory addresses)\n internal\n virtual\n returns (uint256[] memory balances)\n {\n uint256 tokenCodeSize;\n assembly {\n tokenCodeSize := extcodesize(token)\n }\n require(tokenCodeSize > 0, \"StdUtils getTokenBalances(address,address[]): Token address is not a contract.\");\n\n // ABI encode the aggregate call to Multicall3.\n uint256 length = addresses.length;\n IMulticall3.Call[] memory calls = new IMulticall3.Call[](length);\n for (uint256 i = 0; i < length; ++i) {\n // 0x70a08231 = bytes4(\"balanceOf(address)\"))\n calls[i] = IMulticall3.Call({target: token, callData: abi.encodeWithSelector(0x70a08231, (addresses[i]))});\n }\n\n // Make the aggregate call.\n (, bytes[] memory returnData) = multicall.aggregate(calls);\n\n // ABI decode the return data and return the balances.\n balances = new uint256[](length);\n for (uint256 i = 0; i < length; ++i) {\n balances[i] = abi.decode(returnData[i], (uint256));\n }\n }\n\n /*//////////////////////////////////////////////////////////////////////////\n PRIVATE FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address) {\n return address(uint160(uint256(bytesValue)));\n }\n\n // Used to prevent the compilation of console, which shortens the compilation time when console is not used elsewhere.\n\n function console2_log(string memory p0, uint256 p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n status;\n }\n\n function console2_log(string memory p0, string memory p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n status;\n }\n}\n" + }, + "forge-std/Test.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// 💬 ABOUT\n// Standard Library's default Test\n\n// 🧩 MODULES\nimport {console} from \"./console.sol\";\nimport {console2} from \"./console2.sol\";\nimport {StdAssertions} from \"./StdAssertions.sol\";\nimport {StdChains} from \"./StdChains.sol\";\nimport {StdCheats} from \"./StdCheats.sol\";\nimport {stdError} from \"./StdError.sol\";\nimport {StdInvariant} from \"./StdInvariant.sol\";\nimport {stdJson} from \"./StdJson.sol\";\nimport {stdMath} from \"./StdMath.sol\";\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {StdUtils} from \"./StdUtils.sol\";\nimport {Vm} from \"./Vm.sol\";\nimport {StdStyle} from \"./StdStyle.sol\";\n\n// 📦 BOILERPLATE\nimport {TestBase} from \"./Base.sol\";\nimport {DSTest} from \"ds-test/test.sol\";\n\n// ⭐️ TEST\nabstract contract Test is DSTest, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils, TestBase {\n// Note: IS_TEST() must return true.\n// Note: Must have failure system, https://github.com/dapphub/ds-test/blob/cd98eff28324bfac652e63a239a60632a761790b/src/test.sol#L39-L76.\n}\n" + }, + "forge-std/Vm.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// Cheatcodes are marked as view/pure/none using the following rules:\n// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,\n// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure (you are modifying some state be it the EVM, interpreter, filesystem, etc),\n// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,\n// 3. Otherwise you're `pure`.\n\ninterface VmSafe {\n struct Log {\n bytes32[] topics;\n bytes data;\n address emitter;\n }\n\n struct Rpc {\n string key;\n string url;\n }\n\n struct FsMetadata {\n bool isDir;\n bool isSymlink;\n uint256 length;\n bool readOnly;\n uint256 modified;\n uint256 accessed;\n uint256 created;\n }\n\n // Loads a storage slot from an address\n function load(address target, bytes32 slot) external view returns (bytes32 data);\n // Signs data\n function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);\n // Gets the address for a given private key\n function addr(uint256 privateKey) external pure returns (address keyAddr);\n // Gets the nonce of an account\n function getNonce(address account) external view returns (uint64 nonce);\n // Performs a foreign function call via the terminal\n function ffi(string[] calldata commandInput) external returns (bytes memory result);\n // Sets environment variables\n function setEnv(string calldata name, string calldata value) external;\n // Reads environment variables, (name) => (value)\n function envBool(string calldata name) external view returns (bool value);\n function envUint(string calldata name) external view returns (uint256 value);\n function envInt(string calldata name) external view returns (int256 value);\n function envAddress(string calldata name) external view returns (address value);\n function envBytes32(string calldata name) external view returns (bytes32 value);\n function envString(string calldata name) external view returns (string memory value);\n function envBytes(string calldata name) external view returns (bytes memory value);\n // Reads environment variables as arrays\n function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);\n function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);\n function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);\n function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);\n function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);\n function envString(string calldata name, string calldata delim) external view returns (string[] memory value);\n function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);\n // Read environment variables with default value\n function envOr(string calldata name, bool defaultValue) external returns (bool value);\n function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);\n function envOr(string calldata name, int256 defaultValue) external returns (int256 value);\n function envOr(string calldata name, address defaultValue) external returns (address value);\n function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);\n function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);\n function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);\n // Read environment variables as arrays with default value\n function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)\n external\n returns (bool[] memory value);\n function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)\n external\n returns (uint256[] memory value);\n function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)\n external\n returns (int256[] memory value);\n function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)\n external\n returns (address[] memory value);\n function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)\n external\n returns (bytes32[] memory value);\n function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)\n external\n returns (string[] memory value);\n function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)\n external\n returns (bytes[] memory value);\n // Records all storage reads and writes\n function record() external;\n // Gets all accessed reads and write slot from a recording session, for a given address\n function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);\n // Gets the _creation_ bytecode from an artifact file. Takes in the relative path to the json file\n function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);\n // Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file\n function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);\n // Labels an address in call traces\n function label(address account, string calldata newLabel) external;\n // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain\n function broadcast() external;\n // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain\n function broadcast(address signer) external;\n // Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain\n function broadcast(uint256 privateKey) external;\n // Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain\n function startBroadcast() external;\n // Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain\n function startBroadcast(address signer) external;\n // Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain\n function startBroadcast(uint256 privateKey) external;\n // Stops collecting onchain transactions\n function stopBroadcast() external;\n // Reads the entire content of file to string\n function readFile(string calldata path) external view returns (string memory data);\n // Reads the entire content of file as binary. Path is relative to the project root.\n function readFileBinary(string calldata path) external view returns (bytes memory data);\n // Get the path of the current project root\n function projectRoot() external view returns (string memory path);\n // Get the metadata for a file/directory\n function fsMetadata(string calldata fileOrDir) external returns (FsMetadata memory metadata);\n // Reads next line of file to string\n function readLine(string calldata path) external view returns (string memory line);\n // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n function writeFile(string calldata path, string calldata data) external;\n // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n // Path is relative to the project root.\n function writeFileBinary(string calldata path, bytes calldata data) external;\n // Writes line to file, creating a file if it does not exist.\n function writeLine(string calldata path, string calldata data) external;\n // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n function closeFile(string calldata path) external;\n // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases:\n // - Path points to a directory.\n // - The file doesn't exist.\n // - The user lacks permissions to remove the file.\n function removeFile(string calldata path) external;\n // Convert values to a string\n function toString(address value) external pure returns (string memory stringifiedValue);\n function toString(bytes calldata value) external pure returns (string memory stringifiedValue);\n function toString(bytes32 value) external pure returns (string memory stringifiedValue);\n function toString(bool value) external pure returns (string memory stringifiedValue);\n function toString(uint256 value) external pure returns (string memory stringifiedValue);\n function toString(int256 value) external pure returns (string memory stringifiedValue);\n // Convert values from a string\n function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);\n function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);\n function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);\n function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);\n function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);\n function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);\n // Record all the transaction logs\n function recordLogs() external;\n // Gets all the recorded logs\n function getRecordedLogs() external returns (Log[] memory logs);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path m/44'/60'/0'/0/{index}\n function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at {derivationPath}{index}\n function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)\n external\n pure\n returns (uint256 privateKey);\n // Adds a private key to the local forge wallet and returns the address\n function rememberKey(uint256 privateKey) external returns (address keyAddr);\n //\n // parseJson\n //\n // ----\n // In case the returned value is a JSON object, it's encoded as a ABI-encoded tuple. As JSON objects\n // don't have the notion of ordered, but tuples do, they JSON object is encoded with it's fields ordered in\n // ALPHABETICAL order. That means that in order to successfully decode the tuple, we need to define a tuple that\n // encodes the fields in the same order, which is alphabetical. In the case of Solidity structs, they are encoded\n // as tuples, with the attributes in the order in which they are defined.\n // For example: json = { 'a': 1, 'b': 0xa4tb......3xs}\n // a: uint256\n // b: address\n // To decode that json, we need to define a struct or a tuple as follows:\n // struct json = { uint256 a; address b; }\n // If we defined a json struct with the opposite order, meaning placing the address b first, it would try to\n // decode the tuple in that order, and thus fail.\n // ----\n // Given a string of JSON, return it as ABI-encoded\n function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);\n function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);\n\n // The following parseJson cheatcodes will do type coercion, for the type that they indicate.\n // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12'\n // and hex numbers '0xEF'.\n // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not\n // a JSON object.\n function parseJsonUint(string calldata, string calldata) external returns (uint256);\n function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);\n function parseJsonInt(string calldata, string calldata) external returns (int256);\n function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);\n function parseJsonBool(string calldata, string calldata) external returns (bool);\n function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);\n function parseJsonAddress(string calldata, string calldata) external returns (address);\n function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);\n function parseJsonString(string calldata, string calldata) external returns (string memory);\n function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);\n function parseJsonBytes(string calldata, string calldata) external returns (bytes memory);\n function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory);\n function parseJsonBytes32(string calldata, string calldata) external returns (bytes32);\n function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory);\n\n // Serialize a key and value to a JSON object stored in-memory that can be later written to a file\n // It returns the stringified version of the specific JSON file up to that moment.\n function serializeBool(string calldata objectKey, string calldata valueKey, bool value)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address value)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)\n external\n returns (string memory json);\n\n function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)\n external\n returns (string memory json);\n\n //\n // writeJson\n //\n // ----\n // Write a serialized JSON object to a file. If the file exists, it will be overwritten.\n // Let's assume we want to write the following JSON to a file:\n //\n // { \"boolean\": true, \"number\": 342, \"object\": { \"title\": \"finally json serialization\" } }\n //\n // ```\n // string memory json1 = \"some key\";\n // vm.serializeBool(json1, \"boolean\", true);\n // vm.serializeBool(json1, \"number\", uint256(342));\n // json2 = \"some other key\";\n // string memory output = vm.serializeString(json2, \"title\", \"finally json serialization\");\n // string memory finalJson = vm.serialize(json1, \"object\", output);\n // vm.writeJson(finalJson, \"./output/example.json\");\n // ```\n // The critical insight is that every invocation of serialization will return the stringified version of the JSON\n // up to that point. That means we can construct arbitrary JSON objects and then use the return stringified version\n // to serialize them as values to another JSON object.\n //\n // json1 and json2 are simply keys used by the backend to keep track of the objects. So vm.serializeJson(json1,..)\n // will find the object in-memory that is keyed by \"some key\".\n function writeJson(string calldata json, string calldata path) external;\n // Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \n // This is useful to replace a specific value of a JSON file, without having to parse the entire thing\n function writeJson(string calldata json, string calldata path, string calldata valueKey) external;\n // Returns the RPC url for the given alias\n function rpcUrl(string calldata rpcAlias) external view returns (string memory json);\n // Returns all rpc urls and their aliases `[alias, url][]`\n function rpcUrls() external view returns (string[2][] memory urls);\n // Returns all rpc urls and their aliases as structs.\n function rpcUrlStructs() external view returns (Rpc[] memory urls);\n // If the condition is false, discard this run's fuzz inputs and generate new ones.\n function assume(bool condition) external pure;\n // Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.\n function pauseGasMetering() external;\n // Resumes gas metering (i.e. gas usage is counted again). Noop if already on.\n function resumeGasMetering() external;\n}\n\ninterface Vm is VmSafe {\n // Sets block.timestamp\n function warp(uint256 newTimestamp) external;\n // Sets block.height\n function roll(uint256 newHeight) external;\n // Sets block.basefee\n function fee(uint256 newBasefee) external;\n // Sets block.difficulty\n function difficulty(uint256 newDifficulty) external;\n // Sets block.chainid\n function chainId(uint256 newChainId) external;\n // Stores a value to an address' storage slot.\n function store(address target, bytes32 slot, bytes32 value) external;\n // Sets the nonce of an account; must be higher than the current nonce of the account\n function setNonce(address account, uint64 newNonce) external;\n // Sets the *next* call's msg.sender to be the input address\n function prank(address msgSender) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called\n function startPrank(address msgSender) external;\n // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input\n function prank(address msgSender, address txOrigin) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input\n function startPrank(address msgSender, address txOrigin) external;\n // Resets subsequent calls' msg.sender to be `address(this)`\n function stopPrank() external;\n // Sets an address' balance\n function deal(address account, uint256 newBalance) external;\n // Sets an address' code\n function etch(address target, bytes calldata newRuntimeBytecode) external;\n // Expects an error on next call\n function expectRevert(bytes calldata revertData) external;\n function expectRevert(bytes4 revertData) external;\n function expectRevert() external;\n // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData).\n // Call this function, then emit an event, then call a function. Internally after the call, we check if\n // logs were emitted in the expected order with the expected topics and data (as specified by the booleans)\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)\n external;\n // Mocks a call to an address, returning specified data.\n // Calldata can either be strict or a partial match, e.g. if you only\n // pass a Solidity selector to the expected calldata, then the entire Solidity\n // function will be mocked.\n function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;\n // Mocks a call to an address with a specific msg.value, returning specified data.\n // Calldata match takes precedence over msg.value in case of ambiguity.\n function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;\n // Clears all mocked calls\n function clearMockedCalls() external;\n // Expects a call to an address with the specified calldata.\n // Calldata can either be a strict or a partial match\n function expectCall(address callee, bytes calldata data) external;\n // Expects a call to an address with the specified msg.value and calldata\n function expectCall(address callee, uint256 msgValue, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value, gas, and calldata.\n function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas.\n function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;\n // Sets block.coinbase\n function coinbase(address newCoinbase) external;\n // Snapshot the current state of the evm.\n // Returns the id of the snapshot that was created.\n // To revert a snapshot use `revertTo`\n function snapshot() external returns (uint256 snapshotId);\n // Revert the state of the EVM to a previous snapshot\n // Takes the snapshot id to revert to.\n // This deletes the snapshot and all snapshots taken after the given snapshot id.\n function revertTo(uint256 snapshotId) external returns (bool success);\n // Creates a new fork with the given endpoint and block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction,\n // and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before\n // the transaction, returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.\n function selectFork(uint256 forkId) external;\n /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.\n function activeFork() external view returns (uint256 forkId);\n // Updates the currently active fork to given block number\n // This is similar to `roll` but for the currently active fork\n function rollFork(uint256 blockNumber) external;\n // Updates the currently active fork to given transaction\n // this will `rollFork` with the number of the block the transaction was mined in and replays all transaction mined before it in the block\n function rollFork(bytes32 txHash) external;\n // Updates the given fork to given block number\n function rollFork(uint256 forkId, uint256 blockNumber) external;\n // Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block\n function rollFork(uint256 forkId, bytes32 txHash) external;\n // Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\n // Meaning, changes made to the state of this account will be kept when switching forks\n function makePersistent(address account) external;\n function makePersistent(address account0, address account1) external;\n function makePersistent(address account0, address account1, address account2) external;\n function makePersistent(address[] calldata accounts) external;\n // Revokes persistent status from the address, previously added via `makePersistent`\n function revokePersistent(address account) external;\n function revokePersistent(address[] calldata accounts) external;\n // Returns true if the account is marked as persistent\n function isPersistent(address account) external view returns (bool persistent);\n // In forking mode, explicitly grant the given address cheatcode access\n function allowCheatcodes(address account) external;\n // Fetches the given transaction from the active fork and executes it on the current state\n function transact(bytes32 txHash) external;\n // Fetches the given transaction from the given fork and executes it on the current state\n function transact(uint256 forkId, bytes32 txHash) external;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/interfaces/IERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20Upgradeable.sol\";\nimport \"../token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable {\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed sender,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../interfaces/IERC4626Upgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of\n * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable {\n using MathUpgradeable for uint256;\n\n IERC20Upgradeable private _asset;\n uint8 private _decimals;\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n function __ERC4626_init(IERC20Upgradeable asset_) internal onlyInitializing {\n __ERC4626_init_unchained(asset_);\n }\n\n function __ERC4626_init_unchained(IERC20Upgradeable asset_) internal onlyInitializing {\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n _decimals = success ? assetDecimals : super.decimals();\n _asset = asset_;\n }\n\n /**\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n */\n function _tryGetAssetDecimals(IERC20Upgradeable asset_) private returns (bool, uint8) {\n (bool success, bytes memory encodedDecimals) = address(asset_).call(\n abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector)\n );\n if (success && encodedDecimals.length >= 32) {\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n if (returnedDecimals <= type(uint8).max) {\n return (true, uint8(returnedDecimals));\n }\n }\n return (false, 0);\n }\n\n /**\n * @dev Decimals are read from the underlying asset in the constructor and cached. If this fails (e.g., the asset\n * has not been created yet), the cached value is set to a default obtained by `super.decimals()` (which depends on\n * inheritance but is most likely 18). Override this function in order to set a guaranteed hardcoded value.\n * See {IERC20Metadata-decimals}.\n */\n function decimals() public view virtual override(IERC20MetadataUpgradeable, ERC20Upgradeable) returns (uint8) {\n return _decimals;\n }\n\n /** @dev See {IERC4626-asset}. */\n function asset() public view virtual override returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4626-totalAssets}. */\n function totalAssets() public view virtual override returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4626-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxDeposit}. */\n function maxDeposit(address) public view virtual override returns (uint256) {\n return _isVaultCollateralized() ? type(uint256).max : 0;\n }\n\n /** @dev See {IERC4626-maxMint}. */\n function maxMint(address) public view virtual override returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual override returns (uint256) {\n return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxRedeem}. */\n function maxRedeem(address owner) public view virtual override returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4626-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-previewMint}. */\n function previewMint(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-mint}. */\n function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4626-withdraw}. */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-redeem}. */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n *\n * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset\n * would represent an infinite amount of shares.\n */\n function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) {\n uint256 supply = totalSupply();\n return\n (assets == 0 || supply == 0)\n ? _initialConvertToShares(assets, rounding)\n : assets.mulDiv(supply, totalAssets(), rounding);\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToAssets} when overriding it.\n */\n function _initialConvertToShares(\n uint256 assets,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 shares) {\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 assets) {\n uint256 supply = totalSupply();\n return\n (supply == 0) ? _initialConvertToAssets(shares, rounding) : shares.mulDiv(totalAssets(), supply, rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToShares} when overriding it.\n */\n function _initialConvertToAssets(\n uint256 shares,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 assets) {\n return shares;\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transferred and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transferred, which is a valid state.\n _burn(owner, shares);\n SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _isVaultCollateralized() private view returns (bool) {\n return totalAssets() > 0 || totalSupply() == 0;\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/contracts/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/contracts/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/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2Upgradeable {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(\n uint256 amount,\n bytes32 salt,\n bytes memory bytecode\n ) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(\n bytes32 salt,\n bytes32 bytecodeHash,\n address deployer\n ) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "solmate/auth/Auth.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\nabstract contract Auth {\n event OwnerUpdated(address indexed user, address indexed newOwner);\n\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\n\n address public owner;\n\n Authority public authority;\n\n constructor(address _owner, Authority _authority) {\n owner = _owner;\n authority = _authority;\n\n emit OwnerUpdated(msg.sender, _owner);\n emit AuthorityUpdated(msg.sender, _authority);\n }\n\n modifier requiresAuth() virtual {\n require(isAuthorized(msg.sender, msg.sig), \"UNAUTHORIZED\");\n\n _;\n }\n\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\n\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\n }\n\n function setAuthority(Authority newAuthority) public virtual {\n // We check if the caller is the owner first because we want to ensure they can\n // always swap out the authority even if it's reverting or using up a lot of gas.\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\n\n authority = newAuthority;\n\n emit AuthorityUpdated(msg.sender, newAuthority);\n }\n\n function setOwner(address newOwner) public virtual requiresAuth {\n owner = newOwner;\n\n emit OwnerUpdated(msg.sender, newOwner);\n }\n}\n\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\ninterface Authority {\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n}\n" + }, + "solmate/auth/authorities/RolesAuthority.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {Auth, Authority} from \"../Auth.sol\";\n\n/// @notice Role based Authority that supports up to 256 roles.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\ncontract RolesAuthority is Auth, Authority {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\n\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\n\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\n\n /*//////////////////////////////////////////////////////////////\n ROLE/USER STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(address => bytes32) public getUserRoles;\n\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\n\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\n\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\n }\n\n function doesRoleHaveCapability(\n uint8 role,\n address target,\n bytes4 functionSig\n ) public view virtual returns (bool) {\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\n }\n\n /*//////////////////////////////////////////////////////////////\n AUTHORIZATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) public view virtual override returns (bool) {\n return\n isCapabilityPublic[target][functionSig] ||\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\n }\n\n /*//////////////////////////////////////////////////////////////\n ROLE CAPABILITY CONFIGURATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setPublicCapability(\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n isCapabilityPublic[target][functionSig] = enabled;\n\n emit PublicCapabilityUpdated(target, functionSig, enabled);\n }\n\n function setRoleCapability(\n uint8 role,\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\n } else {\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\n }\n\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\n }\n\n /*//////////////////////////////////////////////////////////////\n USER ROLE ASSIGNMENT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setUserRole(\n address user,\n uint8 role,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getUserRoles[user] |= bytes32(1 << role);\n } else {\n getUserRoles[user] &= ~bytes32(1 << role);\n }\n\n emit UserRoleUpdated(user, role, enabled);\n }\n}\n" + }, + "solmate/mixins/ERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\nimport {FixedPointMathLib} from \"../utils/FixedPointMathLib.sol\";\n\n/// @notice Minimal ERC4626 tokenized Vault implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/mixins/ERC4626.sol)\nabstract contract ERC4626 is ERC20 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /*//////////////////////////////////////////////////////////////\n IMMUTABLES\n //////////////////////////////////////////////////////////////*/\n\n ERC20 public immutable asset;\n\n constructor(\n ERC20 _asset,\n string memory _name,\n string memory _symbol\n ) ERC20(_name, _symbol, _asset.decimals()) {\n asset = _asset;\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n /*//////////////////////////////////////////////////////////////\n ACCOUNTING LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function totalAssets() public view virtual returns (uint256);\n\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\n }\n\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\n }\n\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\n return convertToShares(assets);\n }\n\n function previewMint(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\n }\n\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\n }\n\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\n return convertToAssets(shares);\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function maxDeposit(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxMint(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxWithdraw(address owner) public view virtual returns (uint256) {\n return convertToAssets(balanceOf[owner]);\n }\n\n function maxRedeem(address owner) public view virtual returns (uint256) {\n return balanceOf[owner];\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL HOOKS LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\n}\n" + }, + "solmate/test/utils/mocks/MockERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../../../tokens/ERC20.sol\";\n\ncontract MockERC20 is ERC20 {\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) ERC20(_name, _symbol, _decimals) {}\n\n function mint(address to, uint256 value) public virtual {\n _mint(to, value);\n }\n\n function burn(address from, uint256 value) public virtual {\n _burn(from, value);\n }\n}\n" + }, + "solmate/tokens/ERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" + }, + "solmate/tokens/WETH.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"./ERC20.sol\";\n\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\n\n/// @notice Minimalist and modern Wrapped Ether implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)\n/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)\ncontract WETH is ERC20(\"Wrapped Ether\", \"WETH\", 18) {\n using SafeTransferLib for address;\n\n event Deposit(address indexed from, uint256 amount);\n\n event Withdrawal(address indexed to, uint256 amount);\n\n function deposit() public payable virtual {\n _mint(msg.sender, msg.value);\n\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 amount) public virtual {\n _burn(msg.sender, amount);\n\n emit Withdrawal(msg.sender, amount);\n\n msg.sender.safeTransferETH(amount);\n }\n\n receive() external payable virtual {\n deposit();\n }\n}\n" + }, + "solmate/utils/FixedPointMathLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // Divide z by the denominator.\n z := div(z, denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // First, divide z - 1 by the denominator and add 1.\n // We allow z - 1 to underflow if z is 0, because we multiply the\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n assembly {\n let y := x // We start y at x, which will help us make our initial estimate.\n\n z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n // We check y >= 2^(k + 8) but shift right by k bits\n // each branch to ensure that if x >= 256, then y >= 256.\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n y := shr(128, y)\n z := shl(64, z)\n }\n if iszero(lt(y, 0x1000000000000000000)) {\n y := shr(64, y)\n z := shl(32, z)\n }\n if iszero(lt(y, 0x10000000000)) {\n y := shr(32, y)\n z := shl(16, z)\n }\n if iszero(lt(y, 0x1000000)) {\n y := shr(16, y)\n z := shl(8, z)\n }\n\n // Goal was to get z*z*y within a small factor of x. More iterations could\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n // There is no overflow risk here since y < 2^136 after the first branch above.\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // If x+1 is a perfect square, the Babylonian method cycles between\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n z := sub(z, lt(div(x, z), z))\n }\n }\n\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Mod x by y. Note this will return\n // 0 instead of reverting if y is zero.\n z := mod(x, y)\n }\n }\n\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\n assembly {\n // Divide x by y. Note this will return\n // 0 instead of reverting if y is zero.\n r := div(x, y)\n }\n }\n\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Add 1 to x * y if x % y > 0. Note this will\n // return 0 instead of reverting if y is zero.\n z := add(gt(mod(x, y), 0), div(x, y))\n }\n }\n}\n" + }, + "solmate/utils/SafeCastLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Safe unsigned integer casting library that reverts on overflow.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\nlibrary SafeCastLib {\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\n require(x < 1 << 248);\n\n y = uint248(x);\n }\n\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\n require(x < 1 << 224);\n\n y = uint224(x);\n }\n\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\n require(x < 1 << 192);\n\n y = uint192(x);\n }\n\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\n require(x < 1 << 160);\n\n y = uint160(x);\n }\n\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\n require(x < 1 << 128);\n\n y = uint128(x);\n }\n\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\n require(x < 1 << 96);\n\n y = uint96(x);\n }\n\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\n require(x < 1 << 64);\n\n y = uint64(x);\n }\n\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\n require(x < 1 << 32);\n\n y = uint32(x);\n }\n\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\n require(x < 1 << 24);\n\n y = uint24(x);\n }\n\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\n require(x < 1 << 16);\n\n y = uint16(x);\n }\n\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\n require(x < 1 << 8);\n\n y = uint8(x);\n }\n}\n" + }, + "solmate/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/solcInputs/4516d6f7efae8f060f60e63dbb0131ce.json b/packages/contracts/deployments/superseed/solcInputs/4516d6f7efae8f060f60e63dbb0131ce.json new file mode 100644 index 0000000000..11627df822 --- /dev/null +++ b/packages/contracts/deployments/superseed/solcInputs/4516d6f7efae8f060f60e63dbb0131ce.json @@ -0,0 +1,1458 @@ +{ + "language": "Solidity", + "sources": { + "@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol": { + "content": "// SPDX-License-Identifier: LZBL-1.2\n\npragma solidity ^0.8.20;\n\nimport { BytesLib } from \"solidity-bytes-utils/contracts/BytesLib.sol\";\n\nimport { BitMap256 } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol\";\nimport { CalldataBytesLib } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol\";\n\nlibrary DVNOptions {\n using CalldataBytesLib for bytes;\n using BytesLib for bytes;\n\n uint8 internal constant WORKER_ID = 2;\n uint8 internal constant OPTION_TYPE_PRECRIME = 1;\n\n error DVN_InvalidDVNIdx();\n error DVN_InvalidDVNOptions(uint256 cursor);\n\n /// @dev group dvn options by its idx\n /// @param _options [dvn_id][dvn_option][dvn_id][dvn_option]...\n /// dvn_option = [option_size][dvn_idx][option_type][option]\n /// option_size = len(dvn_idx) + len(option_type) + len(option)\n /// dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes\n /// @return dvnOptions the grouped options, still share the same format of _options\n /// @return dvnIndices the dvn indices\n function groupDVNOptionsByIdx(\n bytes memory _options\n ) internal pure returns (bytes[] memory dvnOptions, uint8[] memory dvnIndices) {\n if (_options.length == 0) return (dvnOptions, dvnIndices);\n\n uint8 numDVNs = getNumDVNs(_options);\n\n // if there is only 1 dvn, we can just return the whole options\n if (numDVNs == 1) {\n dvnOptions = new bytes[](1);\n dvnOptions[0] = _options;\n\n dvnIndices = new uint8[](1);\n dvnIndices[0] = _options.toUint8(3); // dvn idx\n return (dvnOptions, dvnIndices);\n }\n\n // otherwise, we need to group the options by dvn_idx\n dvnIndices = new uint8[](numDVNs);\n dvnOptions = new bytes[](numDVNs);\n unchecked {\n uint256 cursor = 0;\n uint256 start = 0;\n uint8 lastDVNIdx = 255; // 255 is an invalid dvn_idx\n\n while (cursor < _options.length) {\n ++cursor; // skip worker_id\n\n // optionLength asserted in getNumDVNs (skip check)\n uint16 optionLength = _options.toUint16(cursor);\n cursor += 2;\n\n // dvnIdx asserted in getNumDVNs (skip check)\n uint8 dvnIdx = _options.toUint8(cursor);\n\n // dvnIdx must equal to the lastDVNIdx for the first option\n // so it is always skipped in the first option\n // this operation slices out options whenever the scan finds a different lastDVNIdx\n if (lastDVNIdx == 255) {\n lastDVNIdx = dvnIdx;\n } else if (dvnIdx != lastDVNIdx) {\n uint256 len = cursor - start - 3; // 3 is for worker_id and option_length\n bytes memory opt = _options.slice(start, len);\n _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, opt);\n\n // reset the start and lastDVNIdx\n start += len;\n lastDVNIdx = dvnIdx;\n }\n\n cursor += optionLength;\n }\n\n // skip check the cursor here because the cursor is asserted in getNumDVNs\n // if we have reached the end of the options, we need to process the last dvn\n uint256 size = cursor - start;\n bytes memory op = _options.slice(start, size);\n _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, op);\n\n // revert dvnIndices to start from 0\n for (uint8 i = 0; i < numDVNs; ++i) {\n --dvnIndices[i];\n }\n }\n }\n\n function _insertDVNOptions(\n bytes[] memory _dvnOptions,\n uint8[] memory _dvnIndices,\n uint8 _dvnIdx,\n bytes memory _newOptions\n ) internal pure {\n // dvnIdx starts from 0 but default value of dvnIndices is 0,\n // so we tell if the slot is empty by adding 1 to dvnIdx\n if (_dvnIdx == 255) revert DVN_InvalidDVNIdx();\n uint8 dvnIdxAdj = _dvnIdx + 1;\n\n for (uint256 j = 0; j < _dvnIndices.length; ++j) {\n uint8 index = _dvnIndices[j];\n if (dvnIdxAdj == index) {\n _dvnOptions[j] = abi.encodePacked(_dvnOptions[j], _newOptions);\n break;\n } else if (index == 0) {\n // empty slot, that means it is the first time we see this dvn\n _dvnIndices[j] = dvnIdxAdj;\n _dvnOptions[j] = _newOptions;\n break;\n }\n }\n }\n\n /// @dev get the number of unique dvns\n /// @param _options the format is the same as groupDVNOptionsByIdx\n function getNumDVNs(bytes memory _options) internal pure returns (uint8 numDVNs) {\n uint256 cursor = 0;\n BitMap256 bitmap;\n\n // find number of unique dvn_idx\n unchecked {\n while (cursor < _options.length) {\n ++cursor; // skip worker_id\n\n uint16 optionLength = _options.toUint16(cursor);\n cursor += 2;\n if (optionLength < 2) revert DVN_InvalidDVNOptions(cursor); // at least 1 byte for dvn_idx and 1 byte for option_type\n\n uint8 dvnIdx = _options.toUint8(cursor);\n\n // if dvnIdx is not set, increment numDVNs\n // max num of dvns is 255, 255 is an invalid dvn_idx\n // The order of the dvnIdx is not required to be sequential, as enforcing the order may weaken\n // the composability of the options. e.g. if we refrain from enforcing the order, an OApp that has\n // already enforced certain options can append additional options to the end of the enforced\n // ones without restrictions.\n if (dvnIdx == 255) revert DVN_InvalidDVNIdx();\n if (!bitmap.get(dvnIdx)) {\n ++numDVNs;\n bitmap = bitmap.set(dvnIdx);\n }\n\n cursor += optionLength;\n }\n }\n if (cursor != _options.length) revert DVN_InvalidDVNOptions(cursor);\n }\n\n /// @dev decode the next dvn option from _options starting from the specified cursor\n /// @param _options the format is the same as groupDVNOptionsByIdx\n /// @param _cursor the cursor to start decoding\n /// @return optionType the type of the option\n /// @return option the option\n /// @return cursor the cursor to start decoding the next option\n function nextDVNOption(\n bytes calldata _options,\n uint256 _cursor\n ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {\n unchecked {\n // skip worker id\n cursor = _cursor + 1;\n\n // read option size\n uint16 size = _options.toU16(cursor);\n cursor += 2;\n\n // read option type\n optionType = _options.toU8(cursor + 1); // skip dvn_idx\n\n // startCursor and endCursor are used to slice the option from _options\n uint256 startCursor = cursor + 2; // skip option type and dvn_idx\n uint256 endCursor = cursor + size;\n option = _options[startCursor:endCursor];\n cursor += size;\n }\n }\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nimport { IMessageLibManager } from \"./IMessageLibManager.sol\";\nimport { IMessagingComposer } from \"./IMessagingComposer.sol\";\nimport { IMessagingChannel } from \"./IMessagingChannel.sol\";\nimport { IMessagingContext } from \"./IMessagingContext.sol\";\n\nstruct MessagingParams {\n uint32 dstEid;\n bytes32 receiver;\n bytes message;\n bytes options;\n bool payInLzToken;\n}\n\nstruct MessagingReceipt {\n bytes32 guid;\n uint64 nonce;\n MessagingFee fee;\n}\n\nstruct MessagingFee {\n uint256 nativeFee;\n uint256 lzTokenFee;\n}\n\nstruct Origin {\n uint32 srcEid;\n bytes32 sender;\n uint64 nonce;\n}\n\ninterface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {\n event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);\n\n event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);\n\n event PacketDelivered(Origin origin, address receiver);\n\n event LzReceiveAlert(\n address indexed receiver,\n address indexed executor,\n Origin origin,\n bytes32 guid,\n uint256 gas,\n uint256 value,\n bytes message,\n bytes extraData,\n bytes reason\n );\n\n event LzTokenSet(address token);\n\n event DelegateSet(address sender, address delegate);\n\n function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);\n\n function send(\n MessagingParams calldata _params,\n address _refundAddress\n ) external payable returns (MessagingReceipt memory);\n\n function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;\n\n function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);\n\n function initializable(Origin calldata _origin, address _receiver) external view returns (bool);\n\n function lzReceive(\n Origin calldata _origin,\n address _receiver,\n bytes32 _guid,\n bytes calldata _message,\n bytes calldata _extraData\n ) external payable;\n\n // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order\n function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;\n\n function setLzToken(address _lzToken) external;\n\n function lzToken() external view returns (address);\n\n function nativeToken() external view returns (address);\n\n function setDelegate(address _delegate) external;\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nimport { Origin } from \"./ILayerZeroEndpointV2.sol\";\n\ninterface ILayerZeroReceiver {\n function allowInitializePath(Origin calldata _origin) external view returns (bool);\n\n function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64);\n\n function lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) external payable;\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nstruct SetConfigParam {\n uint32 eid;\n uint32 configType;\n bytes config;\n}\n\ninterface IMessageLibManager {\n struct Timeout {\n address lib;\n uint256 expiry;\n }\n\n event LibraryRegistered(address newLib);\n event DefaultSendLibrarySet(uint32 eid, address newLib);\n event DefaultReceiveLibrarySet(uint32 eid, address newLib);\n event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);\n event SendLibrarySet(address sender, uint32 eid, address newLib);\n event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);\n event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);\n\n function registerLibrary(address _lib) external;\n\n function isRegisteredLibrary(address _lib) external view returns (bool);\n\n function getRegisteredLibraries() external view returns (address[] memory);\n\n function setDefaultSendLibrary(uint32 _eid, address _newLib) external;\n\n function defaultSendLibrary(uint32 _eid) external view returns (address);\n\n function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _timeout) external;\n\n function defaultReceiveLibrary(uint32 _eid) external view returns (address);\n\n function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;\n\n function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);\n\n function isSupportedEid(uint32 _eid) external view returns (bool);\n\n function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);\n\n /// ------------------- OApp interfaces -------------------\n function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;\n\n function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);\n\n function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);\n\n function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;\n\n function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);\n\n function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external;\n\n function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);\n\n function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;\n\n function getConfig(\n address _oapp,\n address _lib,\n uint32 _eid,\n uint32 _configType\n ) external view returns (bytes memory config);\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingChannel {\n event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);\n event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n\n function eid() external view returns (uint32);\n\n // this is an emergency function if a message cannot be verified for some reasons\n // required to provide _nextNonce to avoid race condition\n function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;\n\n function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);\n\n function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);\n\n function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);\n\n function inboundPayloadHash(\n address _receiver,\n uint32 _srcEid,\n bytes32 _sender,\n uint64 _nonce\n ) external view returns (bytes32);\n\n function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingComposer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingComposer {\n event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);\n event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);\n event LzComposeAlert(\n address indexed from,\n address indexed to,\n address indexed executor,\n bytes32 guid,\n uint16 index,\n uint256 gas,\n uint256 value,\n bytes message,\n bytes extraData,\n bytes reason\n );\n\n function composeQueue(\n address _from,\n address _to,\n bytes32 _guid,\n uint16 _index\n ) external view returns (bytes32 messageHash);\n\n function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;\n\n function lzCompose(\n address _from,\n address _to,\n bytes32 _guid,\n uint16 _index,\n bytes calldata _message,\n bytes calldata _extraData\n ) external payable;\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingContext.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingContext {\n function isSendingMessage() external view returns (bool);\n\n function getSendContext() external view returns (uint32 dstEid, address sender);\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol": { + "content": "// SPDX-License-Identifier: LZBL-1.2\n\npragma solidity ^0.8.20;\n\nlibrary CalldataBytesLib {\n function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) {\n return uint8(_bytes[_start]);\n }\n\n function toU16(bytes calldata _bytes, uint256 _start) internal pure returns (uint16) {\n unchecked {\n uint256 end = _start + 2;\n return uint16(bytes2(_bytes[_start:end]));\n }\n }\n\n function toU32(bytes calldata _bytes, uint256 _start) internal pure returns (uint32) {\n unchecked {\n uint256 end = _start + 4;\n return uint32(bytes4(_bytes[_start:end]));\n }\n }\n\n function toU64(bytes calldata _bytes, uint256 _start) internal pure returns (uint64) {\n unchecked {\n uint256 end = _start + 8;\n return uint64(bytes8(_bytes[_start:end]));\n }\n }\n\n function toU128(bytes calldata _bytes, uint256 _start) internal pure returns (uint128) {\n unchecked {\n uint256 end = _start + 16;\n return uint128(bytes16(_bytes[_start:end]));\n }\n }\n\n function toU256(bytes calldata _bytes, uint256 _start) internal pure returns (uint256) {\n unchecked {\n uint256 end = _start + 32;\n return uint256(bytes32(_bytes[_start:end]));\n }\n }\n\n function toAddr(bytes calldata _bytes, uint256 _start) internal pure returns (address) {\n unchecked {\n uint256 end = _start + 20;\n return address(bytes20(_bytes[_start:end]));\n }\n }\n\n function toB32(bytes calldata _bytes, uint256 _start) internal pure returns (bytes32) {\n unchecked {\n uint256 end = _start + 32;\n return bytes32(_bytes[_start:end]);\n }\n }\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol\npragma solidity ^0.8.20;\n\ntype BitMap256 is uint256;\n\nusing BitMaps for BitMap256 global;\n\nlibrary BitMaps {\n /**\n * @dev Returns whether the bit at `index` is set.\n */\n function get(BitMap256 bitmap, uint8 index) internal pure returns (bool) {\n uint256 mask = 1 << index;\n return BitMap256.unwrap(bitmap) & mask != 0;\n }\n\n /**\n * @dev Sets the bit at `index`.\n */\n function set(BitMap256 bitmap, uint8 index) internal pure returns (BitMap256) {\n uint256 mask = 1 << index;\n return BitMap256.wrap(BitMap256.unwrap(bitmap) | mask);\n }\n}\n" + }, + "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol": { + "content": "// SPDX-License-Identifier: LZBL-1.2\n\npragma solidity ^0.8.20;\n\nimport { CalldataBytesLib } from \"../../libs/CalldataBytesLib.sol\";\n\nlibrary ExecutorOptions {\n using CalldataBytesLib for bytes;\n\n uint8 internal constant WORKER_ID = 1;\n\n uint8 internal constant OPTION_TYPE_LZRECEIVE = 1;\n uint8 internal constant OPTION_TYPE_NATIVE_DROP = 2;\n uint8 internal constant OPTION_TYPE_LZCOMPOSE = 3;\n uint8 internal constant OPTION_TYPE_ORDERED_EXECUTION = 4;\n\n error Executor_InvalidLzReceiveOption();\n error Executor_InvalidNativeDropOption();\n error Executor_InvalidLzComposeOption();\n\n /// @dev decode the next executor option from the options starting from the specified cursor\n /// @param _options [executor_id][executor_option][executor_id][executor_option]...\n /// executor_option = [option_size][option_type][option]\n /// option_size = len(option_type) + len(option)\n /// executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes\n /// @param _cursor the cursor to start decoding from\n /// @return optionType the type of the option\n /// @return option the option of the executor\n /// @return cursor the cursor to start decoding the next executor option\n function nextExecutorOption(\n bytes calldata _options,\n uint256 _cursor\n ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {\n unchecked {\n // skip worker id\n cursor = _cursor + 1;\n\n // read option size\n uint16 size = _options.toU16(cursor);\n cursor += 2;\n\n // read option type\n optionType = _options.toU8(cursor);\n\n // startCursor and endCursor are used to slice the option from _options\n uint256 startCursor = cursor + 1; // skip option type\n uint256 endCursor = cursor + size;\n option = _options[startCursor:endCursor];\n cursor += size;\n }\n }\n\n function decodeLzReceiveOption(bytes calldata _option) internal pure returns (uint128 gas, uint128 value) {\n if (_option.length != 16 && _option.length != 32) revert Executor_InvalidLzReceiveOption();\n gas = _option.toU128(0);\n value = _option.length == 32 ? _option.toU128(16) : 0;\n }\n\n function decodeNativeDropOption(bytes calldata _option) internal pure returns (uint128 amount, bytes32 receiver) {\n if (_option.length != 48) revert Executor_InvalidNativeDropOption();\n amount = _option.toU128(0);\n receiver = _option.toB32(16);\n }\n\n function decodeLzComposeOption(\n bytes calldata _option\n ) internal pure returns (uint16 index, uint128 gas, uint128 value) {\n if (_option.length != 18 && _option.length != 34) revert Executor_InvalidLzComposeOption();\n index = _option.toU16(0);\n gas = _option.toU128(2);\n value = _option.length == 34 ? _option.toU128(18) : 0;\n }\n\n function encodeLzReceiveOption(uint128 _gas, uint128 _value) internal pure returns (bytes memory) {\n return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value);\n }\n\n function encodeNativeDropOption(uint128 _amount, bytes32 _receiver) internal pure returns (bytes memory) {\n return abi.encodePacked(_amount, _receiver);\n }\n\n function encodeLzComposeOption(uint16 _index, uint128 _gas, uint128 _value) internal pure returns (bytes memory) {\n return _value == 0 ? abi.encodePacked(_index, _gas) : abi.encodePacked(_index, _gas, _value);\n }\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppCore.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { ILayerZeroEndpointV2 } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\n\n/**\n * @title IOAppCore\n */\ninterface IOAppCore {\n // Custom error messages\n error OnlyPeer(uint32 eid, bytes32 sender);\n error NoPeer(uint32 eid);\n error InvalidEndpointCall();\n error InvalidDelegate();\n\n // Event emitted when a peer (OApp) is set for a corresponding endpoint\n event PeerSet(uint32 eid, bytes32 peer);\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n */\n function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);\n\n /**\n * @notice Retrieves the LayerZero endpoint associated with the OApp.\n * @return iEndpoint The LayerZero endpoint as an interface.\n */\n function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);\n\n /**\n * @notice Retrieves the peer (OApp) associated with a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @return peer The peer address (OApp instance) associated with the corresponding endpoint.\n */\n function peers(uint32 _eid) external view returns (bytes32 peer);\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n */\n function setPeer(uint32 _eid, bytes32 _peer) external;\n\n /**\n * @notice Sets the delegate address for the OApp Core.\n * @param _delegate The address of the delegate to be set.\n */\n function setDelegate(address _delegate) external;\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppReceiver.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport { ILayerZeroReceiver, Origin } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol\";\n\ninterface IOAppReceiver is ILayerZeroReceiver {\n /**\n * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.\n * @param _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @param _message The lzReceive payload.\n * @param _sender The sender address.\n * @return isSender Is a valid sender.\n *\n * @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer.\n * @dev The default sender IS the OAppReceiver implementer.\n */\n function isComposeMsgSender(\n Origin calldata _origin,\n bytes calldata _message,\n address _sender\n ) external view returns (bool isSender);\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { BytesLib } from \"solidity-bytes-utils/contracts/BytesLib.sol\";\nimport { SafeCast } from \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport { ExecutorOptions } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol\";\nimport { DVNOptions } from \"@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol\";\n\n/**\n * @title OptionsBuilder\n * @dev Library for building and encoding various message options.\n */\nlibrary OptionsBuilder {\n using SafeCast for uint256;\n using BytesLib for bytes;\n\n // Constants for options types\n uint16 internal constant TYPE_1 = 1; // legacy options type 1\n uint16 internal constant TYPE_2 = 2; // legacy options type 2\n uint16 internal constant TYPE_3 = 3;\n\n // Custom error message\n error InvalidSize(uint256 max, uint256 actual);\n error InvalidOptionType(uint16 optionType);\n\n // Modifier to ensure only options of type 3 are used\n modifier onlyType3(bytes memory _options) {\n if (_options.toUint16(0) != TYPE_3) revert InvalidOptionType(_options.toUint16(0));\n _;\n }\n\n /**\n * @dev Creates a new options container with type 3.\n * @return options The newly created options container.\n */\n function newOptions() internal pure returns (bytes memory) {\n return abi.encodePacked(TYPE_3);\n }\n\n /**\n * @dev Adds an executor LZ receive option to the existing options.\n * @param _options The existing options container.\n * @param _gas The gasLimit used on the lzReceive() function in the OApp.\n * @param _value The msg.value passed to the lzReceive() function in the OApp.\n * @return options The updated options container.\n *\n * @dev When multiples of this option are added, they are summed by the executor\n * eg. if (_gas: 200k, and _value: 1 ether) AND (_gas: 100k, _value: 0.5 ether) are sent in an option to the LayerZeroEndpoint,\n * that becomes (300k, 1.5 ether) when the message is executed on the remote lzReceive() function.\n */\n function addExecutorLzReceiveOption(\n bytes memory _options,\n uint128 _gas,\n uint128 _value\n ) internal pure onlyType3(_options) returns (bytes memory) {\n bytes memory option = ExecutorOptions.encodeLzReceiveOption(_gas, _value);\n return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZRECEIVE, option);\n }\n\n /**\n * @dev Adds an executor native drop option to the existing options.\n * @param _options The existing options container.\n * @param _amount The amount for the native value that is airdropped to the 'receiver'.\n * @param _receiver The receiver address for the native drop option.\n * @return options The updated options container.\n *\n * @dev When multiples of this option are added, they are summed by the executor on the remote chain.\n */\n function addExecutorNativeDropOption(\n bytes memory _options,\n uint128 _amount,\n bytes32 _receiver\n ) internal pure onlyType3(_options) returns (bytes memory) {\n bytes memory option = ExecutorOptions.encodeNativeDropOption(_amount, _receiver);\n return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_NATIVE_DROP, option);\n }\n\n /**\n * @dev Adds an executor LZ compose option to the existing options.\n * @param _options The existing options container.\n * @param _index The index for the lzCompose() function call.\n * @param _gas The gasLimit for the lzCompose() function call.\n * @param _value The msg.value for the lzCompose() function call.\n * @return options The updated options container.\n *\n * @dev When multiples of this option are added, they are summed PER index by the executor on the remote chain.\n * @dev If the OApp sends N lzCompose calls on the remote, you must provide N incremented indexes starting with 0.\n * ie. When your remote OApp composes (N = 3) messages, you must set this option for index 0,1,2\n */\n function addExecutorLzComposeOption(\n bytes memory _options,\n uint16 _index,\n uint128 _gas,\n uint128 _value\n ) internal pure onlyType3(_options) returns (bytes memory) {\n bytes memory option = ExecutorOptions.encodeLzComposeOption(_index, _gas, _value);\n return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZCOMPOSE, option);\n }\n\n /**\n * @dev Adds an executor ordered execution option to the existing options.\n * @param _options The existing options container.\n * @return options The updated options container.\n */\n function addExecutorOrderedExecutionOption(\n bytes memory _options\n ) internal pure onlyType3(_options) returns (bytes memory) {\n return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_ORDERED_EXECUTION, bytes(\"\"));\n }\n\n /**\n * @dev Adds a DVN pre-crime option to the existing options.\n * @param _options The existing options container.\n * @param _dvnIdx The DVN index for the pre-crime option.\n * @return options The updated options container.\n */\n function addDVNPreCrimeOption(\n bytes memory _options,\n uint8 _dvnIdx\n ) internal pure onlyType3(_options) returns (bytes memory) {\n return addDVNOption(_options, _dvnIdx, DVNOptions.OPTION_TYPE_PRECRIME, bytes(\"\"));\n }\n\n /**\n * @dev Adds an executor option to the existing options.\n * @param _options The existing options container.\n * @param _optionType The type of the executor option.\n * @param _option The encoded data for the executor option.\n * @return options The updated options container.\n */\n function addExecutorOption(\n bytes memory _options,\n uint8 _optionType,\n bytes memory _option\n ) internal pure onlyType3(_options) returns (bytes memory) {\n return\n abi.encodePacked(\n _options,\n ExecutorOptions.WORKER_ID,\n _option.length.toUint16() + 1, // +1 for optionType\n _optionType,\n _option\n );\n }\n\n /**\n * @dev Adds a DVN option to the existing options.\n * @param _options The existing options container.\n * @param _dvnIdx The DVN index for the DVN option.\n * @param _optionType The type of the DVN option.\n * @param _option The encoded data for the DVN option.\n * @return options The updated options container.\n */\n function addDVNOption(\n bytes memory _options,\n uint8 _dvnIdx,\n uint8 _optionType,\n bytes memory _option\n ) internal pure onlyType3(_options) returns (bytes memory) {\n return\n abi.encodePacked(\n _options,\n DVNOptions.WORKER_ID,\n _option.length.toUint16() + 2, // +2 for optionType and dvnIdx\n _dvnIdx,\n _optionType,\n _option\n );\n }\n\n /**\n * @dev Encodes legacy options of type 1.\n * @param _executionGas The gasLimit value passed to lzReceive().\n * @return legacyOptions The encoded legacy options.\n */\n function encodeLegacyOptionsType1(uint256 _executionGas) internal pure returns (bytes memory) {\n if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);\n return abi.encodePacked(TYPE_1, _executionGas);\n }\n\n /**\n * @dev Encodes legacy options of type 2.\n * @param _executionGas The gasLimit value passed to lzReceive().\n * @param _nativeForDst The amount of native air dropped to the receiver.\n * @param _receiver The _nativeForDst receiver address.\n * @return legacyOptions The encoded legacy options of type 2.\n */\n function encodeLegacyOptionsType2(\n uint256 _executionGas,\n uint256 _nativeForDst,\n bytes memory _receiver // @dev Use bytes instead of bytes32 in legacy type 2 for _receiver.\n ) internal pure returns (bytes memory) {\n if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);\n if (_nativeForDst > type(uint128).max) revert InvalidSize(type(uint128).max, _nativeForDst);\n if (_receiver.length > 32) revert InvalidSize(32, _receiver.length);\n return abi.encodePacked(TYPE_2, _executionGas, _nativeForDst, _receiver);\n }\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/OApp.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\n// @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers\n// solhint-disable-next-line no-unused-import\nimport { OAppSender, MessagingFee, MessagingReceipt } from \"./OAppSender.sol\";\n// @dev Import the 'Origin' so it's exposed to OApp implementers\n// solhint-disable-next-line no-unused-import\nimport { OAppReceiver, Origin } from \"./OAppReceiver.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OApp\n * @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.\n */\nabstract contract OApp is OAppSender, OAppReceiver {\n /**\n * @dev Constructor to initialize the OApp with the provided endpoint and owner.\n * @param _endpoint The address of the LOCAL LayerZero endpoint.\n * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.\n */\n constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {}\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol implementation.\n * @return receiverVersion The version of the OAppReceiver.sol implementation.\n */\n function oAppVersion()\n public\n pure\n virtual\n override(OAppSender, OAppReceiver)\n returns (uint64 senderVersion, uint64 receiverVersion)\n {\n return (SENDER_VERSION, RECEIVER_VERSION);\n }\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/OAppCore.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport { IOAppCore, ILayerZeroEndpointV2 } from \"./interfaces/IOAppCore.sol\";\n\n/**\n * @title OAppCore\n * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.\n */\nabstract contract OAppCore is IOAppCore, Ownable {\n // The LayerZero endpoint associated with the given OApp\n ILayerZeroEndpointV2 public immutable endpoint;\n\n // Mapping to store peers associated with corresponding endpoints\n mapping(uint32 eid => bytes32 peer) public peers;\n\n /**\n * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.\n * @param _endpoint The address of the LOCAL Layer Zero endpoint.\n * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.\n *\n * @dev The delegate typically should be set as the owner of the contract.\n */\n constructor(address _endpoint, address _delegate) {\n endpoint = ILayerZeroEndpointV2(_endpoint);\n\n if (_delegate == address(0)) revert InvalidDelegate();\n endpoint.setDelegate(_delegate);\n }\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n *\n * @dev Only the owner/admin of the OApp can call this function.\n * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.\n * @dev Set this to bytes32(0) to remove the peer address.\n * @dev Peer is a bytes32 to accommodate non-evm chains.\n */\n function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {\n _setPeer(_eid, _peer);\n }\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n *\n * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.\n * @dev Set this to bytes32(0) to remove the peer address.\n * @dev Peer is a bytes32 to accommodate non-evm chains.\n */\n function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {\n peers[_eid] = _peer;\n emit PeerSet(_eid, _peer);\n }\n\n /**\n * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.\n * ie. the peer is set to bytes32(0).\n * @param _eid The endpoint ID.\n * @return peer The address of the peer associated with the specified endpoint.\n */\n function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {\n bytes32 peer = peers[_eid];\n if (peer == bytes32(0)) revert NoPeer(_eid);\n return peer;\n }\n\n /**\n * @notice Sets the delegate address for the OApp.\n * @param _delegate The address of the delegate to be set.\n *\n * @dev Only the owner/admin of the OApp can call this function.\n * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.\n */\n function setDelegate(address _delegate) public onlyOwner {\n endpoint.setDelegate(_delegate);\n }\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/OAppReceiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { IOAppReceiver, Origin } from \"./interfaces/IOAppReceiver.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OAppReceiver\n * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.\n */\nabstract contract OAppReceiver is IOAppReceiver, OAppCore {\n // Custom error message for when the caller is not the registered endpoint/\n error OnlyEndpoint(address addr);\n\n // @dev The version of the OAppReceiver implementation.\n // @dev Version is bumped when changes are made to this contract.\n uint64 internal constant RECEIVER_VERSION = 2;\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n *\n * @dev Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented.\n * ie. this is a RECEIVE only OApp.\n * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions.\n */\n function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {\n return (0, RECEIVER_VERSION);\n }\n\n /**\n * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.\n * @dev _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @dev _message The lzReceive payload.\n * @param _sender The sender address.\n * @return isSender Is a valid sender.\n *\n * @dev Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer.\n * @dev The default sender IS the OAppReceiver implementer.\n */\n function isComposeMsgSender(\n Origin calldata /*_origin*/,\n bytes calldata /*_message*/,\n address _sender\n ) public view virtual returns (bool) {\n return _sender == address(this);\n }\n\n /**\n * @notice Checks if the path initialization is allowed based on the provided origin.\n * @param origin The origin information containing the source endpoint and sender address.\n * @return Whether the path has been initialized.\n *\n * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received.\n * @dev This defaults to assuming if a peer has been set, its initialized.\n * Can be overridden by the OApp if there is other logic to determine this.\n */\n function allowInitializePath(Origin calldata origin) public view virtual returns (bool) {\n return peers[origin.srcEid] == origin.sender;\n }\n\n /**\n * @notice Retrieves the next nonce for a given source endpoint and sender address.\n * @dev _srcEid The source endpoint ID.\n * @dev _sender The sender address.\n * @return nonce The next nonce.\n *\n * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement.\n * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered.\n * @dev This is also enforced by the OApp.\n * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0.\n */\n function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public view virtual returns (uint64 nonce) {\n return 0;\n }\n\n /**\n * @dev Entry point for receiving messages or packets from the endpoint.\n * @param _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @param _guid The unique identifier for the received LayerZero message.\n * @param _message The payload of the received message.\n * @param _executor The address of the executor for the received message.\n * @param _extraData Additional arbitrary data provided by the corresponding executor.\n *\n * @dev Entry point for receiving msg/packet from the LayerZero endpoint.\n */\n function lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) public payable virtual {\n // Ensures that only the endpoint can attempt to lzReceive() messages to this OApp.\n if (address(endpoint) != msg.sender) revert OnlyEndpoint(msg.sender);\n\n // Ensure that the sender matches the expected peer for the source endpoint.\n if (_getPeerOrRevert(_origin.srcEid) != _origin.sender) revert OnlyPeer(_origin.srcEid, _origin.sender);\n\n // Call the internal OApp implementation of lzReceive.\n _lzReceive(_origin, _guid, _message, _executor, _extraData);\n }\n\n /**\n * @dev Internal function to implement lzReceive logic without needing to copy the basic parameter validation.\n */\n function _lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) internal virtual;\n}\n" + }, + "@layerzerolabs/oapp-evm/contracts/oapp/OAppSender.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { SafeERC20, IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { MessagingParams, MessagingFee, MessagingReceipt } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OAppSender\n * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.\n */\nabstract contract OAppSender is OAppCore {\n using SafeERC20 for IERC20;\n\n // Custom error messages\n error NotEnoughNative(uint256 msgValue);\n error LzTokenUnavailable();\n\n // @dev The version of the OAppSender implementation.\n // @dev Version is bumped when changes are made to this contract.\n uint64 internal constant SENDER_VERSION = 1;\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n *\n * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.\n * ie. this is a SEND only OApp.\n * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions\n */\n function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {\n return (SENDER_VERSION, 0);\n }\n\n /**\n * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.\n * @param _dstEid The destination endpoint ID.\n * @param _message The message payload.\n * @param _options Additional options for the message.\n * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.\n * @return fee The calculated MessagingFee for the message.\n * - nativeFee: The native fee for the message.\n * - lzTokenFee: The LZ token fee for the message.\n */\n function _quote(\n uint32 _dstEid,\n bytes memory _message,\n bytes memory _options,\n bool _payInLzToken\n ) internal view virtual returns (MessagingFee memory fee) {\n return\n endpoint.quote(\n MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),\n address(this)\n );\n }\n\n /**\n * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.\n * @param _dstEid The destination endpoint ID.\n * @param _message The message payload.\n * @param _options Additional options for the message.\n * @param _fee The calculated LayerZero fee for the message.\n * - nativeFee: The native fee.\n * - lzTokenFee: The lzToken fee.\n * @param _refundAddress The address to receive any excess fee values sent to the endpoint.\n * @return receipt The receipt for the sent message.\n * - guid: The unique identifier for the sent message.\n * - nonce: The nonce of the sent message.\n * - fee: The LayerZero fee incurred for the message.\n */\n function _lzSend(\n uint32 _dstEid,\n bytes memory _message,\n bytes memory _options,\n MessagingFee memory _fee,\n address _refundAddress\n ) internal virtual returns (MessagingReceipt memory receipt) {\n // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.\n uint256 messageValue = _payNative(_fee.nativeFee);\n if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);\n\n return\n // solhint-disable-next-line check-send-result\n endpoint.send{ value: messageValue }(\n MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),\n _refundAddress\n );\n }\n\n /**\n * @dev Internal function to pay the native fee associated with the message.\n * @param _nativeFee The native fee to be paid.\n * @return nativeFee The amount of native currency paid.\n *\n * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,\n * this will need to be overridden because msg.value would contain multiple lzFees.\n * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.\n * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.\n * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.\n */\n function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {\n if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);\n return _nativeFee;\n }\n\n /**\n * @dev Internal function to pay the LZ token fee associated with the message.\n * @param _lzTokenFee The LZ token fee to be paid.\n *\n * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.\n * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().\n */\n function _payLzToken(uint256 _lzTokenFee) internal virtual {\n // @dev Cannot cache the token because it is not immutable in the endpoint.\n address lzToken = endpoint.lzToken();\n if (lzToken == address(0)) revert LzTokenUnavailable();\n\n // Pay LZ token fee by sending tokens to the endpoint.\n IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable2Step.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 \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.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/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/AbstractPyth.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./PythStructs.sol\";\nimport \"./IPyth.sol\";\nimport \"./PythErrors.sol\";\n\nabstract contract AbstractPyth is IPyth {\n /// @notice Returns the price feed with given id.\n /// @dev Reverts if the price does not exist.\n /// @param id The Pyth Price Feed ID of which to fetch the PriceFeed.\n function queryPriceFeed(\n bytes32 id\n ) public view virtual returns (PythStructs.PriceFeed memory priceFeed);\n\n /// @notice Returns true if a price feed with the given id exists.\n /// @param id The Pyth Price Feed ID of which to check its existence.\n function priceFeedExists(\n bytes32 id\n ) public view virtual returns (bool exists);\n\n function getValidTimePeriod()\n public\n view\n virtual\n override\n returns (uint validTimePeriod);\n\n function getPrice(\n bytes32 id\n ) external view virtual override returns (PythStructs.Price memory price) {\n return getPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getEmaPrice(\n bytes32 id\n ) external view virtual override returns (PythStructs.Price memory price) {\n return getEmaPriceNoOlderThan(id, getValidTimePeriod());\n }\n\n function getPriceUnsafe(\n bytes32 id\n ) public view virtual override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.price;\n }\n\n function getPriceNoOlderThan(\n bytes32 id,\n uint age\n ) public view virtual override returns (PythStructs.Price memory price) {\n price = getPriceUnsafe(id);\n\n if (diff(block.timestamp, price.publishTime) > age)\n revert PythErrors.StalePrice();\n\n return price;\n }\n\n function getEmaPriceUnsafe(\n bytes32 id\n ) public view virtual override returns (PythStructs.Price memory price) {\n PythStructs.PriceFeed memory priceFeed = queryPriceFeed(id);\n return priceFeed.emaPrice;\n }\n\n function getEmaPriceNoOlderThan(\n bytes32 id,\n uint age\n ) public view virtual override returns (PythStructs.Price memory price) {\n price = getEmaPriceUnsafe(id);\n\n if (diff(block.timestamp, price.publishTime) > age)\n revert PythErrors.StalePrice();\n\n return price;\n }\n\n function diff(uint x, uint y) internal pure returns (uint) {\n if (x > y) {\n return x - y;\n } else {\n return y - x;\n }\n }\n\n // Access modifier is overridden to public to be able to call it locally.\n function updatePriceFeeds(\n bytes[] calldata updateData\n ) public payable virtual override;\n\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable virtual override {\n if (priceIds.length != publishTimes.length)\n revert PythErrors.InvalidArgument();\n\n for (uint i = 0; i < priceIds.length; i++) {\n if (\n !priceFeedExists(priceIds[i]) ||\n queryPriceFeed(priceIds[i]).price.publishTime < publishTimes[i]\n ) {\n updatePriceFeeds(updateData);\n return;\n }\n }\n\n revert PythErrors.NoFreshUpdate();\n }\n\n function parsePriceFeedUpdates(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64 minPublishTime,\n uint64 maxPublishTime\n )\n external\n payable\n virtual\n override\n returns (PythStructs.PriceFeed[] memory priceFeeds);\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/IPyth.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./PythStructs.sol\";\nimport \"./IPythEvents.sol\";\n\n/// @title Consume prices from the Pyth Network (https://pyth.network/).\n/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely.\n/// @author Pyth Data Association\ninterface IPyth is IPythEvents {\n /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time\n function getValidTimePeriod() external view returns (uint validTimePeriod);\n\n /// @notice Returns the price and confidence interval.\n /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.\n /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPrice(\n bytes32 id\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price and confidence interval.\n /// @dev Reverts if the EMA price is not available.\n /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPrice(\n bytes32 id\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price of a price feed without any sanity checks.\n /// @dev This function returns the most recent price update in this contract without any recency checks.\n /// This function is unsafe as the returned price update may be arbitrarily far in the past.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceUnsafe(\n bytes32 id\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the price that is no older than `age` seconds of the current time.\n /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getPriceNoOlderThan(\n bytes32 id,\n uint age\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.\n /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.\n /// However, if the price is not recent this function returns the latest available price.\n ///\n /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that\n /// the returned price is recent or useful for any particular application.\n ///\n /// Users of this function should check the `publishTime` in the price to ensure that the returned price is\n /// sufficiently recent for their application. If you are considering using this function, it may be\n /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceUnsafe(\n bytes32 id\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds\n /// of the current time.\n /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in\n /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently\n /// recently.\n /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.\n function getEmaPriceNoOlderThan(\n bytes32 id,\n uint age\n ) external view returns (PythStructs.Price memory price);\n\n /// @notice Update price feeds with given update messages.\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n /// Prices will be updated if they are more recent than the current stored prices.\n /// The call will succeed even if the update is not the most recent.\n /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n function updatePriceFeeds(bytes[] calldata updateData) external payable;\n\n /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is\n /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the\n /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.\n ///\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n ///\n /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime\n /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have\n /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.\n /// Otherwise, it calls updatePriceFeeds method to update the prices.\n ///\n /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.\n /// @param updateData Array of price update data.\n /// @param priceIds Array of price ids.\n /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`\n function updatePriceFeedsIfNecessary(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64[] calldata publishTimes\n ) external payable;\n\n /// @notice Returns the required fee to update an array of price updates.\n /// @param updateData Array of price update data.\n /// @return feeAmount The required fee in Wei.\n function getUpdateFee(\n bytes[] calldata updateData\n ) external view returns (uint feeAmount);\n\n /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published\n /// within `minPublishTime` and `maxPublishTime`.\n ///\n /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;\n /// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain.\n ///\n /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling\n /// `getUpdateFee` with the length of the `updateData` array.\n ///\n ///\n /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is\n /// no update for any of the given `priceIds` within the given time range.\n /// @param updateData Array of price update data.\n /// @param priceIds Array of price ids.\n /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.\n /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.\n /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).\n function parsePriceFeedUpdates(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64 minPublishTime,\n uint64 maxPublishTime\n ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/IPythEvents.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/// @title IPythEvents contains the events that Pyth contract emits.\n/// @dev This interface can be used for listening to the updates for off-chain and testing purposes.\ninterface IPythEvents {\n /// @dev Emitted when the price feed with `id` has received a fresh update.\n /// @param id The Pyth Price Feed ID.\n /// @param publishTime Publish time of the given price update.\n /// @param price Price of the given price update.\n /// @param conf Confidence interval of the given price update.\n event PriceFeedUpdate(\n bytes32 indexed id,\n uint64 publishTime,\n int64 price,\n uint64 conf\n );\n\n /// @dev Emitted when a batch price update is processed successfully.\n /// @param chainId ID of the source chain that the batch price update comes from.\n /// @param sequenceNumber Sequence number of the batch price update.\n event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber);\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/MockPyth.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./AbstractPyth.sol\";\nimport \"./PythStructs.sol\";\nimport \"./PythErrors.sol\";\n\ncontract MockPyth is AbstractPyth {\n mapping(bytes32 => PythStructs.PriceFeed) priceFeeds;\n uint64 sequenceNumber;\n\n uint singleUpdateFeeInWei;\n uint validTimePeriod;\n\n constructor(uint _validTimePeriod, uint _singleUpdateFeeInWei) {\n singleUpdateFeeInWei = _singleUpdateFeeInWei;\n validTimePeriod = _validTimePeriod;\n }\n\n function queryPriceFeed(\n bytes32 id\n ) public view override returns (PythStructs.PriceFeed memory priceFeed) {\n if (priceFeeds[id].id == 0) revert PythErrors.PriceFeedNotFound();\n return priceFeeds[id];\n }\n\n function priceFeedExists(bytes32 id) public view override returns (bool) {\n return (priceFeeds[id].id != 0);\n }\n\n function getValidTimePeriod() public view override returns (uint) {\n return validTimePeriod;\n }\n\n // Takes an array of encoded price feeds and stores them.\n // You can create this data either by calling createPriceFeedData or\n // by using web3.js or ethers abi utilities.\n function updatePriceFeeds(\n bytes[] calldata updateData\n ) public payable override {\n uint requiredFee = getUpdateFee(updateData);\n if (msg.value < requiredFee) revert PythErrors.InsufficientFee();\n\n // Chain ID is id of the source chain that the price update comes from. Since it is just a mock contract\n // We set it to 1.\n uint16 chainId = 1;\n\n for (uint i = 0; i < updateData.length; i++) {\n PythStructs.PriceFeed memory priceFeed = abi.decode(\n updateData[i],\n (PythStructs.PriceFeed)\n );\n\n uint lastPublishTime = priceFeeds[priceFeed.id].price.publishTime;\n\n if (lastPublishTime < priceFeed.price.publishTime) {\n // Price information is more recent than the existing price information.\n priceFeeds[priceFeed.id] = priceFeed;\n emit PriceFeedUpdate(\n priceFeed.id,\n uint64(lastPublishTime),\n priceFeed.price.price,\n priceFeed.price.conf\n );\n }\n }\n\n // In the real contract, the input of this function contains multiple batches that each contain multiple prices.\n // This event is emitted when a batch is processed. In this mock contract we consider there is only one batch of prices.\n // Each batch has (chainId, sequenceNumber) as it's unique identifier. Here chainId is set to 1 and an increasing sequence number is used.\n emit BatchPriceFeedUpdate(chainId, sequenceNumber);\n sequenceNumber += 1;\n }\n\n function getUpdateFee(\n bytes[] calldata updateData\n ) public view override returns (uint feeAmount) {\n return singleUpdateFeeInWei * updateData.length;\n }\n\n function parsePriceFeedUpdates(\n bytes[] calldata updateData,\n bytes32[] calldata priceIds,\n uint64 minPublishTime,\n uint64 maxPublishTime\n ) external payable override returns (PythStructs.PriceFeed[] memory feeds) {\n uint requiredFee = getUpdateFee(updateData);\n if (msg.value < requiredFee) revert PythErrors.InsufficientFee();\n\n feeds = new PythStructs.PriceFeed[](priceIds.length);\n\n for (uint i = 0; i < priceIds.length; i++) {\n for (uint j = 0; j < updateData.length; j++) {\n feeds[i] = abi.decode(updateData[j], (PythStructs.PriceFeed));\n\n if (feeds[i].id == priceIds[i]) {\n uint publishTime = feeds[i].price.publishTime;\n if (\n minPublishTime <= publishTime &&\n publishTime <= maxPublishTime\n ) {\n break;\n } else {\n feeds[i].id = 0;\n }\n }\n }\n\n if (feeds[i].id != priceIds[i])\n revert PythErrors.PriceFeedNotFoundWithinRange();\n }\n }\n\n function createPriceFeedUpdateData(\n bytes32 id,\n int64 price,\n uint64 conf,\n int32 expo,\n int64 emaPrice,\n uint64 emaConf,\n uint64 publishTime\n ) public pure returns (bytes memory priceFeedData) {\n PythStructs.PriceFeed memory priceFeed;\n\n priceFeed.id = id;\n\n priceFeed.price.price = price;\n priceFeed.price.conf = conf;\n priceFeed.price.expo = expo;\n priceFeed.price.publishTime = publishTime;\n\n priceFeed.emaPrice.price = emaPrice;\n priceFeed.emaPrice.conf = emaConf;\n priceFeed.emaPrice.expo = expo;\n priceFeed.emaPrice.publishTime = publishTime;\n\n priceFeedData = abi.encode(priceFeed);\n }\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/PythErrors.sol": { + "content": "// SPDX-License-Identifier: Apache 2\n\npragma solidity ^0.8.0;\n\nlibrary PythErrors {\n // Function arguments are invalid (e.g., the arguments lengths mismatch)\n error InvalidArgument();\n // Update data is coming from an invalid data source.\n error InvalidUpdateDataSource();\n // Update data is invalid (e.g., deserialization error)\n error InvalidUpdateData();\n // Insufficient fee is paid to the method.\n error InsufficientFee();\n // There is no fresh update, whereas expected fresh updates.\n error NoFreshUpdate();\n // There is no price feed found within the given range or it does not exists.\n error PriceFeedNotFoundWithinRange();\n // Price feed not found or it is not pushed on-chain yet.\n error PriceFeedNotFound();\n // Requested price is stale.\n error StalePrice();\n // Given message is not a valid Wormhole VAA.\n error InvalidWormholeVaa();\n // Governance message is invalid (e.g., deserialization error).\n error InvalidGovernanceMessage();\n // Governance message is not for this contract.\n error InvalidGovernanceTarget();\n // Governance message is coming from an invalid data source.\n error InvalidGovernanceDataSource();\n // Governance message is old.\n error OldGovernanceMessage();\n}\n" + }, + "@pythnetwork/pyth-sdk-solidity/PythStructs.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\ncontract PythStructs {\n // A price with a degree of uncertainty, represented as a price +- a confidence interval.\n //\n // The confidence interval roughly corresponds to the standard error of a normal distribution.\n // Both the price and confidence are stored in a fixed-point numeric representation,\n // `x * (10^expo)`, where `expo` is the exponent.\n //\n // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how\n // to how this price safely.\n struct Price {\n // Price\n int64 price;\n // Confidence interval around the price\n uint64 conf;\n // Price exponent\n int32 expo;\n // Unix timestamp describing when the price was published\n uint publishTime;\n }\n\n // PriceFeed represents a current aggregate price from pyth publisher feeds.\n struct PriceFeed {\n // The price ID.\n bytes32 id;\n // Latest available price\n Price price;\n // Latest available exponentially-weighted moving average price\n Price emaPrice;\n }\n}\n" + }, + "adrastia-periphery/rates/IHistoricalRates.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\nimport \"./RateLibrary.sol\";\n\n/**\n * @title IHistoricalRates\n * @notice An interface that defines a contract that stores historical rates.\n */\ninterface IHistoricalRates {\n /// @notice Gets an rate for a token at a specific index.\n /// @param token The address of the token to get the rates for.\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\n /// index contains the oldest rate (uses reverse chronological ordering).\n /// @return rate The rate for the token at the specified index.\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @param offset The index of the first rate to get (default: 0).\n /// @param increment The increment between rates to get (default: 1).\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the number of rates for a token.\n /// @param token The address of the token to get the number of rates for.\n /// @return count The number of rates for the token.\n function getRatesCount(address token) external view returns (uint256);\n\n /// @notice Gets the capacity of rates for a token.\n /// @param token The address of the token to get the capacity of rates for.\n /// @return capacity The capacity of rates for the token.\n function getRatesCapacity(address token) external view returns (uint256);\n\n /// @notice Sets the capacity of rates for a token.\n /// @param token The address of the token to set the capacity of rates for.\n /// @param amount The new capacity of rates for the token.\n function setRatesCapacity(address token, uint256 amount) external;\n}\n" + }, + "adrastia-periphery/rates/IRateComputer.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\n/**\n * @title IRateComputer\n * @notice An interface that defines a contract that computes rates.\n */\ninterface IRateComputer {\n /// @notice Computes the rate for a token.\n /// @param token The address of the token to compute the rate for.\n /// @return rate The rate for the token.\n function computeRate(address token) external view returns (uint64);\n}\n" + }, + "adrastia-periphery/rates/RateLibrary.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nlibrary RateLibrary {\n struct Rate {\n uint64 target;\n uint64 current;\n uint32 timestamp;\n }\n}\n" + }, + "contracts/adrastia/PrudentiaLib.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nlibrary PrudentiaLib {\n struct PrudentiaConfig {\n address controller; // Adrastia Prudentia controller address\n uint8 offset; // Offset for delayed rate activation\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\n }\n}\n" + }, + "contracts/bridge/hyperlane/interfaces/hooks/IPostDispatchHook.sol": { + "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@ @@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n @@@@@@@@@@@@@@@@@@@@@@@@@\n @@@@@ HYPERLANE @@@@@@@\n @@@@@@@@@@@@@@@@@@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n @@@@@@@@@ @@@@@@@@@\n@@@@@@@@@ @@@@@@@@*/\n\ninterface IPostDispatchHook {\n enum Types {\n UNUSED,\n ROUTING,\n AGGREGATION,\n MERKLE_TREE,\n INTERCHAIN_GAS_PAYMASTER,\n FALLBACK_ROUTING,\n ID_AUTH_ISM,\n PAUSABLE,\n PROTOCOL_FEE,\n LAYER_ZERO_V1,\n RATE_LIMITED,\n ARB_L2_TO_L1,\n OP_L2_TO_L1\n }\n\n /**\n * @notice Returns an enum that represents the type of hook\n */\n function hookType() external view returns (uint8);\n\n /**\n * @notice Returns whether the hook supports metadata\n * @param metadata metadata\n * @return Whether the hook supports metadata\n */\n function supportsMetadata(\n bytes calldata metadata\n ) external view returns (bool);\n\n /**\n * @notice Post action after a message is dispatched via the Mailbox\n * @param metadata The metadata required for the hook\n * @param message The message passed from the Mailbox.dispatch() call\n */\n function postDispatch(\n bytes calldata metadata,\n bytes calldata message\n ) external payable;\n\n /**\n * @notice Compute the payment required by the postDispatch call\n * @param metadata The metadata required for the hook\n * @param message The message passed from the Mailbox.dispatch() call\n * @return Quoted payment for the postDispatch call\n */\n function quoteDispatch(\n bytes calldata metadata,\n bytes calldata message\n ) external view returns (uint256);\n}" + }, + "contracts/bridge/hyperlane/interfaces/IInterchainSecurityModule.sol": { + "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\ninterface IInterchainSecurityModule {\n enum Types {\n UNUSED,\n ROUTING,\n AGGREGATION,\n LEGACY_MULTISIG,\n MERKLE_ROOT_MULTISIG,\n MESSAGE_ID_MULTISIG,\n NULL, // used with relayer carrying no metadata\n CCIP_READ,\n ARB_L2_TO_L1,\n WEIGHTED_MERKLE_ROOT_MULTISIG,\n WEIGHTED_MESSAGE_ID_MULTISIG,\n OP_L2_TO_L1\n }\n\n /**\n * @notice Returns an enum that represents the type of security model\n * encoded by this ISM.\n * @dev Relayers infer how to fetch and format metadata.\n */\n function moduleType() external view returns (uint8);\n\n /**\n * @notice Defines a security model responsible for verifying interchain\n * messages based on the provided metadata.\n * @param _metadata Off-chain metadata provided by a relayer, specific to\n * the security model encoded by the module (e.g. validator signatures)\n * @param _message Hyperlane encoded interchain message\n * @return True if the message was verified\n */\n function verify(\n bytes calldata _metadata,\n bytes calldata _message\n ) external returns (bool);\n}\n\ninterface ISpecifiesInterchainSecurityModule {\n function interchainSecurityModule()\n external\n view\n returns (IInterchainSecurityModule);\n}" + }, + "contracts/bridge/hyperlane/interfaces/IMailbox.sol": { + "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IInterchainSecurityModule} from \"./IInterchainSecurityModule.sol\";\nimport {IPostDispatchHook} from \"./hooks/IPostDispatchHook.sol\";\n\ninterface IMailbox {\n // ============ Events ============\n /**\n * @notice Emitted when a new message is dispatched via Hyperlane\n * @param sender The address that dispatched the message\n * @param destination The destination domain of the message\n * @param recipient The message recipient address on `destination`\n * @param message Raw bytes of message\n */\n event Dispatch(\n address indexed sender,\n uint32 indexed destination,\n bytes32 indexed recipient,\n bytes message\n );\n\n /**\n * @notice Emitted when a new message is dispatched via Hyperlane\n * @param messageId The unique message identifier\n */\n event DispatchId(bytes32 indexed messageId);\n\n /**\n * @notice Emitted when a Hyperlane message is processed\n * @param messageId The unique message identifier\n */\n event ProcessId(bytes32 indexed messageId);\n\n /**\n * @notice Emitted when a Hyperlane message is delivered\n * @param origin The origin domain of the message\n * @param sender The message sender address on `origin`\n * @param recipient The address that handled the message\n */\n event Process(\n uint32 indexed origin,\n bytes32 indexed sender,\n address indexed recipient\n );\n\n function localDomain() external view returns (uint32);\n\n function delivered(bytes32 messageId) external view returns (bool);\n\n function defaultIsm() external view returns (IInterchainSecurityModule);\n\n function defaultHook() external view returns (IPostDispatchHook);\n\n function requiredHook() external view returns (IPostDispatchHook);\n\n function latestDispatchedId() external view returns (bytes32);\n\n function dispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata messageBody\n ) external payable returns (bytes32 messageId);\n\n function quoteDispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata messageBody\n ) external view returns (uint256 fee);\n\n function dispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata body,\n bytes calldata defaultHookMetadata\n ) external payable returns (bytes32 messageId);\n\n function quoteDispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata messageBody,\n bytes calldata defaultHookMetadata\n ) external view returns (uint256 fee);\n\n function dispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata body,\n bytes calldata customHookMetadata,\n IPostDispatchHook customHook\n ) external payable returns (bytes32 messageId);\n\n function quoteDispatch(\n uint32 destinationDomain,\n bytes32 recipientAddress,\n bytes calldata messageBody,\n bytes calldata customHookMetadata,\n IPostDispatchHook customHook\n ) external view returns (uint256 fee);\n\n function process(\n bytes calldata metadata,\n bytes calldata message\n ) external payable;\n\n function recipientIsm(\n address recipient\n ) external view returns (IInterchainSecurityModule module);\n}" + }, + "contracts/bridge/interface/IXERC20.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.4 <0.9.0;\n\ninterface IXERC20 {\n /**\n * @notice Emits when a lockbox is set\n *\n * @param _lockbox The address of the lockbox\n */\n event LockboxSet(address _lockbox);\n\n /**\n * @notice Emits when a limit is set\n *\n * @param _mintingLimit The updated minting limit we are setting to the bridge\n * @param _burningLimit The updated burning limit we are setting to the bridge\n * @param _bridge The address of the bridge we are setting the limit too\n */\n event BridgeLimitsSet(uint256 _mintingLimit, uint256 _burningLimit, address indexed _bridge);\n\n /**\n * @notice Reverts when a user with too low of a limit tries to call mint/burn\n */\n error IXERC20_NotHighEnoughLimits();\n\n /**\n * @notice Reverts when caller is not the factory\n */\n error IXERC20_NotFactory();\n\n /**\n * @notice Reverts when limits are too high\n */\n error IXERC20_LimitsTooHigh();\n\n /**\n * @notice Contains the full minting and burning data for a particular bridge\n *\n * @param minterParams The minting parameters for the bridge\n * @param burnerParams The burning parameters for the bridge\n */\n struct Bridge {\n BridgeParameters minterParams;\n BridgeParameters burnerParams;\n }\n\n /**\n * @notice Contains the mint or burn parameters for a bridge\n *\n * @param timestamp The timestamp of the last mint/burn\n * @param ratePerSecond The rate per second of the bridge\n * @param maxLimit The max limit of the bridge\n * @param currentLimit The current limit of the bridge\n */\n struct BridgeParameters {\n uint256 timestamp;\n uint256 ratePerSecond;\n uint256 maxLimit;\n uint256 currentLimit;\n }\n\n /**\n * @notice Sets the lockbox address\n *\n * @param _lockbox The address of the lockbox\n */\n function setLockbox(address _lockbox) external;\n\n /**\n * @notice Updates the limits of any bridge\n * @dev Can only be called by the owner\n * @param _mintingLimit The updated minting limit we are setting to the bridge\n * @param _burningLimit The updated burning limit we are setting to the bridge\n * @param _bridge The address of the bridge we are setting the limits too\n */\n function setLimits(address _bridge, uint256 _mintingLimit, uint256 _burningLimit) external;\n\n /**\n * @notice Returns the max limit of a minter\n *\n * @param _minter The minter we are viewing the limits of\n * @return _limit The limit the minter has\n */\n function mintingMaxLimitOf(address _minter) external view returns (uint256 _limit);\n\n /**\n * @notice Returns the max limit of a bridge\n *\n * @param _bridge the bridge we are viewing the limits of\n * @return _limit The limit the bridge has\n */\n function burningMaxLimitOf(address _bridge) external view returns (uint256 _limit);\n\n /**\n * @notice Returns the current limit of a minter\n *\n * @param _minter The minter we are viewing the limits of\n * @return _limit The limit the minter has\n */\n function mintingCurrentLimitOf(address _minter) external view returns (uint256 _limit);\n\n /**\n * @notice Returns the current limit of a bridge\n *\n * @param _bridge the bridge we are viewing the limits of\n * @return _limit The limit the bridge has\n */\n function burningCurrentLimitOf(address _bridge) external view returns (uint256 _limit);\n\n /**\n * @notice Mints tokens for a user\n * @dev Can only be called by a minter\n * @param _user The address of the user who needs tokens minted\n * @param _amount The amount of tokens being minted\n */\n function mint(address _user, uint256 _amount) external;\n\n /**\n * @notice Burns tokens for a user\n * @dev Can only be called by a minter\n * @param _user The address of the user who needs tokens burned\n * @param _amount The amount of tokens being burned\n */\n function burn(address _user, uint256 _amount) external;\n}" + }, + "contracts/bridge/xERC20Hyperlane.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.22;\n\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { IXERC20 } from \"./interface/IXERC20.sol\";\nimport { IMailbox } from \"./hyperlane/interfaces/IMailbox.sol\";\n\nlibrary TypeCasts {\n // alignment preserving cast\n function addressToBytes32(address _addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(_addr)));\n }\n\n // alignment preserving cast\n function bytes32ToAddress(bytes32 _buf) internal pure returns (address) {\n return address(uint160(uint256(_buf)));\n }\n}\n\ncontract xERC20Hyperlane is Ownable {\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n uint256 public feeBps;\n mapping(address => mapping(uint32 => address)) public mappedTokens;\n mapping(uint32 => address) public mappedBridges;\n IMailbox immutable mailbox;\n\n event TokenMapped(address indexed _token, uint32 indexed _chainId, address indexed _dstToken);\n event BridgeMapped(uint32 indexed _chainId, address indexed _bridge);\n event FeeBpsSet(uint256 indexed _feeBps);\n event TokenSent(\n address indexed _token,\n uint256 _amount,\n address indexed _to,\n uint32 indexed _dstChainId,\n bytes32 _guid\n );\n event TokenReceived(\n address indexed _token,\n uint256 _amount,\n address indexed _to,\n uint32 indexed _srcChainId,\n bytes32 _guid\n );\n\n error TokenNotSet();\n error ChainIdNotSet();\n error DestinationBridgeNotSet(uint32 _chainId);\n error OriginNotAllowed(uint32 _chainId, address _sender);\n\n /**\n * @notice Only accept messages from an Hyperlane Mailbox contract\n */\n modifier onlyMailbox() {\n require(msg.sender == address(mailbox), \"MailboxClient: sender not mailbox\");\n _;\n }\n\n constructor(uint256 _feeBps, address _mailbox) Ownable() {\n mailbox = IMailbox(_mailbox);\n feeBps = _feeBps;\n }\n\n // ADMIN FUNCTIONS\n function setFeeBps(uint256 _feeBps) public onlyOwner {\n feeBps = _feeBps;\n emit FeeBpsSet(_feeBps);\n }\n\n function setMappedToken(uint32 _chainId, address _srcToken, address _dstToken) public onlyOwner {\n mappedTokens[_srcToken][_chainId] = _dstToken;\n emit TokenMapped(_srcToken, _chainId, _dstToken);\n }\n\n function setMappedBridge(uint32 _chainId, address _bridge) public onlyOwner {\n mappedBridges[_chainId] = _bridge;\n emit BridgeMapped(_chainId, _bridge);\n }\n\n function withdrawFee(address _token) public onlyOwner {\n uint256 _amount = IERC20(_token).balanceOf(address(this));\n IERC20(_token).transfer(msg.sender, _amount);\n }\n\n function withdrawFee(address _token, uint256 _amount) public onlyOwner {\n IERC20(_token).transfer(msg.sender, _amount);\n }\n\n function withdrawEth() public onlyOwner {\n uint256 _amount = address(this).balance;\n payable(msg.sender).transfer(_amount);\n }\n\n function withdrawEth(uint256 _amount) public onlyOwner {\n payable(msg.sender).transfer(_amount);\n }\n\n // PUBLIC FUNCTIONS\n function quote(uint32 _dstChainId, address _token, uint256 _amount, address _to) external view returns (uint256 fee) {\n return _quoteInternal(_dstChainId, _token, _amount, _to);\n }\n\n function send(address _token, uint256 _amount, address _to, uint32 _dstChainId) external payable {\n _send(_dstChainId, _token, _amount, _to);\n }\n\n // INTERNAL FUNCTIONS\n function _quoteInternal(\n uint32 _dstChainId,\n address _token,\n uint256 _amount,\n address _to\n ) internal view returns (uint256 fee) {\n address _bridge = mappedBridges[_dstChainId];\n if (_bridge == address(0)) {\n revert DestinationBridgeNotSet(_dstChainId);\n }\n uint256 _amountAfterFee = (_amount * (10000 - feeBps)) / 10000;\n bytes memory _payload = abi.encode(_to, _token, _amountAfterFee);\n fee = mailbox.quoteDispatch(_dstChainId, _bridge.addressToBytes32(), _payload);\n return fee;\n }\n\n function _send(uint32 _dstChainId, address _token, uint256 _amount, address _to) internal {\n address _bridge = mappedBridges[_dstChainId];\n if (_bridge == address(0)) {\n revert DestinationBridgeNotSet(_dstChainId);\n }\n // transfer tokens to this contract\n IERC20(_token).transferFrom(msg.sender, address(this), _amount);\n\n // take fee and burn the tokens\n uint256 _amountAfterFee = (_amount * (10000 - feeBps)) / 10000;\n IXERC20(_token).burn(address(this), _amountAfterFee);\n\n bytes memory _payload = abi.encode(_to, _token, _amountAfterFee);\n bytes32 _guid = mailbox.dispatch{ value: msg.value }(_dstChainId, _bridge.addressToBytes32(), _payload);\n emit TokenSent(_token, _amountAfterFee, _to, _dstChainId, _guid);\n }\n\n function handle(uint32 _origin, bytes32 _sender, bytes calldata _data) external payable virtual onlyMailbox {\n if (mappedBridges[_origin] != _sender.bytes32ToAddress()) {\n revert OriginNotAllowed(_origin, _sender.bytes32ToAddress());\n }\n // Decode the payload to get the message\n (address _to, address _srcToken, uint256 _amount) = abi.decode(_data, (address, address, uint256));\n\n // get the mapped token using the current chain id and received source token\n address _dstToken = mappedTokens[_srcToken][_origin];\n if (_dstToken == address(0)) {\n revert TokenNotSet();\n }\n\n // mint the tokens to the destination address\n IXERC20(_dstToken).mint(_to, _amount);\n emit TokenReceived(_dstToken, _amount, _to, _origin, bytes32(0));\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/bridge/xERC20LayerZero.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.22;\n\nimport { OApp, Origin, MessagingFee, MessagingReceipt } from \"@layerzerolabs/oapp-evm/contracts/oapp/OApp.sol\";\nimport { OptionsBuilder } from \"@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol\";\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { IXERC20 } from \"./interface/IXERC20.sol\";\n\ncontract xERC20LayerZero is Ownable, OApp {\n using OptionsBuilder for bytes;\n\n uint256 public feeBps;\n mapping(address => mapping(uint32 => address)) public mappedTokens;\n mapping(uint32 => uint32) public chainIdToEid;\n mapping(uint32 => uint32) public eidToChainId;\n\n event TokenMapped(address indexed _token, uint32 indexed _chainId, address indexed _dstToken);\n event ChainIdToEidSet(uint32 indexed _chainId, uint32 indexed _eid);\n event EidToChainIdSet(uint32 indexed _eid, uint32 indexed _chainId);\n event FeeBpsSet(uint256 indexed _feeBps);\n event TokenSent(\n address indexed _token,\n uint256 _amount,\n address indexed _to,\n uint32 indexed _dstChainId,\n bytes32 _guid\n );\n event TokenReceived(\n address indexed _token,\n uint256 _amount,\n address indexed _to,\n uint32 indexed _srcChainId,\n bytes32 _guid\n );\n\n error TokenNotSet();\n error ChainIdNotSet();\n error OriginNotMirrorAdapter();\n\n constructor(uint256 _feeBps, address _endpoint) OApp(_endpoint, msg.sender) Ownable() {\n feeBps = _feeBps;\n\n // known chain ids\n // Set initial chain ID to EID mappings\n setChainIdToEid(8453, 30184); // base\n setChainIdToEid(10, 30111); // optimism\n setChainIdToEid(252, 30255); // fraxtal\n setChainIdToEid(60808, 30279); // bob\n setChainIdToEid(34443, 30260); // mode\n\n // Set initial EID to chain ID mappings\n setEidToChainId(30184, 8453); // base\n setEidToChainId(30111, 10); // optimism\n setEidToChainId(30255, 252); // fraxtal\n setEidToChainId(30279, 60808); // bob\n setEidToChainId(30260, 34443); // mode\n }\n\n // ADMIN FUNCTIONS\n function setFeeBps(uint256 _feeBps) public onlyOwner {\n feeBps = _feeBps;\n emit FeeBpsSet(_feeBps);\n }\n\n function setMappedToken(uint32 _chainId, address _srcToken, address _dstToken) public onlyOwner {\n mappedTokens[_srcToken][_chainId] = _dstToken;\n emit TokenMapped(_srcToken, _chainId, _dstToken);\n }\n\n function setChainIdToEid(uint32 _chainId, uint32 _eid) public onlyOwner {\n chainIdToEid[_chainId] = _eid;\n emit ChainIdToEidSet(_chainId, _eid);\n }\n\n function setEidToChainId(uint32 _eid, uint32 _chainId) public onlyOwner {\n eidToChainId[_eid] = _chainId;\n emit EidToChainIdSet(_eid, _chainId);\n }\n\n function withdrawFee(address _token) public onlyOwner {\n uint256 _amount = IERC20(_token).balanceOf(address(this));\n IERC20(_token).transfer(msg.sender, _amount);\n }\n\n function withdrawFee(address _token, uint256 _amount) public onlyOwner {\n IERC20(_token).transfer(msg.sender, _amount);\n }\n\n function withdrawEth() public onlyOwner {\n uint256 _amount = address(this).balance;\n payable(msg.sender).transfer(_amount);\n }\n\n function withdrawEth(uint256 _amount) public onlyOwner {\n payable(msg.sender).transfer(_amount);\n }\n\n // PUBLIC FUNCTIONS\n function quote(\n uint32 _dstChainId,\n address _token,\n uint256 _amount,\n address _to\n ) external view returns (uint256 nativeFee, uint256 zroFee) {\n bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(50000, 0);\n return _quoteInternal(_dstChainId, _token, _amount, _to, options, false);\n }\n\n function quote(\n uint32 _dstChainId, // destination endpoint id\n address _token,\n uint256 _amount,\n address _to,\n bytes memory _options, // your message execution options\n bool _payInLzToken // boolean for which token to return fee in\n ) external view returns (uint256 nativeFee, uint256 zroFee) {\n return _quoteInternal(_dstChainId, _token, _amount, _to, _options, _payInLzToken);\n }\n\n function send(\n address _token,\n uint256 _amount,\n address _to,\n uint32 _dstChainId\n ) external payable {\n bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(50000, 0);\n _send(_dstChainId, _token, _amount, _to, options);\n }\n\n /**\n * @notice Sends tokens to a destination chain\n *\n * @param _token The token to send\n * @param _amount The amount of tokens to send\n * @param _to The address to send the tokens to\n * @param _dstChainId The destination chain id\n * @param _options The options to send the tokens with\n */\n function send(\n address _token,\n uint256 _amount,\n address _to,\n uint32 _dstChainId,\n bytes calldata _options\n ) external payable {\n _send(_dstChainId, _token, _amount, _to, _options);\n }\n\n // INTERNAL FUNCTIONS\n function _quoteInternal(\n uint32 _dstChainId,\n address _token,\n uint256 _amount,\n address _to,\n bytes memory _options,\n bool _payInLzToken\n ) internal view returns (uint256 nativeFee, uint256 zroFee) {\n uint32 _dstEid = chainIdToEid[_dstChainId];\n if (_dstEid == 0) {\n revert ChainIdNotSet();\n }\n uint256 _amountAfterFee = (_amount * (10000 - feeBps)) / 10000;\n bytes memory _payload = abi.encode(_to, _token, _amountAfterFee);\n MessagingFee memory fee = _quote(_dstEid, _payload, _options, _payInLzToken);\n return (fee.nativeFee, fee.lzTokenFee);\n }\n\n function _send(\n uint32 _dstChainId,\n address _token,\n uint256 _amount,\n address _to,\n bytes memory _options\n ) internal {\n uint32 _dstEid = chainIdToEid[_dstChainId];\n if (_dstEid == 0) {\n revert ChainIdNotSet();\n }\n\n // transfer tokens to this contract\n IERC20(_token).transferFrom(msg.sender, address(this), _amount);\n\n // take fee and burn the tokens\n uint256 _amountAfterFee = (_amount * (10000 - feeBps)) / 10000;\n IXERC20(_token).burn(address(this), _amountAfterFee);\n\n bytes memory _payload = abi.encode(_to, _token, _amountAfterFee);\n MessagingReceipt memory _receipt = _lzSend(\n _dstEid,\n _payload,\n _options,\n // Fee in native gas and ZRO token.\n MessagingFee(msg.value, 0),\n // Refund address in case of failed source message.\n payable(msg.sender)\n );\n emit TokenSent(_token, _amountAfterFee, _to, _dstChainId, _receipt.guid);\n }\n\n // LAYERZERO FUNCTIONS\n /**\n * @dev Called when data is received from the protocol. It overrides the equivalent function in the parent contract.\n * Protocol messages are defined as packets, comprised of the following parameters.\n * @param _origin A struct containing information about where the packet came from.\n * @param _guid A global unique identifier for tracking the packet.\n * @param payload Encoded message.\n */\n function _lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata payload,\n address, // Executor address as specified by the OApp.\n bytes calldata // Any extra data or options to trigger on receipt.\n ) internal override {\n // Decode the payload to get the message\n (address _to, address _srcToken, uint256 _amount) = abi.decode(payload, (address, address, uint256));\n\n uint32 _srcChainId = eidToChainId[_origin.srcEid];\n // get the mapped token using the current chain id and received source token\n address _dstToken = mappedTokens[_srcToken][_srcChainId];\n if (_dstToken == address(0)) {\n revert TokenNotSet();\n }\n\n // mint the tokens to the destination address\n IXERC20(_dstToken).mint(_to, _amount);\n emit TokenReceived(_dstToken, _amount, _to, _srcChainId, _guid);\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/compound/CarefulMath.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Careful Math\n * @author Compound\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint256 c;\n unchecked {\n c = a * b;\n }\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n uint256 c;\n unchecked {\n c = a + b;\n }\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(\n uint256 a,\n uint256 b,\n uint256 c\n ) internal pure returns (MathError, uint256) {\n (MathError err0, uint256 sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/compound/CErc20Delegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CToken.sol\";\n\n/**\n * @title Compound's CErc20Delegate Contract\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\n * @author Compound\n */\ncontract CErc20Delegate is CErc20 {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 3;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n */\n function _becomeImplementation(bytes memory) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 1;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20Delegate\";\n }\n}\n" + }, + "contracts/compound/CErc20Delegator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ComptrollerInterface.sol\";\nimport \"./InterestRateModel.sol\";\nimport \"../ionic/DiamondExtension.sol\";\nimport { CErc20DelegatorBase, CDelegateInterface } from \"./CTokenInterfaces.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\n/**\n * @title Compound's CErc20Delegator Contract\n * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Compound\n */\ncontract CErc20Delegator is CErc20DelegatorBase, DiamondBase {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param ionicAdmin_ The FeeDistributor contract address.\n * @param interestRateModel_ The address of the interest rate model\n * @param name_ ERC-20 name of this token\n * @param symbol_ ERC-20 symbol of this token\n */\n constructor(\n address underlying_,\n IonicComptroller comptroller_,\n address payable ionicAdmin_,\n InterestRateModel interestRateModel_,\n string memory name_,\n string memory symbol_,\n uint256 reserveFactorMantissa_,\n uint256 adminFeeMantissa_\n ) {\n require(msg.sender == ionicAdmin_, \"!admin\");\n uint8 decimals_ = EIP20Interface(underlying_).decimals();\n {\n ionicAdmin = ionicAdmin_;\n\n // Set initial exchange rate\n initialExchangeRateMantissa = 0.2e18;\n\n // Set the comptroller\n comptroller = comptroller_;\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = 1e18;\n\n // Set the interest rate model (depends on block number / borrow index)\n require(interestRateModel_.isInterestRateModel(), \"!notIrm\");\n interestRateModel = interestRateModel_;\n emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // Set reserve factor\n // Check newReserveFactor ≤ maxReserveFactor\n require(\n reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!rf:set\"\n );\n reserveFactorMantissa = reserveFactorMantissa_;\n emit NewReserveFactor(0, reserveFactorMantissa_);\n\n // Set admin fee\n // Sanitize adminFeeMantissa_\n if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n require(\n reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!adminFee:set\"\n );\n adminFeeMantissa = adminFeeMantissa_;\n emit NewAdminFee(0, adminFeeMantissa_);\n ionicFeeMantissa = newIonicFeeMantissa;\n emit NewIonicFee(0, newIonicFeeMantissa);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n function implementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"delegateType()\"))));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {\n // Check admin rights\n require(hasAdminRights(), \"!admin\");\n\n // Set implementation\n _setImplementationInternal(implementation_, becomeImplementationData);\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self or admin\");\n\n (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature(\"delegateType()\"));\n require(success, \"no delegate type\");\n\n uint8 currentDelegateType = abi.decode(data, (uint8));\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)\n .latestCErc20Delegate(currentDelegateType);\n\n address currentDelegate = implementation();\n if (currentDelegate != latestCErc20Delegate) {\n _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);\n } else {\n // only update the extensions without reinitializing with becomeImplementationData\n _updateExtensions(currentDelegate);\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(msg.sender == address(ionicAdmin), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n /**\n * @dev Internal function to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {\n address delegateBefore = implementation();\n _updateExtensions(implementation_);\n\n _functionCall(\n address(this),\n abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),\n \"!become impl\"\n );\n\n emit NewImplementation(delegateBefore, implementation_);\n }\n\n function _updateExtensions(address newDelegate) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CErc20PluginDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\nimport \"./IERC4626.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\n/**\n * @title Rari's CErc20Plugin's Contract\n * @notice CToken which outsources token logic to a plugin\n * @author Joey Santoro\n *\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\n */\ncontract CErc20PluginDelegate is CErc20Delegate {\n event NewPluginImplementation(address oldImpl, address newImpl);\n\n /**\n * @notice Plugin address\n */\n IERC4626 public plugin;\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Delegate interface to become the implementation\n * @param data The encoded arguments for becoming\n */\n function _becomeImplementation(bytes memory data) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _becomeImplementation\");\n\n address _plugin = abi.decode(data, (address));\n\n if (_plugin == address(0) && address(plugin) != address(0)) {\n // if no new plugin address is given, use the latest implementation\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\n }\n\n if (_plugin != address(0) && _plugin != address(plugin)) {\n _updatePlugin(_plugin);\n }\n }\n\n /**\n * @notice Update the plugin implementation to a whitelisted implementation\n * @param _plugin The address of the plugin implementation to use\n */\n function _updatePlugin(address _plugin) public {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _updatePlugin\");\n\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\n\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\n }\n\n plugin = IERC4626(_plugin);\n\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\n\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\n if (amount != 0) {\n deposit(amount);\n }\n\n emit NewPluginImplementation(oldImplementation, _plugin);\n }\n\n /*** CToken Overrides ***/\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of the plugin in terms of the underlying\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view override returns (uint256) {\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\n }\n\n /**\n * @notice Transfer the underlying to the cToken and trigger a deposit\n * @param from Address to transfer funds from\n * @param amount Amount of underlying to transfer\n * @return The actual amount that is transferred\n */\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\n // Perform the EIP-20 transfer in\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \"send\");\n\n deposit(amount);\n return amount;\n }\n\n function deposit(uint256 amount) internal {\n plugin.deposit(amount, address(this));\n }\n\n /**\n * @notice Transfer the underlying from plugin to destination\n * @param to Address to transfer funds to\n * @param amount Amount of underlying to transfer\n */\n function doTransferOut(address to, uint256 amount) internal override {\n plugin.withdraw(amount, to, address(this));\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 2;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20PluginDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20PluginRewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20PluginDelegate.sol\";\n\ncontract CErc20PluginRewardsDelegate is CErc20PluginDelegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying && _token != address(plugin), \"!token\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 4;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20PluginRewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20RewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\n\ncontract CErc20RewardsDelegate is CErc20Delegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n \n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying, \"!underlying\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 3;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20RewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/Comptroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./Unitroller.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { IIonicFlywheel } from \"../ionic/strategies/flywheel/IIonicFlywheel.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\n */\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when an admin supports a market\n event MarketListed(ICErc20 cToken);\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(ICErc20 cToken, address account);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(ICErc20 cToken, address account);\n\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\n\n /// @notice Emitted when the whitelist enforcement is changed\n event WhitelistEnforcementChanged(bool enforce);\n\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\n event AddedRewardsDistributor(address rewardsDistributor);\n\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n // liquidationIncentiveMantissa must be no less than this value\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\n\n // liquidationIncentiveMantissa must be no greater than this value\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\n\n modifier isAuthorized() {\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \"not authorized\");\n _;\n }\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\n return ComptrollerBase.effectiveSupplyCaps(cToken);\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\n return ComptrollerBase.effectiveBorrowCaps(cToken);\n }\n\n /*** Assets You Are In ***/\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\n ICErc20[] memory assetsIn = accountAssets[account];\n\n return assetsIn;\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param cToken The cToken to check\n * @return True if the account is in the asset, otherwise false.\n */\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\n return markets[address(cToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param cTokens The list of addresses of the cToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\n uint256 len = cTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i = 0; i < len; i++) {\n ICErc20 cToken = ICErc20(cTokens[i]);\n\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param cToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\n Market storage marketToJoin = markets[address(cToken)];\n\n if (!marketToJoin.isListed) {\n // market is not listed, cannot join\n return Error.MARKET_NOT_LISTED;\n }\n\n if (marketToJoin.accountMembership[borrower] == true) {\n // already joined\n return Error.NO_ERROR;\n }\n\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(cToken);\n\n // Add to allBorrowers\n if (!borrowers[borrower]) {\n allBorrowers.push(borrower);\n borrowers[borrower] = true;\n borrowerIndexes[borrower] = allBorrowers.length - 1;\n }\n\n emit MarketEntered(cToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow.\n * @param cTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\n // TODO\n require(markets[cTokenAddress].isListed, \"!Comptroller:exitMarket\");\n\n ICErc20 cToken = ICErc20(cTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"!exitMarket\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[cTokenAddress];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set cToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete cToken from the account’s list of assets */\n // load into memory for faster iteration\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n ICErc20[] storage storedList = accountAssets[msg.sender];\n storedList[assetIndex] = storedList[storedList.length - 1];\n storedList.pop();\n\n // If the user has exited all markets, remove them from the `allBorrowers` array\n if (storedList.length == 0) {\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\n allBorrowers.pop(); // Reduce length by 1\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\n }\n\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Policy Hooks ***/\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param cTokenAddress The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintGuardianPaused[cTokenAddress], \"!mint:paused\");\n\n // Make sure market is listed\n if (!markets[cTokenAddress].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure minter is whitelisted\n if (enforceWhitelist && !whitelist[minter]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\n\n // Supply cap of 0 corresponds to unlimited supplying\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\n uint256 nonWhitelistedTotalSupply;\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\n\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \"!supply cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cTokenAddress, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param cToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n function redeemAllowedInternal(\n address cToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[cToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n ICErc20(cToken),\n redeemTokens,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint and reverts on rejection. May emit logs.\n * @param cToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n // Add minter to suppliers mapping\n suppliers[minter] = true;\n }\n\n /**\n * @notice Validates redeem and reverts on rejection. May emit logs.\n * @param cToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(\n address cToken,\n address redeemer,\n uint256 redeemAmount,\n uint256 redeemTokens\n ) external override {\n require(markets[msg.sender].isListed, \"!market\");\n\n // Require tokens is zero or amount is also zero\n if (redeemTokens == 0 && redeemAmount > 0) {\n revert(\"!zero\");\n }\n }\n\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) external view override returns (uint256) {\n address cToken = address(cTokenModify);\n // Accrue interest\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\n\n // Get account liquidity\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n isBorrow ? cTokenModify : ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n require(err == Error.NO_ERROR, \"!liquidity\");\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\n\n // Get max borrow/redeem\n uint256 maxBorrowOrRedeemAmount;\n\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\n // Max redeem = balance of underlying if not used as collateral\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\n } else {\n // Avoid \"stack too deep\" error by separating this logic\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\n\n // Redeem only: max out at underlying balance\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\n }\n\n // Get max borrow or redeem considering cToken liquidity\n uint256 cTokenLiquidity = cTokenModify.getCash();\n\n // Return the minimum of the two maximums\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\n }\n\n /**\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \"stack too deep\" errors.\n */\n function _getMaxRedeemOrBorrow(\n uint256 liquidity,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal view returns (uint256) {\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\n\n // Get the normalized price of the asset\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\n require(conversionFactor > 0, \"!oracle\");\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n if (!isBorrow) {\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\n }\n\n // Get max borrow or redeem considering excess account liquidity\n return (liquidity * 1e18) / conversionFactor;\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!borrowGuardianPaused[cToken], \"!borrow:paused\");\n\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n if (!markets[cToken].accountMembership[borrower]) {\n // only cTokens may call borrowAllowed if borrower not in market\n require(msg.sender == cToken, \"!ctoken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n // it should be impossible to break the important invariant\n assert(markets[cToken].accountMembership[borrower]);\n }\n\n // Make sure oracle price is available\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n // Make sure borrower is whitelisted\n if (enforceWhitelist && !whitelist[borrower]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 borrowCap = effectiveBorrowCaps(cToken);\n\n // Borrow cap of 0 corresponds to unlimited borrowing\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\n uint256 nonWhitelistedTotalBorrows;\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \"!borrow:cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n // Perform a hypothetical liquidity check to guard against shortfall\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\n if (err != uint256(Error.NO_ERROR)) {\n return err;\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken Asset whose underlying is being borrowed\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\n */\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\n // Check if min borrow exists\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\n\n if (minBorrowEth > 0) {\n // Get new underlying borrow balance of account for this cToken\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\n Exp({ mantissa: oraclePriceMantissa }),\n accountBorrowsNew\n );\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\n\n // Check against min borrow\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\n }\n\n // Return no error\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param cToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which would borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure markets are listed\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Get borrowers' underlying borrow balance\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\n\n /* allow accounts to be liquidated if the market is deprecated */\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\n require(borrowBalance >= repayAmount, \"!borrow>repay\");\n } else {\n /* The borrower must have shortfall in order to be liquidateable */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n /* The liquidator may not repay more than what is allowed by the closeFactor */\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\n if (repayAmount > maxClose) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!seizeGuardianPaused, \"!seize:paused\");\n\n // Make sure markets are listed\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure cToken Comptrollers are identical\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param cToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of cTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address cToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!transferGuardianPaused, \"!transfer:paused\");\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cToken, src, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Flywheel Hooks ***/\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\n * @param cToken The relevant market\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n */\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\n }\n\n /*** Liquidity/Liquidation Calculations ***/\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n ICErc20 asset;\n uint256 sumCollateral;\n uint256 sumBorrowPlusEffects;\n uint256 cTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n uint256 borrowCapForCollateral;\n uint256 borrowedAssetPrice;\n uint256 assetAsCollateralValueCap;\n }\n\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(\n account,\n ICErc20(cTokenModify),\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code,\n hypothetical account collateral value,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n ICErc20 cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) internal view returns (Error, uint256, uint256, uint256) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n\n if (address(cTokenModify) != address(0)) {\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n }\n\n // For each asset the account is in\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\n vars.asset = accountAssets[account][i];\n\n {\n // Read the balances and exchange rate from the cToken\n uint256 oErr;\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\n }\n }\n {\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\n if (vars.oraclePriceMantissa == 0) {\n return (Error.PRICE_ERROR, 0, 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n }\n {\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\n vars.asset,\n cTokenModify,\n redeemTokens > 0,\n account\n );\n\n // accumulate the collateral value to sumCollateral\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\n assetCollateralValue = vars.assetAsCollateralValueCap;\n vars.sumCollateral += assetCollateralValue;\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with cTokenModify\n if (vars.asset == cTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\n if (repayEffect >= vars.sumBorrowPlusEffects) {\n vars.sumBorrowPlusEffects = 0;\n } else {\n vars.sumBorrowPlusEffects -= repayEffect;\n }\n }\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\n * @param cTokenBorrowed The address of the borrowed cToken\n * @param cTokenCollateral The address of the collateral cToken\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 actualRepayAmount\n ) external view override returns (uint256, uint256) {\n /* Read oracle prices for borrowed and collateral markets */\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\n uint256 seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\n\n /*\n * The liquidation penalty includes\n * - the liquidator incentive\n * - the protocol fees (Ionic admin fees)\n * - the market fee\n */\n Exp memory totalPenaltyMantissa = add_(\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\n Exp({ mantissa: feeSeizeShareMantissa })\n );\n\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n return (uint256(Error.NO_ERROR), seizeTokens);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Add a RewardsDistributor contracts.\n * @dev Admin function to add a RewardsDistributor contract\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addRewardsDistributor(address distributor) external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n\n // Check marker method\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \"!isRewardsDistributor\");\n\n // Check for existing RewardsDistributor\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \"!added\");\n\n // Add RewardsDistributor to array\n rewardsDistributors.push(distributor);\n emit AddedRewardsDistributor(distributor);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist enforcement for the comptroller\n * @dev Admin function to set a new whitelist enforcement boolean\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\n }\n\n // Check if `enforceWhitelist` already equals `enforce`\n if (enforceWhitelist == enforce) {\n return uint256(Error.NO_ERROR);\n }\n\n // Set comptroller's `enforceWhitelist` to `enforce`\n enforceWhitelist = enforce;\n\n // Emit WhitelistEnforcementChanged(bool enforce);\n emit WhitelistEnforcementChanged(enforce);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist `statuses` for `suppliers`\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\n }\n\n // Set whitelist statuses for suppliers\n for (uint256 i = 0; i < suppliers.length; i++) {\n address supplier = suppliers[i];\n\n if (statuses[i]) {\n // If not already whitelisted, add to whitelist\n if (!whitelist[supplier]) {\n whitelist[supplier] = true;\n whitelistArray.push(supplier);\n whitelistIndexes[supplier] = whitelistArray.length - 1;\n }\n } else {\n // If whitelisted, remove from whitelist\n if (whitelist[supplier]) {\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\n whitelistArray.pop(); // Reduce length by 1\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\n }\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Admin function to set a new price oracle\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\n }\n\n // Track the old oracle for the comptroller\n BasePriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Admin function to set closeFactor\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\n }\n\n // Check limits\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n if (lessThanExp(highLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n // Set pool close factor to new close factor, remember old value\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n\n // Emit event\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Admin function to set per-market collateralFactor\n * @param cToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\n }\n\n // Verify market is listed\n Market storage market = markets[address(cToken)];\n if (!market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\n }\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n // Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Admin function to set liquidationIncentive\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\n }\n\n // Check de-scaled min <= newLiquidationIncentive <= max\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Admin function to set isListed and add support for the market\n * @param cToken The address of the market (token) to list\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Is market already listed?\n if (markets[address(cToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // Check cToken.comptroller == this\n require(address(cToken.comptroller()) == address(this), \"!comptroller\");\n\n // Make sure market is not already listed\n address underlying = ICErc20(address(cToken)).underlying();\n\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // List market and emit event\n Market storage market = markets[address(cToken)];\n market.isListed = true;\n market.collateralFactorMantissa = 0;\n allMarkets.push(cToken);\n cTokensByUnderlying[underlying] = cToken;\n emit MarketListed(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _deployMarket(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\n bool oldIonicAdminHasRights = ionicAdminHasRights;\n ionicAdminHasRights = true;\n\n // Deploy via Ionic admin\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\n // Reset Ionic admin rights to the original value\n ionicAdminHasRights = oldIonicAdminHasRights;\n // Support market here in the Comptroller\n uint256 err = _supportMarket(cToken);\n\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\n\n // Set collateral factor\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\n }\n\n function _becomeImplementation() external {\n require(msg.sender == address(this), \"!self call\");\n\n if (!_notEnteredInitialized) {\n _notEntered = true;\n _notEnteredInitialized = true;\n }\n }\n\n /*** Helper Functions ***/\n\n /**\n * @notice Returns true if the given cToken market has been deprecated\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\n * @param cToken The market to check if deprecated\n */\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\n return\n markets[address(cToken)].collateralFactorMantissa == 0 &&\n borrowGuardianPaused[address(cToken)] == true &&\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\n }\n\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\n return ComptrollerExtensionInterface(address(this));\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 32;\n\n functionSelectors = new bytes4[](fnsCount);\n\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\n functionSelectors[--fnsCount] = this._deployMarket.selector;\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\n functionSelectors[--fnsCount] = this.checkMembership.selector;\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\n functionSelectors[--fnsCount] = this.exitMarket.selector;\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\n functionSelectors[--fnsCount] = this.mintVerify.selector;\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n /**\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _beforeNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_beforeNonReentrant\");\n require(_notEntered, \"!reentered\");\n _notEntered = false;\n }\n\n /**\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _afterNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_afterNonReentrant\");\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n}\n" + }, + "contracts/compound/ComptrollerFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ComptrollerFirstExtension is\n DiamondExtension,\n ComptrollerBase,\n ComptrollerExtensionInterface,\n ComptrollerErrorReporter\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when supply cap for a cToken is changed\n event NewSupplyCap(ICErc20 indexed cToken, uint256 newSupplyCap);\n\n /// @notice Emitted when borrow cap for a cToken is changed\n event NewBorrowCap(ICErc20 indexed cToken, uint256 newBorrowCap);\n\n /// @notice Emitted when borrow cap guardian is changed\n event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused globally\n event ActionPaused(string action, bool pauseState);\n\n /// @notice Emitted when an action is paused on a market\n event MarketActionPaused(ICErc20 cToken, string action, bool pauseState);\n\n /// @notice Emitted when an admin unsupports a market\n event MarketUnlisted(ICErc20 cToken);\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 33;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector;\n functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector;\n functionSelectors[--fnsCount] = this._setMarketBorrowCaps.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._supplyCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._borrowCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapGuardian.selector;\n functionSelectors[--fnsCount] = this._setPauseGuardian.selector;\n functionSelectors[--fnsCount] = this._setMintPaused.selector;\n functionSelectors[--fnsCount] = this._setBorrowPaused.selector;\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this._unsupportMarket.selector;\n functionSelectors[--fnsCount] = this.getAllMarkets.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowers.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowersCount.selector;\n functionSelectors[--fnsCount] = this.getPaginatedBorrowers.selector;\n functionSelectors[--fnsCount] = this.getWhitelist.selector;\n functionSelectors[--fnsCount] = this.getRewardsDistributors.selector;\n functionSelectors[--fnsCount] = this.isUserOfPool.selector;\n functionSelectors[--fnsCount] = this.getAccruingFlywheels.selector;\n functionSelectors[--fnsCount] = this._removeFlywheel.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateral.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateral.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapForCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBlacklistBorrowingAgainstCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isSupplyCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector;\n functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /**\n * @notice Returns true if the accruing flyhwheel was found and replaced\n * @dev Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\n * @param flywheelAddress The address of the flywheel to add to the non-accruing\n */\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n require(flywheelAddress != nonAccruingRewardsDistributors[i], \"!alreadyadded\");\n }\n\n // add it to the non-accruing\n nonAccruingRewardsDistributors.push(flywheelAddress);\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256) {\n if (address(collateral) == address(cTokenModify) && !redeeming) {\n // the collateral asset counts as 0 liquidity when borrowed\n return 0;\n }\n\n uint256 assetAsCollateralValueCap = type(uint256).max;\n if (address(cTokenModify) != address(0)) {\n // if the borrowed asset is blacklisted against this collateral & account is not whitelisted\n if (\n borrowingAgainstCollateralBlacklist[address(cTokenModify)][address(collateral)] &&\n !borrowingAgainstCollateralBlacklistWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n assetAsCollateralValueCap = 0;\n } else {\n // for each user the value of this kind of collateral is capped regardless of the amount borrowed\n // denominated in the borrowed asset\n uint256 borrowCapForCollateral = borrowCapForCollateral[address(cTokenModify)][address(collateral)];\n // check if set to any value & account is not whitelisted\n if (\n borrowCapForCollateral != 0 &&\n !borrowCapForCollateralWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n // this asset usage as collateral is capped at the native value of the borrow cap\n assetAsCollateralValueCap = (borrowCapForCollateral * borrowedAssetPrice) / 1e18;\n }\n }\n }\n\n uint256 supplyCap = effectiveSupplyCaps(address(collateral));\n\n // if there is any supply cap, don't allow donations to the market/plugin to go around it\n if (supplyCap > 0 && !supplyCapWhitelist[address(collateral)].contains(account)) {\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateral);\n uint256 supplyCapValue = (supplyCap * collateralAssetPrice) / 1e18;\n supplyCapValue = (supplyCapValue * markets[address(collateral)].collateralFactorMantissa) / 1e18;\n if (supplyCapValue < assetAsCollateralValueCap) assetAsCollateralValueCap = supplyCapValue;\n }\n\n return assetAsCollateralValueCap;\n }\n\n /**\n * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\n * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\n * @param cTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\n */\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n supplyCaps[address(cTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(cTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\n * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\n * @param cTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\n */\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n borrowCaps[address(cTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Admin function to change the Borrow Cap Guardian\n * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian\n */\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external {\n require(msg.sender == admin, \"!admin\");\n\n // Save current value for inclusion in log\n address oldBorrowCapGuardian = borrowCapGuardian;\n\n // Store borrowCapGuardian with value newBorrowCapGuardian\n borrowCapGuardian = newBorrowCapGuardian;\n\n // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)\n emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(address newPauseGuardian) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);\n }\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setMintPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n mintGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Mint\", state);\n return state;\n }\n\n function _setBorrowPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n borrowGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Borrow\", state);\n return state;\n }\n\n function _setTransferPaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n transferGuardianPaused = state;\n emit ActionPaused(\"Transfer\", state);\n return state;\n }\n\n function _setSeizePaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n seizeGuardianPaused = state;\n emit ActionPaused(\"Seize\", state);\n return state;\n }\n\n /**\n * @notice Removed a market from the markets mapping and sets it as unlisted\n * @dev Admin function unset isListed and collateralFactorMantissa and unadd support for the market\n * @param cToken The address of the market (token) to unlist\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _unsupportMarket(ICErc20 cToken) external returns (uint256) {\n // Check admin rights\n if (!hasAdminRights()) return fail(Error.UNAUTHORIZED, FailureInfo.UNSUPPORT_MARKET_OWNER_CHECK);\n\n // Check if market is already unlisted\n if (!markets[address(cToken)].isListed)\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNSUPPORT_MARKET_DOES_NOT_EXIST);\n\n // Check if market is in use\n if (cToken.totalSupply() > 0) return fail(Error.NONZERO_TOTAL_SUPPLY, FailureInfo.UNSUPPORT_MARKET_IN_USE);\n\n // Unlist market\n delete markets[address(cToken)];\n\n /* Delete cToken from allMarkets */\n // load into memory for faster iteration\n ICErc20[] memory _allMarkets = allMarkets;\n uint256 len = _allMarkets.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (_allMarkets[i] == cToken) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n allMarkets[assetIndex] = allMarkets[allMarkets.length - 1];\n allMarkets.pop();\n\n cTokensByUnderlying[ICErc20(address(cToken)).underlying()] = ICErc20(address(0));\n emit MarketUnlisted(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) public {\n require(hasAdminRights(), \"!admin\");\n borrowCapForCollateral[cTokenBorrow][cTokenCollateral] = borrowCap;\n }\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n borrowingAgainstCollateralBlacklist[cTokenBorrow][cTokenCollateral] = blacklisted;\n }\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) supplyCapWhitelist[cToken].add(account);\n else supplyCapWhitelist[cToken].remove(account);\n }\n\n function isSupplyCapWhitelisted(address cToken, address account) public view returns (bool) {\n return supplyCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedSuppliersSupply(address cToken) public view returns (uint256 supplied) {\n address[] memory whitelistedSuppliers = supplyCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedSuppliers.length; i++) {\n supplied += ICErc20(cToken).balanceOfUnderlying(whitelistedSuppliers[i]);\n }\n }\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapWhitelist[cToken].add(account);\n else borrowCapWhitelist[cToken].remove(account);\n }\n\n function isBorrowCapWhitelisted(address cToken, address account) public view returns (bool) {\n return borrowCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedBorrowersBorrows(address cToken) public view returns (uint256 borrowed) {\n address[] memory whitelistedBorrowers = borrowCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedBorrowers.length; i++) {\n borrowed += ICErc20(cToken).borrowBalanceCurrent(whitelistedBorrowers[i]);\n }\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market.\n * @return The list of market addresses\n */\n function getAllMarkets() public view returns (ICErc20[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Return all of the borrowers\n * @dev The automatic getter may be used to access an individual borrower.\n * @return The list of borrower account addresses\n */\n function getAllBorrowers() public view returns (address[] memory) {\n return allBorrowers;\n }\n\n function getAllBorrowersCount() public view returns (uint256) {\n return allBorrowers.length;\n }\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) public view returns (uint256 _totalPages, address[] memory _pageOfBorrowers) {\n uint256 allBorrowersCount = allBorrowers.length;\n if (allBorrowersCount == 0) {\n return (0, new address[](0));\n }\n\n if (pageSize == 0) pageSize = 300;\n uint256 currentPageSize = pageSize;\n uint256 sizeOfPageFromRemainder = allBorrowersCount % pageSize;\n\n _totalPages = allBorrowersCount / pageSize;\n if (sizeOfPageFromRemainder > 0) {\n _totalPages++;\n if (page + 1 == _totalPages) {\n currentPageSize = sizeOfPageFromRemainder;\n }\n }\n\n if (page + 1 > _totalPages) {\n return (_totalPages, new address[](0));\n }\n\n uint256 offset = page * pageSize;\n _pageOfBorrowers = new address[](currentPageSize);\n for (uint256 i = 0; i < currentPageSize; i++) {\n _pageOfBorrowers[i] = allBorrowers[i + offset];\n }\n }\n\n /**\n * @notice Return all of the whitelist\n * @dev The automatic getter may be used to access an individual whitelist status.\n * @return The list of borrower account addresses\n */\n function getWhitelist() external view returns (address[] memory) {\n return whitelistArray;\n }\n\n /**\n * @notice Returns an array of all accruing and non-accruing flywheels\n */\n function getRewardsDistributors() external view returns (address[] memory) {\n address[] memory allFlywheels = new address[](rewardsDistributors.length + nonAccruingRewardsDistributors.length);\n\n uint8 i = 0;\n while (i < rewardsDistributors.length) {\n allFlywheels[i] = rewardsDistributors[i];\n i++;\n }\n uint8 j = 0;\n while (j < nonAccruingRewardsDistributors.length) {\n allFlywheels[i + j] = nonAccruingRewardsDistributors[j];\n j++;\n }\n\n return allFlywheels;\n }\n\n function getAccruingFlywheels() external view returns (address[] memory) {\n return rewardsDistributors;\n }\n\n /**\n * @dev Removes a flywheel from the accruing or non-accruing array\n * @param flywheelAddress The address of the flywheel to remove from the accruing or non-accruing array\n * @return true if the flywheel was found and removed\n */\n function _removeFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n // or remove it from the non-accruing\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n if (flywheelAddress == nonAccruingRewardsDistributors[i]) {\n nonAccruingRewardsDistributors[i] = nonAccruingRewardsDistributors[nonAccruingRewardsDistributors.length - 1];\n nonAccruingRewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function isUserOfPool(address user) external view returns (bool) {\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address marketAddress = address(allMarkets[i]);\n if (markets[marketAddress].accountMembership[user]) {\n return true;\n }\n }\n\n return false;\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n\n for (uint256 i = 0; i < allMarkets.length; i++) {\n allMarkets[i].registerInSFS();\n }\n\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/ComptrollerInterface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerV4Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\nimport { IHistoricalRates } from \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\ninterface ComptrollerInterface {\n function isDeprecated(ICErc20 cToken) external view returns (bool);\n\n function _becomeImplementation() external;\n\n function _deployMarket(\n uint8 delegateType,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\n\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\n\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _addRewardsDistributor(address distributor) external returns (uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) external view returns (uint256, uint256, uint256, uint256);\n\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cToken) external returns (uint256);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\n\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\n\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function getAccountLiquidity(\n address account\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\n\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 repayAmount\n ) external view returns (uint256, uint256);\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n function _beforeNonReentrant() external;\n\n function _afterNonReentrant() external;\n\n /*** New supply and borrow cap view functions ***/\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\n}\n\ninterface ComptrollerStorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function pendingAdmin() external view returns (address);\n\n function oracle() external view returns (BasePriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function enforceWhitelist() external view returns (bool);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function suppliers(address account) external view returns (bool);\n\n function cTokensByUnderlying(address) external view returns (address);\n\n /**\n * Gets the supply cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\n * `effectiveSupplyCaps` to get the correct supply cap.\n * @param cToken The address of the cToken.\n * @return The supply cap in the units of the underlying asset.\n */\n function supplyCaps(address cToken) external view returns (uint256);\n\n /**\n * Gets the borrow cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\n * `effectiveBorrowCaps` to get the correct borrow cap.\n * @param cToken The address of the cToken.\n * @return The borrow cap in the units of the underlying asset.\n */\n function borrowCaps(address cToken) external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function accountAssets(address, uint256) external view returns (address);\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function rewardsDistributors(uint256) external view returns (address);\n}\n\ninterface SFSRegister {\n function register(address _recipient) external returns (uint256 tokenId);\n}\n\ninterface ComptrollerExtensionInterface {\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function getAllBorrowersCount() external view returns (uint256);\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAccruingFlywheels() external view returns (address[] memory);\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) external;\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _removeFlywheel(address flywheelAddress) external returns (bool);\n\n function getWhitelist() external view returns (address[] memory);\n\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\n\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setTransferPaused(bool state) external returns (bool);\n\n function _setSeizePaused(bool state) external returns (bool);\n\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\n * @return The config.\n */\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\n * @return The config.\n */\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\n * @param newConfig The new config.\n */\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\n * @param newConfig The new config.\n */\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n}\n\ninterface UnitrollerInterface {\n function comptrollerImplementation() external view returns (address);\n\n function _upgrade() external;\n\n function _acceptAdmin() external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n\n function _toggleAdminRights(bool hasRights) external returns (uint256);\n}\n\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\n\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\n\ninterface IonicComptroller is\n ComptrollerInterface,\n ComptrollerExtensionInterface,\n UnitrollerInterface,\n ComptrollerStorageInterface\n{\n\n}\n\nabstract contract ComptrollerBase is ComptrollerV4Storage {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\n\n // Check if we're using Adrastia Prudentia for the supply cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the supply cap from Adrastia Prudentia\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n supplyCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n supplyCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local supply cap\n\n // Get the supply cap from the local supply cap\n supplyCap = supplyCaps[cToken];\n }\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\n\n // Check if we're using Adrastia Prudentia for the borrow cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the borrow cap from Adrastia Prudentia\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n borrowCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n borrowCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local borrow cap\n borrowCap = borrowCaps[cToken];\n }\n }\n}\n" + }, + "contracts/compound/ComptrollerPrudentiaCapsExt.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerPrudentiaCapsExtInterface, ComptrollerBase } from \"./ComptrollerInterface.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\n/**\n * @title ComptrollerPrudentiaCapsExt\n * @author Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)\n * @notice A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.\n */\ncontract ComptrollerPrudentiaCapsExt is DiamondExtension, ComptrollerBase, ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Emitted when the Adrastia Prudentia supply cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /**\n * @notice Emitted when the Adrastia Prudentia borrow cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = supplyCapConfig;\n supplyCapConfig = newConfig;\n\n emit NewSupplyCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = borrowCapConfig;\n borrowCapConfig = newConfig;\n\n emit NewBorrowCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return borrowCapConfig;\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return supplyCapConfig;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setSupplyCapConfig.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getSupplyCapConfig.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n" + }, + "contracts/compound/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IFeeDistributor.sol\";\nimport \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract UnitrollerAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Whether or not the Ionic admin has admin rights\n */\n bool public ionicAdminHasRights = true;\n\n /**\n * @notice Whether or not the admin has admin rights\n */\n bool public adminHasRights = true;\n\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\n }\n}\n\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n BasePriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /*\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 internal maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => ICErc20[]) public accountAssets;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n struct Market {\n // Whether or not this market is listed\n bool isListed;\n // Multiplier representing the most one can borrow against their collateral in this market.\n // For instance, 0.9 to allow borrowing 90% of collateral value.\n // Must be between 0 and 1, and stored as a mantissa.\n uint256 collateralFactorMantissa;\n // Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n }\n\n /**\n * @notice Official mapping of cTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /// @notice A list of all markets\n ICErc20[] public allMarkets;\n\n /**\n * @dev Maps borrowers to booleans indicating if they have entered any markets\n */\n mapping(address => bool) internal borrowers;\n\n /// @notice A list of all borrowers who have entered markets\n address[] public allBorrowers;\n\n // Indexes of borrower account addresses in the `allBorrowers` array\n mapping(address => uint256) internal borrowerIndexes;\n\n /**\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\n */\n mapping(address => bool) public suppliers;\n\n /// @notice All cTokens addresses mapped by their underlying token addresses\n mapping(address => ICErc20) public cTokensByUnderlying;\n\n /// @notice Whether or not the supplier whitelist is enforced\n bool public enforceWhitelist;\n\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\n mapping(address => bool) public whitelist;\n\n /// @notice An array of all whitelisted accounts\n address[] public whitelistArray;\n\n // Indexes of account addresses in the `whitelistArray` array\n mapping(address => uint256) internal whitelistIndexes;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n * Actions which allow users to remove their own assets cannot be paused.\n * Liquidation / seizing / transfer can only be paused globally, not by market.\n */\n address public pauseGuardian;\n bool public _mintGuardianPaused;\n bool public _borrowGuardianPaused;\n bool public transferGuardianPaused;\n bool public seizeGuardianPaused;\n mapping(address => bool) public mintGuardianPaused;\n mapping(address => bool) public borrowGuardianPaused;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\n mapping(address => uint256) public borrowCaps;\n\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\n mapping(address => uint256) public supplyCaps;\n\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\n address[] public rewardsDistributors;\n\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\n bool internal _notEntered;\n\n /// @dev Whether or not _notEntered has been initialized\n bool internal _notEnteredInitialized;\n\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\n address[] public nonAccruingRewardsDistributors;\n\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\n\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => mapping(address => EnumerableSet.AddressSet))\n internal borrowingAgainstCollateralBlacklistWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @dev Adrastia Prudentia config for controlling borrow caps.\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\n\n /// @dev Adrastia Prudentia config for controlling supply caps.\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\n}\n" + }, + "contracts/compound/CToken.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { CTokenSecondExtensionBase, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { DiamondExtension, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\n/**\n * @title Compound's CErc20 Contract\n * @notice CTokens which wrap an EIP-20 underlying\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\n * @author Compound\n */\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n modifier isMinHFThresholdExceeded(address borrower) {\n PoolLens lens = PoolLens(ap.getAddress(\"PoolLens\"));\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\n require(msg.sender == address(liquidator), \"Health factor not low enough for non-permissioned liquidations\");\n _;\n } else {\n _;\n }\n }\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 13;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.mint.selector;\n functionSelectors[--fnsCount] = this.redeem.selector;\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\n functionSelectors[--fnsCount] = this.borrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\n functionSelectors[--fnsCount] = this.getCash.selector;\n functionSelectors[--fnsCount] = this.seize.selector;\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemInternal(redeemTokens);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemUnderlyingInternal(redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return borrowInternal(borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\n return err;\n }\n\n /**\n * @notice Get cash balance of this cToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view override returns (uint256) {\n return getCashInternal();\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another cToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n function selfTransferOut(address to, uint256 amount) external override {\n require(msg.sender == address(this), \"!self\");\n doTransferOut(to, amount);\n }\n\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\n require(msg.sender == address(this), \"!self\");\n return doTransferIn(from, amount);\n }\n\n /**\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\n }\n\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalIonicFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\n totalIonicFees = totalIonicFeesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(address(ionicAdmin), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces admin fees by transferring to admin\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalAdminFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n totalAdminFees = totalAdminFees - withdrawAmount;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view virtual returns (uint256) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\n \"TOKEN_TRANSFER_IN_FAILED\"\n );\n\n // Calculate the amount that was *actually* transferred\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address to, uint256 amount) internal virtual {\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\n \"TOKEN_TRANSFER_OUT_FAILED\"\n );\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n struct MintLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 mintTokens;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n uint256 actualMintAmount;\n }\n\n /**\n * @notice User supplies assets into the market and receives cTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\n /* Fail if mint not allowed */\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n // Check max supply\n // unused function\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n } */\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of cTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n // mintTokens is rounded down here - correct\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n require(vars.mathErr == MathError.NO_ERROR, \"MINT_EXCHANGE_CALCULATION_FAILED\");\n require(vars.mintTokens > 0, \"MINT_ZERO_CTOKENS_REJECTED\");\n\n /*\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\n\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, 0, redeemAmount);\n }\n\n struct RedeemLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 redeemTokens;\n uint256 redeemAmount;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n }\n\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\n res = (x * 1e18) / y;\n if (x % y != 0) res += 1;\n }\n\n /**\n * @notice User redeems cTokens in exchange for the underlying asset\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemFresh(\n address redeemer,\n uint256 redeemTokensIn,\n uint256 redeemAmountIn\n ) internal returns (uint256) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"!redeem tokens or amount\");\n\n RedeemLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n if (redeemTokensIn > 0) {\n // don't allow dust tokens/assets to be left after\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\n\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n } else {\n if (redeemAmountIn == type(uint256).max) {\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\n }\n\n // don't allow dust tokens/assets to be left after\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\n\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\n\n // don't allow dust tokens/assets to be left after\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashInternal() < vars.redeemAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the redeemer and the redeemAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(redeemer, vars.redeemAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\n\n /* We call the defense hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(msg.sender, borrowAmount);\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n }\n\n /**\n * @notice Users borrow assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\n /* Fail if borrow not allowed */\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\n }\n\n /* Fail gracefully if protocol has insufficient underlying cash */\n uint256 cashPrior = getCashInternal();\n\n if (cashPrior < borrowAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n uint256(vars.mathErr)\n );\n }\n\n // Check min borrow for this user for this asset\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the borrower and the borrowAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(borrower, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\n internal\n nonReentrant(false)\n returns (uint256, uint256)\n {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint256 repayAmount;\n uint256 borrowerIndex;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n uint256 actualRepayAmount;\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer the account paying off the borrow\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(\n address payer,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256, uint256) {\n /* Fail if repayBorrow not allowed */\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == type(uint256).max) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\");\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\");\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n ICErc20(cTokenCollateral).accrueInterest();\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal returns (uint256, uint256) {\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n cTokenCollateral,\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify cTokenCollateral market's block number equals current block number */\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == type(uint256).max) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n cTokenCollateral,\n actualRepayAmount\n );\n require(amountSeizeError == uint256(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint256 seizeError;\n if (cTokenCollateral == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"!seize\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n\n struct SeizeInternalLocalVars {\n MathError mathErr;\n uint256 borrowerTokensNew;\n uint256 liquidatorTokensNew;\n uint256 liquidatorSeizeTokens;\n uint256 protocolSeizeTokens;\n uint256 protocolSeizeAmount;\n uint256 exchangeRateMantissa;\n uint256 totalReservesNew;\n uint256 totalIonicFeeNew;\n uint256 totalSupplyNew;\n uint256 feeSeizeTokens;\n uint256 feeSeizeAmount;\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) internal returns (uint256) {\n /* Fail if seize not allowed */\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n SeizeInternalLocalVars memory vars;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\n }\n\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n vars.protocolSeizeAmount = mul_ScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n vars.protocolSeizeTokens\n );\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\n\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\n\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n totalReserves = vars.totalReservesNew;\n totalSupply = vars.totalSupplyNew;\n totalIonicFees = vars.totalIonicFeeNew;\n\n accountTokens[borrower] = vars.borrowerTokensNew;\n accountTokens[liquidator] = vars.liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n function asCTokenExtension() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\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 * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CTokenFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { IFlashLoanReceiver } from \"../ionic/IFlashLoanReceiver.sol\";\nimport { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { SFSRegister } from \"./ComptrollerInterface.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport { Multicall } from \"../utils/Multicall.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenFirstExtension is\n CTokenOracleProtected,\n CErc20FirstExtensionBase,\n TokenErrorReporter,\n Exponential,\n DiamondExtension,\n Multicall\n{\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 25;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.transfer.selector;\n functionSelectors[--fnsCount] = this.transferFrom.selector;\n functionSelectors[--fnsCount] = this.allowance.selector;\n functionSelectors[--fnsCount] = this.approve.selector;\n functionSelectors[--fnsCount] = this.balanceOf.selector;\n functionSelectors[--fnsCount] = this._setAdminFee.selector;\n functionSelectors[--fnsCount] = this._setInterestRateModel.selector;\n functionSelectors[--fnsCount] = this._setNameAndSymbol.selector;\n functionSelectors[--fnsCount] = this._setAddressesProvider.selector;\n functionSelectors[--fnsCount] = this._setReserveFactor.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.exchangeRateCurrent.selector;\n functionSelectors[--fnsCount] = this.accrueInterest.selector;\n functionSelectors[--fnsCount] = this.totalBorrowsCurrent.selector;\n functionSelectors[--fnsCount] = this.balanceOfUnderlying.selector;\n functionSelectors[--fnsCount] = this.multicall.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterDeposit.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterWithdraw.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlockAfterBorrow.selector;\n functionSelectors[--fnsCount] = this.getTotalUnderlyingSupplied.selector;\n functionSelectors[--fnsCount] = this.flash.selector;\n functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;\n functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getTotalUnderlyingSupplied() public view override returns (uint256) {\n // (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees))\n return asCToken().getCash() + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees);\n }\n\n /* ERC20 fns */\n /**\n * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {\n /* Fail if transfer not allowed */\n uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint256 startingAllowance = 0;\n if (spender == src) {\n startingAllowance = type(uint256).max;\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint256 allowanceNew;\n uint256 srcTokensNew;\n uint256 dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srcTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != type(uint256).max) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(\n address spender,\n uint256 amount\n ) public override isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n address src = msg.sender;\n transferAllowances[src][spender] = amount;\n emit Approval(src, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) public view override returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) public view override returns (uint256) {\n return accountTokens[owner];\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice updates the cToken ERC20 name and symbol\n * @dev Admin function to update the cToken ERC20 name and symbol\n * @param _name the new ERC20 token name to use\n * @param _symbol the new ERC20 token symbol to use\n */\n function _setNameAndSymbol(string calldata _name, string calldata _symbol) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n // Set ERC20 name and symbol\n name = _name;\n symbol = _symbol;\n }\n\n function _setAddressesProvider(address _ap) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n ap = AddressesProvider(_ap);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(\n uint256 newReserveFactorMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK);\n }\n\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa + adminFeeMantissa + ionicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint256 oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\n * @dev Admin function to accrue interest and set a new admin fee\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setAdminFee(\n uint256 newAdminFeeMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_ADMIN_FEE_FRESH_CHECK);\n }\n\n // Sanitize newAdminFeeMantissa\n if (newAdminFeeMantissa == type(uint256).max) newAdminFeeMantissa = adminFeeMantissa;\n\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n\n // Check reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa ≤ reserveFactorPlusFeesMaxMantissa\n if (reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK);\n }\n\n // If setting admin fee\n if (adminFeeMantissa != newAdminFeeMantissa) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_ADMIN_FEE_ADMIN_CHECK);\n }\n\n // Set admin fee\n uint256 oldAdminFeeMantissa = adminFeeMantissa;\n adminFeeMantissa = newAdminFeeMantissa;\n\n // Emit event\n emit NewAdminFee(oldAdminFeeMantissa, newAdminFeeMantissa);\n }\n\n // If setting Ionic fee\n if (ionicFeeMantissa != newIonicFeeMantissa) {\n // Set Ionic fee\n uint256 oldIonicFeeMantissa = ionicFeeMantissa;\n ionicFeeMantissa = newIonicFeeMantissa;\n\n // Emit event\n emit NewIonicFee(oldIonicFeeMantissa, newIonicFeeMantissa);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(\n InterestRateModel newInterestRateModel\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);\n }\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n require(newInterestRateModel.isInterestRateModel(), \"!notIrm\");\n\n InterestRateModel oldInterestRateModel = interestRateModel;\n interestRateModel = newInterestRateModel;\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this cToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getBorrowRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) public view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= borrowAmount, \"market cash not enough\");\n\n return\n interestRateModel.getBorrowRate(\n cash - borrowAmount,\n totalBorrows + borrowAmount,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this cToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash() + mintAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= withdrawAmount, \"market cash not enough\");\n return\n interestRateModel.getSupplyRate(\n cash - withdrawAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public view override returns (uint256) {\n if (block.number == accrualBlockNumber) {\n return\n _exchangeRateHypothetical(\n totalSupply,\n initialExchangeRateMantissa,\n asCToken().getCash(),\n totalBorrows,\n totalReserves,\n totalAdminFees,\n totalIonicFees\n );\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n\n return\n _exchangeRateHypothetical(\n accrual.totalSupply,\n initialExchangeRateMantissa,\n cashPrior,\n accrual.totalBorrows,\n accrual.totalReserves,\n accrual.totalAdminFees,\n accrual.totalIonicFees\n );\n }\n }\n\n function _exchangeRateHypothetical(\n uint256 _totalSupply,\n uint256 _initialExchangeRateMantissa,\n uint256 _totalCash,\n uint256 _totalBorrows,\n uint256 _totalReserves,\n uint256 _totalAdminFees,\n uint256 _totalIonicFees\n ) internal pure returns (uint256) {\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return _initialExchangeRateMantissa;\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees)) / totalSupply\n */\n uint256 cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(\n _totalCash,\n _totalBorrows,\n _totalReserves + _totalAdminFees + _totalIonicFees\n );\n require(mathErr == MathError.NO_ERROR, \"!addThenSubUInt overflow check failed\");\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n require(mathErr == MathError.NO_ERROR, \"!getExp overflow check failed\");\n\n return exchangeRate.mantissa;\n }\n }\n\n struct InterestAccrual {\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalSupply;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n uint256 interestAccumulated;\n }\n\n function _accrueInterestHypothetical(\n uint256 blockNumber,\n uint256 cashPrior\n ) internal view returns (InterestAccrual memory accrual) {\n uint256 totalFees = totalAdminFees + totalIonicFees;\n uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);\n if (borrowRateMantissa > borrowRateMaxMantissa) {\n if (cashPrior > totalFees) revert(\"!borrowRate\");\n else borrowRateMantissa = borrowRateMaxMantissa;\n }\n (MathError mathErr, uint256 blockDelta) = subUInt(blockNumber, accrualBlockNumber);\n require(mathErr == MathError.NO_ERROR, \"!blockDelta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * totalIonicFeesNew = interestAccumulated * ionicFee + totalIonicFees\n * totalAdminFeesNew = interestAccumulated * adminFee + totalAdminFees\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n accrual.accrualBlockNumber = blockNumber;\n accrual.totalSupply = totalSupply;\n Exp memory simpleInterestFactor = mul_(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n accrual.interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, totalBorrows);\n accrual.totalBorrows = accrual.interestAccumulated + totalBorrows;\n accrual.totalReserves = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n accrual.interestAccumulated,\n totalReserves\n );\n accrual.totalIonicFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: ionicFeeMantissa }),\n accrual.interestAccumulated,\n totalIonicFees\n );\n accrual.totalAdminFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: adminFeeMantissa }),\n accrual.interestAccumulated,\n totalAdminFees\n );\n accrual.borrowIndex = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndex, borrowIndex);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public override returns (uint256) {\n /* Remember the initial block number */\n uint256 currentBlockNumber = block.number;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumber == currentBlockNumber) {\n return uint256(Error.NO_ERROR);\n }\n\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(currentBlockNumber, cashPrior);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = accrual.borrowIndex;\n totalBorrows = accrual.totalBorrows;\n totalReserves = accrual.totalReserves;\n totalIonicFees = accrual.totalIonicFees;\n totalAdminFees = accrual.totalAdminFees;\n emit AccrueInterest(cashPrior, accrual.interestAccumulated, borrowIndex, totalBorrows);\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external view override returns (uint256) {\n if (accrualBlockNumber == block.number) {\n return totalBorrows;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n return accrual.totalBorrows;\n }\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {\n uint256 cTokenBalance = accountTokens[account];\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n\n borrowBalance = borrowBalanceCurrent(account);\n\n exchangeRateMantissa = exchangeRateCurrent();\n\n return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\n * @param account The address whose balance should be calculated after recalculating the borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) public view override returns (uint256) {\n uint256 _borrowIndex;\n if (accrualBlockNumber == block.number) {\n _borrowIndex = borrowIndex;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n _borrowIndex = accrual.borrowIndex;\n }\n\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint256 principalTimesIndex;\n uint256 result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return 0;\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, _borrowIndex);\n require(mathErr == MathError.NO_ERROR, \"!mulUInt overflow check failed\");\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n require(mathErr == MathError.NO_ERROR, \"!divUInt overflow check failed\");\n\n return result;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external view override returns (uint256) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint256 balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n require(mErr == MathError.NO_ERROR, \"!balance\");\n return balance;\n }\n\n function flash(uint256 amount, bytes calldata data) public override isAuthorized onlyOracleApprovedAllowEOA {\n accrueInterest();\n\n totalBorrows += amount;\n asCToken().selfTransferOut(msg.sender, amount);\n\n IFlashLoanReceiver(msg.sender).receiveFlashLoan(underlying, amount, data);\n\n asCToken().selfTransferIn(msg.sender, amount);\n totalBorrows -= amount;\n\n emit Flash(msg.sender, amount);\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\n }\n\n function asCToken() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n function multicall(\n bytes[] calldata data\n ) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {\n return Multicall.multicall(data);\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights() || msg.sender == address(comptroller), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/CTokenInterfaces.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\n\nabstract contract CTokenAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n}\n\nabstract contract CErc20Storage is CTokenAdminStorage {\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /*\n * Maximum borrow rate that can ever be applied (.0005% / block)\n */\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /*\n * Maximum fraction of interest that can be set aside for reserves + fees\n */\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\n\n /**\n * @notice Contract which oversees inter-cToken operations\n */\n IonicComptroller public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /*\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\n */\n uint256 internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for admin fees\n */\n uint256 public adminFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for Ionic fees\n */\n uint256 public ionicFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint256 public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint256 public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint256 public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint256 public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint256 public totalReserves;\n\n /**\n * @notice Total amount of admin fees of the underlying held in this market\n */\n uint256 public totalAdminFees;\n\n /**\n * @notice Total amount of Ionic fees of the underlying held in this market\n */\n uint256 public totalIonicFees;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint256 public totalSupply;\n\n /*\n * Official record of token balances for each account\n */\n mapping(address => uint256) internal accountTokens;\n\n /*\n * Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint256)) internal transferAllowances;\n\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint256 principal;\n uint256 interestIndex;\n }\n\n /*\n * Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /*\n * Share of seized collateral that is added to reserves\n */\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\n\n /*\n * Share of seized collateral taken as fees\n */\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\n\n /**\n * @notice Underlying asset for this CToken\n */\n address public underlying;\n\n /**\n * @notice Addresses Provider\n */\n AddressesProvider public ap;\n}\n\nabstract contract CTokenBaseEvents {\n /* ERC20 */\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the admin fee is changed\n */\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\n\n /**\n * @notice Event emitted when the Ionic fee is changed\n */\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\n}\n\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\n event Flash(address receiver, uint256 amount);\n}\n\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral,\n uint256 seizeTokens\n );\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\n}\n\ninterface CTokenFirstExtensionInterface {\n /*** User Interface ***/\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n /*** Admin Functions ***/\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\n\n function getAccountSnapshot(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256\n );\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function exchangeRateCurrent() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function totalBorrowsCurrent() external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external view returns (uint256);\n\n function getTotalUnderlyingSupplied() external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external view returns (uint256);\n\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n\n function flash(uint256 amount, bytes calldata data) external;\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface CTokenSecondExtensionInterface {\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n /*** Admin Functions ***/\n\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\n\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\n\n function selfTransferOut(address to, uint256 amount) external;\n\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\n}\n\ninterface CDelegatorInterface {\n function implementation() external view returns (address);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external;\n}\n\ninterface CDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes calldata data) external;\n\n function delegateType() external pure returns (uint8);\n\n function contractType() external pure returns (string memory);\n}\n\nabstract contract CErc20AdminBase is CErc20Storage {\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\n return\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\n }\n}\n\nabstract contract CErc20FirstExtensionBase is\n CErc20AdminBase,\n CTokenFirstExtensionEvents,\n CTokenFirstExtensionInterface\n{}\n\nabstract contract CTokenSecondExtensionBase is\n CErc20AdminBase,\n CTokenSecondExtensionEvents,\n CTokenSecondExtensionInterface,\n CDelegateInterface\n{}\n\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\n\ninterface CErc20StorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function comptroller() external view returns (IonicComptroller);\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function accrualBlockNumber() external view returns (uint256);\n\n function underlying() external view returns (address);\n\n function borrowIndex() external view returns (uint256);\n\n function interestRateModel() external view returns (address);\n}\n\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\n function plugin() external view returns (address);\n}\n\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\n function approve(address, address) external;\n}\n\ninterface ICErc20 is\n CErc20StorageInterface,\n CTokenSecondExtensionInterface,\n CTokenFirstExtensionInterface,\n CDelegatorInterface,\n CDelegateInterface\n{}\n\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\n function _updatePlugin(address _plugin) external;\n}\n\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\n" + }, + "contracts/compound/CTokenOracleProtected.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { CErc20Storage } from \"./CTokenInterfaces.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenOracleProtected is CErc20Storage {\n error InteractionNotAllowed();\n\n modifier onlyOracleApproved() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n if (oracle.isBlacklistedContext(msg.sender, tx.origin) || !oracle.isTimeExceeded(msg.sender)) {\n revert InteractionNotAllowed();\n }\n _;\n }\n\n modifier onlyOracleApprovedAllowEOA() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n if (oracle.isBlacklistedAccount(msg.sender) || msg.sender != tx.origin) {\n revert InteractionNotAllowed();\n }\n _;\n }\n}\n" + }, + "contracts/compound/EIP20Interface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title ERC 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return uint256 The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance uint256 The balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success bool Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/compound/EIP20NonStandardInterface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title EIP20NonStandardInterface\n * @dev Version of ERC20 with no return values for `transfer` and `transferFrom`\n * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\ninterface EIP20NonStandardInterface {\n /**\n * @notice Get the total number of tokens in circulation\n * @return The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance uint256 The balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transfer(address dst, uint256 amount) external;\n\n ///\n /// !!!!!!!!!!!!!!\n /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification\n /// !!!!!!!!!!!!!!\n ///\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external;\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved\n * @return success bool Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining uint256 The number of tokens allowed to be spent\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/compound/ErrorReporter.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n SUPPLIER_NOT_WHITELISTED,\n BORROW_BELOW_MIN,\n SUPPLY_ABOVE_MAX,\n NONZERO_TOTAL_SUPPLY\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\n SET_WHITELIST_STATUS_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n UNSUPPORT_MARKET_OWNER_CHECK,\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\n UNSUPPORT_MARKET_IN_USE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return uint256(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n UTILIZATION_ABOVE_MAX\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n NEW_UTILIZATION_RATE_ABOVE_MAX,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\n WITHDRAW_IONIC_FEES_VALIDATION,\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\n WITHDRAW_ADMIN_FEES_VALIDATION,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\n SET_ADMIN_FEE_ADMIN_CHECK,\n SET_ADMIN_FEE_FRESH_CHECK,\n SET_ADMIN_FEE_BOUNDS_CHECK,\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\n SET_IONIC_FEE_FRESH_CHECK,\n SET_IONIC_FEE_BOUNDS_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\n }\n}\n" + }, + "contracts/compound/Exponential.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(\n Exp memory a,\n Exp memory b,\n Exp memory c\n ) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/compound/ExponentialNoError.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint256 constant expScale = 1e18;\n uint256 constant doubleScale = 1e36;\n uint256 constant halfExpScale = expScale / 2;\n uint256 constant mantissaOne = expScale;\n\n struct Exp {\n uint256 mantissa;\n }\n\n struct Double {\n uint256 mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint256) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(\n Exp memory a,\n uint256 scalar,\n uint256 addend\n ) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2**224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2**32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint256 c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/compound/IERC4626.sol": { + "content": "pragma solidity >=0.8.0;\npragma experimental ABIEncoderV2;\n\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\ninterface IERC4626 is EIP20Interface {\n /*----------------------------------------------------------------\n Events\n ----------------------------------------------------------------*/\n\n event Deposit(address indexed from, address indexed to, uint256 value);\n\n event Withdraw(address indexed from, address indexed to, uint256 value);\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n /**\n @notice Deposit a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to deposit.\n @param to The address to receive shares corresponding to the deposit\n @return shares The shares in the vault credited to `to`\n */\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\n\n /**\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\n @param shareAmount The amount of vault shares to mint.\n @param to The address to receive shares corresponding to the mint.\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\n */\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\n\n /**\n @notice Withdraw a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to withdraw.\n @param to The address to receive underlying corresponding to the withdrawal.\n @param from The address to burn shares from corresponding to the withdrawal.\n @return shares The shares in the vault burned from sender\n */\n function withdraw(\n uint256 underlyingAmount,\n address to,\n address from\n ) external returns (uint256 shares);\n\n /**\n @notice Redeem a specific amount of shares for underlying tokens.\n @param shareAmount The amount of shares to redeem.\n @param to The address to receive underlying corresponding to the redemption.\n @param from The address to burn shares from corresponding to the redemption.\n @return value The underlying amount transferred to `to`.\n */\n function redeem(\n uint256 shareAmount,\n address to,\n address from\n ) external returns (uint256 value);\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n /** \n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n @return the address of the asset\n */\n function asset() external view returns (address);\n\n /** \n @notice Returns a user's Vault balance in underlying tokens.\n @param user The user to get the underlying balance of.\n @return balance The user's Vault balance in underlying tokens.\n */\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\n\n /** \n @notice Calculates the total amount of underlying tokens the Vault manages.\n @return The total amount of underlying tokens the Vault manages.\n */\n function totalAssets() external view returns (uint256);\n\n /** \n @notice Returns the value in underlying terms of one vault token. \n */\n function exchangeRate() external view returns (uint256);\n\n /**\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\n */\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\n @param shareAmount the amount of shares from a mint call.\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\n */\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n\n /**\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\n */\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\n @param shareAmount the amount of shares from a redeem call.\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\n */\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n}\n" + }, + "contracts/compound/IFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../ionic/AuthoritiesRegistry.sol\";\n\ninterface IFeeDistributor {\n function minBorrowEth() external view returns (uint256);\n\n function maxUtilizationRate() external view returns (uint256);\n\n function interestFeeRate() external view returns (uint256);\n\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\n\n function latestCErc20Delegate(uint8 delegateType)\n external\n view\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\n\n function latestPluginImplementation(address oldImplementation) external view returns (address);\n\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\n\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address);\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\n\n fallback() external payable;\n\n receive() external payable;\n}\n" + }, + "contracts/compound/InterestRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's InterestRateModel Interface\n * @author Compound\n */\nabstract contract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual returns (uint256);\n}\n" + }, + "contracts/compound/JumpRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Compound's JumpRateModel Contract\n * @author Compound\n */\ncontract JumpRateModel is InterestRateModel {\n event NewInterestParams(\n uint256 baseRatePerBlock,\n uint256 multiplierPerBlock,\n uint256 jumpMultiplierPerBlock,\n uint256 kink\n );\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint256 public blocksPerYear;\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint256 public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint256 public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint256 public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint256 public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param _blocksPerYear The approximate number of blocks per year\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(\n uint256 _blocksPerYear,\n uint256 baseRatePerYear,\n uint256 multiplierPerYear,\n uint256 jumpMultiplierPerYear,\n uint256 kink_\n ) {\n blocksPerYear = _blocksPerYear;\n baseRatePerBlock = baseRatePerYear / blocksPerYear;\n multiplierPerBlock = multiplierPerYear / blocksPerYear;\n jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return (borrows * 1e18) / (cash + borrows - reserves);\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n uint256 util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return ((util * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n } else {\n uint256 normalRate = ((kink * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n uint256 excessUtil = util - kink;\n return ((excessUtil * jumpMultiplierPerBlock) / 1e18) + normalRate;\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\n }\n}\n" + }, + "contracts/compound/PriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\n\nabstract contract PriceOracle {\n /// @notice Indicator that this is a PriceOracle contract (for inspection)\n bool public constant isPriceOracle = true;\n\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view virtual returns (uint256);\n}\n" + }, + "contracts/compound/SafeMath.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol\n// Subject to the MIT license.\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, reverting on overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\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\n return c;\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n * - Addition cannot overflow.\n */\n function add(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot underflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction underflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n * - Subtraction cannot underflow.\n */\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (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) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n * - Multiplication cannot overflow.\n */\n function mul(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (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) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, errorMessage);\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers.\n * Reverts on 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 * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers.\n * Reverts with custom message on 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 * - The divisor cannot be zero.\n */\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts 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 * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message 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 * - The divisor cannot be zero.\n */\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "contracts/compound/Timelock.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./SafeMath.sol\";\n\ncontract Timelock {\n using SafeMath for uint256;\n\n event NewAdmin(address indexed newAdmin);\n event NewPendingAdmin(address indexed newPendingAdmin);\n event NewDelay(uint256 indexed newDelay);\n event CancelTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n event ExecuteTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n event QueueTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n uint256 public constant GRACE_PERIOD = 14 days;\n uint256 public constant MINIMUM_DELAY = 2 days;\n uint256 public constant MAXIMUM_DELAY = 30 days;\n\n address public admin;\n address public pendingAdmin;\n uint256 public delay;\n\n mapping(bytes32 => bool) public queuedTransactions;\n\n constructor(address admin_, uint256 delay_) {\n require(delay_ >= MINIMUM_DELAY, \"Timelock::constructor: Delay must exceed minimum delay.\");\n require(delay_ <= MAXIMUM_DELAY, \"Timelock::setDelay: Delay must not exceed maximum delay.\");\n\n admin = admin_;\n delay = delay_;\n }\n\n receive() external payable {}\n\n function setDelay(uint256 delay_) public {\n require(msg.sender == address(this), \"Timelock::setDelay: Call must come from Timelock.\");\n require(delay_ >= MINIMUM_DELAY, \"Timelock::setDelay: Delay must exceed minimum delay.\");\n require(delay_ <= MAXIMUM_DELAY, \"Timelock::setDelay: Delay must not exceed maximum delay.\");\n delay = delay_;\n\n emit NewDelay(delay);\n }\n\n function acceptAdmin() public {\n require(msg.sender == pendingAdmin, \"Timelock::acceptAdmin: Call must come from pendingAdmin.\");\n admin = msg.sender;\n pendingAdmin = address(0);\n\n emit NewAdmin(admin);\n }\n\n function setPendingAdmin(address pendingAdmin_) public {\n require(msg.sender == address(this), \"Timelock::setPendingAdmin: Call must come from Timelock.\");\n pendingAdmin = pendingAdmin_;\n\n emit NewPendingAdmin(pendingAdmin);\n }\n\n function queueTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) public returns (bytes32) {\n require(msg.sender == admin, \"Timelock::queueTransaction: Call must come from admin.\");\n require(\n eta >= getBlockTimestamp().add(delay),\n \"Timelock::queueTransaction: Estimated execution block must satisfy delay.\"\n );\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = true;\n\n emit QueueTransaction(txHash, target, value, signature, data, eta);\n return txHash;\n }\n\n function cancelTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) public {\n require(msg.sender == admin, \"Timelock::cancelTransaction: Call must come from admin.\");\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = false;\n\n emit CancelTransaction(txHash, target, value, signature, data, eta);\n }\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) public payable returns (bytes memory) {\n require(msg.sender == admin, \"Timelock::executeTransaction: Call must come from admin.\");\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n require(queuedTransactions[txHash], \"Timelock::executeTransaction: Transaction hasn't been queued.\");\n require(getBlockTimestamp() >= eta, \"Timelock::executeTransaction: Transaction hasn't surpassed time lock.\");\n require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), \"Timelock::executeTransaction: Transaction is stale.\");\n\n queuedTransactions[txHash] = false;\n\n bytes memory callData;\n\n if (bytes(signature).length == 0) {\n callData = data;\n } else {\n callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);\n }\n\n // solium-disable-next-line security/no-call-value\n (bool success, bytes memory returnData) = target.call{ value: value }(callData);\n require(success, \"Timelock::executeTransaction: Transaction execution reverted.\");\n\n emit ExecuteTransaction(txHash, target, value, signature, data, eta);\n\n return returnData;\n }\n\n function getBlockTimestamp() internal view returns (uint256) {\n // solium-disable-next-line security/no-block-members\n return block.timestamp;\n }\n}\n" + }, + "contracts/compound/Unitroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ErrorReporter.sol\";\nimport \"./ComptrollerStorage.sol\";\nimport \"./Comptroller.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\n\n/**\n * @title Unitroller\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\n * CTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\n /**\n * @notice Event emitted when the admin rights are changed\n */\n event AdminRightsToggled(bool hasRights);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address payable _ionicAdmin) {\n admin = msg.sender;\n ionicAdmin = _ionicAdmin;\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Toggles admin rights.\n * @param hasRights Boolean indicating if the admin is to have rights.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\n }\n\n // Check that rights have not already been set to the desired value\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\n\n adminHasRights = hasRights;\n emit AdminRightsToggled(hasRights);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = newPendingAdmin;\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n function comptrollerImplementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"_deployMarket(uint8,bytes,bytes,uint256)\"))));\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n\n address currentImplementation = comptrollerImplementation();\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\n currentImplementation\n );\n\n _updateExtensions(latestComptrollerImplementation);\n\n if (currentImplementation != latestComptrollerImplementation) {\n // reinitialize\n _functionCall(address(this), abi.encodeWithSignature(\"_becomeImplementation()\"), \"!become impl\");\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function _updateExtensions(address currentComptroller) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(hasAdminRights(), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/external/aave/IAToken.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity >=0.8.0;\n\nimport \"./ILendingPool.sol\";\n\n/**\n * @title IAToken\n * @author Aave\n * @notice Defines the basic interface for an AToken.\n */\ninterface IAToken {\n /**\n * @notice Mints `amount` aTokens to `user`\n * @param caller The address performing the mint\n * @param onBehalfOf The address of the user that will receive the minted aTokens\n * @param amount The amount of tokens getting minted\n * @param index The next liquidity index of the reserve\n * @return `true` if the the previous balance of the user was 0\n */\n function mint(\n address caller,\n address onBehalfOf,\n uint256 amount,\n uint256 index\n ) external returns (bool);\n\n /**\n * @notice Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying`\n * @dev In some instances, the mint event could be emitted from a burn transaction\n * if the amount to burn is less than the interest that the user accrued\n * @param from The address from which the aTokens will be burned\n * @param receiverOfUnderlying The address that will receive the underlying\n * @param amount The amount being burned\n * @param index The next liquidity index of the reserve\n */\n function burn(\n address from,\n address receiverOfUnderlying,\n uint256 amount,\n uint256 index\n ) external;\n\n /**\n * @notice Mints aTokens to the reserve treasury\n * @param amount The amount of tokens getting minted\n * @param index The next liquidity index of the reserve\n */\n function mintToTreasury(uint256 amount, uint256 index) external;\n\n function getPreviousIndex(address user) external view returns (uint256);\n\n /**\n * @notice Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken\n * @param from The address getting liquidated, current owner of the aTokens\n * @param to The recipient\n * @param value The amount of tokens getting transferred\n */\n function transferOnLiquidation(\n address from,\n address to,\n uint256 value\n ) external;\n\n /**\n * @notice Transfers the underlying asset to `target`.\n * @dev Used by the Pool to transfer assets in borrow(), withdraw() and flashLoan()\n * @param target The recipient of the underlying\n * @param amount The amount getting transferred\n */\n function transferUnderlyingTo(address target, uint256 amount) external;\n\n /**\n * @notice Handles the underlying received by the aToken after the transfer has been completed.\n * @dev The default implementation is empty as with standard ERC20 tokens, nothing needs to be done after the\n * transfer is concluded. However in the future there may be aTokens that allow for example to stake the underlying\n * to receive LM rewards. In that case, `handleRepayment()` would perform the staking of the underlying asset.\n * @param user The user executing the repayment\n * @param onBehalfOf The address of the user who will get his debt reduced/removed\n * @param amount The amount getting repaid\n */\n function handleRepayment(\n address user,\n address onBehalfOf,\n uint256 amount\n ) external;\n\n /**\n * @notice Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)\n * @return The address of the underlying asset\n */\n function UNDERLYING_ASSET_ADDRESS() external view returns (address);\n\n function POOL() external view returns (ILendingPool);\n}\n" + }, + "contracts/external/aave/ILendingPool.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity >=0.8.0;\n\n/**\n * @title LendingPoolAddressesProvider contract\n * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles\n * - Acting also as factory of proxies and admin of those, so with right to change its implementations\n * - Owned by the Aave Governance\n * @author Aave\n **/\ninterface ILendingPoolAddressesProvider {\n event MarketIdSet(string newMarketId);\n event LendingPoolUpdated(address indexed newAddress);\n event ConfigurationAdminUpdated(address indexed newAddress);\n event EmergencyAdminUpdated(address indexed newAddress);\n event LendingPoolConfiguratorUpdated(address indexed newAddress);\n event LendingPoolCollateralManagerUpdated(address indexed newAddress);\n event PriceOracleUpdated(address indexed newAddress);\n event LendingRateOracleUpdated(address indexed newAddress);\n event ProxyCreated(bytes32 id, address indexed newAddress);\n event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy);\n\n function getMarketId() external view returns (string memory);\n\n function setMarketId(string calldata marketId) external;\n\n function setAddress(bytes32 id, address newAddress) external;\n\n function setAddressAsProxy(bytes32 id, address impl) external;\n\n function getAddress(bytes32 id) external view returns (address);\n\n function getLendingPool() external view returns (address);\n\n function setLendingPoolImpl(address pool) external;\n\n function getLendingPoolConfigurator() external view returns (address);\n\n function setLendingPoolConfiguratorImpl(address configurator) external;\n\n function getLendingPoolCollateralManager() external view returns (address);\n\n function setLendingPoolCollateralManager(address manager) external;\n\n function getPoolAdmin() external view returns (address);\n\n function setPoolAdmin(address admin) external;\n\n function getEmergencyAdmin() external view returns (address);\n\n function setEmergencyAdmin(address admin) external;\n\n function getPriceOracle() external view returns (address);\n\n function setPriceOracle(address priceOracle) external;\n\n function getLendingRateOracle() external view returns (address);\n\n function setLendingRateOracle(address lendingRateOracle) external;\n}\n\nlibrary DataTypes {\n // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.\n struct ReserveData {\n //stores the reserve configuration\n ReserveConfigurationMap configuration;\n //the liquidity index. Expressed in ray\n uint128 liquidityIndex;\n //variable borrow index. Expressed in ray\n uint128 variableBorrowIndex;\n //the current supply rate. Expressed in ray\n uint128 currentLiquidityRate;\n //the current variable borrow rate. Expressed in ray\n uint128 currentVariableBorrowRate;\n //the current stable borrow rate. Expressed in ray\n uint128 currentStableBorrowRate;\n uint40 lastUpdateTimestamp;\n //tokens addresses\n address aTokenAddress;\n address stableDebtTokenAddress;\n address variableDebtTokenAddress;\n //address of the interest rate strategy\n address interestRateStrategyAddress;\n //the id of the reserve. Represents the position in the list of the active reserves\n uint8 id;\n }\n\n struct ReserveConfigurationMap {\n //bit 0-15: LTV\n //bit 16-31: Liq. threshold\n //bit 32-47: Liq. bonus\n //bit 48-55: Decimals\n //bit 56: Reserve is active\n //bit 57: reserve is frozen\n //bit 58: borrowing is enabled\n //bit 59: stable rate borrowing enabled\n //bit 60-63: reserved\n //bit 64-79: reserve factor\n uint256 data;\n }\n\n struct UserConfigurationMap {\n uint256 data;\n }\n\n enum InterestRateMode {\n NONE,\n STABLE,\n VARIABLE\n }\n}\n\ninterface ILendingPool {\n /**\n * @dev Emitted on deposit()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address initiating the deposit\n * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens\n * @param amount The amount deposited\n * @param referral The referral code used\n **/\n event Deposit(\n address indexed reserve,\n address user,\n address indexed onBehalfOf,\n uint256 amount,\n uint16 indexed referral\n );\n\n /**\n * @dev Emitted on withdraw()\n * @param reserve The address of the underlyng asset being withdrawn\n * @param user The address initiating the withdrawal, owner of aTokens\n * @param to Address that will receive the underlying\n * @param amount The amount to be withdrawn\n **/\n event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);\n\n /**\n * @dev Emitted on borrow() and flashLoan() when debt needs to be opened\n * @param reserve The address of the underlying asset being borrowed\n * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just\n * initiator of the transaction on flashLoan()\n * @param onBehalfOf The address that will be getting the debt\n * @param amount The amount borrowed out\n * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable\n * @param borrowRate The numeric rate at which the user has borrowed\n * @param referral The referral code used\n **/\n event Borrow(\n address indexed reserve,\n address user,\n address indexed onBehalfOf,\n uint256 amount,\n uint256 borrowRateMode,\n uint256 borrowRate,\n uint16 indexed referral\n );\n\n /**\n * @dev Emitted on repay()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The beneficiary of the repayment, getting his debt reduced\n * @param repayer The address of the user initiating the repay(), providing the funds\n * @param amount The amount repaid\n **/\n event Repay(address indexed reserve, address indexed user, address indexed repayer, uint256 amount);\n\n /**\n * @dev Emitted on swapBorrowRateMode()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user swapping his rate mode\n * @param rateMode The rate mode that the user wants to swap to\n **/\n event Swap(address indexed reserve, address indexed user, uint256 rateMode);\n\n /**\n * @dev Emitted on setUserUseReserveAsCollateral()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user enabling the usage as collateral\n **/\n event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on setUserUseReserveAsCollateral()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user enabling the usage as collateral\n **/\n event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on rebalanceStableBorrowRate()\n * @param reserve The address of the underlying asset of the reserve\n * @param user The address of the user for which the rebalance has been executed\n **/\n event RebalanceStableBorrowRate(address indexed reserve, address indexed user);\n\n /**\n * @dev Emitted on flashLoan()\n * @param target The address of the flash loan receiver contract\n * @param initiator The address initiating the flash loan\n * @param asset The address of the asset being flash borrowed\n * @param amount The amount flash borrowed\n * @param premium The fee flash borrowed\n * @param referralCode The referral code used\n **/\n event FlashLoan(\n address indexed target,\n address indexed initiator,\n address indexed asset,\n uint256 amount,\n uint256 premium,\n uint16 referralCode\n );\n\n /**\n * @dev Emitted when the pause is triggered.\n */\n event Paused();\n\n /**\n * @dev Emitted when the pause is lifted.\n */\n event Unpaused();\n\n /**\n * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via\n * LendingPoolCollateral manager using a DELEGATECALL\n * This allows to have the events in the generated ABI for LendingPool.\n * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n * @param user The address of the borrower getting liquidated\n * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator\n * @param liquidator The address of the liquidator\n * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants\n * to receive the underlying collateral asset directly\n **/\n event LiquidationCall(\n address indexed collateralAsset,\n address indexed debtAsset,\n address indexed user,\n uint256 debtToCover,\n uint256 liquidatedCollateralAmount,\n address liquidator,\n bool receiveAToken\n );\n\n /**\n * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared\n * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,\n * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it\n * gets added to the LendingPool ABI\n * @param reserve The address of the underlying asset of the reserve\n * @param liquidityRate The new liquidity rate\n * @param stableBorrowRate The new stable borrow rate\n * @param variableBorrowRate The new variable borrow rate\n * @param liquidityIndex The new liquidity index\n * @param variableBorrowIndex The new variable borrow index\n **/\n event ReserveDataUpdated(\n address indexed reserve,\n uint256 liquidityRate,\n uint256 stableBorrowRate,\n uint256 variableBorrowRate,\n uint256 liquidityIndex,\n uint256 variableBorrowIndex\n );\n\n /**\n * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.\n * - E.g. User deposits 100 USDC and gets in return 100 aUSDC\n * @param asset The address of the underlying asset to deposit\n * @param amount The amount to be deposited\n * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user\n * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens\n * is a different wallet\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n **/\n function deposit(\n address asset,\n uint256 amount,\n address onBehalfOf,\n uint16 referralCode\n ) external;\n\n /**\n * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned\n * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC\n * @param asset The address of the underlying asset to withdraw\n * @param amount The underlying amount to be withdrawn\n * - Send the value type(uint256).max in order to withdraw the whole aToken balance\n * @param to Address that will receive the underlying, same as msg.sender if the user\n * wants to receive it on his own wallet, or a different address if the beneficiary is a\n * different wallet\n * @return The final amount withdrawn\n **/\n function withdraw(\n address asset,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n /**\n * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower\n * already deposited enough collateral, or he was given enough allowance by a credit delegator on the\n * corresponding debt token (StableDebtToken or VariableDebtToken)\n * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet\n * and 100 stable/variable debt tokens, depending on the `interestRateMode`\n * @param asset The address of the underlying asset to borrow\n * @param amount The amount to be borrowed\n * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself\n * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator\n * if he has been given credit delegation allowance\n **/\n function borrow(\n address asset,\n uint256 amount,\n uint256 interestRateMode,\n uint16 referralCode,\n address onBehalfOf\n ) external;\n\n /**\n * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned\n * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address\n * @param asset The address of the borrowed underlying asset previously borrowed\n * @param amount The amount to repay\n * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`\n * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable\n * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the\n * user calling the function if he wants to reduce/remove his own debt, or the address of any other\n * other borrower whose debt should be removed\n * @return The final amount repaid\n **/\n function repay(\n address asset,\n uint256 amount,\n uint256 rateMode,\n address onBehalfOf\n ) external returns (uint256);\n\n /**\n * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa\n * @param asset The address of the underlying asset borrowed\n * @param rateMode The rate mode that the user wants to swap to\n **/\n function swapBorrowRateMode(address asset, uint256 rateMode) external;\n\n /**\n * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.\n * - Users can be rebalanced if the following conditions are satisfied:\n * 1. Usage ratio is above 95%\n * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been\n * borrowed at a stable rate and depositors are not earning enough\n * @param asset The address of the underlying asset borrowed\n * @param user The address of the user to be rebalanced\n **/\n function rebalanceStableBorrowRate(address asset, address user) external;\n\n /**\n * @dev Allows depositors to enable/disable a specific deposited asset as collateral\n * @param asset The address of the underlying asset deposited\n * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise\n **/\n function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;\n\n /**\n * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1\n * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives\n * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk\n * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n * @param user The address of the borrower getting liquidated\n * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants\n * to receive the underlying collateral asset directly\n **/\n function liquidationCall(\n address collateralAsset,\n address debtAsset,\n address user,\n uint256 debtToCover,\n bool receiveAToken\n ) external;\n\n /**\n * @dev Allows smartcontracts to access the liquidity of the pool within one transaction,\n * as long as the amount taken plus a fee is returned.\n * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration.\n * For further details please visit https://developers.aave.com\n * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface\n * @param assets The addresses of the assets being flash-borrowed\n * @param amounts The amounts amounts being flash-borrowed\n * @param modes Types of the debt to open if the flash loan is not returned:\n * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver\n * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2\n * @param params Variadic packed params to pass to the receiver as extra information\n * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n * 0 if the action is executed directly by the user, without any middle-man\n **/\n function flashLoan(\n address receiverAddress,\n address[] calldata assets,\n uint256[] calldata amounts,\n uint256[] calldata modes,\n address onBehalfOf,\n bytes calldata params,\n uint16 referralCode\n ) external;\n\n /**\n * @dev Returns the user account data across all the reserves\n * @param user The address of the user\n * @return totalCollateralETH the total collateral in ETH of the user\n * @return totalDebtETH the total debt in ETH of the user\n * @return availableBorrowsETH the borrowing power left of the user\n * @return currentLiquidationThreshold the liquidation threshold of the user\n * @return ltv the loan to value of the user\n * @return healthFactor the current health factor of the user\n **/\n function getUserAccountData(address user)\n external\n view\n returns (\n uint256 totalCollateralETH,\n uint256 totalDebtETH,\n uint256 availableBorrowsETH,\n uint256 currentLiquidationThreshold,\n uint256 ltv,\n uint256 healthFactor\n );\n\n function initReserve(\n address reserve,\n address aTokenAddress,\n address stableDebtAddress,\n address variableDebtAddress,\n address interestRateStrategyAddress\n ) external;\n\n function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external;\n\n function setConfiguration(address reserve, uint256 configuration) external;\n\n /**\n * @dev Returns the configuration of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The configuration of the reserve\n **/\n function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory);\n\n /**\n * @dev Returns the configuration of the user across all the reserves\n * @param user The user address\n * @return The configuration of the user\n **/\n function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory);\n\n /**\n * @dev Returns the normalized income normalized income of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The reserve's normalized income\n */\n function getReserveNormalizedIncome(address asset) external view returns (uint256);\n\n /**\n * @dev Returns the normalized variable debt per unit of asset\n * @param asset The address of the underlying asset of the reserve\n * @return The reserve normalized variable debt\n */\n function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);\n\n /**\n * @dev Returns the state and configuration of the reserve\n * @param asset The address of the underlying asset of the reserve\n * @return The state of the reserve\n **/\n function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);\n\n function finalizeTransfer(\n address asset,\n address from,\n address to,\n uint256 amount,\n uint256 balanceFromAfter,\n uint256 balanceToBefore\n ) external;\n\n function getReservesList() external view returns (address[] memory);\n\n function getAddressesProvider() external view returns (ILendingPoolAddressesProvider);\n\n function setPause(bool val) external;\n\n function paused() external view returns (bool);\n}\n" + }, + "contracts/external/aerodrome/IAerodromeRouter.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.10;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20_Router {\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(address from, address to, uint256 amount) external returns (bool);\n}\n\ninterface IWETH is IERC20_Router {\n function deposit() external payable;\n\n function withdraw(uint256) external;\n}\n\ninterface IRouter_Aerodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n address factory;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientAmountAOptimal();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidAmountInForETHDeposit();\n error InvalidTokenInForETHDeposit();\n error InvalidPath();\n error InvalidRouteA();\n error InvalidRouteB();\n error OnlyWETH();\n error PoolDoesNotExist();\n error PoolFactoryDoesNotExist();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of FactoryRegistry.sol\n function factoryRegistry() external view returns (address);\n\n /// @notice Address of Protocol PoolFactory.sol\n function defaultFactory() external view returns (address);\n\n /// @notice Address of Voter.sol\n function voter() external view returns (address);\n\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\n function weth() external view returns (IWETH);\n\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\n function ETHER() external view returns (address);\n\n /// @dev Struct containing information necessary to zap in and out of pools\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable Stable or volatile pool\n /// @param factory factory of pool\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\n struct Zap {\n address tokenA;\n address tokenB;\n bool stable;\n address factory;\n uint256 amountOutMinA;\n uint256 amountOutMinB;\n uint256 amountAMin;\n uint256 amountBMin;\n }\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\n /// Reverts if _factory is not approved by the FactoryRegistry\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of factory which created the pool\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n // **** SWAP ****\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap one token for another without slippage protection\n /// @return amounts Array of amounts to swap per route\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function UNSAFE_swapExactTokensForTokens(\n uint256[] memory amounts,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n // **** SWAP (supporting fee-on-transfer tokens) ****\n\n /// @notice Swap one token for another supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable;\n\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the initial swap.\n /// Additional slippage may be required when adding liquidity as the\n /// price of the token may have changed.\n /// @param tokenIn Token you are zapping in from (i.e. input token).\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param zapInPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @param to Address you wish to mint liquidity to.\n /// @param stake Auto-stake liquidity in corresponding gauge.\n /// @return liquidity Amount of LP tokens created from zapping in.\n function zapIn(\n address tokenIn,\n uint256 amountInA,\n uint256 amountInB,\n Zap calldata zapInPool,\n Route[] calldata routesA,\n Route[] calldata routesB,\n address to,\n bool stake\n ) external payable returns (uint256 liquidity);\n\n /// @notice Zap out a pool (B, C) into A.\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the removal of liquidity.\n /// Additional slippage may be required on the swap as the\n /// price of the token may have changed.\n /// @param tokenOut Token you are zapping out to (i.e. output token).\n /// @param liquidity Amount of liquidity you wish to remove.\n /// @param zapOutPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n function zapOut(\n address tokenOut,\n uint256 liquidity,\n Zap calldata zapOutPool,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external;\n\n /// @notice Used to generate params required for zapping in.\n /// Zap in => remove liquidity then swap.\n /// Apply slippage to expected swap values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap in from.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\n function generateZapInParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountInA,\n uint256 amountInB,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used to generate params required for zapping out.\n /// Zap out => swap then add liquidity.\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap out of.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\n function generateZapOutParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\n /// @dev Returns stable liquidity ratio of B to (A + B).\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\n /// Therefore you should deposit more of token A than B.\n /// @param tokenA tokenA of stable pool you are zapping into.\n /// @param tokenB tokenB of stable pool you are zapping into.\n /// @param factory Factory that created stable pool.\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\n function quoteStableLiquidityRatio(\n address tokenA,\n address tokenB,\n address factory\n ) external view returns (uint256 ratio);\n}\n" + }, + "contracts/external/aerodrome/IAerodromeSwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.10;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via CL\ninterface ISwapRouter_Aerodrome {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/algebra/IAlgebraFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/**\n * @title The interface for the Algebra Factory\n * @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n * https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\n */\ninterface IAlgebraFactory {\n /**\n * @notice Emitted when the owner of the factory is changed\n * @param newOwner The owner after the owner was changed\n */\n event Owner(address indexed newOwner);\n\n /**\n * @notice Emitted when the vault address is changed\n * @param newVaultAddress The vault address after the address was changed\n */\n event VaultAddress(address indexed newVaultAddress);\n\n /**\n * @notice Emitted when a pool is created\n * @param token0 The first token of the pool by address sort order\n * @param token1 The second token of the pool by address sort order\n * @param pool The address of the created pool\n */\n event Pool(address indexed token0, address indexed token1, address pool);\n\n /**\n * @notice Emitted when the farming address is changed\n * @param newFarmingAddress The farming address after the address was changed\n */\n event FarmingAddress(address indexed newFarmingAddress);\n\n event FeeConfiguration(\n uint16 alpha1,\n uint16 alpha2,\n uint32 beta1,\n uint32 beta2,\n uint16 gamma1,\n uint16 gamma2,\n uint32 volumeBeta,\n uint16 volumeGamma,\n uint16 baseFee\n );\n\n /**\n * @notice Returns the current owner of the factory\n * @dev Can be changed by the current owner via setOwner\n * @return The address of the factory owner\n */\n function owner() external view returns (address);\n\n /**\n * @notice Returns the current poolDeployerAddress\n * @return The address of the poolDeployer\n */\n function poolDeployer() external view returns (address);\n\n /**\n * @dev Is retrieved from the pools to restrict calling\n * certain functions not by a tokenomics contract\n * @return The tokenomics contract address\n */\n function farmingAddress() external view returns (address);\n\n function vaultAddress() external view returns (address);\n\n /**\n * @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\n * @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\n * @param tokenA The contract address of either token0 or token1\n * @param tokenB The contract address of the other token\n * @return pool The pool address\n */\n function poolByPair(address tokenA, address tokenB) external view returns (address pool);\n\n /**\n * @notice Creates a pool for the given two tokens and fee\n * @param tokenA One of the two tokens in the desired pool\n * @param tokenB The other of the two tokens in the desired pool\n * @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\n * from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\n * are invalid.\n * @return pool The address of the newly created pool\n */\n function createPool(address tokenA, address tokenB) external returns (address pool);\n\n /**\n * @notice Updates the owner of the factory\n * @dev Must be called by the current owner\n * @param _owner The new owner of the factory\n */\n function setOwner(address _owner) external;\n\n /**\n * @dev updates tokenomics address on the factory\n * @param _farmingAddress The new tokenomics contract address\n */\n function setFarmingAddress(address _farmingAddress) external;\n\n /**\n * @dev updates vault address on the factory\n * @param _vaultAddress The new vault contract address\n */\n function setVaultAddress(address _vaultAddress) external;\n\n /**\n * @notice Changes initial fee configuration for new pools\n * @dev changes coefficients for sigmoids: α / (1 + e^( (β-x) / γ))\n * alpha1 + alpha2 + baseFee (max possible fee) must be <= type(uint16).max\n * gammas must be > 0\n * @param alpha1 max value of the first sigmoid\n * @param alpha2 max value of the second sigmoid\n * @param beta1 shift along the x-axis for the first sigmoid\n * @param beta2 shift along the x-axis for the second sigmoid\n * @param gamma1 horizontal stretch factor for the first sigmoid\n * @param gamma2 horizontal stretch factor for the second sigmoid\n * @param volumeBeta shift along the x-axis for the outer volume-sigmoid\n * @param volumeGamma horizontal stretch factor the outer volume-sigmoid\n * @param baseFee minimum possible fee\n */\n function setBaseFeeConfiguration(\n uint16 alpha1,\n uint16 alpha2,\n uint32 beta1,\n uint32 beta2,\n uint16 gamma1,\n uint16 gamma2,\n uint32 volumeBeta,\n uint16 volumeGamma,\n uint16 baseFee\n ) external;\n}\n" + }, + "contracts/external/algebra/IAlgebraPool.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./IAlgebraPoolState.sol\";\nimport \"./IAlgebraPoolActions.sol\";\n\n/// @title Pool state that can change\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraPool is IAlgebraPoolState, IAlgebraPoolActions {\n /**\n * @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\n * @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\n * the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\n * you must call it with secondsAgos = [3600, 0].\n * @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\n * log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\n * @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\n * @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\n * @return secondsPerLiquidityCumulatives Cumulative seconds per liquidity-in-range value as of each `secondsAgos`\n * from the current block timestamp\n * @return volatilityCumulatives Cumulative standard deviation as of each `secondsAgos`\n * @return volumePerAvgLiquiditys Cumulative swap volume per liquidity as of each `secondsAgos`\n */\n function getTimepoints(uint32[] calldata secondsAgos)\n external\n view\n returns (\n int56[] memory tickCumulatives,\n uint160[] memory secondsPerLiquidityCumulatives,\n uint112[] memory volatilityCumulatives,\n uint256[] memory volumePerAvgLiquiditys\n );\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function tickSpacing() external view returns (int24);\n}\n" + }, + "contracts/external/algebra/IAlgebraPoolActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraPoolActions {\n /**\n * @notice Sets the initial price for the pool\n * @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n * @param price the initial sqrt price of the pool as a Q64.96\n */\n function initialize(uint160 price) external;\n\n /**\n * @notice Adds liquidity for the given recipient/bottomTick/topTick position\n * @dev The caller of this method receives a callback in the form of IAlgebraMintCallback# AlgebraMintCallback\n * in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n * on bottomTick, topTick, the amount of liquidity, and the current price.\n * @param sender The address which will receive potential surplus of paid tokens\n * @param recipient The address for which the liquidity will be created\n * @param bottomTick The lower tick of the position in which to add liquidity\n * @param topTick The upper tick of the position in which to add liquidity\n * @param amount The desired amount of liquidity to mint\n * @param data Any data that should be passed through to the callback\n * @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n * @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n * @return liquidityActual The actual minted amount of liquidity\n */\n function mint(\n address sender,\n address recipient,\n int24 bottomTick,\n int24 topTick,\n uint128 amount,\n bytes calldata data\n )\n external\n returns (\n uint256 amount0,\n uint256 amount1,\n uint128 liquidityActual\n );\n\n /**\n * @notice Collects tokens owed to a position\n * @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n * Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n * amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n * actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n * @param recipient The address which should receive the fees collected\n * @param bottomTick The lower tick of the position for which to collect fees\n * @param topTick The upper tick of the position for which to collect fees\n * @param amount0Requested How much token0 should be withdrawn from the fees owed\n * @param amount1Requested How much token1 should be withdrawn from the fees owed\n * @return amount0 The amount of fees collected in token0\n * @return amount1 The amount of fees collected in token1\n */\n function collect(\n address recipient,\n int24 bottomTick,\n int24 topTick,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n\n /**\n * @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n * @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n * @dev Fees must be collected separately via a call to #collect\n * @param bottomTick The lower tick of the position for which to burn liquidity\n * @param topTick The upper tick of the position for which to burn liquidity\n * @param amount How much liquidity to burn\n * @return amount0 The amount of token0 sent to the recipient\n * @return amount1 The amount of token1 sent to the recipient\n */\n function burn(\n int24 bottomTick,\n int24 topTick,\n uint128 amount\n ) external returns (uint256 amount0, uint256 amount1);\n\n /**\n * @notice Swap token0 for token1, or token1 for token0\n * @dev The caller of this method receives a callback in the form of IAlgebraSwapCallback# AlgebraSwapCallback\n * @param recipient The address to receive the output of the swap\n * @param zeroToOne The direction of the swap, true for token0 to token1, false for token1 to token0\n * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n * @param limitSqrtPrice The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n * value after the swap. If one for zero, the price cannot be greater than this value after the swap\n * @param data Any data to be passed through to the callback. If using the Router it should contain\n * SwapRouter#SwapCallbackData\n * @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n * @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n */\n function swap(\n address recipient,\n bool zeroToOne,\n int256 amountSpecified,\n uint160 limitSqrtPrice,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /**\n * @notice Swap token0 for token1, or token1 for token0 (tokens that have fee on transfer)\n * @dev The caller of this method receives a callback in the form of I AlgebraSwapCallback# AlgebraSwapCallback\n * @param sender The address called this function (Comes from the Router)\n * @param recipient The address to receive the output of the swap\n * @param zeroToOne The direction of the swap, true for token0 to token1, false for token1 to token0\n * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n * @param limitSqrtPrice The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n * value after the swap. If one for zero, the price cannot be greater than this value after the swap\n * @param data Any data to be passed through to the callback. If using the Router it should contain\n * SwapRouter#SwapCallbackData\n * @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n * @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n */\n function swapSupportingFeeOnInputTokens(\n address sender,\n address recipient,\n bool zeroToOne,\n int256 amountSpecified,\n uint160 limitSqrtPrice,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /**\n * @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n * @dev The caller of this method receives a callback in the form of IAlgebraFlashCallback# AlgebraFlashCallback\n * @dev All excess tokens paid in the callback are distributed to liquidity providers as an additional fee. So this method can be used\n * to donate underlying tokens to currently in-range liquidity providers by calling with 0 amount{0,1} and sending\n * the donation amount(s) from the callback\n * @param recipient The address which will receive the token0 and token1 amounts\n * @param amount0 The amount of token0 to send\n * @param amount1 The amount of token1 to send\n * @param data Any data to be passed through to the callback\n */\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/algebra/IAlgebraPoolState.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraPoolState {\n /**\n * @notice The globalState structure in the pool stores many values but requires only one slot\n * and is exposed as a single method to save gas when accessed externally.\n * @return price The current price of the pool as a sqrt(token1/token0) Q64.96 value;\n * Returns tick The current tick of the pool, i.e. according to the last tick transition that was run;\n * Returns This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(price) if the price is on a tick\n * boundary;\n * Returns fee The last pool fee value in hundredths of a bip, i.e. 1e-6;\n * Returns timepointIndex The index of the last written timepoint;\n * Returns communityFeeToken0 The community fee percentage of the swap fee in thousandths (1e-3) for token0;\n * Returns communityFeeToken1 The community fee percentage of the swap fee in thousandths (1e-3) for token1;\n * Returns unlocked Whether the pool is currently locked to reentrancy;\n */\n function globalState()\n external\n view\n returns (\n uint160 price,\n int24 tick,\n uint16 fee,\n uint16 timepointIndex,\n uint8 communityFeeToken0,\n uint8 communityFeeToken1,\n bool unlocked\n );\n\n /**\n * @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\n * @dev This value can overflow the uint256\n */\n function totalFeeGrowth0Token() external view returns (uint256);\n\n /**\n * @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\n * @dev This value can overflow the uint256\n */\n function totalFeeGrowth1Token() external view returns (uint256);\n\n /**\n * @notice The currently in range liquidity available to the pool\n * @dev This value has no relationship to the total liquidity across all ticks.\n * Returned value cannot exceed type(uint128).max\n */\n function liquidity() external view returns (uint128);\n\n /**\n * @notice Look up information about a specific tick in the pool\n * @dev This is a public structure, so the `return` natspec tags are omitted.\n * @param tick The tick to look up\n * @return liquidityTotal the total amount of position liquidity that uses the pool either as tick lower or\n * tick upper;\n * Returns liquidityDelta how much liquidity changes when the pool price crosses the tick;\n * Returns outerFeeGrowth0Token the fee growth on the other side of the tick from the current tick in token0;\n * Returns outerFeeGrowth1Token the fee growth on the other side of the tick from the current tick in token1;\n * Returns outerTickCumulative the cumulative tick value on the other side of the tick from the current tick;\n * Returns outerSecondsPerLiquidity the seconds spent per liquidity on the other side of the tick from the current tick;\n * Returns outerSecondsSpent the seconds spent on the other side of the tick from the current tick;\n * Returns initialized Set to true if the tick is initialized, i.e. liquidityTotal is greater than 0\n * otherwise equal to false. Outside values can only be used if the tick is initialized.\n * In addition, these values are only relative and must be used only in comparison to previous snapshots for\n * a specific position.\n */\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityTotal,\n int128 liquidityDelta,\n uint256 outerFeeGrowth0Token,\n uint256 outerFeeGrowth1Token,\n int56 outerTickCumulative,\n uint160 outerSecondsPerLiquidity,\n uint32 outerSecondsSpent,\n bool initialized\n );\n\n /** @notice Returns 256 packed tick initialized boolean values. See TickTable for more information */\n function tickTable(int16 wordPosition) external view returns (uint256);\n\n /**\n * @notice Returns the information about a position by the position's key\n * @dev This is a public mapping of structures, so the `return` natspec tags are omitted.\n * @param key The position's key is a hash of a preimage composed by the owner, bottomTick and topTick\n * @return liquidityAmount The amount of liquidity in the position;\n * Returns lastLiquidityAddTimestamp Timestamp of last adding of liquidity;\n * Returns innerFeeGrowth0Token Fee growth of token0 inside the tick range as of the last mint/burn/poke;\n * Returns innerFeeGrowth1Token Fee growth of token1 inside the tick range as of the last mint/burn/poke;\n * Returns fees0 The computed amount of token0 owed to the position as of the last mint/burn/poke;\n * Returns fees1 The computed amount of token1 owed to the position as of the last mint/burn/poke\n */\n function positions(bytes32 key)\n external\n view\n returns (\n uint128 liquidityAmount,\n uint32 lastLiquidityAddTimestamp,\n uint256 innerFeeGrowth0Token,\n uint256 innerFeeGrowth1Token,\n uint128 fees0,\n uint128 fees1\n );\n\n /**\n * @notice Returns data about a specific timepoint index\n * @param index The element of the timepoints array to fetch\n * @dev You most likely want to use #getTimepoints() instead of this method to get an timepoint as of some amount of time\n * ago, rather than at a specific index in the array.\n * This is a public mapping of structures, so the `return` natspec tags are omitted.\n * @return initialized whether the timepoint has been initialized and the values are safe to use;\n * Returns blockTimestamp The timestamp of the timepoint;\n * Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the timepoint timestamp;\n * Returns secondsPerLiquidityCumulative the seconds per in range liquidity for the life of the pool as of the timepoint timestamp;\n * Returns volatilityCumulative Cumulative standard deviation for the life of the pool as of the timepoint timestamp;\n * Returns averageTick Time-weighted average tick;\n * Returns volumePerLiquidityCumulative Cumulative swap volume per liquidity for the life of the pool as of the timepoint timestamp;\n */\n function timepoints(uint256 index)\n external\n view\n returns (\n bool initialized,\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 secondsPerLiquidityCumulative,\n uint88 volatilityCumulative,\n int24 averageTick,\n uint144 volumePerLiquidityCumulative\n );\n\n /**\n * @notice Returns the information about active incentive\n * @dev if there is no active incentive at the moment, virtualPool,endTimestamp,startTimestamp would be equal to 0\n * @return virtualPool The address of a virtual pool associated with the current active incentive\n */\n function activeIncentive() external view returns (address virtualPool);\n\n /**\n * @notice Returns the lock time for added liquidity\n */\n function liquidityCooldown() external view returns (uint32 cooldownInSeconds);\n}\n" + }, + "contracts/external/algebra/IAlgebraSwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IAlgebraPoolActions#swap\n/// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraSwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call\n function algebraSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/algebra/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport \"./IAlgebraSwapCallback.sol\";\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Algebra\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-periphery\ninterface IAlgebraSwapRouter is IAlgebraSwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Unlike standard swaps, handles transferring from user before the actual swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingleSupportingFeeOnTransferTokens(ExactInputSingleParams calldata params)\n external\n returns (uint256 amountOut);\n}\n" + }, + "contracts/external/alpha/Bank.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface Bank is IERC20Upgradeable {\n /// @dev Return the total ETH entitled to the token holders. Be careful of unaccrued interests.\n function totalETH() external view returns (uint256);\n\n /// @dev Add more ETH to the bank. Hope to get some good returns.\n function deposit() external payable;\n\n /// @dev Withdraw ETH from the bank by burning the share tokens.\n function withdraw(uint256 share) external;\n}\n" + }, + "contracts/external/alpha/ISafeBox.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ISafeBox is IERC20Upgradeable {\n function cToken() external view returns (address);\n\n function uToken() external view returns (address);\n\n function deposit(uint256 amount) external;\n\n function withdraw(uint256 amount) external;\n}\n" + }, + "contracts/external/alpha/ISafeBoxETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ISafeBoxETH is IERC20Upgradeable {\n function cToken() external view returns (address);\n\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n}\n" + }, + "contracts/external/angle/IGenericLender.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\n/// @title IGenericLender\n/// @author Yearn with slight modifications from Angle Core Team\n/// @dev Interface for the `GenericLender` contract, the base interface for contracts interacting\n/// with lending and yield farming platforms\ninterface IGenericLender {\n /// @notice Name of the lender on which funds are invested\n function lenderName() external view returns (string memory);\n\n /// @notice Returns an estimation of the current Annual Percentage Rate on the lender\n function apr() external view returns (uint256);\n\n /// @notice Returns an estimation of the current Annual Percentage Rate weighted by the assets under\n /// management of the lender\n function weightedApr() external view returns (uint256);\n\n /// @notice Withdraws a given amount from lender\n /// @param amount The amount the caller wants to withdraw\n /// @return Amount actually withdrawn\n function withdraw(uint256 amount) external returns (uint256);\n\n /// @notice Withdraws as much as possible from the lending platform\n /// @return Whether everything was withdrawn or not\n function withdrawAll() external returns (bool);\n\n /// @notice Returns an estimation of the current Annual Percentage Rate after a new deposit\n /// of `amount`\n /// @param amount Amount to add to the lending platform, and that we want to take into account\n /// in the apr computation\n function aprAfterDeposit(uint256 amount) external view returns (uint256);\n\n function aprAfterWithdraw(uint256 amount) external view returns (uint256);\n\n /// @notice Removes tokens from this Strategy that are not the type of tokens\n /// managed by this Strategy. This may be used in case of accidentally\n /// sending the wrong kind of token to this Strategy.\n ///\n /// @param _token The token to transfer out of this poolManager.\n /// @param to Address to send the tokens to.\n function sweep(address _token, address to) external;\n}\n" + }, + "contracts/external/api3/IProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IProxy {\n function read() external view returns (int224 value, uint32 timestamp);\n\n function api3ServerV1() external view returns (address);\n}\n" + }, + "contracts/external/balancer/BalancerErrors.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.8.0;\n\n// solhint-disable\n\n/**\n * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are\n * supported.\n * Uses the default 'BAL' prefix for the error code\n */\nfunction _require(bool condition, uint256 errorCode) pure {\n if (!condition) _revert(errorCode);\n}\n\n/**\n * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are\n * supported.\n */\nfunction _require(\n bool condition,\n uint256 errorCode,\n bytes3 prefix\n) pure {\n if (!condition) _revert(errorCode, prefix);\n}\n\n/**\n * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.\n * Uses the default 'BAL' prefix for the error code\n */\nfunction _revert(uint256 errorCode) pure {\n _revert(errorCode, 0x42414c); // This is the raw byte representation of \"BAL\"\n}\n\n/**\n * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.\n */\nfunction _revert(uint256 errorCode, bytes3 prefix) pure {\n uint256 prefixUint = uint256(uint24(prefix));\n // We're going to dynamically create a revert string based on the error code, with the following format:\n // 'BAL#{errorCode}'\n // where the code is left-padded with zeroes to three digits (so they range from 000 to 999).\n //\n // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a\n // number (8 to 16 bits) than the individual string characters.\n //\n // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a\n // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a\n // safe place to rely on it without worrying about how its usage might affect e.g. memory contents.\n assembly {\n // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999\n // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for\n // the '0' character.\n\n let units := add(mod(errorCode, 10), 0x30)\n\n errorCode := div(errorCode, 10)\n let tenths := add(mod(errorCode, 10), 0x30)\n\n errorCode := div(errorCode, 10)\n let hundreds := add(mod(errorCode, 10), 0x30)\n\n // With the individual characters, we can now construct the full string.\n // We first append the '#' character (0x23) to the prefix. In the case of 'BAL', it results in 0x42414c23 ('BAL#')\n // Then, we shift this by 24 (to provide space for the 3 bytes of the error code), and add the\n // characters to it, each shifted by a multiple of 8.\n // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits\n // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte\n // array).\n let formattedPrefix := shl(24, add(0x23, shl(8, prefixUint)))\n\n let revertReason := shl(200, add(formattedPrefix, add(add(units, shl(8, tenths)), shl(16, hundreds))))\n\n // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded\n // message will have the following layout:\n // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ]\n\n // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We\n // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten.\n mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away).\n mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)\n // The string length is fixed: 7 characters.\n mstore(0x24, 7)\n // Finally, the string itself is stored.\n mstore(0x44, revertReason)\n\n // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of\n // the encoded message is therefore 4 + 32 + 32 + 32 = 100.\n revert(0, 100)\n }\n}\n\nlibrary Errors {\n // Math\n uint256 internal constant ADD_OVERFLOW = 0;\n uint256 internal constant SUB_OVERFLOW = 1;\n uint256 internal constant SUB_UNDERFLOW = 2;\n uint256 internal constant MUL_OVERFLOW = 3;\n uint256 internal constant ZERO_DIVISION = 4;\n uint256 internal constant DIV_INTERNAL = 5;\n uint256 internal constant X_OUT_OF_BOUNDS = 6;\n uint256 internal constant Y_OUT_OF_BOUNDS = 7;\n uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8;\n uint256 internal constant INVALID_EXPONENT = 9;\n\n // Input\n uint256 internal constant OUT_OF_BOUNDS = 100;\n uint256 internal constant UNSORTED_ARRAY = 101;\n uint256 internal constant UNSORTED_TOKENS = 102;\n uint256 internal constant INPUT_LENGTH_MISMATCH = 103;\n uint256 internal constant ZERO_TOKEN = 104;\n\n // Shared pools\n uint256 internal constant MIN_TOKENS = 200;\n uint256 internal constant MAX_TOKENS = 201;\n uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202;\n uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203;\n uint256 internal constant MINIMUM_BPT = 204;\n uint256 internal constant CALLER_NOT_VAULT = 205;\n uint256 internal constant UNINITIALIZED = 206;\n uint256 internal constant BPT_IN_MAX_AMOUNT = 207;\n uint256 internal constant BPT_OUT_MIN_AMOUNT = 208;\n uint256 internal constant EXPIRED_PERMIT = 209;\n uint256 internal constant NOT_TWO_TOKENS = 210;\n uint256 internal constant DISABLED = 211;\n\n // Pools\n uint256 internal constant MIN_AMP = 300;\n uint256 internal constant MAX_AMP = 301;\n uint256 internal constant MIN_WEIGHT = 302;\n uint256 internal constant MAX_STABLE_TOKENS = 303;\n uint256 internal constant MAX_IN_RATIO = 304;\n uint256 internal constant MAX_OUT_RATIO = 305;\n uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306;\n uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307;\n uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308;\n uint256 internal constant INVALID_TOKEN = 309;\n uint256 internal constant UNHANDLED_JOIN_KIND = 310;\n uint256 internal constant ZERO_INVARIANT = 311;\n uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312;\n uint256 internal constant ORACLE_NOT_INITIALIZED = 313;\n uint256 internal constant ORACLE_QUERY_TOO_OLD = 314;\n uint256 internal constant ORACLE_INVALID_INDEX = 315;\n uint256 internal constant ORACLE_BAD_SECS = 316;\n uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317;\n uint256 internal constant AMP_ONGOING_UPDATE = 318;\n uint256 internal constant AMP_RATE_TOO_HIGH = 319;\n uint256 internal constant AMP_NO_ONGOING_UPDATE = 320;\n uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321;\n uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322;\n uint256 internal constant RELAYER_NOT_CONTRACT = 323;\n uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324;\n uint256 internal constant REBALANCING_RELAYER_REENTERED = 325;\n uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326;\n uint256 internal constant SWAPS_DISABLED = 327;\n uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328;\n uint256 internal constant PRICE_RATE_OVERFLOW = 329;\n uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330;\n uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331;\n uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332;\n uint256 internal constant UPPER_TARGET_TOO_HIGH = 333;\n uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334;\n uint256 internal constant OUT_OF_TARGET_RANGE = 335;\n uint256 internal constant UNHANDLED_EXIT_KIND = 336;\n uint256 internal constant UNAUTHORIZED_EXIT = 337;\n uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338;\n uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339;\n uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340;\n uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341;\n uint256 internal constant INVALID_INITIALIZATION = 342;\n uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343;\n uint256 internal constant FEATURE_DISABLED = 344;\n uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345;\n uint256 internal constant SET_SWAP_FEE_DURING_FEE_CHANGE = 346;\n uint256 internal constant SET_SWAP_FEE_PENDING_FEE_CHANGE = 347;\n uint256 internal constant CHANGE_TOKENS_DURING_WEIGHT_CHANGE = 348;\n uint256 internal constant CHANGE_TOKENS_PENDING_WEIGHT_CHANGE = 349;\n uint256 internal constant MAX_WEIGHT = 350;\n uint256 internal constant UNAUTHORIZED_JOIN = 351;\n uint256 internal constant MAX_MANAGEMENT_AUM_FEE_PERCENTAGE = 352;\n uint256 internal constant FRACTIONAL_TARGET = 353;\n\n // Lib\n uint256 internal constant REENTRANCY = 400;\n uint256 internal constant SENDER_NOT_ALLOWED = 401;\n uint256 internal constant PAUSED = 402;\n uint256 internal constant PAUSE_WINDOW_EXPIRED = 403;\n uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404;\n uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405;\n uint256 internal constant INSUFFICIENT_BALANCE = 406;\n uint256 internal constant INSUFFICIENT_ALLOWANCE = 407;\n uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408;\n uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409;\n uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410;\n uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411;\n uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412;\n uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413;\n uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414;\n uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415;\n uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416;\n uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417;\n uint256 internal constant SAFE_ERC20_CALL_FAILED = 418;\n uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419;\n uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420;\n uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421;\n uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422;\n uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423;\n uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424;\n uint256 internal constant BUFFER_PERIOD_EXPIRED = 425;\n uint256 internal constant CALLER_IS_NOT_OWNER = 426;\n uint256 internal constant NEW_OWNER_IS_ZERO = 427;\n uint256 internal constant CODE_DEPLOYMENT_FAILED = 428;\n uint256 internal constant CALL_TO_NON_CONTRACT = 429;\n uint256 internal constant LOW_LEVEL_CALL_FAILED = 430;\n uint256 internal constant NOT_PAUSED = 431;\n uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432;\n uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433;\n uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434;\n uint256 internal constant INVALID_OPERATION = 435;\n uint256 internal constant CODEC_OVERFLOW = 436;\n uint256 internal constant IN_RECOVERY_MODE = 437;\n uint256 internal constant NOT_IN_RECOVERY_MODE = 438;\n uint256 internal constant INDUCED_FAILURE = 439;\n uint256 internal constant EXPIRED_SIGNATURE = 440;\n uint256 internal constant MALFORMED_SIGNATURE = 441;\n uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_UINT64 = 442;\n uint256 internal constant UNHANDLED_FEE_TYPE = 443;\n\n // Vault\n uint256 internal constant INVALID_POOL_ID = 500;\n uint256 internal constant CALLER_NOT_POOL = 501;\n uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502;\n uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503;\n uint256 internal constant INVALID_SIGNATURE = 504;\n uint256 internal constant EXIT_BELOW_MIN = 505;\n uint256 internal constant JOIN_ABOVE_MAX = 506;\n uint256 internal constant SWAP_LIMIT = 507;\n uint256 internal constant SWAP_DEADLINE = 508;\n uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509;\n uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510;\n uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511;\n uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512;\n uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513;\n uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514;\n uint256 internal constant INVALID_POST_LOAN_BALANCE = 515;\n uint256 internal constant INSUFFICIENT_ETH = 516;\n uint256 internal constant UNALLOCATED_ETH = 517;\n uint256 internal constant ETH_TRANSFER = 518;\n uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519;\n uint256 internal constant TOKENS_MISMATCH = 520;\n uint256 internal constant TOKEN_NOT_REGISTERED = 521;\n uint256 internal constant TOKEN_ALREADY_REGISTERED = 522;\n uint256 internal constant TOKENS_ALREADY_SET = 523;\n uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524;\n uint256 internal constant NONZERO_TOKEN_BALANCE = 525;\n uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526;\n uint256 internal constant POOL_NO_TOKENS = 527;\n uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528;\n\n // Fees\n uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600;\n uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601;\n uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602;\n uint256 internal constant AUM_FEE_PERCENTAGE_TOO_HIGH = 603;\n\n // Misc\n uint256 internal constant UNIMPLEMENTED = 998;\n uint256 internal constant SHOULD_NOT_HAPPEN = 999;\n}\n" + }, + "contracts/external/balancer/BConst.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\ncontract BConst {\n uint256 public constant BONE = 10**18;\n\n uint256 public constant MIN_BOUND_TOKENS = 2;\n uint256 public constant MAX_BOUND_TOKENS = 8;\n\n uint256 public constant MIN_FEE = BONE / 10**6;\n uint256 public constant MAX_FEE = BONE / 10;\n uint256 public constant EXIT_FEE = 0;\n\n uint256 public constant MIN_WEIGHT = BONE;\n uint256 public constant MAX_WEIGHT = BONE * 50;\n uint256 public constant MAX_TOTAL_WEIGHT = BONE * 50;\n uint256 public constant MIN_BALANCE = BONE / 10**12;\n\n uint256 public constant INIT_POOL_SUPPLY = BONE * 100;\n\n uint256 public constant MIN_BPOW_BASE = 1 wei;\n uint256 public constant MAX_BPOW_BASE = (2 * BONE) - 1 wei;\n uint256 public constant BPOW_PRECISION = BONE / 10**10;\n\n uint256 public constant MAX_IN_RATIO = BONE / 2;\n uint256 public constant MAX_OUT_RATIO = (BONE / 3) + 1 wei;\n}\n" + }, + "contracts/external/balancer/BNum.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./BConst.sol\";\n\ncontract BNum is BConst {\n function btoi(uint256 a) internal pure returns (uint256) {\n return a / BONE;\n }\n\n function bfloor(uint256 a) internal pure returns (uint256) {\n return btoi(a) * BONE;\n }\n\n function badd(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"ERR_ADD_OVERFLOW\");\n return c;\n }\n\n function bsub(uint256 a, uint256 b) internal pure returns (uint256) {\n (uint256 c, bool flag) = bsubSign(a, b);\n require(!flag, \"ERR_SUB_UNDERFLOW\");\n return c;\n }\n\n function bsubSign(uint256 a, uint256 b) internal pure returns (uint256, bool) {\n if (a >= b) {\n return (a - b, false);\n } else {\n return (b - a, true);\n }\n }\n\n function bmul(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c0 = a * b;\n require(a == 0 || c0 / a == b, \"ERR_MUL_OVERFLOW\");\n uint256 c1 = c0 + (BONE / 2);\n require(c1 >= c0, \"ERR_MUL_OVERFLOW\");\n uint256 c2 = c1 / BONE;\n return c2;\n }\n\n function bdiv(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0, \"ERR_DIV_ZERO\");\n uint256 c0 = a * BONE;\n require(a == 0 || c0 / a == BONE, \"ERR_DIV_INTERNAL\"); // bmul overflow\n uint256 c1 = c0 + (b / 2);\n require(c1 >= c0, \"ERR_DIV_INTERNAL\"); // badd require\n uint256 c2 = c1 / b;\n return c2;\n }\n\n // DSMath.wpow\n function bpowi(uint256 a, uint256 n) internal pure returns (uint256) {\n uint256 z = n % 2 != 0 ? a : BONE;\n\n for (n /= 2; n != 0; n /= 2) {\n a = bmul(a, a);\n\n if (n % 2 != 0) {\n z = bmul(z, a);\n }\n }\n return z;\n }\n\n // Compute b^(e.w) by splitting it into (b^e)*(b^0.w).\n // Use `bpowi` for `b^e` and `bpowK` for k iterations\n // of approximation of b^0.w\n function bpow(uint256 base, uint256 exp) internal pure returns (uint256) {\n require(base >= MIN_BPOW_BASE, \"ERR_BPOW_BASE_TOO_LOW\");\n require(base <= MAX_BPOW_BASE, \"ERR_BPOW_BASE_TOO_HIGH\");\n\n uint256 whole = bfloor(exp);\n uint256 remain = bsub(exp, whole);\n\n uint256 wholePow = bpowi(base, btoi(whole));\n\n if (remain == 0) {\n return wholePow;\n }\n\n uint256 partialResult = bpowApprox(base, remain, BPOW_PRECISION);\n return bmul(wholePow, partialResult);\n }\n\n function bpowApprox(\n uint256 base,\n uint256 exp,\n uint256 precision\n ) internal pure returns (uint256) {\n // term 0:\n uint256 a = exp;\n (uint256 x, bool xneg) = bsubSign(base, BONE);\n uint256 term = BONE;\n uint256 sum = term;\n bool negative = false;\n\n // term(k) = numer / denom\n // = (product(a - i - 1, i=1-->k) * x^k) / (k!)\n // each iteration, multiply previous term by (a-(k-1)) * x / k\n // continue until term is less than precision\n for (uint256 i = 1; term >= precision; i++) {\n uint256 bigK = i * BONE;\n (uint256 c, bool cneg) = bsubSign(a, bsub(bigK, BONE));\n term = bmul(term, bmul(c, x));\n term = bdiv(term, bigK);\n if (term == 0) break;\n\n if (xneg) negative = !negative;\n if (cneg) negative = !negative;\n if (negative) {\n sum = bsub(sum, term);\n } else {\n sum = badd(sum, term);\n }\n }\n\n return sum;\n }\n}\n" + }, + "contracts/external/balancer/IBalancerLinearPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\n\ninterface IBalancerLinearPool {\n function getActualSupply() external view returns (uint256);\n\n function getBptIndex() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function getRate() external view returns (uint256);\n\n function getScalingFactros() external view returns (uint256[] memory);\n\n function getTokenRate(address token) external view returns (uint256);\n\n function getMainToken() external view returns (address);\n}\n" + }, + "contracts/external/balancer/IBalancerPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\n\ninterface IBalancerPool {\n function getFinalTokens() external view returns (address[] memory);\n\n function getNormalizedWeight(address token) external view returns (uint256);\n\n function getNormalizedWeights() external view returns (uint256[] memory);\n\n function getSwapFee() external view returns (uint256);\n\n function getNumTokens() external view returns (uint256);\n\n function getBalance(address token) external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;\n\n function swapExactAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n address tokenOut,\n uint256 minAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter);\n\n function swapExactAmountOut(\n address tokenIn,\n uint256 maxAmountIn,\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountIn, uint256 spotPriceAfter);\n\n function joinswapExternAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n uint256 minPoolAmountOut\n ) external returns (uint256 poolAmountOut);\n\n function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;\n\n function exitswapExternAmountOut(\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPoolAmountIn\n ) external returns (uint256 poolAmountIn);\n}\n" + }, + "contracts/external/balancer/IBalancerStablePool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\nimport { IRateProvider } from \"./IRateProvider.sol\";\n\ninterface IBalancerStablePool {\n function getActualSupply() external view returns (uint256);\n\n function getBptIndex() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function getRate() external view returns (uint256);\n\n function getRateProviders() external view returns (IRateProvider[] memory);\n\n function getScalingFactros() external view returns (uint256[] memory);\n\n function getTokenRate(address token) external view returns (uint256);\n\n function updateTokenRateCache(address token) external;\n}\n" + }, + "contracts/external/balancer/IBalancerVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IAsset {}\n\nenum UserBalanceOpKind {\n DEPOSIT_INTERNAL,\n WITHDRAW_INTERNAL,\n TRANSFER_INTERNAL,\n TRANSFER_EXTERNAL\n}\n\nenum SwapKind {\n GIVEN_IN,\n GIVEN_OUT\n}\n\nenum ExitKind {\n EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,\n EXACT_BPT_IN_FOR_TOKENS_OUT,\n BPT_IN_FOR_EXACT_TOKENS_OUT,\n MANAGEMENT_FEE_TOKENS_OUT\n}\n\nstruct UserBalanceOp {\n UserBalanceOpKind kind;\n IAsset asset;\n uint256 amount;\n address sender;\n address payable recipient;\n}\nstruct FundManagement {\n address sender;\n bool fromInternalBalance;\n address payable recipient;\n bool toInternalBalance;\n}\n\nstruct SingleSwap {\n bytes32 poolId;\n SwapKind kind;\n IAsset assetIn;\n IAsset assetOut;\n uint256 amount;\n bytes userData;\n}\n\nstruct ExitPoolRequest {\n IERC20Upgradeable[] assets;\n uint256[] minAmountsOut;\n bytes userData;\n bool toInternalBalance;\n}\n\ninterface IBalancerVault {\n function swap(\n SingleSwap memory singleSwap,\n FundManagement memory funds,\n uint256 limit,\n uint256 deadline\n ) external returns (uint256 amountCalculated);\n\n function manageUserBalance(UserBalanceOp[] memory ops) external payable;\n\n function getPoolTokens(bytes32 poolId)\n external\n view\n returns (\n IERC20Upgradeable[] memory tokens,\n uint256[] memory balances,\n uint256 lastChangeBlock\n );\n\n function exitPool(\n bytes32 poolId,\n address sender,\n address payable recipient,\n ExitPoolRequest memory request\n ) external;\n}\n" + }, + "contracts/external/balancer/IRateProvider.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\ninterface IRateProvider {\n /**\n * @dev Returns an 18 decimal fixed point number that is the exchange rate of the token to some other underlying\n * token. The meaning of this rate depends on the context.\n */\n function getRate() external view returns (uint256);\n}\n" + }, + "contracts/external/bomb/IXBomb.sol": { + "content": "pragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IXBomb is IERC20Upgradeable {\n function reward() external view returns (IERC20Upgradeable);\n\n function leave(uint256 _share) external;\n\n function enter(uint256 _amount) external;\n\n function getExchangeRate() external view returns (uint256);\n\n function toREWARD(uint256 stakedAmount) external view returns (uint256 rewardAmount);\n\n function toSTAKED(uint256 rewardAmount) external view returns (uint256 stakedAmount);\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n}\n" + }, + "contracts/external/chainlink/AggregatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" + }, + "contracts/external/chainlink/AggregatorV2V3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" + }, + "contracts/external/chainlink/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "contracts/external/chainlink/Denominations.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nlibrary Denominations {\n address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n address public constant BTC = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;\n\n // Fiat currencies follow https://en.wikipedia.org/wiki/ISO_4217\n address public constant USD = address(840);\n address public constant GBP = address(826);\n address public constant EUR = address(978);\n address public constant JPY = address(392);\n address public constant KRW = address(410);\n address public constant CNY = address(156);\n address public constant AUD = address(36);\n address public constant CAD = address(124);\n address public constant CHF = address(756);\n address public constant ARS = address(32);\n address public constant PHP = address(608);\n address public constant NZD = address(554);\n address public constant SGD = address(702);\n address public constant NGN = address(566);\n address public constant ZAR = address(710);\n address public constant RUB = address(643);\n address public constant INR = address(356);\n address public constant BRL = address(986);\n}\n" + }, + "contracts/external/chainlink/FeedRegistryInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"./AggregatorV2V3Interface.sol\";\n\ninterface FeedRegistryInterface {\n struct Phase {\n uint16 phaseId;\n uint80 startingAggregatorRoundId;\n uint80 endingAggregatorRoundId;\n }\n\n event FeedProposed(\n address indexed asset,\n address indexed denomination,\n address indexed proposedAggregator,\n address currentAggregator,\n address sender\n );\n event FeedConfirmed(\n address indexed asset,\n address indexed denomination,\n address indexed latestAggregator,\n address previousAggregator,\n uint16 nextPhaseId,\n address sender\n );\n\n // V3 AggregatorV3Interface\n\n function decimals(address base, address quote) external view returns (uint8);\n\n function description(address base, address quote) external view returns (string memory);\n\n function version(address base, address quote) external view returns (uint256);\n\n function latestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function getRoundData(\n address base,\n address quote,\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // V2 AggregatorInterface\n\n function latestAnswer(address base, address quote) external view returns (int256 answer);\n\n function latestTimestamp(address base, address quote) external view returns (uint256 timestamp);\n\n function latestRound(address base, address quote) external view returns (uint256 roundId);\n\n function getAnswer(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (int256 answer);\n\n function getTimestamp(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (uint256 timestamp);\n\n // Registry getters\n\n function getFeed(address base, address quote) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseFeed(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function isFeedEnabled(address aggregator) external view returns (bool);\n\n function getPhase(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (Phase memory phase);\n\n // Round helpers\n\n function getRoundFeed(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseRange(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (uint80 startingRoundId, uint80 endingRoundId);\n\n function getPreviousRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 previousRoundId);\n\n function getNextRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 nextRoundId);\n\n // Feed management\n\n function proposeFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n function confirmFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n // Proposed aggregator\n\n function getProposedFeed(address base, address quote)\n external\n view\n returns (AggregatorV2V3Interface proposedAggregator);\n\n function proposedGetRoundData(\n address base,\n address quote,\n uint80 roundId\n )\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function proposedLatestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // Phases\n function getCurrentPhaseId(address base, address quote) external view returns (uint16 currentPhaseId);\n}\n" + }, + "contracts/external/compound/ICErc20.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\n/**\n * @title Compound's CErc20 Contract\n * @notice CTokens which wrap an EIP-20 underlying\n * @author Compound\n */\ninterface ICErc20Compound is ICToken {\n function underlying() external view returns (address);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n ICToken cTokenCollateral\n ) external returns (uint256);\n\n function getTotalUnderlyingSupplied() external view returns (uint256);\n}\n" + }, + "contracts/external/compound/IComptroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./IPriceOracle.sol\";\nimport \"./ICToken.sol\";\nimport \"./IUnitroller.sol\";\nimport \"./IRewardsDistributor.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n */\ninterface IComptroller {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function oracle() external view returns (IPriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function getAssetsIn(address account) external view returns (ICToken[] memory);\n\n function checkMembership(address account, ICToken cToken) external view returns (bool);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n )\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function getAccountLiquidity(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _become(IUnitroller unitroller) external;\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAllMarkets() external view returns (ICToken[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function suppliers(address account) external view returns (bool);\n\n function supplyCaps(address cToken) external view returns (uint256);\n\n function borrowCaps(address cToken) external view returns (uint256);\n\n function enforceWhitelist() external view returns (bool);\n\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cTokenAddress) external returns (uint256);\n\n function autoImplementation() external view returns (bool);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\n\n function _deployMarket(\n bool isCEther,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getMaxRedeemOrBorrow(\n address account,\n ICToken cTokenModify,\n bool isBorrow\n ) external view returns (uint256);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function isDeprecated(ICToken cToken) external view returns (bool);\n\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n}\n" + }, + "contracts/external/compound/ICToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's CToken Contract\n * @notice Abstract base for CTokens\n * @author Compound\n */\ninterface ICToken {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function symbol() external view returns (string memory);\n\n function comptroller() external view returns (address);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function isCToken() external view returns (bool);\n\n function isCEther() external view returns (bool);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function totalBorrowsCurrent() external returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external returns (uint256);\n\n function exchangeRateCurrent() external returns (uint256);\n\n function exchangeRateStored() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n}\n" + }, + "contracts/external/compound/IPriceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\ninterface IPriceOracle {\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\n}\n" + }, + "contracts/external/compound/IRewardsDistributor.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\n/**\n * @title RewardsDistributor\n * @author Compound\n */\ninterface IRewardsDistributor {\n /// @dev The token to reward (i.e., COMP)\n function rewardToken() external view returns (address);\n\n /// @notice The portion of compRate that each market currently receives\n function compSupplySpeeds(address) external view returns (uint256);\n\n /// @notice The portion of compRate that each market currently receives\n function compBorrowSpeeds(address) external view returns (uint256);\n\n /// @notice The COMP accrued but not yet transferred to each user\n function compAccrued(address) external view returns (uint256);\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n /**\n * @notice Returns an array of all markets.\n */\n function getAllMarkets() external view returns (ICToken[] memory);\n}\n" + }, + "contracts/external/compound/IUnitroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * CTokens should reference this contract as their comptroller.\n */\ninterface IUnitroller {\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n}\n" + }, + "contracts/external/curve/ICurveLiquidityGaugeV2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface ICurveLiquidityGaugeV2 {\n function lp_token() external view returns (address);\n\n function deposit(uint256 _value) external;\n\n function withdraw(uint256 _value) external;\n}\n" + }, + "contracts/external/curve/ICurvePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ICurvePool is IERC20Upgradeable {\n function get_virtual_price() external view returns (uint256);\n\n function remove_liquidity_one_coin(\n uint256 _token_amount,\n int128 i,\n uint256 min_amount\n ) external;\n\n function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);\n\n function add_liquidity(uint256[2] calldata _amounts, uint256 _min_mint_amount) external returns (uint256);\n\n function exchange(\n int128 i,\n int128 j,\n uint256 dx,\n uint256 min_dy\n ) external returns (uint256);\n\n function get_dy(\n int128 i,\n int128 j,\n uint256 _dx\n ) external view returns (uint256);\n\n function coins(uint256 index) external view returns (address);\n\n function lp_token() external view returns (address);\n}\n" + }, + "contracts/external/curve/ICurveRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface ICurveRegistry {\n function get_n_coins(address lp) external view returns (uint256);\n\n function get_coins(address pool) external view returns (address[8] memory);\n\n function get_pool_from_lp_token(address lp) external view returns (address);\n}\n" + }, + "contracts/external/curve/ICurveStableSwap.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ICurveStableSwap is IERC20Upgradeable {\n function get_balances() external view returns (uint256[2] memory);\n\n function remove_liquidity_one_coin(\n uint256 _token_amount,\n int128 i,\n uint256 min_amount\n ) external;\n}\n" + }, + "contracts/external/curve/ICurveV2Pool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurvePool } from \"./ICurvePool.sol\";\n\ninterface ICurveV2Pool is ICurvePool {\n function price_oracle() external view returns (uint256);\n\n function lp_price() external view returns (uint256);\n\n function coins(uint256 arg0) external view returns (address);\n}\n" + }, + "contracts/external/gamma/IHypervisor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IHypervisor is IERC20Upgradeable {\n function baseLower() external view returns (int24);\n\n function baseUpper() external view returns (int24);\n\n function limitLower() external view returns (int24);\n\n function limitUpper() external view returns (int24);\n\n function pool() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function directDeposit() external view returns (bool);\n\n function getBasePosition()\n external\n view\n returns (\n uint256 liquidity,\n uint256 total0,\n uint256 total1\n );\n\n function getTotalAmounts() external view returns (uint256 total0, uint256 total1);\n\n function setWhitelist(address _address) external;\n\n function setFee(uint8 newFee) external;\n\n function removeWhitelisted() external;\n\n function transferOwnership(address newOwner) external;\n\n function withdraw(\n uint256 shares,\n address to,\n address from,\n uint256[4] memory minAmounts\n ) external returns (uint256 amount0, uint256 amount1);\n\n function deposit(\n uint256 deposit0,\n uint256 deposit1,\n address to,\n address from,\n uint256[4] memory inMin\n ) external returns (uint256 shares);\n}\n" + }, + "contracts/external/gamma/IUniProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\ninterface IUniProxy {\n /// @notice Deposit into the given position\n /// @param deposit0 Amount of token0 to deposit\n /// @param deposit1 Amount of token1 to deposit\n /// @param to Address to receive liquidity tokens\n /// @param pos Hypervisor Address\n /// @return shares Amount of liquidity tokens received\n function deposit(\n uint256 deposit0,\n uint256 deposit1,\n address to,\n address pos, // IHypervisor\n uint256[4] memory minIn\n ) external returns (uint256 shares);\n\n /// @notice Get the amount of token to deposit for the given amount of pair token\n /// @param pos Hypervisor Address\n /// @param token Address of token to deposit\n /// @param _deposit Amount of token to deposit\n /// @return amountStart Minimum amounts of the pair token to deposit\n /// @return amountEnd Maximum amounts of the pair token to deposit\n function getDepositAmount(\n address pos,\n address token,\n uint256 _deposit\n ) external view returns (uint256 amountStart, uint256 amountEnd);\n}\n" + }, + "contracts/external/gelato/GUniPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0;\n\ninterface GUniPool {\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n /// @notice compute total underlying holdings of the G-UNI token supply\n /// includes current liquidity invested in uniswap position, current fees earned\n /// and any uninvested leftover (but does not include manager or gelato fees accrued)\n /// @return amount0Current current total underlying balance of token0\n /// @return amount1Current current total underlying balance of token1\n function getUnderlyingBalancesAtPrice(uint160 sqrtRatioX96)\n external\n view\n returns (uint256 amount0Current, uint256 amount1Current);\n\n /// @notice burn G-UNI tokens (fractional shares of a Uniswap V3 position) and receive tokens\n /// @param burnAmount The number of G-UNI tokens to burn\n /// @param receiver The account to receive the underlying amounts of token0 and token1\n /// @return amount0 amount of token0 transferred to receiver for burning `burnAmount`\n /// @return amount1 amount of token1 transferred to receiver for burning `burnAmount`\n /// @return liquidityBurned amount of liquidity removed from the underlying Uniswap V3 position\n // solhint-disable-next-line function-max-lines\n function burn(uint256 burnAmount, address receiver)\n external\n returns (\n uint256 amount0,\n uint256 amount1,\n uint128 liquidityBurned\n );\n}\n" + }, + "contracts/external/harvest/IFarmVault.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface IFarmVault {\n function underlyingBalanceInVault() external view returns (uint256);\n\n function underlyingBalanceWithInvestment() external view returns (uint256);\n\n // function store() external view returns (address);\n function governance() external view returns (address);\n\n function controller() external view returns (address);\n\n function underlying() external view returns (address);\n\n function strategy() external view returns (address);\n\n function setStrategy(address _strategy) external;\n\n function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external;\n\n function deposit(uint256 amountWei) external;\n\n function depositFor(uint256 amountWei, address holder) external;\n\n function withdrawAll() external;\n\n function withdraw(uint256 numberOfShares) external;\n\n function getPricePerFullShare() external view returns (uint256);\n\n function underlyingBalanceWithInvestmentForHolder(address holder) external view returns (uint256);\n\n // hard work should be callable only by the controller (by the hard worker) or by governance\n function doHardWork() external;\n}\n" + }, + "contracts/external/hypernative/interfaces/IHypernativeOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IHypernativeOracle {\n function register(address account) external;\n function registerStrict(address account) external;\n function isBlacklistedAccount(address account) external view returns (bool);\n function isBlacklistedContext(address sender, address origin) external view returns (bool);\n function isTimeExceeded(address account) external view returns (bool);\n}\n" + }, + "contracts/external/inverse/Stabilizer.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\ninterface Stabilizer {\n function buyFee() external view returns (uint256);\n\n function synth() external view returns (address);\n\n function reserve() external view returns (address);\n\n function buy(uint256 amount) external;\n\n function sell(uint256 amount) external;\n}\n" + }, + "contracts/external/jarvis/ISynthereumDeployment.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./ISynthereumFinder.sol\";\n\n/**\n * @title Interface that a pool MUST have in order to be included in the deployer\n */\ninterface ISynthereumDeployment {\n /**\n * @notice Get Synthereum finder of the pool/self-minting derivative\n * @return finder Returns finder contract\n */\n function synthereumFinder() external view returns (ISynthereumFinder finder);\n\n /**\n * @notice Get Synthereum version\n * @return poolVersion Returns the version of this pool/self-minting derivative\n */\n function version() external view returns (uint8 poolVersion);\n\n /**\n * @notice Get the collateral token of this pool/self-minting derivative\n * @return collateralCurrency The ERC20 collateral token\n */\n function collateralToken() external view returns (IERC20Upgradeable collateralCurrency);\n\n /**\n * @notice Get the synthetic token associated to this pool/self-minting derivative\n * @return syntheticCurrency The ERC20 synthetic token\n */\n function syntheticToken() external view returns (IERC20Upgradeable syntheticCurrency);\n\n /**\n * @notice Get the synthetic token symbol associated to this pool/self-minting derivative\n * @return symbol The ERC20 synthetic token symbol\n */\n function syntheticTokenSymbol() external view returns (string memory symbol);\n}\n" + }, + "contracts/external/jarvis/ISynthereumFinder.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\n/**\n * @title Provides addresses of the contracts implementing certain interfaces.\n */\ninterface ISynthereumFinder {\n /**\n * @notice Updates the address of the contract that implements `interfaceName`.\n * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.\n * @param implementationAddress address of the deployed contract that implements the interface.\n */\n function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;\n\n /**\n * @notice Gets the address of the contract that implements the given `interfaceName`.\n * @param interfaceName queried interface.\n * @return implementationAddress Address of the deployed contract that implements the interface.\n */\n function getImplementationAddress(bytes32 interfaceName) external view returns (address);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPool.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumLiquidityPoolGeneral.sol\";\n\n//import {\n//IEmergencyShutdown\n//} from '../../../common/interfaces/IEmergencyShutdown.sol';\n//import {ISynthereumLiquidityPoolGeneral} from './ILiquidityPoolGeneral.sol';\n//import {ISynthereumLiquidityPoolStorage} from './ILiquidityPoolStorage.sol';\n//import {ITypology} from '../../../common/interfaces/ITypology.sol';\n\n/**\n * @title Token Issuer Contract Interface\n */\n//ITypology,\n//IEmergencyShutdown,\ninterface ISynthereumLiquidityPool is ISynthereumLiquidityPoolGeneral {\n struct MintParams {\n // Minimum amount of synthetic tokens that a user wants to mint using collateral (anti-slippage)\n uint256 minNumTokens;\n // Amount of collateral that a user wants to spend for minting\n uint256 collateralAmount;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send synthetic tokens minted\n address recipient;\n }\n\n struct RedeemParams {\n // Amount of synthetic tokens that user wants to use for redeeming\n uint256 numTokens;\n // Minimium amount of collateral that user wants to redeem (anti-slippage)\n uint256 minCollateral;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send collateral tokens redeemed\n address recipient;\n }\n\n // struct ExchangeParams {\n // // Destination pool\n // ISynthereumLiquidityPoolGeneral destPool;\n // // Amount of source synthetic tokens that user wants to use for exchanging\n // uint256 numTokens;\n // // Minimum Amount of destination synthetic tokens that user wants to receive (anti-slippage)\n // uint256 minDestNumTokens;\n // // Expiration time of the transaction\n // uint256 expiration;\n // // Address to which send synthetic tokens exchanged\n // address recipient;\n // }\n\n /**\n * @notice Mint synthetic tokens using fixed amount of collateral\n * @notice This calculate the price using on chain price feed\n * @notice User must approve collateral transfer for the mint request to succeed\n * @param mintParams Input parameters for minting (see MintParams struct)\n * @return syntheticTokensMinted Amount of synthetic tokens minted by a user\n * @return feePaid Amount of collateral paid by the user as fee\n */\n function mint(MintParams calldata mintParams) external returns (uint256 syntheticTokensMinted, uint256 feePaid);\n\n /**\n * @notice Redeem amount of collateral using fixed number of synthetic token\n * @notice This calculate the price using on chain price feed\n * @notice User must approve synthetic token transfer for the redeem request to succeed\n * @param redeemParams Input parameters for redeeming (see RedeemParams struct)\n * @return collateralRedeemed Amount of collateral redeem by user\n * @return feePaid Amount of collateral paid by user as fee\n */\n function redeem(RedeemParams calldata redeemParams) external returns (uint256 collateralRedeemed, uint256 feePaid);\n\n // /**\n // * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool\n // * @notice This calculate the price using on chain price feed\n // * @notice User must approve synthetic token transfer for the redeem request to succeed\n // * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct)\n // * @return destNumTokensMinted Amount of collateral redeem by user\n // * @return feePaid Amount of collateral paid by user as fee\n // */\n // function exchange(ExchangeParams calldata exchangeParams)\n // external\n // returns (uint256 destNumTokensMinted, uint256 feePaid);\n\n /**\n * @notice Withdraw unused deposited collateral by the LP\n * @notice Only a sender with LP role can call this function\n * @param collateralAmount Collateral to be withdrawn\n * @return remainingLiquidity Remaining unused collateral in the pool\n */\n function withdrawLiquidity(uint256 collateralAmount) external returns (uint256 remainingLiquidity);\n\n /**\n * @notice Increase collaterallization of Lp position\n * @notice Only a sender with LP role can call this function\n * @param collateralToTransfer Collateral to be transferred before increase collateral in the position\n * @param collateralToIncrease Collateral to be added to the position\n * @return newTotalCollateral New total collateral amount\n */\n function increaseCollateral(uint256 collateralToTransfer, uint256 collateralToIncrease)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Decrease collaterallization of Lp position\n * @notice Check that final poosition is not undercollateralized\n * @notice Only a sender with LP role can call this function\n * @param collateralToDecrease Collateral to decreased from the position\n * @param collateralToWithdraw Collateral to be transferred to the LP\n * @return newTotalCollateral New total collateral amount\n */\n function decreaseCollateral(uint256 collateralToDecrease, uint256 collateralToWithdraw)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Withdraw fees gained by the sender\n * @return feeClaimed Amount of fee claimed\n */\n function claimFee() external returns (uint256 feeClaimed);\n\n /**\n * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized\n * @notice Revert if position is not undercollateralized\n * @param numSynthTokens Number of synthetic tokens that user wants to liquidate\n * @return synthTokensLiquidated Amount of synthetic tokens liquidated\n * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated\n * @return rewardAmount Amount of received collateral as reward for the liquidation\n */\n function liquidate(uint256 numSynthTokens)\n external\n returns (\n uint256 synthTokensLiquidated,\n uint256 collateralReceived,\n uint256 rewardAmount\n );\n\n /**\n * @notice Redeem tokens after emergency shutdown\n * @return synthTokensSettled Amount of synthetic tokens liquidated\n * @return collateralSettled Amount of collateral withdrawn after emergency shutdown\n */\n function settleEmergencyShutdown() external returns (uint256 synthTokensSettled, uint256 collateralSettled);\n\n // /**\n // * @notice Update the fee percentage, recipients and recipient proportions\n // * @notice Only the maintainer can call this function\n // * @param _feeData Fee info (percentage + recipients + weigths)\n // */\n // function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData)\n // external;\n\n /**\n * @notice Update the fee percentage\n * @notice Only the maintainer can call this function\n * @param _feePercentage The new fee percentage\n */\n function setFeePercentage(uint256 _feePercentage) external;\n\n /**\n * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive\n * @notice Only the maintainer can call this function\n * @param feeRecipients An array of the addresses of recipients that will receive generated fees\n * @param feeProportions An array of the proportions of fees generated each recipient will receive\n */\n function setFeeRecipients(address[] calldata feeRecipients, uint32[] calldata feeProportions) external;\n\n /**\n * @notice Update the overcollateralization percentage\n * @notice Only the maintainer can call this function\n * @param _overCollateralization Overcollateralization percentage\n */\n function setOverCollateralization(uint256 _overCollateralization) external;\n\n /**\n * @notice Update the liquidation reward percentage\n * @notice Only the maintainer can call this function\n * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator\n */\n function setLiquidationReward(uint256 _liquidationReward) external;\n\n /**\n * @notice Returns fee percentage set by the maintainer\n * @return Fee percentage\n */\n function feePercentage() external view returns (uint256);\n\n /**\n * @notice Returns fee recipients info\n * @return Addresses, weigths and total of weigths\n */\n function feeRecipientsInfo()\n external\n view\n returns (\n address[] memory,\n uint32[] memory,\n uint256\n );\n\n /**\n * @notice Returns total number of synthetic tokens generated by this pool\n * @return Number of synthetic tokens\n */\n function totalSyntheticTokens() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP)\n * @return Total collateral amount\n */\n function totalCollateralAmount() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of fees to be withdrawn\n * @return Total fee amount\n */\n function totalFeeAmount() external view returns (uint256);\n\n /**\n * @notice Returns the user's fee to be withdrawn\n * @param user User's address\n * @return User's fee\n */\n function userFee(address user) external view returns (uint256);\n\n /**\n * @notice Returns the percentage of overcollateralization to which a liquidation can triggered\n * @return Percentage of overcollateralization\n */\n function collateralRequirement() external view returns (uint256);\n\n /**\n * @notice Returns the percentage of reward for correct liquidation by a liquidator\n * @return Percentage of reward\n */\n function liquidationReward() external view returns (uint256);\n\n /**\n * @notice Returns the price of the pair at the moment of the shutdown\n * @return Price of the pair\n */\n function emergencyShutdownPrice() external view returns (uint256);\n\n /**\n * @notice Returns the timestamp (unix time) at the moment of the shutdown\n * @return Timestamp\n */\n function emergencyShutdownTimestamp() external view returns (uint256);\n\n /**\n * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price\n * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized))\n */\n function collateralCoverage() external returns (bool, uint256);\n\n /**\n * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param inputCollateral Input collateral amount to be exchanged\n * @return synthTokensReceived Synthetic tokens will be minted\n * @return feePaid Collateral fee will be paid\n */\n function getMintTradeInfo(uint256 inputCollateral)\n external\n view\n returns (uint256 synthTokensReceived, uint256 feePaid);\n\n /**\n * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param syntheticTokens Amount of synthetic tokens to be exchanged\n * @return collateralAmountReceived Collateral amount will be received by the user\n * @return feePaid Collateral fee will be paid\n */\n function getRedeemTradeInfo(uint256 syntheticTokens)\n external\n view\n returns (uint256 collateralAmountReceived, uint256 feePaid);\n\n // /**\n // * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n // * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n // * @param syntheticTokens Amount of synthetic tokens to be exchanged\n // * @param destinationPool Pool in which mint the destination synthetic token\n // * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool\n // * @return feePaid Collateral fee will be paid\n // */\n // function getExchangeTradeInfo(\n // uint256 syntheticTokens,\n // ISynthereumLiquidityPoolGeneral destinationPool\n // )\n // external\n // view\n // returns (uint256 destSyntheticTokensReceived, uint256 feePaid);\n /**\n * @notice Shutdown the pool or self-minting-derivative in case of emergency\n * @notice Only Synthereum manager contract can call this function\n * @return timestamp Timestamp of emergency shutdown transaction\n * @return price Price of the pair at the moment of shutdown execution\n */\n function emergencyShutdown() external returns (uint256 timestamp, uint256 price);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPoolGeneral.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumDeployment.sol\";\n\ninterface ISynthereumLiquidityPoolGeneral is\n ISynthereumDeployment\n //,\n //ISynthereumLiquidityPoolInteraction\n{}\n" + }, + "contracts/external/kyber/IPool.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport { IPoolOracle } from \"./IPoolOracle.sol\";\n\ninterface IPool {\n /// @notice The contract that deployed the pool, which must adhere to the IFactory interface\n /// @return The contract address\n function factory() external view returns (address);\n\n /// @notice The oracle contract that stores necessary data for price oracle\n /// @return The contract address\n function poolOracle() external view returns (IPoolOracle);\n\n /// @notice The first of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token0() external view returns (address);\n\n /// @notice The second of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token1() external view returns (address);\n\n /// @notice The fee to be charged for a swap in basis points\n /// @return The swap fee in basis points\n function swapFeeUnits() external view returns (uint24);\n\n /// @notice The pool tick distance\n /// @dev Ticks can only be initialized and used at multiples of this value\n /// It remains an int24 to avoid casting even though it is >= 1.\n /// e.g: a tickDistance of 5 means ticks can be initialized every 5th tick, i.e., ..., -10, -5, 0, 5, 10, ...\n /// @return The tick distance\n function tickDistance() external view returns (int24);\n\n /// @notice Maximum gross liquidity that an initialized tick can have\n /// @dev This is to prevent overflow the pool's active base liquidity (uint128)\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n /// @return The max amount of liquidity per tick\n function maxTickLiquidity() external view returns (uint128);\n\n /// @notice Look up information about a specific tick in the pool\n /// @param tick The tick to look up\n /// @return liquidityGross total liquidity amount from positions that uses this tick as a lower or upper tick\n /// liquidityNet how much liquidity changes when the pool tick crosses above the tick\n /// feeGrowthOutside the fee growth on the other side of the tick relative to the current tick\n /// secondsPerLiquidityOutside the seconds per unit of liquidity spent on the other side of the tick relative to the current tick\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityGross,\n int128 liquidityNet,\n uint256 feeGrowthOutside,\n uint128 secondsPerLiquidityOutside\n );\n\n /// @notice Returns the previous and next initialized ticks of a specific tick\n /// @dev If specified tick is uninitialized, the returned values are zero.\n /// @param tick The tick to look up\n function initializedTicks(int24 tick) external view returns (int24 previous, int24 next);\n\n /// @notice Returns the information about a position by the position's key\n /// @return liquidity the liquidity quantity of the position\n /// @return feeGrowthInsideLast fee growth inside the tick range as of the last mint / burn action performed\n function getPositions(\n address owner,\n int24 tickLower,\n int24 tickUpper\n ) external view returns (uint128 liquidity, uint256 feeGrowthInsideLast);\n\n /// @notice Fetches the pool's prices, ticks and lock status\n /// @return sqrtP sqrt of current price: sqrt(token1/token0)\n /// @return currentTick pool's current tick\n /// @return nearestCurrentTick pool's nearest initialized tick that is <= currentTick\n /// @return locked true if pool is locked, false otherwise\n function getPoolState()\n external\n view\n returns (\n uint160 sqrtP,\n int24 currentTick,\n int24 nearestCurrentTick,\n bool locked\n );\n\n /// @notice Fetches the pool's liquidity values\n /// @return baseL pool's base liquidity without reinvest liqudity\n /// @return reinvestL the liquidity is reinvested into the pool\n /// @return reinvestLLast last cached value of reinvestL, used for calculating reinvestment token qty\n function getLiquidityState()\n external\n view\n returns (\n uint128 baseL,\n uint128 reinvestL,\n uint128 reinvestLLast\n );\n\n /// @return feeGrowthGlobal All-time fee growth per unit of liquidity of the pool\n function getFeeGrowthGlobal() external view returns (uint256);\n\n /// @return secondsPerLiquidityGlobal All-time seconds per unit of liquidity of the pool\n /// @return lastUpdateTime The timestamp in which secondsPerLiquidityGlobal was last updated\n function getSecondsPerLiquidityData()\n external\n view\n returns (uint128 secondsPerLiquidityGlobal, uint32 lastUpdateTime);\n\n /// @notice Calculates and returns the active time per unit of liquidity until current block.timestamp\n /// @param tickLower The lower tick (of a position)\n /// @param tickUpper The upper tick (of a position)\n /// @return secondsPerLiquidityInside active time (multiplied by 2^96)\n /// between the 2 ticks, per unit of liquidity.\n function getSecondsPerLiquidityInside(int24 tickLower, int24 tickUpper)\n external\n view\n returns (uint128 secondsPerLiquidityInside);\n}\n" + }, + "contracts/external/kyber/IPoolOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IPoolOracle {\n /// @notice Owner withdrew funds in the pool oracle in case some funds are stuck there\n event OwnerWithdrew(address indexed owner, address indexed token, uint256 indexed amount);\n\n /// @notice Emitted by the Pool Oracle for increases to the number of observations that can be stored\n /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\n /// just before a mint/swap/burn.\n /// @param pool The pool address to update\n /// @param observationCardinalityNextOld The previous value of the next observation cardinality\n /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n event IncreaseObservationCardinalityNext(\n address pool,\n uint16 observationCardinalityNextOld,\n uint16 observationCardinalityNextNew\n );\n\n /// @notice Initalize observation data for the caller.\n function initializeOracle(uint32 time) external returns (uint16 cardinality, uint16 cardinalityNext);\n\n /// @notice Write a new oracle entry into the array\n /// and update the observation index and cardinality\n /// Read the Oralce.write function for more details\n function writeNewEntry(\n uint16 index,\n uint32 blockTimestamp,\n int24 tick,\n uint128 liquidity,\n uint16 cardinality,\n uint16 cardinalityNext\n ) external returns (uint16 indexUpdated, uint16 cardinalityUpdated);\n\n /// @notice Write a new oracle entry into the array, take the latest observaion data as inputs\n /// and update the observation index and cardinality\n /// Read the Oralce.write function for more details\n function write(\n uint32 blockTimestamp,\n int24 tick,\n uint128 liquidity\n ) external returns (uint16 indexUpdated, uint16 cardinalityUpdated);\n\n /// @notice Increase the maximum number of price observations that this pool will store\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n /// the input observationCardinalityNext.\n /// @param pool The pool address to be updated\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n function increaseObservationCardinalityNext(address pool, uint16 observationCardinalityNext) external;\n\n /// @notice Returns the accumulator values as of each time seconds ago from the latest block time in the array of `secondsAgos`\n /// @dev Reverts if `secondsAgos` > oldest observation\n /// @dev It fetches the latest current tick data from the pool\n /// Read the Oracle.observe function for more details\n function observeFromPool(address pool, uint32[] memory secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives);\n\n /// @notice Returns the accumulator values as the time seconds ago from the latest block time of secondsAgo\n /// @dev Reverts if `secondsAgo` > oldest observation\n /// @dev It fetches the latest current tick data from the pool\n /// Read the Oracle.observeSingle function for more details\n function observeSingleFromPool(address pool, uint32 secondsAgo) external view returns (int56 tickCumulative);\n\n /// @notice Return the latest pool observation data given the pool address\n function getPoolObservation(address pool)\n external\n view\n returns (\n bool initialized,\n uint16 index,\n uint16 cardinality,\n uint16 cardinalityNext\n );\n\n /// @notice Returns data about a specific observation index\n /// @param pool The pool address of the observations array to fetch\n /// @param index The element of the observations array to fetch\n /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\n /// ago, rather than at a specific index in the array.\n /// @return blockTimestamp The timestamp of the observation,\n /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\n /// Returns initialized whether the observation has been initialized and the values are safe to use\n function getObservationAt(address pool, uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n bool initialized\n );\n}\n" + }, + "contracts/external/lido/IWstETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title StETH token wrapper with static balances.\n * @dev It's an ERC20 token that represents the account's share of the total\n * supply of stETH tokens. WstETH token's balance only changes on transfers,\n * unlike StETH that is also changed when oracles report staking rewards and\n * penalties. It's a \"power user\" token for DeFi protocols which don't\n * support rebasable tokens.\n *\n * The contract is also a trustless wrapper that accepts stETH tokens and mints\n * wstETH in return. Then the user unwraps, the contract burns user's wstETH\n * and sends user locked stETH in return.\n *\n * The contract provides the staking shortcut: user can send ETH with regular\n * transfer and get wstETH in return. The contract will send ETH to Lido submit\n * method, staking it and wrapping the received stETH.\n *\n */\ninterface IWstETH {\n function stETH() external view returns (address);\n\n /**\n * @notice Get amount of stETH for a one wstETH\n * @return Amount of stETH for 1 wstETH\n */\n function stEthPerToken() external view returns (uint256);\n\n /**\n * @notice Get amount of wstETH for a one stETH\n * @return Amount of wstETH for a 1 stETH\n */\n function tokensPerStEth() external view returns (uint256);\n\n /**\n * @notice Exchanges wstETH to stETH\n * @param _wstETHAmount amount of wstETH to uwrap in exchange for stETH\n * @dev Requirements:\n * - `_wstETHAmount` must be non-zero\n * - msg.sender must have at least `_wstETHAmount` wstETH.\n * @return Amount of stETH user receives after unwrap\n */\n function unwrap(uint256 _wstETHAmount) external returns (uint256);\n}\n" + }, + "contracts/external/mstable/IMasset.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./MassetStructs.sol\";\n\n/**\n * @title IMasset\n * @dev (Internal) Interface for interacting with Masset\n * VERSION: 1.0\n * DATE: 2020-05-05\n */\ninterface IMasset is MassetStructs {\n // Mint\n function mint(\n address _input,\n uint256 _inputQuantity,\n uint256 _minOutputQuantity,\n address _recipient\n ) external returns (uint256 mintOutput);\n\n function mintMulti(\n address[] calldata _inputs,\n uint256[] calldata _inputQuantities,\n uint256 _minOutputQuantity,\n address _recipient\n ) external returns (uint256 mintOutput);\n\n function getMintOutput(address _input, uint256 _inputQuantity) external view returns (uint256 mintOutput);\n\n function getMintMultiOutput(address[] calldata _inputs, uint256[] calldata _inputQuantities)\n external\n view\n returns (uint256 mintOutput);\n\n // Swaps\n function swap(\n address _input,\n address _output,\n uint256 _inputQuantity,\n uint256 _minOutputQuantity,\n address _recipient\n ) external returns (uint256 swapOutput);\n\n function getSwapOutput(\n address _input,\n address _output,\n uint256 _inputQuantity\n ) external view returns (uint256 swapOutput);\n\n // Redemption\n function redeem(\n address _output,\n uint256 _mAssetQuantity,\n uint256 _minOutputQuantity,\n address _recipient\n ) external returns (uint256 outputQuantity);\n\n function redeemMasset(\n uint256 _mAssetQuantity,\n uint256[] calldata _minOutputQuantities,\n address _recipient\n ) external returns (uint256[] memory outputQuantities);\n\n function redeemExactBassets(\n address[] calldata _outputs,\n uint256[] calldata _outputQuantities,\n uint256 _maxMassetQuantity,\n address _recipient\n ) external returns (uint256 mAssetRedeemed);\n\n function getRedeemOutput(address _output, uint256 _mAssetQuantity) external view returns (uint256 bAssetOutput);\n\n function getRedeemExactBassetsOutput(address[] calldata _outputs, uint256[] calldata _outputQuantities)\n external\n view\n returns (uint256 mAssetAmount);\n\n // Views\n function getBasket() external view returns (bool, bool);\n\n function getBasset(address _token) external view returns (BassetPersonal memory personal, BassetData memory data);\n\n function getBassets() external view returns (BassetPersonal[] memory personal, BassetData[] memory data);\n\n function bAssetIndexes(address) external view returns (uint8);\n\n // SavingsManager\n function collectInterest() external returns (uint256 swapFeesGained, uint256 newSupply);\n\n function collectPlatformInterest() external returns (uint256 mintAmount, uint256 newSupply);\n\n // Admin\n function setCacheSize(uint256 _cacheSize) external;\n\n function upgradeForgeValidator(address _newForgeValidator) external;\n\n function setFees(uint256 _swapFee, uint256 _redemptionFee) external;\n\n function setTransferFeesFlag(address _bAsset, bool _flag) external;\n\n function migrateBassets(address[] calldata _bAssets, address _newIntegration) external;\n}\n" + }, + "contracts/external/mstable/ISavingsContractV2.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\npragma solidity >=0.8.0;\n\n/**\n * @title ISavingsContractV2\n */\ninterface ISavingsContractV2 {\n function redeemCredits(uint256 _amount) external returns (uint256 underlyingReturned); // V2\n\n function exchangeRate() external view returns (uint256); // V1 & V2\n}\n" + }, + "contracts/external/mstable/MassetStructs.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-or-later\npragma solidity >=0.8.0;\n\ninterface MassetStructs {\n struct BassetPersonal {\n // Address of the bAsset\n address addr;\n // Address of the bAsset\n address integrator;\n // An ERC20 can charge transfer fee, for example USDT, DGX tokens.\n bool hasTxFee; // takes a byte in storage\n // Status of the bAsset\n BassetStatus status;\n }\n\n struct BassetData {\n // 1 Basset * ratio / ratioScale == x Masset (relative value)\n // If ratio == 10e8 then 1 bAsset = 10 mAssets\n // A ratio is divised as 10^(18-tokenDecimals) * measurementMultiple(relative value of 1 base unit)\n uint128 ratio;\n // Amount of the Basset that is held in Collateral\n uint128 vaultBalance;\n }\n\n // Status of the Basset - has it broken its peg?\n enum BassetStatus {\n Default,\n Normal,\n BrokenBelowPeg,\n BrokenAbovePeg,\n Blacklisted,\n Liquidating,\n Liquidated,\n Failed\n }\n\n struct BasketState {\n bool undergoingRecol;\n bool failed;\n }\n\n struct InvariantConfig {\n uint256 a;\n WeightLimits limits;\n }\n\n struct WeightLimits {\n uint128 min;\n uint128 max;\n }\n\n struct AmpData {\n uint64 initialA;\n uint64 targetA;\n uint64 rampStartTime;\n uint64 rampEndTime;\n }\n}\n" + }, + "contracts/external/olympus/OlympusStaking.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nabstract contract OlympusStaking {\n address public OHM;\n\n function unstake(uint256 _amount, bool _trigger) external virtual;\n}\n" + }, + "contracts/external/olympus/sOlympus.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nabstract contract sOlympus {\n address public stakingContract;\n}\n" + }, + "contracts/external/pcs/IPancakePair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IPancakePair {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/external/pstake/IStakePool.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n// 1 stkBNB = (totalWei / poolTokenSupply) BNB\n// 1 BNB = (poolTokenSupply / totalWei) stkBNB\n// Over time, stkBNB appreciates in value as compared to BNB.\nstruct ExchangeRateData {\n uint256 totalWei; // total amount of BNB managed by the pool\n uint256 poolTokenSupply; // total amount of stkBNB managed by the pool\n}\n\n// External protocols (eg: Wombat Exchange) that integrate with us, rely on this interface.\n// We must always ensure that StakePool conforms to this interface.\ninterface IStakePool {\n function exchangeRate() external view returns (ExchangeRateData memory);\n}\n" + }, + "contracts/external/pyth/IExpressRelay.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelay {\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\n // This will return true if and only if it's being called while executing the auction winner(s) call.\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\n // @param permissionId The id that represents the action being gated\n // @return permissioned True if the permission is allowed, false otherwise\n function isPermissioned(\n address protocolFeeReceiver,\n bytes calldata permissionId\n ) external view returns (bool permissioned);\n}\n" + }, + "contracts/external/pyth/IExpressRelayFeeReceiver.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelayFeeReceiver {\n // Receive the proceeds of an auction.\n // @param permissionKey The permission key where the auction was conducted on.\n function receiveAuctionProceedings(\n bytes calldata permissionKey\n ) external payable;\n}\n" + }, + "contracts/external/redstone/IRedstoneOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IRedstoneOracle {\n function priceOf(address asset) external view returns (uint256);\n\n function priceOfETH() external view returns (uint256);\n\n function getDataFeedIdForAsset(address asset) external view returns (bytes32);\n\n function getDataFeedIds() external view returns (bytes32[] memory dataFeedIds);\n}\n" + }, + "contracts/external/saddle/ISwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\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 getToken(uint8 index) external view returns (address);\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 // 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) external view returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount) external view returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(uint256 tokenAmount, uint8 tokenIndex)\n external\n view\n returns (uint256 availableTokenAmount);\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/external/solidly/IPair.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nstruct Observation {\n uint256 timestamp;\n uint256 reserve0Cumulative;\n uint256 reserve1Cumulative;\n}\n\ninterface IPair {\n function observations(uint256 index) external pure returns (Observation memory);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function metadata()\n external\n view\n returns (\n uint256 dec0,\n uint256 dec1,\n uint256 r0,\n uint256 r1,\n bool st,\n address t0,\n address t1\n );\n\n function claimFees() external returns (uint256, uint256);\n\n function tokens() external returns (address, address);\n\n function stable() external view returns (bool);\n\n function observationLength() external view returns (uint256);\n\n function lastObservation() external view returns (Observation memory);\n\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\n\n function currentCumulativePrices()\n external\n view\n returns (\n uint256 reserve0Cumulative,\n uint256 reserve1Cumulative,\n uint256 blockTimestamp\n );\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\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 function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function sync() external;\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function getReserves()\n external\n view\n returns (\n uint256 _reserve0,\n uint256 _reserve1,\n uint256 _blockTimestampLast\n );\n\n function getAmountOut(uint256, address) external view returns (uint256);\n}\n" + }, + "contracts/external/solidly/IRouter.sol": { + "content": "pragma solidity >=0.8.0;\n\ninterface IRouter {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n function isPair(address pair) external view returns (bool);\n\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n function pairFor(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (address pair);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function swapExactTokensForTokensSimple(\n uint256 amountIn,\n uint256 amountOutMin,\n address tokenFrom,\n address tokenTo,\n bool stable,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n )\n external\n view\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n}\n" + }, + "contracts/external/stader/IStakeManager.sol": { + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.0;\n\ninterface IStakeManager {\n function deposit() external payable;\n\n function getTotalPooledBnb() external view returns (uint256);\n\n function getContracts()\n external\n view\n returns (\n address _manager,\n address _bnbX,\n address _tokenHub,\n address _bcDepositWallet\n );\n\n function getExtraBnbInContract() external view returns (uint256 _extraBnb);\n\n function convertBnbToBnbX(uint256 _amount) external view returns (uint256);\n\n function convertBnbXToBnb(uint256 _amountInBnbX) external view returns (uint256);\n}\n" + }, + "contracts/external/sushi/SushiBar.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nabstract contract SushiBar is IERC20Upgradeable {\n IERC20Upgradeable public sushi;\n\n // Enter the bar. Pay some SUSHIs. Earn some shares.\n function enter(uint256 _amount) public virtual;\n\n // Leave the bar. Claim back your SUSHIs.\n function leave(uint256 _share) public virtual;\n}\n" + }, + "contracts/external/umbrella/IRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRegistry {\n event LogRegistered(address indexed destination, bytes32 name);\n\n /// @dev imports new contract addresses and override old addresses, if they exist under provided name\n /// This method can be used for contracts that for some reason do not have `getName` method\n /// @param _names array of contract names that we want to register\n /// @param _destinations array of contract addresses\n function importAddresses(bytes32[] calldata _names, address[] calldata _destinations) external;\n\n /// @dev imports new contracts and override old addresses, if they exist.\n /// Names of contracts are fetched directly from each contract by calling `getName`\n /// @param _destinations array of contract addresses\n function importContracts(address[] calldata _destinations) external;\n\n /// @dev this method ensure, that old and new contract is aware of it state in registry\n /// Note: BSC registry does not have this method. This method was introduced in later stage.\n /// @param _newContract address of contract that will replace old one\n function atomicUpdate(address _newContract) external;\n\n /// @dev similar to `getAddress` but throws when contract name not exists\n /// @param name contract name\n /// @return contract address registered under provided name or throws, if does not exists\n function requireAndGetAddress(bytes32 name) external view returns (address);\n\n /// @param name contract name in a form of bytes32\n /// @return contract address registered under provided name\n function getAddress(bytes32 name) external view returns (address);\n\n /// @param _name contract name\n /// @return contract address assigned to the name or address(0) if not exists\n function getAddressByString(string memory _name) external view returns (address);\n\n /// @dev helper method that converts string to bytes32,\n /// you can use to to generate contract name\n function stringToBytes32(string memory _string) external pure returns (bytes32 result);\n}\n" + }, + "contracts/external/umbrella/IUmbrellaFeeds.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IUmbrellaFeeds {\n struct PriceData {\n /// @dev this is placeholder, that can be used for some additional data\n /// atm of creating this smart contract, it is only used as marker for removed data (when == type(uint8).max)\n uint8 data;\n /// @dev heartbeat: how often price data will be refreshed in case price stay flat\n uint24 heartbeat;\n /// @dev timestamp: price time, at this time validators run consensus\n uint32 timestamp;\n /// @dev price\n uint128 price;\n }\n\n /// @dev this is main endpoint for reading feeds.\n /// In case timestamp is empty (that means there is no data), contract will execute fallback call.\n /// Check main contract description for fallback details.\n /// If you do not need whole data from `PriceData` struct, you can save some gas by using other view methods that\n /// returns just what you need.\n /// @notice method will revert if data for `_key` not exists.\n /// @param _key hash of feed name\n /// @return data full PriceData struct\n function getPriceData(bytes32 _key) external view returns (PriceData memory data);\n\n /// @dev this is only for dev debug,\n /// please use `getPriceData` directly for lower has cost and fallback functionality\n function priceData(string memory _key) external view returns (PriceData memory);\n\n /// @notice same as `getPriceData` but does not revert when no data\n /// @param _key hash of feed name\n /// @return data full PriceData struct\n function getPriceDataRaw(bytes32 _key) external view returns (PriceData memory data);\n\n /// @notice reader for mapping\n /// @param _key hash of feed name\n /// @return data full PriceData struct\n function prices(bytes32 _key) external view returns (PriceData memory data);\n\n /// @notice method will revert if data for `_key` not exists.\n /// @param _key hash of feed name\n /// @return price\n function getPrice(bytes32 _key) external view returns (uint128 price);\n\n /// @notice method will revert if data for `_key` not exists.\n /// @param _key hash of feed name\n /// @return price\n /// @return timestamp\n function getPriceTimestamp(bytes32 _key) external view returns (uint128 price, uint32 timestamp);\n\n /// @notice method will revert if data for `_key` not exists.\n /// @param _key hash of feed name\n /// @return price\n /// @return timestamp\n /// @return heartbeat\n function getPriceTimestampHeartbeat(bytes32 _key)\n external\n view\n returns (\n uint128 price,\n uint32 timestamp,\n uint24 heartbeat\n );\n\n /// @dev This method should be used only for Layer2 as it is more gas consuming than others views.\n /// @notice It does not revert on empty data.\n /// @param _name string feed name\n /// @return data PriceData\n function getPriceDataByName(string calldata _name) external view returns (PriceData memory data);\n\n /// @dev decimals for prices stored in this contract\n function DECIMALS() external view returns (uint8); // solhint-disable-line func-name-mixedcase\n}\n" + }, + "contracts/external/uniswap/FullMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Rewrite unary negation of denominator, which is a uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = a * b\n // Compute the product mod 2**256 and mod 2**256 - 1\n // then use the Chinese Remainder Theorem to reconstruct\n // the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2**256 + prod0\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(a, b, not(0))\n prod0 := mul(a, b)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division\n if (prod1 == 0) {\n require(denominator > 0);\n assembly {\n result := div(prod0, denominator)\n }\n return result;\n }\n\n // Make sure the result is less than 2**256.\n // Also prevents denominator == 0\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0]\n // Compute remainder using mulmod\n uint256 remainder;\n assembly {\n remainder := mulmod(a, b, denominator)\n }\n // Subtract 256 bit number from 512 bit number\n assembly {\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator\n // Compute largest power of two divisor of denominator.\n // Always >= 1.\n uint256 twos = denominator & (~denominator + 1);\n\n // Divide denominator by power of two\n assembly {\n denominator := div(denominator, twos)\n }\n\n // Divide [prod1 prod0] by the factors of two\n assembly {\n prod0 := div(prod0, twos)\n }\n // Shift in bits from prod1 into prod0. For this we need\n // to flip `twos` such that it is 2**256 / twos.\n // If twos is zero, then it becomes one\n assembly {\n twos := add(div(sub(0, twos), twos), 1)\n }\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2**256\n // Now that denominator is an odd number, it has an inverse\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n // Compute the inverse by starting with a seed that is correct\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\n uint256 inv = (3 * denominator) ^ 2;\n // Now use Newton-Raphson iteration to improve the precision.\n // Thanks to Hensel's lifting lemma, this also works in modular\n // arithmetic, doubling the correct bits in each step.\n inv *= 2 - denominator * inv; // inverse mod 2**8\n inv *= 2 - denominator * inv; // inverse mod 2**16\n inv *= 2 - denominator * inv; // inverse mod 2**32\n inv *= 2 - denominator * inv; // inverse mod 2**64\n inv *= 2 - denominator * inv; // inverse mod 2**128\n inv *= 2 - denominator * inv; // inverse mod 2**256\n\n // Because the division is now exact we can divide by multiplying\n // with the modular inverse of denominator. This will give us the\n // correct result modulo 2**256. Since the precoditions guarantee\n // that the outcome is less than 2**256, this is the final result.\n // We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inv;\n return result;\n }\n }\n\n /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n function mulDivRoundingUp(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n result = mulDiv(a, b, denominator);\n if (mulmod(a, b, denominator) > 0) {\n require(result < type(uint256).max);\n result++;\n }\n }\n }\n}\n" + }, + "contracts/external/uniswap/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n function exactInput(ExactInputParams calldata params) external returns (uint256 amountOut);\n\n function exactOutputSingle(ExactOutputSingleParams calldata params) external returns (uint256 amountIn);\n\n function exactOutput(ExactOutputParams calldata params) external returns (uint256 amountIn);\n\n function factory() external returns (address);\n\n function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory);\n}\n" + }, + "contracts/external/uniswap/IUniswapV1Exchange.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV1Exchange {\n function tokenToEthSwapInput(\n uint256 tokens_sold,\n uint256 min_eth,\n uint256 deadline\n ) external returns (uint256);\n}\n" + }, + "contracts/external/uniswap/IUniswapV1Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV1Factory {\n function getExchange(address token) external view returns (address);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Callee.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Callee {\n function uniswapV2Call(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint256);\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n\n function allPairs(uint256) external view returns (address pair);\n\n function allPairsLength() external view returns (uint256);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Pair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router01.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (\n uint256 amountToken,\n uint256 amountETH,\n uint256 liquidity\n );\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router02.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Router01.sol\";\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n address referrer,\n uint256 deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title The interface for the Uniswap V3 Factory\n/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees\ninterface IUniswapV3Factory {\n /// @notice Emitted when the owner of the factory is changed\n /// @param oldOwner The owner before the owner was changed\n /// @param newOwner The owner after the owner was changed\n event OwnerChanged(address indexed oldOwner, address indexed newOwner);\n\n /// @notice Emitted when a pool is created\n /// @param token0 The first token of the pool by address sort order\n /// @param token1 The second token of the pool by address sort order\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks\n /// @param pool The address of the created pool\n event PoolCreated(\n address indexed token0,\n address indexed token1,\n uint24 indexed fee,\n int24 tickSpacing,\n address pool\n );\n\n /// @notice Emitted when a new fee amount is enabled for pool creation via the factory\n /// @param fee The enabled fee, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee\n event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);\n\n /// @notice Returns the current owner of the factory\n /// @dev Can be changed by the current owner via setOwner\n /// @return The address of the factory owner\n function owner() external view returns (address);\n\n /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled\n /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context\n /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee\n /// @return The tick spacing\n function feeAmountTickSpacing(uint24 fee) external view returns (int24);\n\n /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\n /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\n /// @param tokenA The contract address of either token0 or token1\n /// @param tokenB The contract address of the other token\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @return pool The pool address\n function getPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external view returns (address pool);\n\n /// @notice Creates a pool for the given two tokens and fee\n /// @param tokenA One of the two tokens in the desired pool\n /// @param tokenB The other of the two tokens in the desired pool\n /// @param fee The desired fee for the pool\n /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\n /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\n /// are invalid.\n /// @return pool The address of the newly created pool\n function createPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external returns (address pool);\n\n /// @notice Updates the owner of the factory\n /// @dev Must be called by the current owner\n /// @param _owner The new owner of the factory\n function setOwner(address _owner) external;\n\n /// @notice Enables a fee amount with the given tickSpacing\n /// @dev Fee amounts may never be removed once enabled\n /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)\n /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount\n function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3FlashCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#flash\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\ninterface IUniswapV3FlashCallback {\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\n function uniswapV3FlashCallback(\n uint256 fee0,\n uint256 fee1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV3PoolActions.sol\";\n\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function fee() external view returns (uint24);\n\n function slot0()\n external\n view\n returns (\n uint160 sqrtPriceX96,\n int24 tick,\n uint16 observationIndex,\n uint16 observationCardinality,\n uint16 observationCardinalityNext,\n uint8 feeProtocol,\n bool unlocked\n );\n\n function liquidity() external view returns (uint128);\n\n function observe(uint32[] calldata secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\n\n function observations(uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 liquidityCumulative,\n bool initialized\n );\n\n function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityGross,\n int128 liquidityNet,\n uint256 feeGrowthOutside0X128,\n uint256 feeGrowthOutside1X128,\n int56 tickCumulativeOutside,\n uint160 secondsPerLiquidityOutsideX128,\n uint32 secondsOutside,\n bool initialized\n );\n\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n\n function positions(bytes32 key)\n external\n view\n returns (\n uint128 _liquidity,\n uint256 feeGrowthInside0LastX128,\n uint256 feeGrowthInside1LastX128,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n /// @notice Sets the initial price for the pool\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n function initialize(uint160 sqrtPriceX96) external;\n\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n /// @param recipient The address for which the liquidity will be created\n /// @param tickLower The lower tick of the position in which to add liquidity\n /// @param tickUpper The upper tick of the position in which to add liquidity\n /// @param amount The amount of liquidity to mint\n /// @param data Any data that should be passed through to the callback\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n function mint(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount,\n bytes calldata data\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Collects tokens owed to a position\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n /// @param recipient The address which should receive the fees collected\n /// @param tickLower The lower tick of the position for which to collect fees\n /// @param tickUpper The upper tick of the position for which to collect fees\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n /// @return amount0 The amount of fees collected in token0\n /// @return amount1 The amount of fees collected in token1\n function collect(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n /// @dev Fees must be collected separately via a call to #collect\n /// @param tickLower The lower tick of the position for which to burn liquidity\n /// @param tickUpper The upper tick of the position for which to burn liquidity\n /// @param amount How much liquidity to burn\n /// @return amount0 The amount of token0 sent to the recipient\n /// @return amount1 The amount of token1 sent to the recipient\n function burn(\n int24 tickLower,\n int24 tickUpper,\n uint128 amount\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Swap token0 for token1, or token1 for token0\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n /// @param recipient The address to receive the output of the swap\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n /// @param data Any data to be passed through to the callback\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n /// @param recipient The address which will receive the token0 and token1 amounts\n /// @param amount0 The amount of token0 to send\n /// @param amount1 The amount of token1 to send\n /// @param data Any data to be passed through to the callback\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n /// the input observationCardinalityNext.\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolImmutables.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n /// @return The contract address\n function factory() external view returns (address);\n\n /// @notice The first of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token0() external view returns (address);\n\n /// @notice The second of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token1() external view returns (address);\n\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n /// @return The fee\n function fee() external view returns (uint24);\n\n /// @notice The pool tick spacing\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n /// This value is an int24 to avoid casting even though it is always positive.\n /// @return The tick spacing\n function tickSpacing() external view returns (int24);\n\n /// @notice The maximum amount of position liquidity that can use any tick in the range\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n /// @return The max amount of liquidity per tick\n function maxLiquidityPerTick() external view returns (uint128);\n}\n" + }, + "contracts/external/uniswap/IUniswapV3SwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IV3SwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport './IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/LiquidityAmounts.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.5.0;\n\nimport { FullMath } from \"./FullMath.sol\";\n\nlibrary FixedPoint96 {\n uint8 internal constant RESOLUTION = 96;\n uint256 internal constant Q96 = 0x1000000000000000000000000;\n}\n\n/// @title Liquidity amount functions\n/// @notice Provides functions for computing liquidity amounts from token amounts and prices\nlibrary LiquidityAmounts {\n function toUint128(uint256 x) private pure returns (uint128 y) {\n require((y = uint128(x)) == x);\n }\n\n /// @notice Computes the amount of liquidity received for a given amount of token0 and price range\n /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)).\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param amount0 The amount0 being sent in\n /// @return liquidity The amount of returned liquidity\n function getLiquidityForAmount0(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint256 amount0\n ) internal pure returns (uint128 liquidity) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);\n return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));\n }\n\n /// @notice Computes the amount of liquidity received for a given amount of token1 and price range\n /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param amount1 The amount1 being sent in\n /// @return liquidity The amount of returned liquidity\n function getLiquidityForAmount1(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));\n }\n\n /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current\n /// pool prices and the prices at the tick boundaries\n function getLiquidityForAmounts(\n uint160 sqrtRatioX96,\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint256 amount0,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n if (sqrtRatioX96 <= sqrtRatioAX96) {\n liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);\n } else if (sqrtRatioX96 < sqrtRatioBX96) {\n uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);\n uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);\n\n liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;\n } else {\n liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);\n }\n }\n\n /// @notice Computes the amount of token0 for a given amount of liquidity and a price range\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The liquidity being valued\n /// @return amount0 The amount0\n function getAmount0ForLiquidity(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity\n ) internal pure returns (uint256 amount0) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return\n FullMath.mulDiv(uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96) /\n sqrtRatioAX96;\n }\n\n /// @notice Computes the amount of token1 for a given amount of liquidity and a price range\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The liquidity being valued\n /// @return amount1 The amount1\n function getAmount1ForLiquidity(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity\n ) internal pure returns (uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n }\n\n /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current\n /// pool prices and the prices at the tick boundaries\n function getAmountsForLiquidity(\n uint160 sqrtRatioX96,\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity\n ) internal pure returns (uint256 amount0, uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n if (sqrtRatioX96 <= sqrtRatioAX96) {\n amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);\n } else if (sqrtRatioX96 < sqrtRatioBX96) {\n amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);\n amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);\n } else {\n amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IQuoter.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IQuoter {\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Quoter Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IUniswapV3Quoter {\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee\n /// @param amountIn The amount of the first token to swap\n /// @return amountOut The amount of the last token that would be received\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\n\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountIn The desired input amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountOut The amount of `tokenOut` that would be received\n function quoteExactInputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountIn,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountOut);\n\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n /// @param amountOut The amount of the last token to receive\n /// @return amountIn The amount of first token required to be paid\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\n\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountOut The desired output amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n function quoteExactOutputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountOut,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/BitMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title BitMath\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\nlibrary BitMath {\n /// @notice Returns the index of the most significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\n /// @param x the value for which to compute the most significant bit, must be greater than 0\n /// @return r the index of the most significant bit\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n if (x >= 0x100000000000000000000000000000000) {\n x >>= 128;\n r += 128;\n }\n if (x >= 0x10000000000000000) {\n x >>= 64;\n r += 64;\n }\n if (x >= 0x100000000) {\n x >>= 32;\n r += 32;\n }\n if (x >= 0x10000) {\n x >>= 16;\n r += 16;\n }\n if (x >= 0x100) {\n x >>= 8;\n r += 8;\n }\n if (x >= 0x10) {\n x >>= 4;\n r += 4;\n }\n if (x >= 0x4) {\n x >>= 2;\n r += 2;\n }\n if (x >= 0x2) r += 1;\n }\n\n /// @notice Returns the index of the least significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\n /// @param x the value for which to compute the least significant bit, must be greater than 0\n /// @return r the index of the least significant bit\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n r = 255;\n if (x & type(uint128).max > 0) {\n r -= 128;\n } else {\n x >>= 128;\n }\n if (x & type(uint64).max > 0) {\n r -= 64;\n } else {\n x >>= 64;\n }\n if (x & type(uint32).max > 0) {\n r -= 32;\n } else {\n x >>= 32;\n }\n if (x & type(uint16).max > 0) {\n r -= 16;\n } else {\n x >>= 16;\n }\n if (x & type(uint8).max > 0) {\n r -= 8;\n } else {\n x >>= 8;\n }\n if (x & 0xf > 0) {\n r -= 4;\n } else {\n x >>= 4;\n }\n if (x & 0x3 > 0) {\n r -= 2;\n } else {\n x >>= 2;\n }\n if (x & 0x1 > 0) r -= 1;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/FixedPoint96.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n uint8 internal constant RESOLUTION = 96;\n uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LiquidityMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math library for liquidity\nlibrary LiquidityMath {\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n /// @param x The liquidity before change\n /// @param y The delta by which liquidity should be changed\n /// @return z The liquidity delta\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\n if (y < 0) {\n require((z = x - uint128(-y)) < x, \"LS\");\n } else {\n require((z = x + uint128(y)) >= x, \"LA\");\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LowGasSafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\n/// @title Optimized overflow and underflow safe math operations\n/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost\nlibrary LowGasSafeMath {\n /// @notice Returns x + y, reverts if sum overflows uint256\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x);\n }\n\n /// @notice Returns x - y, reverts if underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x);\n }\n\n /// @notice Returns x * y, reverts if overflows\n /// @param x The multiplicand\n /// @param y The multiplier\n /// @return z The product of x and y\n function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require(x == 0 || (z = x * y) / x == y);\n }\n\n /// @notice Returns x + y, reverts if overflows or underflows\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x + y) >= x == (y >= 0));\n }\n\n /// @notice Returns x - y, reverts if overflows or underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x - y) <= x == (y >= 0));\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Safe casting methods\n/// @notice Contains methods for safely casting between types\nlibrary SafeCast {\n /// @notice Cast a uint256 to a uint160, revert on overflow\n /// @param y The uint256 to be downcasted\n /// @return z The downcasted integer, now type uint160\n function toUint160(uint256 y) internal pure returns (uint160 z) {\n require((z = uint160(y)) == y);\n }\n\n /// @notice Cast a int256 to a int128, revert on overflow or underflow\n /// @param y The int256 to be downcasted\n /// @return z The downcasted integer, now type int128\n function toInt128(int256 y) internal pure returns (int128 z) {\n require((z = int128(y)) == y);\n }\n\n /// @notice Cast a uint256 to a int256, revert on overflow\n /// @param y The uint256 to be casted\n /// @return z The casted integer, now type int256\n function toInt256(uint256 y) internal pure returns (int256 z) {\n require(y < 2**255);\n z = int256(y);\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SqrtPriceMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../FullMath.sol\";\nimport \"./UnsafeMath.sol\";\nimport \"./FixedPoint96.sol\";\nimport \"./BitMath.sol\";\n\n/// @title Functions based on Q64.96 sqrt price and liquidity\n/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas\nlibrary SqrtPriceMath {\n using LowGasSafeMath for uint256;\n using SafeCast for uint256;\n\n /// @notice Gets the next sqrt price given a delta of token0\n /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the\n /// price less in order to not send too much output.\n /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),\n /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).\n /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token0 to add or remove from virtual reserves\n /// @param add Whether to add or remove the amount of token0\n /// @return The price after adding or removing amount, depending on add\n function getNextSqrtPriceFromAmount0RoundingUp(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price\n if (amount == 0) return sqrtPX96;\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n\n bool overflow = false;\n if (numerator1 != 0 && sqrtPX96 != 0)\n overflow = uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(sqrtPX96)) >= 254;\n\n if (add) {\n uint256 product;\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 + product;\n if (denominator >= numerator1) {\n // always fits in 160 bits\n return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));\n }\n }\n\n return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));\n } else {\n uint256 product;\n // if the product overflows, we know the denominator underflows\n // in addition, we must check that the denominator does not underflow\n require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 - product;\n return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();\n }\n }\n\n /// @notice Gets the next sqrt price given a delta of token1\n /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the\n /// price less in order to not send too much output.\n /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity\n /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token1 to add, or remove, from virtual reserves\n /// @param add Whether to add, or remove, the amount of token1\n /// @return The price after adding or removing `amount`\n function getNextSqrtPriceFromAmount1RoundingDown(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // if we're adding (subtracting), rounding down requires rounding the quotient down (up)\n // in both cases, avoid a mulDiv for most inputs\n if (add) {\n uint256 quotient = (\n amount <= type(uint160).max\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\n );\n\n return uint256(sqrtPX96).add(quotient).toUint160();\n } else {\n uint256 quotient = (\n amount <= type(uint160).max\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\n );\n\n require(sqrtPX96 > quotient);\n // always fits 160 bits\n return uint160(sqrtPX96 - quotient);\n }\n }\n\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountIn How much of token0, or token1, is being swapped in\n /// @param zeroForOne Whether the amount in is token0 or token1\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\n function getNextSqrtPriceFromInput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountIn,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we don't pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\n }\n\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\n /// @param sqrtPX96 The starting price before accounting for the output amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountOut How much of token0, or token1, is being swapped out\n /// @param zeroForOne Whether the amount out is token0 or token1\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\n function getNextSqrtPriceFromOutput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountOut,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\n }\n\n /// @notice Gets the amount0 delta between two prices\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up or down\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount0) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\n require(sqrtRatioAX96 > 0);\n\n bool overflow = false;\n if (numerator1 != 0 && numerator2 != 0)\n overflow =\n uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(numerator2)) >= 254;\n\n if (overflow) {\n return\n roundUp\n ? FullMath.mulDivRoundingUp(\n FullMath.mulDivRoundingUp(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n )\n : FullMath.mulDiv(\n FullMath.mulDiv(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n );\n } else {\n return\n roundUp\n ? UnsafeMath.divRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96)\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\n }\n }\n\n /// @notice Gets the amount1 delta between two prices\n /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up, or down\n /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return\n roundUp\n ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)\n : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n }\n\n /// @notice Helper that gets signed token0 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount0 delta\n /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount0) {\n return\n liquidity < 0\n ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n\n /// @notice Helper that gets signed token1 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount1 delta\n /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount1) {\n return\n liquidity < 0\n ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SwapMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"../../FullMath.sol\";\nimport \"./SqrtPriceMath.sol\";\n\n/// @title Computes the result of a swap within ticks\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\nlibrary SwapMath {\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\n /// @param liquidity The usable liquidity\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\n /// @return feeAmount The amount of input that will be taken as a fee\n function computeSwapStep(\n uint160 sqrtRatioCurrentX96,\n uint160 sqrtRatioTargetX96,\n uint128 liquidity,\n int256 amountRemaining,\n uint24 feePips,\n bool zeroForOne\n )\n internal\n pure\n returns (\n uint160 sqrtRatioNextX96,\n uint256 amountIn,\n uint256 amountOut,\n uint256 feeAmount\n )\n {\n require(zeroForOne == sqrtRatioCurrentX96 >= sqrtRatioTargetX96, \"SPD\");\n bool exactIn = amountRemaining >= 0;\n\n if (exactIn) {\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\n amountIn = zeroForOne\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\n sqrtRatioCurrentX96,\n liquidity,\n amountRemainingLessFee,\n zeroForOne\n );\n } else {\n amountOut = zeroForOne\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\n\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\n sqrtRatioCurrentX96,\n liquidity,\n uint256(-amountRemaining),\n zeroForOne\n );\n }\n\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\n\n // get the input/output amounts\n if (zeroForOne) {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\n } else {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\n }\n\n // cap the output amount to not exceed the remaining output amount\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\n amountOut = uint256(-amountRemaining);\n }\n\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\n // we didn't reach the target, so take the remainder of the maximum input as fee\n feeAmount = uint256(amountRemaining) - amountIn;\n } else {\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/Tick.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../TickMath.sol\";\nimport \"./LiquidityMath.sol\";\n\n/// @title Tick\n/// @notice Contains functions for managing tick processes and relevant calculations\n\n/// Ithil to modify it, since it does not have access to storage arrays\nlibrary Tick {\n using LowGasSafeMath for int256;\n using SafeCast for int256;\n\n // info stored for each initialized individual tick\n struct Info {\n // the total position liquidity that references this tick\n uint128 liquidityGross;\n // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),\n int128 liquidityNet;\n // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint256 feeGrowthOutside0X128;\n uint256 feeGrowthOutside1X128;\n // the cumulative tick value on the other side of the tick\n int56 tickCumulativeOutside;\n // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint160 secondsPerLiquidityOutsideX128;\n // the seconds spent on the other side of the tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint32 secondsOutside;\n // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0\n // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks\n bool initialized;\n }\n\n /// @notice Derives max liquidity per tick from given tick spacing\n /// @dev Executed within the pool constructor\n /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`\n /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...\n /// @return The max liquidity per tick\n function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {\n int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\n int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\n uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;\n return type(uint128).max / numTicks;\n }\n\n /// @notice Retrieves fee growth data\n /// Ithil: only use it with lower = self[tickLower] and upper = self[tickUpper]\n /// @param lower The info of the lower tick boundary of the position\n /// @param upper The info of the upper tick boundary of the position\n /// @param tickLower The lower tick boundary of the position\n /// @param tickUpper The upper tick boundary of the position\n /// @param tickCurrent The current tick\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries\n /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries\n function getFeeGrowthInside(\n Tick.Info memory lower,\n Tick.Info memory upper,\n int24 tickLower,\n int24 tickUpper,\n int24 tickCurrent,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128\n ) internal pure returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n // calculate fee growth below\n uint256 feeGrowthBelow0X128;\n uint256 feeGrowthBelow1X128;\n if (tickCurrent >= tickLower) {\n feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;\n } else {\n feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;\n }\n\n // calculate fee growth above\n uint256 feeGrowthAbove0X128;\n uint256 feeGrowthAbove1X128;\n if (tickCurrent < tickUpper) {\n feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;\n } else {\n feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;\n }\n\n feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;\n feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;\n }\n\n /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa\n /// Ithil: always use with info = self[tick]\n /// @param info The info tick that will be updated\n /// @param tick The tick that will be updated\n /// @param tickCurrent The current tick\n /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block timestamp cast to a uint32\n /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick\n /// @param maxLiquidity The maximum liquidity allocation for a single tick\n /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa\n function update(\n Tick.Info memory info,\n int24 tick,\n int24 tickCurrent,\n int128 liquidityDelta,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time,\n bool upper,\n uint128 maxLiquidity\n ) internal pure returns (bool flipped) {\n uint128 liquidityGrossBefore = info.liquidityGross;\n uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);\n\n require(liquidityGrossAfter <= maxLiquidity, \"LO\");\n\n flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);\n\n if (liquidityGrossBefore == 0) {\n // by convention, we assume that all growth before a tick was initialized happened _below_ the tick\n if (tick <= tickCurrent) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;\n info.tickCumulativeOutside = tickCumulative;\n info.secondsOutside = time;\n }\n info.initialized = true;\n }\n\n info.liquidityGross = liquidityGrossAfter;\n\n // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)\n info.liquidityNet = upper\n ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()\n : int256(info.liquidityNet).add(liquidityDelta).toInt128();\n }\n\n /// @notice Transitions to next tick as needed by price movement\n /// @param info The result of the mapping containing all tick information for initialized ticks\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block.timestamp\n /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)\n function cross(\n Tick.Info memory info,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time\n ) internal pure returns (int128 liquidityNet) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;\n info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;\n info.secondsOutside = time - info.secondsOutside;\n liquidityNet = info.liquidityNet;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/TickBitmap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./BitMath.sol\";\n\n/// @title Packed tick initialized state library\n/// @notice Stores a packed mapping of tick index to its initialized state\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\nlibrary TickBitmap {\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\n /// @param tick The tick for which to compute the position\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\n /// @return bitPos The bit position in the word where the flag is stored\n /// @dev simply divides @param tick by 256 with remainder: tick = wordPos * 256 + bitPos\n function position(int24 tick) internal pure returns (int16 wordPos, uint8 bitPos) {\n wordPos = int16(tick >> 8);\n bitPos = uint8(int8(tick % 256));\n }\n\n /// Written by Ithil\n function computeWordPos(\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int16 wordPos) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n (wordPos, ) = lte ? position(compressed) : position(compressed + 1);\n }\n\n /// @notice Flips the initialized state for a given tick from false to true, or vice versa\n /// @param selfResult The result of the mapping in which to flip the tick (Ithil modified)\n /// @param tick The tick to flip\n /// @param tickSpacing The spacing between usable ticks\n function flipTick(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing\n ) internal pure {\n require(tick % tickSpacing == 0); // ensure that the tick is spaced\n (, uint8 bitPos) = position(tick / tickSpacing);\n uint256 mask = 1 << bitPos;\n selfResult ^= mask;\n }\n\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\n /// to the left (less than or equal to) or right (greater than) of the given tick\n /// @param selfResult The result of the mapping in which to compute the next initialized tick (Ithil modified)\n /// @param tick The starting tick\n /// @param tickSpacing The spacing between usable ticks\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\n function nextInitializedTickWithinOneWord(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int24 next, bool initialized) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n if (lte) {\n (, uint8 bitPos) = position(compressed);\n // all the 1s at or to the right of the current bitPos\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed - int24(uint24(bitPos) - uint24(BitMath.mostSignificantBit(masked)))) * tickSpacing\n : (compressed - int24(uint24(bitPos))) * tickSpacing;\n } else {\n // start from the word of the next tick, since the current tick state doesn't matter\n (, uint8 bitPos) = position(compressed + 1);\n // all the 1s at or to the left of the bitPos\n uint256 mask = ~((1 << bitPos) - 1);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed + 1 + int24(uint24(BitMath.leastSignificantBit(masked) - bitPos))) * tickSpacing\n : (compressed + 1 + int24(uint24(type(uint8).max - bitPos))) * tickSpacing;\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/UnsafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math functions that do not check inputs or outputs\n/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks\nlibrary UnsafeMath {\n /// @notice Returns ceil(x / y)\n /// @dev division by 0 has unspecified behavior, and must be checked externally\n /// @param x The dividend\n /// @param y The divisor\n /// @return z The quotient, ceil(x / y)\n function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n z := add(div(x, y), gt(mod(x, y), 0))\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../IUniswapV3Factory.sol\";\nimport \"./interfaces/IQuoter.sol\";\nimport \"./UniswapV3Quoter.sol\";\n\ncontract Quoter is IQuoter, UniswapV3Quoter {\n IUniswapV3Factory internal uniV3Factory; // TODO should it be immutable?\n\n constructor(address _uniV3Factory) {\n uniV3Factory = IUniswapV3Factory(_uniV3Factory);\n }\n\n // This should be equal to quoteExactInputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateOutputSingle(_toToken, _fromToken, _amount, pool);\n }\n\n // This should be equal to quoteExactOutputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateInputSingle(_fromToken, _toToken, _amount, pool);\n }\n\n // todo: add price limit\n function _estimateOutputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken > _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n else amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n }\n\n // todo: add price limit\n function _estimateInputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken < _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n -int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n else amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n }\n\n function doesPoolExist(address _token0, address _token1) external view returns (bool) {\n // try 0.05%\n address pool = uniV3Factory.getPool(_token0, _token1, 500);\n if (pool != address(0)) return true;\n\n // try 0.3%\n pool = uniV3Factory.getPool(_token0, _token1, 3000);\n if (pool != address(0)) return true;\n\n // try 1%\n pool = uniV3Factory.getPool(_token0, _token1, 10000);\n if (pool != address(0)) return true;\n else return false;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/UniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.6;\n\nimport \"./libraries/LowGasSafeMath.sol\";\nimport \"./libraries/SafeCast.sol\";\nimport \"./libraries/Tick.sol\";\nimport \"./libraries/TickBitmap.sol\";\n\nimport \"../FullMath.sol\";\nimport \"../TickMath.sol\";\nimport \"./libraries/LiquidityMath.sol\";\nimport \"./libraries/SqrtPriceMath.sol\";\nimport \"./libraries/SwapMath.sol\";\n\nimport \"./interfaces/IUniswapV3Quoter.sol\";\nimport \"../IUniswapV3Pool.sol\";\nimport \"../IUniswapV3PoolImmutables.sol\";\n\ncontract UniswapV3Quoter {\n using LowGasSafeMath for int256;\n using SafeCast for uint256;\n using Tick for mapping(int24 => Tick.Info);\n\n struct PoolState {\n // the current price\n uint160 sqrtPriceX96;\n // the current tick\n int24 tick;\n // the tick spacing\n int24 tickSpacing;\n // the pool's fee\n uint24 fee;\n // the pool's liquidity\n uint128 liquidity;\n // whether the pool is locked\n bool unlocked;\n }\n\n // accumulated protocol fees in token0/token1 units\n struct ProtocolFees {\n uint128 token0;\n uint128 token1;\n }\n\n // the top level state of the swap, the results of which are recorded in storage at the end\n struct SwapState {\n // the amount remaining to be swapped in/out of the input/output asset\n int256 amountSpecifiedRemaining;\n // the amount already swapped out/in of the output/input asset\n int256 amountCalculated;\n // current sqrt(price)\n uint160 sqrtPriceX96;\n // the tick associated with the current price\n int24 tick;\n // the current liquidity in range\n uint128 liquidity;\n }\n\n struct StepComputations {\n // the price at the beginning of the step\n uint160 sqrtPriceStartX96;\n // the next tick to swap to from the current tick in the swap direction\n int24 tickNext;\n // whether tickNext is initialized or not\n bool initialized;\n // sqrt(price) for the next tick (1/0)\n uint160 sqrtPriceNextX96;\n // how much is being swapped in in this step\n uint256 amountIn;\n // how much is being swapped out\n uint256 amountOut;\n // how much fee is being paid in\n uint256 feeAmount;\n }\n\n struct InitialState {\n address poolAddress;\n PoolState poolState;\n uint256 feeGrowthGlobal0X128;\n uint256 feeGrowthGlobal1X128;\n }\n\n struct NextTickPassage {\n int24 tick;\n int24 tickSpacing;\n }\n\n function fetchState(address _pool) internal view returns (PoolState memory poolState) {\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\n (uint160 sqrtPriceX96, int24 tick, , , , , bool unlocked) = pool.slot0(); // external call\n uint128 liquidity = pool.liquidity(); // external call\n int24 tickSpacing = IUniswapV3PoolImmutables(_pool).tickSpacing(); // external call\n uint24 fee = IUniswapV3PoolImmutables(_pool).fee(); // external call\n poolState = PoolState(sqrtPriceX96, tick, tickSpacing, fee, liquidity, unlocked);\n }\n\n function setInitialState(\n PoolState memory initialPoolState,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n )\n internal\n pure\n returns (\n SwapState memory state,\n uint128 liquidity,\n uint160 sqrtPriceX96\n )\n {\n liquidity = initialPoolState.liquidity;\n\n sqrtPriceX96 = initialPoolState.sqrtPriceX96;\n\n require(\n zeroForOne\n ? sqrtPriceLimitX96 < initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO\n : sqrtPriceLimitX96 > initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,\n \"SPL\"\n );\n\n state = SwapState({\n amountSpecifiedRemaining: amountSpecified,\n amountCalculated: 0,\n sqrtPriceX96: initialPoolState.sqrtPriceX96,\n tick: initialPoolState.tick,\n liquidity: 0 // to be modified after initialization\n });\n }\n\n function getNextTickAndPrice(\n int24 tickSpacing,\n int24 currentTick,\n IUniswapV3Pool pool,\n bool zeroForOne\n )\n internal\n view\n returns (\n int24 tickNext,\n bool initialized,\n uint160 sqrtPriceNextX96\n )\n {\n int24 compressed = currentTick / tickSpacing;\n if (!zeroForOne) compressed++;\n if (currentTick < 0 && currentTick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n uint256 selfResult = pool.tickBitmap(int16(compressed >> 8)); // external call\n\n (tickNext, initialized) = TickBitmap.nextInitializedTickWithinOneWord(\n selfResult,\n currentTick,\n tickSpacing,\n zeroForOne\n );\n\n if (tickNext < TickMath.MIN_TICK) {\n tickNext = TickMath.MIN_TICK;\n } else if (tickNext > TickMath.MAX_TICK) {\n tickNext = TickMath.MAX_TICK;\n }\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\n }\n\n function processSwapWithinTick(\n IUniswapV3Pool pool,\n PoolState memory initialPoolState,\n SwapState memory state,\n uint160 firstSqrtPriceX96,\n uint128 firstLiquidity,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne,\n bool exactAmount\n )\n internal\n view\n returns (\n uint160 sqrtPriceNextX96,\n uint160 finalSqrtPriceX96,\n uint128 finalLiquidity\n )\n {\n StepComputations memory step;\n\n step.sqrtPriceStartX96 = firstSqrtPriceX96;\n\n (step.tickNext, step.initialized, sqrtPriceNextX96) = getNextTickAndPrice(\n initialPoolState.tickSpacing,\n state.tick,\n pool,\n zeroForOne\n );\n\n (finalSqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\n firstSqrtPriceX96,\n (zeroForOne ? sqrtPriceNextX96 < sqrtPriceLimitX96 : sqrtPriceNextX96 > sqrtPriceLimitX96)\n ? sqrtPriceLimitX96\n : sqrtPriceNextX96,\n firstLiquidity,\n state.amountSpecifiedRemaining,\n initialPoolState.fee,\n zeroForOne\n );\n\n if (exactAmount) {\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\n } else {\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\n }\n\n if (finalSqrtPriceX96 == sqrtPriceNextX96) {\n if (step.initialized) {\n (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext);\n if (zeroForOne) liquidityNet = -liquidityNet;\n finalLiquidity = LiquidityMath.addDelta(firstLiquidity, liquidityNet);\n }\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\n } else if (finalSqrtPriceX96 != step.sqrtPriceStartX96) {\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\n state.tick = TickMath.getTickAtSqrtRatio(finalSqrtPriceX96);\n }\n }\n\n function returnedAmount(\n SwapState memory state,\n int256 amountSpecified,\n bool zeroForOne\n ) internal pure returns (int256 amount0, int256 amount1) {\n if (amountSpecified > 0) {\n (amount0, amount1) = zeroForOne\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\n } else {\n (amount0, amount1) = zeroForOne\n ? (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining)\n : (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated);\n }\n }\n\n function quoteSwap(\n address poolAddress,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n ) internal view returns (int256 amount0, int256 amount1) {\n bool exactAmount = amountSpecified > 0;\n\n PoolState memory initialPoolState = fetchState(poolAddress);\n uint160 sqrtPriceNextX96;\n\n (SwapState memory state, uint128 liquidity, uint160 sqrtPriceX96) = setInitialState(\n initialPoolState,\n amountSpecified,\n sqrtPriceLimitX96,\n zeroForOne\n );\n\n while (state.amountSpecifiedRemaining != 0 && sqrtPriceX96 != sqrtPriceLimitX96)\n (sqrtPriceNextX96, sqrtPriceX96, liquidity) = processSwapWithinTick(\n IUniswapV3Pool(poolAddress),\n initialPoolState,\n state,\n sqrtPriceX96,\n liquidity,\n sqrtPriceLimitX96,\n zeroForOne,\n exactAmount\n );\n\n (amount0, amount1) = returnedAmount(state, amountSpecified, zeroForOne);\n }\n}\n" + }, + "contracts/external/uniswap/TickMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Cast MAX_TICK to int256 before casting to uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n int24 internal constant MIN_TICK = -887272;\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n int24 internal constant MAX_TICK = -MIN_TICK;\n\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\n /// @dev Throws if |tick| > max tick\n /// @param tick The input tick for the above formula\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n /// at the given tick\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n unchecked {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n if (tick > 0) ratio = type(uint256).max / ratio;\n\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n }\n }\n\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n /// ever return.\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n unchecked {\n // second inequality must be < because the price can never reach the price at the max tick\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, \"R\");\n uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n uint256 r = ratio;\n uint256 msb = 0;\n\n assembly {\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(5, gt(r, 0xFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(4, gt(r, 0xFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(3, gt(r, 0xFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(2, gt(r, 0xF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(1, gt(r, 0x3))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := gt(r, 0x1)\n msb := or(msb, f)\n }\n\n if (msb >= 128) r = ratio >> (msb - 127);\n else r = ratio << (127 - msb);\n\n int256 log_2 = (int256(msb) - 128) << 64;\n\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(63, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(62, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(61, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(60, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(59, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(58, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(57, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(56, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(55, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(54, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(53, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(52, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(51, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(50, f))\n }\n\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n }\n }\n}\n" + }, + "contracts/external/uniswap/UniswapV2Library.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Pair.sol\";\nimport \"./IUniswapV2Factory.sol\";\n\nlibrary UniswapV2Library {\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, \"UniswapV2Library: IDENTICAL_ADDRESSES\");\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), \"UniswapV2Library: ZERO_ADDRESS\");\n }\n\n function pairFor(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (address pair) {\n return IUniswapV2Factory(factory).getPair(tokenA, tokenB);\n }\n\n // fetches and sorts the reserves for a pair\n function getReserves(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (uint256 reserveA, uint256 reserveB) {\n (address token0, ) = sortTokens(tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n }\n\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) internal pure returns (uint256 amountB) {\n require(amountA > 0, \"UniswapV2Library: INSUFFICIENT_AMOUNT\");\n require(reserveA > 0 && reserveB > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n amountB = (amountA * reserveB) / reserveA;\n }\n\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountOut) {\n require(amountIn > 0, \"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 amountInWithFee = amountIn * (10000 - flashSwapFee);\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = reserveIn * 10000 + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountIn) {\n require(amountOut > 0, \"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 numerator = reserveIn * amountOut * 10000;\n uint256 denominator = (reserveOut - amountOut) * (10000 - flashSwapFee);\n amountIn = numerator / denominator + 1;\n }\n\n // performs chained getAmountOut calculations on any number of pairs\n function getAmountsOut(\n address factory,\n uint256 amountIn,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[0] = amountIn;\n for (uint256 i; i < path.length - 1; i++) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n\n // performs chained getAmountIn calculations on any number of pairs\n function getAmountsIn(\n address factory,\n uint256 amountOut,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[amounts.length - 1] = amountOut;\n for (uint256 i = path.length - 1; i > 0; i--) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n}\n" + }, + "contracts/external/velodrome/IVelodromeRouter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRouter_Velodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidPath();\n error OnlyWETH();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of Velodrome v2 pool factory\n function factory() external view returns (address);\n\n /// @notice Address of Velodrome v2 pool implementation\n function poolImplementation() external view returns (address);\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n}\n" + }, + "contracts/external/yearn/IVault.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IVault {\n function getPricePerFullShare() external view returns (uint256);\n\n function token() external view returns (address);\n\n function decimals() external view returns (uint8);\n\n function deposit(uint256 _amount) external;\n\n function withdraw(uint256 _shares) external;\n}\n" + }, + "contracts/external/yearn/IVaultV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IVaultV2 {\n function pricePerShare() external view returns (uint256);\n\n function token() external view returns (address);\n\n function decimals() external view returns (uint8);\n\n function deposit(uint256 _amount) external returns (uint256);\n\n function withdraw(uint256 maxShares) external returns (uint256);\n}\n" + }, + "contracts/FeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { CErc20Delegator } from \"./compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"./compound/CErc20PluginDelegate.sol\";\nimport { SafeOwnableUpgradeable } from \"./ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { DiamondExtension, DiamondBase } from \"./ionic/DiamondExtension.sol\";\nimport { AuthoritiesRegistry } from \"./ionic/AuthoritiesRegistry.sol\";\n\ncontract FeeDistributorStorage {\n struct CDelegateUpgradeData {\n address implementation;\n bytes becomeImplementationData;\n }\n\n /**\n * @notice Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n * @dev A value of 0 means unset whereas a negative value means 0.\n */\n mapping(address => int256) public customInterestFeeRates;\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n mapping(address => address) internal _latestComptrollerImplementation;\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n mapping(uint8 => CDelegateUpgradeData) internal _latestCErc20Delegate;\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n mapping(address => address) internal _latestPluginImplementation;\n\n mapping(address => DiamondExtension[]) public comptrollerExtensions;\n\n mapping(address => DiamondExtension[]) public cErc20DelegateExtensions;\n\n AuthoritiesRegistry public authoritiesRegistry;\n\n /**\n * @dev used as salt for the creation of new markets\n */\n uint256 public marketsCounter;\n\n /**\n * @dev Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n */\n uint256 public minBorrowEth;\n\n /**\n * @dev Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n * No longer used as of `Rari-Capital/compound-protocol` version `fuse-v1.1.0`.\n */\n uint256 public maxUtilizationRate;\n\n /**\n * @notice The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n uint256 public defaultInterestFeeRate;\n}\n\n/**\n * @title FeeDistributor\n * @author David Lucid (https://github.com/davidlucid)\n * @notice FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\n */\ncontract FeeDistributor is SafeOwnableUpgradeable, FeeDistributorStorage {\n using AddressUpgradeable for address;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Initializer that sets initial values of state variables.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function initialize(uint256 _defaultInterestFeeRate) public initializer {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n __SafeOwnable_init(msg.sender);\n defaultInterestFeeRate = _defaultInterestFeeRate;\n maxUtilizationRate = type(uint256).max;\n }\n\n function reinitialize(AuthoritiesRegistry _ar) public onlyOwnerOrAdmin {\n authoritiesRegistry = _ar;\n }\n\n /**\n * @dev Sets the default proportion of Ionic pool interest taken as a protocol fee.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setDefaultInterestFeeRate(uint256 _defaultInterestFeeRate) external onlyOwner {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n defaultInterestFeeRate = _defaultInterestFeeRate;\n }\n\n /**\n * @dev Withdraws accrued fees on interest.\n * @param erc20Contract The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\n */\n function _withdrawAssets(address erc20Contract) external {\n if (erc20Contract == address(0)) {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No balance available to withdraw.\");\n (bool success, ) = owner().call{ value: balance }(\"\");\n require(success, \"Failed to transfer ETH balance to msg.sender.\");\n } else {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 balance = token.balanceOf(address(this));\n require(balance > 0, \"No token balance available to withdraw.\");\n token.safeTransfer(owner(), balance);\n }\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param _minBorrowEth Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n * @param _maxUtilizationRate Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n */\n function _setPoolLimits(uint256 _minBorrowEth, uint256 _maxUtilizationRate) external onlyOwner {\n minBorrowEth = _minBorrowEth;\n maxUtilizationRate = _maxUtilizationRate;\n }\n\n function getMinBorrowEth(ICErc20 _ctoken) public view returns (uint256) {\n (, , uint256 borrowBalance, ) = _ctoken.getAccountSnapshot(_msgSender());\n if (borrowBalance == 0) return minBorrowEth;\n IonicComptroller comptroller = IonicComptroller(address(_ctoken.comptroller()));\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPriceEth = oracle.price(ICErc20(address(_ctoken)).underlying());\n uint256 underlyingDecimals = _ctoken.decimals();\n uint256 borrowBalanceEth = (underlyingPriceEth * borrowBalance) / 10**underlyingDecimals;\n if (borrowBalanceEth > minBorrowEth) {\n return 0;\n }\n return minBorrowEth - borrowBalanceEth;\n }\n\n /**\n * @dev Receives native fees.\n */\n receive() external payable {}\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes[] calldata data) external onlyOwner {\n require(targets.length > 0 && targets.length == data.length, \"Array lengths must be equal and greater than 0.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data[i]);\n }\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes calldata data) external onlyOwner {\n require(targets.length > 0, \"No target addresses specified.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data);\n }\n\n /**\n * @dev Deploys a CToken for an underlying ERC20\n * @param constructorData Encoded construction data for `CToken initialize()`\n */\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address) {\n // Make sure comptroller == msg.sender\n (address underlying, address comptroller) = abi.decode(constructorData[0:64], (address, address));\n require(comptroller == msg.sender, \"Comptroller is not sender.\");\n\n // Deploy CErc20Delegator using msg.sender, underlying, and block.number as a salt\n bytes32 salt = keccak256(abi.encodePacked(msg.sender, underlying, ++marketsCounter));\n\n bytes memory cErc20DelegatorCreationCode = abi.encodePacked(type(CErc20Delegator).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(0, salt, cErc20DelegatorCreationCode);\n\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n DiamondExtension delegateAsExtension = DiamondExtension(data.implementation);\n // register the first extension\n DiamondBase(proxy)._registerExtension(delegateAsExtension, DiamondExtension(address(0)));\n // derive and configure the other extensions\n DiamondExtension[] memory ctokenExts = cErc20DelegateExtensions[address(delegateAsExtension)];\n for (uint256 i = 0; i < ctokenExts.length; i++) {\n if (ctokenExts[i] == delegateAsExtension) continue;\n DiamondBase(proxy)._registerExtension(ctokenExts[i], DiamondExtension(address(0)));\n }\n CErc20PluginDelegate(address(proxy))._becomeImplementation(becomeImplData);\n\n return proxy;\n }\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n function latestComptrollerImplementation(address oldImplementation) external view returns (address) {\n return\n _latestComptrollerImplementation[oldImplementation] != address(0)\n ? _latestComptrollerImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest `Comptroller` upgrade implementation address.\n * @param oldImplementation The old `Comptroller` implementation address to upgrade from.\n * @param newImplementation Latest `Comptroller` implementation address.\n */\n function _setLatestComptrollerImplementation(address oldImplementation, address newImplementation)\n external\n onlyOwner\n {\n _latestComptrollerImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n function latestCErc20Delegate(uint8 delegateType) external view returns (address, bytes memory) {\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n bytes memory emptyBytes;\n return\n data.implementation != address(0)\n ? (data.implementation, data.becomeImplementationData)\n : (address(0), emptyBytes);\n }\n\n /**\n * @dev Sets the latest `CErc20Delegate` upgrade implementation address and data.\n * @param delegateType The old `CErc20Delegate` implementation address to upgrade from.\n * @param newImplementation Latest `CErc20Delegate` implementation address.\n * @param becomeImplementationData Data passed to the new implementation via `becomeImplementation` after upgrade.\n */\n function _setLatestCErc20Delegate(\n uint8 delegateType,\n address newImplementation,\n bytes calldata becomeImplementationData\n ) external onlyOwner {\n _latestCErc20Delegate[delegateType] = CDelegateUpgradeData(newImplementation, becomeImplementationData);\n }\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n function latestPluginImplementation(address oldImplementation) external view returns (address) {\n return\n _latestPluginImplementation[oldImplementation] != address(0)\n ? _latestPluginImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest plugin upgrade implementation address.\n * @param oldImplementation The old plugin implementation address to upgrade from.\n * @param newImplementation Latest plugin implementation address.\n */\n function _setLatestPluginImplementation(address oldImplementation, address newImplementation) external onlyOwner {\n _latestPluginImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\n * @param cDelegator the proxy address\n * @return if the plugin was upgraded or not\n */\n function _upgradePluginToLatestImplementation(address cDelegator) external onlyOwner returns (bool) {\n CErc20PluginDelegate market = CErc20PluginDelegate(cDelegator);\n\n address oldPluginAddress = address(market.plugin());\n market._updatePlugin(_latestPluginImplementation[oldPluginAddress]);\n address newPluginAddress = address(market.plugin());\n\n return newPluginAddress != oldPluginAddress;\n }\n\n /**\n * @notice Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function interestFeeRate() external view returns (uint256) {\n (bool success, bytes memory data) = msg.sender.staticcall(abi.encodeWithSignature(\"comptroller()\"));\n\n if (success && data.length == 32) {\n address comptroller = abi.decode(data, (address));\n int256 customRate = customInterestFeeRates[comptroller];\n if (customRate > 0) return uint256(customRate);\n if (customRate < 0) return 0;\n }\n\n return defaultInterestFeeRate;\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param comptroller The Unitroller (Comptroller proxy) address.\n * @param rate The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setCustomInterestFeeRate(address comptroller, int256 rate) external onlyOwner {\n require(rate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n customInterestFeeRates[comptroller] = rate;\n }\n\n function getComptrollerExtensions(address comptroller) external view returns (DiamondExtension[] memory) {\n return comptrollerExtensions[comptroller];\n }\n\n function _setComptrollerExtensions(address comptroller, DiamondExtension[] calldata extensions) external onlyOwner {\n comptrollerExtensions[comptroller] = extensions;\n }\n\n function _registerComptrollerExtension(\n address payable pool,\n DiamondExtension extensionToAdd,\n DiamondExtension extensionToReplace\n ) external onlyOwner {\n DiamondBase(pool)._registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (DiamondExtension[] memory) {\n return cErc20DelegateExtensions[cErc20Delegate];\n }\n\n function _setCErc20DelegateExtensions(address cErc20Delegate, DiamondExtension[] calldata extensions)\n external\n onlyOwner\n {\n cErc20DelegateExtensions[cErc20Delegate] = extensions;\n }\n\n function autoUpgradePool(IonicComptroller pool) external onlyOwner {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n // auto upgrade the pool\n pool._upgrade();\n\n for (uint8 i = 0; i < markets.length; i++) {\n // upgrade the market\n markets[i]._upgrade();\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n return authoritiesRegistry.canCall(pool, user, target, functionSig);\n }\n}\n" + }, + "contracts/GlobalPauser.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\ninterface IPoolDirectory {\n struct Pool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n function getActivePools() external view returns (uint256, Pool[] memory);\n}\n\ncontract GlobalPauser is Ownable2Step {\n IPoolDirectory public poolDirectory;\n mapping(address => bool) public pauseGuardian;\n\n modifier onlyPauseGuardian() {\n require(pauseGuardian[msg.sender], \"!guardian\");\n _;\n }\n\n constructor(address _poolDirectory) Ownable2Step() {\n poolDirectory = IPoolDirectory(_poolDirectory);\n }\n\n function setPauseGuardian(address _pauseGuardian, bool _isPauseGuardian) external onlyOwner {\n pauseGuardian[_pauseGuardian] = _isPauseGuardian;\n }\n\n function pauseAll() external onlyPauseGuardian {\n (, IPoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));\n if (!isPaused) {\n IonicComptroller(pools[i].comptroller)._setBorrowPaused(markets[j], true);\n }\n\n isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));\n if (!isPaused) {\n IonicComptroller(pools[i].comptroller)._setMintPaused(markets[j], true);\n }\n }\n }\n }\n}\n" + }, + "contracts/ILiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\n\ninterface ILiquidator {\n /**\n * borrower The borrower's Ethereum address.\n * repayAmount The amount to repay to liquidate the unhealthy loan.\n * cErc20 The borrowed CErc20 contract to repay.\n * cTokenCollateral The cToken collateral contract to be liquidated.\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\n */\n struct LiquidateToTokensWithFlashSwapVars {\n address borrower;\n uint256 repayAmount;\n ICErc20 cErc20;\n ICErc20 cTokenCollateral;\n address flashSwapContract;\n uint256 minProfitAmount;\n IRedemptionStrategy[] redemptionStrategies;\n bytes[] strategyData;\n IFundsConversionStrategy[] debtFundingStrategies;\n bytes[] debtFundingStrategiesData;\n }\n\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256);\n\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n returns (uint256);\n\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\n\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external;\n\n function setExpressRelay(address _expressRelay) external;\n\n function setPoolLens(address _poolLens) external;\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\n}\n" + }, + "contracts/ionic/AddressesProvider.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title AddressesProvider\n * @notice The Addresses Provider serves as a central storage of system internal and external\n * contract addresses that change between deploys and across chains\n * @author Veliko Minkov \n */\ncontract AddressesProvider is SafeOwnableUpgradeable {\n mapping(string => address) private _addresses;\n mapping(address => Contract) public plugins;\n mapping(address => Contract) public flywheelRewards;\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\n JarvisPool[] public jarvisPoolsConfig;\n CurveSwapPool[] public curveSwapPoolsConfig;\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\n\n /// @dev Initializer to set the admin that can set and change contracts addresses\n function initialize(address owner) public initializer {\n __SafeOwnable_init(owner);\n }\n\n /**\n * @dev The contract address and a string that uniquely identifies the contract's interface\n */\n struct Contract {\n address addr;\n string contractInterface;\n }\n\n struct RedemptionStrategy {\n address addr;\n string contractInterface;\n address outputToken;\n }\n\n struct FundingStrategy {\n address addr;\n string contractInterface;\n address inputToken;\n }\n\n struct JarvisPool {\n address syntheticToken;\n address collateralToken;\n address liquidityPool;\n uint256 expirationTime;\n }\n\n struct CurveSwapPool {\n address poolAddress;\n address[] coins;\n }\n\n /**\n * @dev sets the address and contract interface ID of the flywheel for the reward token\n * @param rewardToken the reward token address\n * @param flywheelRewardsModule the flywheel rewards module address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFlywheelRewards(\n address rewardToken,\n address flywheelRewardsModule,\n string calldata contractInterface\n ) public onlyOwner {\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\n * @param asset the asset address\n * @param plugin the ERC4626 plugin address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setPlugin(\n address asset,\n address plugin,\n string calldata contractInterface\n ) public onlyOwner {\n plugins[asset] = Contract(plugin, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\n * @param asset the asset address\n * @param strategy redemption strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setRedemptionStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address outputToken\n ) public onlyOwner {\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\n }\n\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\n return redemptionStrategiesConfig[asset];\n }\n\n /**\n * @dev sets the address and contract interface ID of the funding strategy for the asset\n * @param asset the asset address\n * @param strategy funding strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFundingStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address inputToken\n ) public onlyOwner {\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\n }\n\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\n return fundingStrategiesConfig[asset];\n }\n\n /**\n * @dev configures the Jarvis pool of a Jarvis synthetic token\n * @param syntheticToken the synthetic token address\n * @param collateralToken the collateral token address\n * @param liquidityPool the liquidity pool address\n * @param expirationTime the operation expiration time\n */\n function setJarvisPool(\n address syntheticToken,\n address collateralToken,\n address liquidityPool,\n uint256 expirationTime\n ) public onlyOwner {\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\n }\n\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\n }\n\n /**\n * @dev Sets an address for an id replacing the address saved in the addresses map\n * @param id The id\n * @param newAddress The address to set\n */\n function setAddress(string calldata id, address newAddress) external onlyOwner {\n _addresses[id] = newAddress;\n }\n\n /**\n * @dev Returns an address by id\n * @return The address\n */\n function getAddress(string calldata id) public view returns (address) {\n return _addresses[id];\n }\n\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\n return curveSwapPoolsConfig;\n }\n\n function getJarvisPools() public view returns (JarvisPool[] memory) {\n return jarvisPoolsConfig;\n }\n\n function setBalancerPoolForTokens(\n address inputToken,\n address outputToken,\n address pool\n ) external onlyOwner {\n balancerPoolForTokens[inputToken][outputToken] = pool;\n }\n\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\n return balancerPoolForTokens[inputToken][outputToken];\n }\n}\n" + }, + "contracts/ionic/AuthoritiesRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\n PoolRolesAuthority public poolAuthLogic;\n address public leveredPositionsFactory;\n bool public noAuthRequired;\n\n function initialize(address _leveredPositionsFactory) public initializer {\n __SafeOwnable_init(msg.sender);\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n }\n\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n // for Neon the auth is not required\n noAuthRequired = block.chainid == 245022934;\n }\n\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\n require(address(poolsAuthorities[pool]) == address(0), \"already created\");\n\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \"\");\n auth = PoolRolesAuthority(address(proxy));\n auth.initialize(address(this));\n poolsAuthorities[pool] = auth;\n\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\n // sets the registry owner as the auth owner\n reconfigureAuthority(pool);\n }\n\n function reconfigureAuthority(address poolAddress) public {\n IonicComptroller pool = IonicComptroller(poolAddress);\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\n\n if (msg.sender != poolAddress || address(auth) != address(0)) {\n require(address(auth) != address(0), \"no such authority\");\n require(msg.sender == owner() || msg.sender == poolAddress, \"not owner or pool\");\n\n auth.configureRegistryCapabilities();\n auth.configurePoolSupplierCapabilities(pool);\n auth.configurePoolBorrowerCapabilities(pool);\n // everyone can be a liquidator\n auth.configureOpenPoolLiquidatorCapabilities(pool);\n auth.configureLeveredPositionCapabilities(pool);\n\n if (auth.owner() != owner()) {\n auth.setOwner(owner());\n }\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\n if (address(authorityForPool) == address(0)) {\n return noAuthRequired;\n } else {\n // allow only if an auth exists and it allows the action\n return authorityForPool.canCall(user, target, functionSig);\n }\n }\n\n function setUserRole(\n address pool,\n address user,\n uint8 role,\n bool enabled\n ) external {\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\n\n require(address(poolAuth) != address(0), \"auth does not exist\");\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \"not owner or factory\");\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \"only lev pos role\");\n\n poolAuth.setUserRole(user, role, enabled);\n }\n}\n" + }, + "contracts/ionic/CollateralSwap.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nimport { IFlashLoanReceiver } from \"./IFlashLoanReceiver.sol\";\nimport { Exponential } from \"../compound/Exponential.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\ncontract CollateralSwap is Ownable2Step, Exponential, IFlashLoanReceiver {\n using SafeERC20 for IERC20;\n\n uint256 public feeBps;\n address public feeRecipient;\n IonicComptroller public comptroller;\n mapping(address => bool) public allowedSwapTargets;\n\n error SwapCollateralFailed();\n error TransferFailed(address market, address user, address target);\n error MintFailed(address market, uint256 errorCode);\n error RedeemFailed(address market, uint256 errorCode);\n error InvalidFlashloanCaller(address caller);\n error InvalidSwapTarget(address target);\n\n constructor(\n uint256 _feeBps,\n address _feeRecipient,\n address _comptroller,\n address[] memory _allowedSwapTargets\n ) Ownable2Step() {\n feeBps = _feeBps;\n feeRecipient = _feeRecipient;\n comptroller = IonicComptroller(_comptroller);\n for (uint256 i = 0; i < _allowedSwapTargets.length; i++) {\n allowedSwapTargets[_allowedSwapTargets[i]] = true;\n }\n }\n\n // ADMIN FUNCTIONS\n\n function setFeeBps(uint256 _feeBps) public onlyOwner {\n feeBps = _feeBps;\n }\n\n function setFeeRecipient(address _feeRecipient) public onlyOwner {\n feeRecipient = _feeRecipient;\n }\n\n function setAllowedSwapTarget(address _target, bool _allowed) public onlyOwner {\n allowedSwapTargets[_target] = _allowed;\n }\n\n function sweep(address token) public onlyOwner {\n IERC20(token).safeTransfer(owner(), IERC20(token).balanceOf(address(this)));\n }\n\n // PUBLIC FUNCTIONS\n\n function swapCollateral(\n uint256 amountUnderlying,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes calldata swapData\n ) public {\n oldCollateralMarket.flash(\n amountUnderlying,\n abi.encode(msg.sender, oldCollateralMarket, newCollateralMarket, swapTarget, swapData)\n );\n }\n\n function receiveFlashLoan(address borrowedAsset, uint256 borrowedAmount, bytes calldata data) external {\n // make sure the caller is a valid market\n {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n bool isAllowed = false;\n for (uint256 i = 0; i < markets.length; i++) {\n if (msg.sender == address(markets[i])) {\n isAllowed = true;\n break;\n }\n }\n if (!isAllowed) {\n revert InvalidFlashloanCaller(msg.sender);\n }\n }\n\n (\n address borrower,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes memory swapData\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes));\n\n // swap the collateral\n {\n if (!allowedSwapTargets[swapTarget]) {\n revert InvalidSwapTarget(swapTarget);\n }\n IERC20(borrowedAsset).approve(swapTarget, borrowedAmount);\n (bool success, ) = swapTarget.call(swapData);\n if (!success) {\n revert SwapCollateralFailed();\n }\n }\n\n // mint the new collateral\n {\n IERC20 newCollateralAsset = IERC20(newCollateralMarket.underlying());\n uint256 outputAmount = newCollateralAsset.balanceOf(address(this));\n uint256 fee = (outputAmount * feeBps) / 10_000;\n outputAmount -= fee;\n if (fee > 0) {\n newCollateralAsset.safeTransfer(feeRecipient, fee);\n }\n newCollateralAsset.approve(address(newCollateralMarket), outputAmount);\n uint256 mintResult = newCollateralMarket.mint(outputAmount);\n if (mintResult != 0) {\n revert MintFailed(address(newCollateralMarket), mintResult);\n }\n }\n\n // transfer the new collateral to the borrower\n {\n uint256 cTokenBalance = IERC20(address(newCollateralMarket)).balanceOf(address(this));\n IERC20(address(newCollateralMarket)).safeTransfer(borrower, cTokenBalance);\n }\n\n // withdraw the old collateral\n {\n (MathError mErr, uint256 amountCTokensToSwap) = divScalarByExpTruncate(\n borrowedAmount,\n Exp({ mantissa: oldCollateralMarket.exchangeRateCurrent() })\n );\n require(mErr == MathError.NO_ERROR, \"exchange rate error\");\n bool transferStatus = oldCollateralMarket.transferFrom(borrower, address(this), amountCTokensToSwap + 1);\n if (!transferStatus) {\n revert TransferFailed(address(oldCollateralMarket), borrower, address(this));\n }\n uint256 redeemResult = oldCollateralMarket.redeemUnderlying(type(uint256).max);\n if (redeemResult != 0) {\n revert RedeemFailed(address(oldCollateralMarket), redeemResult);\n }\n IERC20(borrowedAsset).approve(address(oldCollateralMarket), borrowedAmount);\n }\n // flashloan gets paid back from redeemed collateral\n }\n}\n" + }, + "contracts/ionic/DiamondExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @notice a base contract for logic extensions that use the diamond pattern storage\n * to map the functions when looking up the extension contract to delegate to.\n */\nabstract contract DiamondExtension {\n /**\n * @return a list of all the function selectors that this logic extension exposes\n */\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\n}\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\n// When no extension exists for function called\nerror ExtensionNotFound(bytes4 _functionSelector);\n\n// When the function is already added\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\n\nabstract contract DiamondBase {\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\n\n function _listExtensions() public view returns (address[] memory) {\n return LibDiamond.listExtensions();\n }\n\n fallback() external {\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n\n/**\n * @notice a library to use in a contract, whose logic is extended with diamond extension\n */\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.extensions.diamond.storage\");\n\n struct Function {\n address extension;\n bytes4 selector;\n }\n\n struct LogicStorage {\n Function[] functions;\n address[] extensions;\n }\n\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\n return getExtensionForSelector(msgSig, diamondStorage());\n }\n\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n function listExtensions() internal view returns (address[] memory) {\n return diamondStorage().extensions;\n }\n\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\n if (address(extensionToReplace) != address(0)) {\n removeExtension(extensionToReplace);\n }\n addExtension(extensionToAdd);\n }\n\n function removeExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n // remove all functions of the extension to replace\n removeExtensionFunctions(extension);\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n if (ds.extensions[i] == address(extension)) {\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\n ds.extensions.pop();\n }\n }\n }\n\n function addExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n require(ds.extensions[i] != address(extension), \"extension already added\");\n }\n addExtensionFunctions(extension);\n ds.extensions.push(address(extension));\n }\n\n function removeExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\n bytes4 selectorToRemove = fnsToRemove[i];\n // must never fail\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\n // swap with the last element in the selectorAtIndex array and remove the last element\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\n ds.functions.pop();\n }\n }\n\n function addExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n uint16 functionsCount = uint16(ds.functions.length);\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\n bytes4 selector = fnsToAdd[functionsIndex];\n address oldImplementation = getExtensionForSelector(selector, ds);\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\n ds.functions.push(Function(address(extension), selector));\n functionsCount++;\n }\n }\n\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\n uint256 fnsLen = ds.functions.length;\n for (uint256 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\n }\n\n return address(0);\n }\n\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\n uint16 fnsLen = uint16(ds.functions.length);\n for (uint16 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return i;\n }\n\n return type(uint16).max;\n }\n}\n" + }, + "contracts/ionic/IFlashLoanReceiver.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface IFlashLoanReceiver {\n function receiveFlashLoan(\n address borrowedAsset,\n uint256 borrowedAmount,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/ionic/irms/AdjustableJumpRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../../compound/InterestRateModel.sol\";\nimport \"../../compound/SafeMath.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title Compound's JumpRateModel Contract\n * @author Compound\n */\n\nstruct InterestRateModelParams {\n uint256 blocksPerYear; // The approximate number of blocks per year\n uint256 baseRatePerYear; // The approximate target base APR, as a mantissa (scaled by 1e18)\n uint256 multiplierPerYear; // The rate of increase in interest rate wrt utilization (scaled by 1e18)\n uint256 jumpMultiplierPerYear; // The multiplierPerBlock after hitting a specified utilization point\n uint256 kink; // The utilization point at which the jump multiplier is applied\n}\n\ncontract AdjustableJumpRateModel is Ownable, InterestRateModel {\n using SafeMath for uint256;\n\n event NewInterestParams(\n uint256 baseRatePerBlock,\n uint256 multiplierPerBlock,\n uint256 jumpMultiplierPerBlock,\n uint256 kink\n );\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint256 public blocksPerYear;\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint256 public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint256 public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint256 public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint256 public kink;\n\n /**\n * @notice Initialise an interest rate model\n */\n\n constructor(InterestRateModelParams memory params) {\n blocksPerYear = params.blocksPerYear;\n baseRatePerBlock = params.baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = params.multiplierPerYear.div(blocksPerYear);\n jumpMultiplierPerBlock = params.jumpMultiplierPerYear.div(blocksPerYear);\n kink = params.kink;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));\n }\n\n function _setIrmParameters(InterestRateModelParams memory params) public onlyOwner {\n blocksPerYear = params.blocksPerYear;\n baseRatePerBlock = params.baseRatePerYear.div(blocksPerYear);\n multiplierPerBlock = params.multiplierPerYear.div(blocksPerYear);\n jumpMultiplierPerBlock = params.jumpMultiplierPerYear.div(blocksPerYear);\n kink = params.kink;\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n uint256 util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n } else {\n uint256 normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);\n uint256 excessUtil = util.sub(kink);\n return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = uint256(1e18).sub(reserveFactorMantissa);\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);\n return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);\n }\n}\n" + }, + "contracts/ionic/irms/PrudentiaInterestRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\n\nimport { IRateComputer } from \"adrastia-periphery/rates/IRateComputer.sol\";\n\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\n/**\n * @title Adrastia Prudentia Interest Rate Model\n * @author TRILEZ SOFTWARE INC.\n */\ncontract PrudentiaInterestRateModel is InterestRateModel {\n using Math for uint256;\n\n /**\n * @notice The address of the underlying token for which the interest rate model calculates rates.\n */\n address public immutable underlyingToken;\n\n /**\n * @notice The address of the Adrastia Prudentia interest rate controller.\n */\n IRateComputer public immutable rateController;\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model.\n */\n uint256 public immutable blocksPerYear;\n\n /**\n * @notice Construct a new interest rate model that reads from an Adrastia Prudentia interest rate controller.\n *\n * @param blocksPerYear_ The approximate number of blocks per year that is assumed by the interest rate model.\n * @param underlyingToken_ The address of the underlying token for which the interest rate model calculates rates.\n * @param rateController_ The address of the Adrastia Prudentia interest rate controller.\n */\n constructor(\n uint256 blocksPerYear_,\n address underlyingToken_,\n IRateComputer rateController_\n ) {\n if (underlyingToken_ == address(0)) {\n revert(\"PrudentiaInterestRateModel: underlyingToken is the zero address\");\n }\n if (address(rateController_) == address(0)) {\n revert(\"PrudentiaInterestRateModel: rateController is the zero address\");\n }\n\n blocksPerYear = blocksPerYear_;\n underlyingToken = underlyingToken_;\n rateController = rateController_;\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`.\n *\n * @param cash The amount of cash in the market.\n * @param borrows The amount of borrows in the market.\n * @param reserves The amount of reserves in the market.\n *\n * @return The utilization rate as a mantissa between [0, 1e18].\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n uint256 total = cash + borrows - reserves;\n if (total == 0) {\n // Utilization rate is zero when nothing is available (prevents division by zero)\n return 0;\n }\n\n return (borrows * 1e18) / total;\n }\n\n /**\n * @notice Calculates the current borrow rate per block by reading the current rate from the Adrastia Prudentia\n * interest rate controller.\n *\n * @param cash Not used.\n * @param borrows Not used.\n * @param reserves Not used.\n *\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18).\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n // Silence unused variable warnings\n cash;\n borrows;\n reserves;\n\n uint256 annualRate = rateController.computeRate(underlyingToken);\n\n return annualRate.ceilDiv(blocksPerYear); // Convert the annual rate to a per-block rate, rounding up\n }\n\n /**\n * @notice Calculates the current supply rate per block.\n *\n * @param cash The amount of cash in the market.\n * @param borrows The amount of borrows in the market.\n * @param reserves The amount of reserves in the market.\n * @param reserveFactorMantissa The current reserve factor for the market.\n *\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18).\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\n\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\n }\n}\n" + }, + "contracts/ionic/levered/ILeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILeveredPositionFactoryStorage {\n function feeDistributor() external view returns (IFeeDistributor);\n\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\n\n function blocksPerYear() external view returns (uint256);\n\n function owner() external view returns (address);\n}\n\ninterface ILeveredPositionFactoryBase {\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external;\n}\n\ninterface ILeveredPositionFactoryFirstExtension {\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getMinBorrowNative() external view returns (uint256);\n\n function removeClosedPosition(address closedPosition) external returns (bool removed);\n\n function closeAndRemoveUserPosition(\n LeveredPosition position,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) external returns (bool);\n\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\n\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\n\n function getAccountsWithOpenPositions() external view returns (address[] memory);\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\n\n function getAllWhitelistedSwapRouters() external view returns (address[] memory);\n\n function isSwapRoutersWhitelisted(address swapRouter) external view returns (bool);\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\n\n function _setWhitelistedSwapRouters(address[] memory newSet) external;\n\n function calculateAdjustmentAmountDeltas(\n bool ratioIncreases,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice,\n uint256 expectedSlippage,\n uint256 positionSupplyAmount,\n uint256 debtAmount\n ) external pure returns (uint256 supplyDelta, uint256 borrowsDelta);\n}\n\ninterface ILeveredPositionFactorySecondExtension {\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external returns (LeveredPosition);\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio,\n address _fundingAssetSwapAggregatorTarget,\n bytes memory _fundingAssetSwapAggregatorData,\n address _adjustLeverageRatioAggregatorTarget,\n bytes memory _adjustLeverageRatioAggregatorData,\n uint256 _expectedSlippage\n ) external returns (LeveredPosition);\n}\n\ninterface ILeveredPositionFactoryExtension is\n ILeveredPositionFactoryFirstExtension,\n ILeveredPositionFactorySecondExtension\n{}\n\ninterface ILeveredPositionFactory is\n ILeveredPositionFactoryStorage,\n ILeveredPositionFactoryBase,\n ILeveredPositionFactoryExtension\n{}\n" + }, + "contracts/ionic/levered/LeveredPosition.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IFlashLoanReceiver } from \"../IFlashLoanReceiver.sol\";\nimport { IonicFlywheel } from \"../../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { LeveredPositionStorage } from \"./LeveredPositionStorage.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFlywheelLensRouter_LP {\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\n}\n\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error OnlyWhenClosed();\n error NotPositionOwner();\n error OnlyFactoryOwner();\n error AssetNotRescuable();\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\n\n error ConvertFundsFailed();\n error ExitFailed(uint256 errorCode);\n error RedeemFailed(uint256 errorCode);\n error SupplyCollateralFailed(uint256 errorCode);\n error BorrowStableFailed(uint256 errorCode);\n error RepayBorrowFailed(uint256 errorCode);\n error RedeemCollateralFailed(uint256 errorCode);\n error ExtNotFound(bytes4 _functionSelector);\n error RouterNotWhitelisted();\n error AggregatorCallFailed();\n error MarketsPoolsDiffer();\n error FlashLoanSourceError();\n error DelegateCallToNonContract();\n error LowLevelDelegateCallFailed();\n\n constructor(\n address _positionOwner,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket\n ) LeveredPositionStorage(_positionOwner) {\n IonicComptroller collateralPool = _collateralMarket.comptroller();\n IonicComptroller stablePool = _stableMarket.comptroller();\n if(collateralPool != stablePool) revert MarketsPoolsDiffer();\n pool = collateralPool;\n\n collateralMarket = _collateralMarket;\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\n stableMarket = _stableMarket;\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\n\n factory = ILeveredPositionFactory(msg.sender);\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\n fundPosition(fundingAsset, amount, address(0), \"\");\n }\n\n function fundPosition(\n IERC20Upgradeable fundingAsset,\n uint256 amount,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) public {\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\n _supplyCollateral(fundingAsset, aggregatorTarget, aggregatorData);\n\n if (!pool.checkMembership(address(this), collateralMarket)) {\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(collateralMarket);\n pool.enterMarkets(cTokens);\n }\n }\n\n function closePosition() public returns (uint256) {\n return closePosition(msg.sender);\n }\n\n function closePosition(\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) public returns (uint256) {\n return closePosition(msg.sender, aggregatorTarget, aggregatorData, expectedSlippage);\n }\n\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\n return closePosition(withdrawTo, address(0), \"\", _getAssumedSlippage(false));\n }\n\n function closePosition(\n address withdrawTo,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) public returns (uint256 withdrawAmount) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n _leverDown(1e18, aggregatorTarget, aggregatorData, expectedSlippage);\n\n // calling accrue and exit allows to redeem the full underlying balance\n collateralMarket.accrueInterest();\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\n if (errorCode != 0) revert ExitFailed(errorCode);\n\n // redeem all cTokens should leave no dust\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\n if (errorCode != 0) revert RedeemFailed(errorCode);\n\n if (stableAsset.balanceOf(address(this)) > 0) {\n // // convert all overborrowed leftovers/profits to the collateral asset\n // convertAllTo(stableAsset, collateralAsset, address(0), aggregatorData);\n // transfer the stable asset to the owner\n stableAsset.safeTransfer(withdrawTo, stableAsset.balanceOf(address(this)));\n }\n\n // withdraw the redeemed collateral\n withdrawAmount = collateralAsset.balanceOf(address(this));\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\n }\n\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256){\n return adjustLeverageRatio(targetRatioMantissa, address(0), \"\", 0);\n }\n\n function adjustLeverageRatio(\n uint256 targetRatioMantissa,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) public returns (uint256) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n if (targetRatioMantissa <= 1e18) {\n // anything under 1x means removing the leverage\n _leverDown(1e18, aggregatorTarget, aggregatorData, expectedSlippage);\n } else {\n if (getCurrentLeverageRatio() < targetRatioMantissa) {\n _leverUp(targetRatioMantissa, aggregatorTarget, aggregatorData, expectedSlippage);\n } else {\n _leverDown(targetRatioMantissa, aggregatorTarget, aggregatorData, expectedSlippage);\n }\n }\n\n // return the de facto achieved ratio\n return getCurrentLeverageRatio();\n }\n\n function receiveFlashLoan(address assetAddress, uint256 borrowedAmount, bytes calldata data) external override {\n if (msg.sender == address(collateralMarket)) {\n // increasing the leverage ratio\n (uint256 stableBorrowAmount, address aggregatorTarget, bytes memory aggregatorData) = abi.decode(\n data,\n (uint256, address, bytes)\n );\n _leverUpPostFL(stableBorrowAmount, aggregatorTarget, aggregatorData);\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\n if (positionCollateralBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\n } else if (msg.sender == address(stableMarket)) {\n // decreasing the leverage ratio\n (uint256 amountToRedeem, address aggregatorTarget, bytes memory aggregatorData) = abi.decode(\n data,\n (uint256, address, bytes)\n );\n _leverDownPostFL(borrowedAmount, amountToRedeem, aggregatorTarget, aggregatorData);\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\n if (positionStableBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\n } else {\n revert FlashLoanSourceError();\n }\n\n // repay FL\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\n }\n\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\n if (msg.sender != positionOwner) revert NotPositionOwner();\n if (!isPositionClosed()) revert OnlyWhenClosed();\n\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\n return stableLeftovers;\n }\n\n function claimRewards() public {\n claimRewards(msg.sender);\n }\n\n function claimRewards(address withdrawTo) public {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n address[] memory flywheels = pool.getRewardsDistributors();\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n fw.claimRewards(address(this));\n ERC20 rewardToken = fw.rewardToken();\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\n if (rewardsAccrued > 0) {\n rewardToken.transfer(withdrawTo, rewardsAccrued);\n }\n }\n }\n\n function rescueTokens(IERC20Upgradeable asset) external {\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\n\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\n }\n\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\n }\n return (rewardTokens, rewards);\n }\n\n fallback() external {\n address extension = factory.getPositionsExtension(msg.sig);\n if (extension == address(0)) revert ExtNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getAccruedRewards()\n external\n returns (\n /*view*/\n ERC20[] memory rewardTokens,\n uint256[] memory amounts\n )\n {\n address[] memory flywheels = pool.getRewardsDistributors();\n\n rewardTokens = new ERC20[](flywheels.length);\n amounts = new uint256[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n rewardTokens[i] = fw.rewardToken();\n amounts[i] = fw.rewardsAccrued(address(this));\n }\n }\n\n function getCurrentLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtValue = 0;\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n if (debtAmount > 0) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n }\n\n // TODO check if positionValue > debtValue\n // s / ( s - b )\n return (positionValue * 1e18) / (positionValue - debtValue);\n }\n\n function getMinLeverageRatio() public view returns (uint256) {\n return getMinLeverageRatio(0);\n }\n\n function getMinLeverageRatio(uint256 assumedSlippage) public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\n\n if (assumedSlippage == 0) assumedSlippage = _getAssumedSlippage(false);\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0, assumedSlippage);\n }\n\n function getMaxLeverageRatio() public view returns (uint256) {\n return getMaxLeverageRatio(0);\n }\n\n function getMaxLeverageRatio(uint256 assumedSlippage) public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\n\n if (assumedSlippage == 0) assumedSlippage = _getAssumedSlippage(true);\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount, assumedSlippage);\n }\n\n function isPositionClosed() public view returns (bool) {\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\n }\n\n function getEquityAmount() external view returns (uint256 equityAmount) {\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n\n uint256 equityValue = positionValue - debtValue;\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\n }\n\n function getAdjustmentAmountDeltas(uint256 targetRatio) public view returns (uint256, uint256) {\n return getAdjustmentAmountDeltas(targetRatio, 0);\n }\n\n function getAdjustmentAmountDeltas(uint256 targetRatio, uint256 assumedSlippage) public view returns (uint256, uint256) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentRatio = getCurrentLeverageRatio();\n bool up = targetRatio > currentRatio;\n if (assumedSlippage == 0) assumedSlippage = _getAssumedSlippage(up);\n return _getAdjustmentAmountDeltas(\n up,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice,\n assumedSlippage\n );\n }\n\n /*----------------------------------------------------------------\n Internal Functions\n ----------------------------------------------------------------*/\n\n function _getLeverageRatioAfterBorrow(\n uint256 newBorrowsAmount,\n uint256 positionSupplyAmount,\n uint256 positionBorrowAmount,\n uint256 assumedSlippage\n ) internal view returns (uint256 r) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\n\n int256 s = int256(positionValue);\n int256 b = int256(currentBorrowsValue);\n int256 x = int256(topUpCollateralValue);\n\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\n }\n\n function _getAdjustmentAmountDeltas(\n bool ratioIncreases,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice,\n uint256 expectedSlippage\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n\n return factory.calculateAdjustmentAmountDeltas(\n ratioIncreases,\n targetRatio,\n collateralAssetPrice,\n borrowedAssetPrice,\n expectedSlippage,\n positionSupplyAmount,\n debtAmount\n );\n }\n\n function _getAssumedSlippage(bool collateralToBorrowed) internal view returns (uint256) {\n if (collateralToBorrowed) {\n return factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n } else {\n return factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n }\n }\n\n function _supplyCollateral(\n IERC20Upgradeable fundingAsset,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) internal returns (uint256 amountToSupply) {\n // in case the funding is with a different asset\n if (address(collateralAsset) != address(fundingAsset)) {\n // swap for collateral asset\n convertAllTo(fundingAsset, collateralAsset, aggregatorTarget, aggregatorData);\n }\n\n // supply the collateral\n amountToSupply = collateralAsset.balanceOf(address(this));\n collateralAsset.approve(address(collateralMarket), amountToSupply);\n uint256 errorCode = collateralMarket.mint(amountToSupply);\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\n }\n\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\n function _leverUp(\n uint256 targetRatio,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) internal {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n if (expectedSlippage == 0) expectedSlippage = _getAssumedSlippage(true);\n\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getAdjustmentAmountDeltas(\n true,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice,\n expectedSlippage\n );\n\n collateralMarket.flash(\n flashLoanCollateralAmount,\n abi.encode(stableToBorrow, aggregatorTarget, aggregatorData)\n );\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n\n // all stables are swapped for collateral to repay the FL\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\n if (collateralLeftovers > 0) {\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\n collateralMarket.mint(collateralLeftovers);\n }\n }\n\n // @dev supply the flash loaned collateral and then borrow stables with it\n function _leverUpPostFL(\n uint256 stableToBorrow,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) internal {\n // supply the flash loaned collateral\n _supplyCollateral(collateralAsset, address(0), \"\");\n\n // borrow stables that will be swapped to repay the FL\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(stableAsset, collateralAsset, aggregatorTarget, aggregatorData);\n }\n\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\n function _leverDown(\n uint256 targetRatio,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) internal {\n uint256 amountToRedeem;\n uint256 borrowsToRepay;\n\n if (expectedSlippage == 0) expectedSlippage = _getAssumedSlippage(false);\n\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n if (targetRatio <= 1e18) {\n // if max levering down, then derive the amount to redeem from the debt to be repaid\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\n // accounting for swaps slippage\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + expectedSlippage)) / 10000;\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\n } else {\n // else derive the debt to be repaid from the amount to redeem\n (amountToRedeem, borrowsToRepay) = _getAdjustmentAmountDeltas(\n false,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice,\n expectedSlippage\n );\n // the slippage is already accounted for in _getAdjustmentAmountDeltas\n }\n\n if (borrowsToRepay > 0) {\n ICErc20(address(stableMarket)).flash(\n borrowsToRepay,\n abi.encode(amountToRedeem, aggregatorTarget, aggregatorData)\n );\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n }\n\n // all the redeemed collateral is swapped for stables to repay the FL\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n if (stableLeftovers > 0) {\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n if (borrowBalance > 0) {\n // whatever is smaller\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\n stableAsset.approve(address(stableMarket), amountToRepay);\n stableMarket.repayBorrow(amountToRepay);\n }\n }\n }\n\n function _leverDownPostFL(\n uint256 _flashLoanedCollateral,\n uint256 _amountToRedeem,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) internal {\n // repay the borrows\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\n stableAsset.approve(address(stableMarket), repayAmount);\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\n\n // redeem the corresponding amount needed to repay the FL\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(collateralAsset, stableAsset, aggregatorTarget, aggregatorData);\n }\n\n function convertAllTo(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) private returns (uint256 outputAmount) {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n// if (aggregatorTarget != address(0)) {\n bool isRouterWhitelisted = factory.isSwapRoutersWhitelisted(aggregatorTarget);\n if (!isRouterWhitelisted) revert RouterNotWhitelisted();\n\n uint256 balanceBefore = outputToken.balanceOf(address(this));\n inputToken.approve(aggregatorTarget, inputAmount);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n if (!success) revert AggregatorCallFailed();\n outputAmount = outputToken.balanceOf(address(this)) - balanceBefore;\n// } else {\n// (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\n// .getRedemptionStrategies(inputToken, outputToken);\n//\n// if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\n//\n// for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n// IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n// bytes memory strategyData = strategiesData[i];\n// (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\n// inputAmount = outputAmount;\n// inputToken = outputToken;\n// }\n// }\n }\n\n// function convertCustomFunds(\n// IERC20Upgradeable inputToken,\n// uint256 inputAmount,\n// IRedemptionStrategy strategy,\n// bytes memory strategyData\n// ) private returns (IERC20Upgradeable, uint256) {\n// bytes memory returndata = _functionDelegateCall(\n// address(strategy),\n// abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n// );\n// return abi.decode(returndata, (IERC20Upgradeable, uint256));\n// }\n//\n// function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n// if(!AddressUpgradeable.isContract(target)) revert DelegateCallToNonContract();// \"Address: delegate call to non-contract\";\n// (bool success, bytes memory returndata) = target.delegatecall(data);\n// return _verifyCallResult(success, returndata);\n// }\n//\n// function _verifyCallResult(\n// bool success,\n// bytes memory returndata\n// ) private pure returns (bytes memory) {\n// if (success) {\n// return returndata;\n// } else {\n// if (returndata.length > 0) {\n// assembly {\n// let returndata_size := mload(returndata)\n// revert(add(32, returndata), returndata_size)\n// }\n// } else {\n// revert LowLevelDelegateCallFailed();\n// }\n// }\n// }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { DiamondBase, DiamondExtension, LibDiamond } from \"../../ionic/DiamondExtension.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactory is LeveredPositionFactoryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /*----------------------------------------------------------------\n Constructor\n ----------------------------------------------------------------*/\n\n constructor(\n IFeeDistributor _feeDistributor,\n ILiquidatorsRegistry _registry,\n uint256 _blocksPerYear\n ) {\n feeDistributor = _feeDistributor;\n liquidatorsRegistry = _registry;\n blocksPerYear = _blocksPerYear;\n }\n\n /*----------------------------------------------------------------\n Admin Functions\n ----------------------------------------------------------------*/\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external onlyOwner {\n require(_collateralMarket.comptroller() == _stableMarket.comptroller(), \"markets not of the same pool\");\n\n if (_whitelisted) {\n collateralMarkets.add(address(_collateralMarket));\n borrowableMarketsByCollateral[_collateralMarket].add(address(_stableMarket));\n } else {\n borrowableMarketsByCollateral[_collateralMarket].remove(address(_stableMarket));\n if (borrowableMarketsByCollateral[_collateralMarket].length() == 0)\n collateralMarkets.remove(address(_collateralMarket));\n }\n }\n\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external onlyOwner {\n liquidatorsRegistry = _liquidatorsRegistry;\n }\n\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactoryFirstExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactoryFirstExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactoryFirstExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n error NoSuchPosition();\n error PositionNotClosed();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 15;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.removeClosedPosition.selector;\n functionSelectors[--fnsCount] = bytes4(keccak256(bytes(\"closeAndRemoveUserPosition(address,address,bytes,uint256)\")));\n functionSelectors[--fnsCount] = bytes4(keccak256(bytes(\"closeAndRemoveUserPosition(address)\")));\n functionSelectors[--fnsCount] = this.getMinBorrowNative.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getBorrowableMarketsByCollateral.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedCollateralMarkets.selector;\n functionSelectors[--fnsCount] = this.getAccountsWithOpenPositions.selector;\n functionSelectors[--fnsCount] = this.getPositionsByAccount.selector;\n functionSelectors[--fnsCount] = this.getPositionsExtension.selector;\n functionSelectors[--fnsCount] = this._setPositionsExtension.selector;\n functionSelectors[--fnsCount] = this.getAllWhitelistedSwapRouters.selector;\n functionSelectors[--fnsCount] = this.isSwapRoutersWhitelisted.selector;\n functionSelectors[--fnsCount] = this._setWhitelistedSwapRouters.selector;\n functionSelectors[--fnsCount] = this.calculateAdjustmentAmountDeltas.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n // @return true if removed, otherwise false\n function removeClosedPosition(address closedPosition) external returns (bool) {\n return _removeClosedPosition(closedPosition, msg.sender);\n }\n\n function closeAndRemoveUserPosition(\n LeveredPosition position,\n address aggregatorTarget,\n bytes memory aggregatorData,\n uint256 expectedSlippage\n ) external onlyOwner returns (bool) {\n address positionOwner = position.positionOwner();\n position.closePosition(positionOwner, aggregatorTarget, aggregatorData, expectedSlippage);\n return _removeClosedPosition(address(position), positionOwner);\n }\n\n function closeAndRemoveUserPosition(LeveredPosition position) external onlyOwner returns (bool) {\n address positionOwner = position.positionOwner();\n position.closePosition(positionOwner);\n return _removeClosedPosition(address(position), positionOwner);\n }\n\n function _removeClosedPosition(address closedPosition, address positionOwner) internal returns (bool removed) {\n EnumerableSet.AddressSet storage userPositions = positionsByAccount[positionOwner];\n if (!userPositions.contains(closedPosition)) revert NoSuchPosition();\n if (!LeveredPosition(closedPosition).isPositionClosed()) revert PositionNotClosed();\n\n removed = userPositions.remove(closedPosition);\n if (userPositions.length() == 0) accountsWithOpenPositions.remove(positionOwner);\n }\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external onlyOwner {\n _positionsExtensions[msgSig] = extension;\n }\n\n function _setWhitelistedSwapRouters(address[] memory newSet) external onlyOwner {\n address[] memory currentSet = _whitelistedSwapRouters.values();\n for (uint256 i = 0; i < currentSet.length; i++) {\n _whitelistedSwapRouters.remove(currentSet[i]);\n }\n\n for (uint256 i = 0; i < newSet.length; i++) {\n _whitelistedSwapRouters.add(newSet[i]);\n }\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n function calculateAdjustmentAmountDeltas(\n bool ratioIncreases,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice,\n uint256 expectedSlippage,\n uint256 positionSupplyAmount,\n uint256 debtAmount\n ) external pure returns (uint256 supplyDelta, uint256 borrowsDelta) {\n uint256 slippageFactor = (1e18 * (10000 + expectedSlippage)) / 10000;\n\n uint256 supplyValueDeltaAbs;\n {\n // s = supply value before\n // b = borrow value before\n // r = target ratio after\n // c = borrow value coefficient to account for the slippage\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\n int256 r = int256(targetRatio);\n int256 r1 = r - 1e18;\n int256 c = int256(slippageFactor);\n\n // some math magic here\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\n\n // x = supplyValueDelta\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\n }\n\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\n\n if (ratioIncreases) {\n // stables to borrow = c * x\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\n } else {\n // amount to redeem = c * x\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\n }\n }\n\n function getMinBorrowNative() external view returns (uint256) {\n return feeDistributor.minBorrowEth();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n return liquidatorsRegistry.getRedemptionStrategies(inputToken, outputToken);\n }\n\n function getPositionsByAccount(\n address account\n ) external view returns (address[] memory positions, bool[] memory closed) {\n positions = positionsByAccount[account].values();\n closed = new bool[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n closed[i] = LeveredPosition(positions[i]).isPositionClosed();\n }\n }\n\n function getAccountsWithOpenPositions() external view returns (address[] memory) {\n return accountsWithOpenPositions.values();\n }\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory) {\n return collateralMarkets.values();\n }\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory) {\n return borrowableMarketsByCollateral[_collateralMarket].values();\n }\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address) {\n return _positionsExtensions[msgSig];\n }\n\n function isSwapRoutersWhitelisted(address swapRouter) external view returns (bool) {\n return _whitelistedSwapRouters.contains(swapRouter);\n }\n\n function getAllWhitelistedSwapRouters() external view returns (address[] memory) {\n return _whitelistedSwapRouters.values();\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactorySecondExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactorySecondExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactorySecondExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n error WrongFnsArrayLength();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 3;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.createPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPositionAtRatio.selector;\n if(fnsCount != 0) revert WrongFnsArrayLength();\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) public returns (LeveredPosition) {\n if (!borrowableMarketsByCollateral[_collateralMarket].contains(address(_stableMarket))) revert PairNotWhitelisted();\n\n LeveredPosition position = new LeveredPosition(msg.sender, _collateralMarket, _stableMarket);\n\n accountsWithOpenPositions.add(msg.sender);\n positionsByAccount[msg.sender].add(address(position));\n\n AuthoritiesRegistry authoritiesRegistry = feeDistributor.authoritiesRegistry();\n address poolAddress = address(_collateralMarket.comptroller());\n PoolRolesAuthority poolAuth = authoritiesRegistry.poolsAuthorities(poolAddress);\n if (address(poolAuth) != address(0)) {\n authoritiesRegistry.setUserRole(poolAddress, address(position), poolAuth.LEVERED_POSITION_ROLE(), true);\n }\n\n return position;\n }\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n address _aggregatorTarget,\n bytes memory _aggregatorData\n ) public returns (LeveredPosition) {\n LeveredPosition position = createPosition(_collateralMarket, _stableMarket);\n _fundingAsset.safeTransferFrom(msg.sender, address(this), _fundingAmount);\n _fundingAsset.approve(address(position), _fundingAmount);\n position.fundPosition(_fundingAsset, _fundingAmount, _aggregatorTarget, _aggregatorData);\n return position;\n }\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio,\n address _fundingAssetSwapAggregatorTarget,\n bytes memory _fundingAssetSwapAggregatorData,\n address _adjustLeverageRatioAggregatorTarget,\n bytes memory _adjustLeverageRatioAggregatorData,\n uint256 _expectedSlippage\n ) external returns (LeveredPosition) {\n LeveredPosition position = createAndFundPosition(\n _collateralMarket,\n _stableMarket,\n _fundingAsset,\n _fundingAmount,\n _fundingAssetSwapAggregatorTarget,\n _fundingAssetSwapAggregatorData\n );\n if (_leverageRatio > 1e18) {\n position.adjustLeverageRatio(\n _leverageRatio,\n _adjustLeverageRatioAggregatorTarget,\n _adjustLeverageRatioAggregatorData,\n _expectedSlippage\n );\n }\n return position;\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\n EnumerableSet.AddressSet internal collateralMarkets;\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\n\n IFeeDistributor public feeDistributor;\n ILiquidatorsRegistry public liquidatorsRegistry;\n uint256 public blocksPerYear;\n\n mapping(bytes4 => address) internal _positionsExtensions;\n EnumerableSet.AddressSet internal _whitelistedSwapRouters;\n}\n" + }, + "contracts/ionic/levered/LeveredPositionsLens.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract LeveredPositionsLens is Initializable {\n ILeveredPositionFactory public factory;\n\n function initialize(ILeveredPositionFactory _factory) external initializer {\n factory = _factory;\n }\n\n function reinitialize(ILeveredPositionFactory _factory) external reinitializer(2) {\n factory = _factory;\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\n function getCollateralMarkets()\n external\n view\n returns (\n address[] memory markets,\n IonicComptroller[] memory poolOfMarket,\n address[] memory underlyings,\n uint256[] memory underlyingPrices,\n string[] memory names,\n string[] memory symbols,\n uint8[] memory decimals,\n uint256[] memory totalUnderlyingSupplied,\n uint256[] memory ratesPerBlock\n )\n {\n markets = factory.getWhitelistedCollateralMarkets();\n poolOfMarket = new IonicComptroller[](markets.length);\n underlyings = new address[](markets.length);\n underlyingPrices = new uint256[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n totalUnderlyingSupplied = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n ratesPerBlock = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n poolOfMarket[i] = market.comptroller();\n underlyingPrices[i] = BasePriceOracle(poolOfMarket[i].oracle()).getUnderlyingPrice(market);\n underlyings[i] = market.underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyings[i]);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n decimals[i] = underlying.decimals();\n totalUnderlyingSupplied[i] = market.getTotalUnderlyingSupplied();\n ratesPerBlock[i] = market.supplyRatePerBlock();\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\n function getBorrowRateAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _equityAmount,\n uint256 _targetLeverageRatio\n ) external view returns (uint256) {\n IonicComptroller pool = IonicComptroller(_stableMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(_stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n uint256 borrowAmount = ((_targetLeverageRatio - 1e18) * _equityAmount * collateralAssetPrice) /\n (stableAssetPrice * 1e18);\n return _stableMarket.borrowRatePerBlockAfterBorrow(borrowAmount) * factory.blocksPerYear();\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\n function getBorrowableMarketsAndRates(ICErc20 _collateralMarket)\n external\n view\n returns (\n address[] memory markets,\n address[] memory underlyings,\n uint256[] memory underlyingsPrices,\n string[] memory names,\n string[] memory symbols,\n uint256[] memory rates,\n uint8[] memory decimals\n )\n {\n markets = factory.getBorrowableMarketsByCollateral(_collateralMarket);\n underlyings = new address[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n rates = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n underlyingsPrices = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n address underlyingAddress = market.underlying();\n underlyings[i] = underlyingAddress;\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyingAddress);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n rates[i] = market.borrowRatePerBlock();\n decimals[i] = underlying.decimals();\n underlyingsPrices[i] = market.comptroller().oracle().getUnderlyingPrice(market);\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getNetAPY(\n uint256 _supplyAPY,\n uint256 _supplyAmount,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _targetLeverageRatio\n ) public view returns (int256 netAPY) {\n if (_supplyAmount == 0 || _targetLeverageRatio <= 1e18) return 0;\n\n IonicComptroller pool = IonicComptroller(_collateralMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n // TODO the calcs can be implemented without using collateralAssetPrice\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n // total collateral = base collateral + levered collateral\n uint256 totalCollateral = (_supplyAmount * _targetLeverageRatio) / 1e18;\n uint256 yieldFromTotalSupplyScaled = _supplyAPY * totalCollateral;\n int256 yieldValueScaled = int256((yieldFromTotalSupplyScaled * collateralAssetPrice) / 1e18);\n\n uint256 borrowedValueScaled = (totalCollateral - _supplyAmount) * collateralAssetPrice;\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n int256 borrowInterestValueScaled = int256((_borrowRate * borrowedValueScaled) / 1e18);\n\n int256 netValueDiffScaled = yieldValueScaled - borrowInterestValueScaled;\n\n netAPY = ((netValueDiffScaled / int256(collateralAssetPrice)) * 1e18) / int256(_supplyAmount);\n }\n\n function getPositionsInfo(LeveredPosition[] calldata positions, uint256[] calldata supplyApys)\n external\n view\n returns (PositionInfo[] memory infos)\n {\n infos = new PositionInfo[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n infos[i] = getPositionInfo(positions[i], supplyApys[i]);\n }\n }\n\n function getLeverageRatioAfterFunding(LeveredPosition pos, uint256 newFunding) public view returns (uint256) {\n uint256 equityAmount = pos.getEquityAmount();\n if (equityAmount == 0 && newFunding == 0) return 0;\n\n uint256 suppliedCollateralCurrent = pos.collateralMarket().balanceOfUnderlying(address(pos));\n return ((suppliedCollateralCurrent + newFunding) * 1e18) / (equityAmount + newFunding);\n }\n\n function getNetApyForPositionAfterFunding(\n LeveredPosition pos,\n uint256 supplyAPY,\n uint256 newFunding\n ) public view returns (int256) {\n return\n getNetAPY(\n supplyAPY,\n pos.getEquityAmount() + newFunding,\n pos.collateralMarket(),\n pos.stableMarket(),\n getLeverageRatioAfterFunding(pos, newFunding)\n );\n }\n\n function getNetApyForPosition(LeveredPosition pos, uint256 supplyAPY) public view returns (int256) {\n return getNetApyForPositionAfterFunding(pos, supplyAPY, 0);\n }\n\n struct PositionInfo {\n uint256 collateralAssetPrice;\n uint256 borrowedAssetPrice;\n uint256 positionSupplyAmount;\n uint256 positionValue;\n uint256 debtAmount;\n uint256 debtValue;\n uint256 equityAmount;\n uint256 equityValue;\n int256 currentApy;\n uint256 debtRatio;\n uint256 liquidationThreshold;\n uint256 safetyBuffer;\n }\n\n function getPositionInfo(LeveredPosition pos, uint256 supplyApy) public view returns (PositionInfo memory info) {\n ICErc20 collateralMarket = pos.collateralMarket();\n IonicComptroller pool = pos.pool();\n info.collateralAssetPrice = pool.oracle().getUnderlyingPrice(collateralMarket);\n {\n info.positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(pos));\n info.positionValue = (info.collateralAssetPrice * info.positionSupplyAmount) / 1e18;\n info.currentApy = getNetApyForPosition(pos, supplyApy);\n }\n\n {\n ICErc20 stableMarket = pos.stableMarket();\n info.borrowedAssetPrice = pool.oracle().getUnderlyingPrice(stableMarket);\n info.debtAmount = stableMarket.borrowBalanceCurrent(address(pos));\n info.debtValue = (info.borrowedAssetPrice * info.debtAmount) / 1e18;\n info.equityValue = info.positionValue - info.debtValue;\n info.debtRatio = info.positionValue == 0 ? 0 : (info.debtValue * 1e18) / info.positionValue;\n info.equityAmount = (info.equityValue * 1e18) / info.collateralAssetPrice;\n }\n\n {\n (, uint256 collateralFactor) = pool.markets(address(collateralMarket));\n info.liquidationThreshold = collateralFactor;\n info.safetyBuffer = collateralFactor - info.debtRatio;\n }\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract LeveredPositionStorage {\n address public immutable positionOwner;\n ILeveredPositionFactory public factory;\n\n ICErc20 public collateralMarket;\n ICErc20 public stableMarket;\n IonicComptroller public pool;\n\n IERC20Upgradeable public collateralAsset;\n IERC20Upgradeable public stableAsset;\n\n constructor(address _positionOwner) {\n positionOwner = _positionOwner;\n }\n}\n" + }, + "contracts/ionic/PoolRolesAuthority.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller, ComptrollerInterface } from \"../compound/ComptrollerInterface.sol\";\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \"../compound/CTokenInterfaces.sol\";\n\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\n constructor() RolesAuthority(address(0), Authority(address(0))) {\n _disableInitializers();\n }\n\n function initialize(address _owner) public initializer {\n owner = _owner;\n authority = this;\n }\n\n // up to 256 roles\n uint8 public constant REGISTRY_ROLE = 0;\n uint8 public constant SUPPLIER_ROLE = 1;\n uint8 public constant BORROWER_ROLE = 2;\n uint8 public constant LIQUIDATOR_ROLE = 3;\n uint8 public constant LEVERED_POSITION_ROLE = 4;\n\n function configureRegistryCapabilities() external requiresAuth {\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\n true\n );\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\n }\n\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, true);\n }\n\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, false);\n }\n\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\n }\n }\n }\n\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\n }\n\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\n uint8 fnsCount = 6;\n selectors = new bytes4[](fnsCount);\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return selectors;\n }\n\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\n }\n }\n }\n\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, true);\n }\n\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, false);\n }\n\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\n }\n }\n\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n // borrowers have the SUPPLIER_ROLE capabilities by default\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n // TODO this leaves redeeming open for everyone\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\n\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n}\n" + }, + "contracts/ionic/RewardsClaimer.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.10;\n\nimport { Initializable } from \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport { SafeERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract RewardsClaimer is Initializable {\n using SafeERC20Upgradeable for ERC20Upgradeable;\n\n event RewardDestinationUpdate(address indexed newDestination);\n\n event ClaimRewards(address indexed rewardToken, uint256 amount);\n\n /// @notice the address to send rewards\n address public rewardDestination;\n\n /// @notice the array of reward tokens to send to\n ERC20Upgradeable[] public rewardTokens;\n\n function __RewardsClaimer_init(address _rewardDestination, ERC20Upgradeable[] memory _rewardTokens)\n internal\n onlyInitializing\n {\n rewardDestination = _rewardDestination;\n rewardTokens = _rewardTokens;\n }\n\n /// @notice claim all token rewards\n function claimRewards() public {\n beforeClaim(); // hook to accrue/pull in rewards, if needed\n\n uint256 len = rewardTokens.length;\n // send all tokens to destination\n for (uint256 i = 0; i < len; i++) {\n ERC20Upgradeable token = rewardTokens[i];\n uint256 amount = token.balanceOf(address(this));\n\n token.safeTransfer(rewardDestination, amount);\n\n emit ClaimRewards(address(token), amount);\n }\n }\n\n /// @notice set the address of the new reward destination\n /// @param newDestination the new reward destination\n function setRewardDestination(address newDestination) external {\n require(msg.sender == rewardDestination, \"UNAUTHORIZED\");\n rewardDestination = newDestination;\n emit RewardDestinationUpdate(newDestination);\n }\n\n /// @notice hook to accrue/pull in rewards, if needed\n function beforeClaim() internal virtual {}\n}\n" + }, + "contracts/ionic/SafeOwnable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nabstract contract SafeOwnable is Ownable2Step {\n function renounceOwnership() public override onlyOwner {\n revert(\"renounce ownership not allowed\");\n }\n}\n" + }, + "contracts/ionic/SafeOwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\n/**\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\n * that will shift the other.\n */\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\n /**\n * @notice Pending owner of this contract\n */\n address public pendingOwner;\n\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\n __Ownable_init();\n _transferOwnership(owner_);\n }\n\n struct AddressSlot {\n address value;\n }\n\n modifier onlyOwnerOrAdmin() {\n bool isOwner = owner() == _msgSender();\n if (!isOwner) {\n address admin = _getProxyAdmin();\n bool isAdmin = admin == _msgSender();\n require(isAdmin, \"Ownable: caller is neither the owner nor the admin\");\n }\n _;\n }\n\n /**\n * @notice Emitted when pendingOwner is changed\n */\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\n\n /**\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\n */\n event NewOwner(address oldOwner, address newOwner);\n\n /**\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @param newPendingOwner New pending owner.\n */\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\n // Save current value, if any, for inclusion in log\n address oldPendingOwner = pendingOwner;\n\n // Store pendingOwner with value newPendingOwner\n pendingOwner = newPendingOwner;\n\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\n }\n\n /**\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\n * @dev Owner function for pending owner to accept role and update owner\n */\n function _acceptOwner() public {\n // Check caller is pendingOwner and pendingOwner ≠ address(0)\n require(msg.sender == pendingOwner, \"not the pending owner\");\n\n // Save current values for inclusion in log\n address oldOwner = owner();\n address oldPendingOwner = pendingOwner;\n\n // Store owner with value pendingOwner\n _transferOwnership(pendingOwner);\n\n // Clear the pending value\n pendingOwner = address(0);\n\n emit NewOwner(oldOwner, pendingOwner);\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\n }\n\n function renounceOwnership() public override onlyOwner {\n // do not remove this overriding fn\n revert(\"not used anymore\");\n }\n\n function transferOwnership(address newOwner) public override onlyOwner {\n emit NewPendingOwner(pendingOwner, newOwner);\n pendingOwner = newOwner;\n }\n\n function _getProxyAdmin() internal view returns (address admin) {\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n AddressSlot storage adminSlot;\n assembly {\n adminSlot.slot := _ADMIN_SLOT\n }\n admin = adminSlot.value;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/FlywheelCore.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {Auth, Authority} from \"solmate/auth/Auth.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\nimport {SafeCastLib} from \"solmate/utils/SafeCastLib.sol\";\n\nimport {IFlywheelRewards} from \"./rewards/IFlywheelRewards.sol\";\nimport {IFlywheelBooster} from \"./IFlywheelBooster.sol\";\n\n/**\n @title Flywheel Core Incentives Manager\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Core contract maintaings three important pieces of state:\n * the rewards index which determines how many rewards are owed per token per strategy. User indexes track how far behind the strategy they are to lazily calculate all catch-up rewards.\n * the accrued (unclaimed) rewards per user.\n * references to the booster and rewards module described below.\n\n Core does not manage any tokens directly. The rewards module maintains token balances, and approves core to pull transfer them to users when they claim.\n\n SECURITY NOTE: For maximum accuracy and to avoid exploits, rewards accrual should be notified atomically through the accrue hook. \n Accrue should be called any time tokens are transferred, minted, or burned.\n */\ncontract FlywheelCore is Auth {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n /// @notice The token to reward\n ERC20 public immutable rewardToken;\n\n /// @notice append-only list of strategies added\n ERC20[] public allStrategies;\n\n /// @notice the rewards contract for managing streams\n IFlywheelRewards public flywheelRewards;\n\n /// @notice optional booster module for calculating virtual balances on strategies\n IFlywheelBooster public flywheelBooster;\n\n constructor(\n ERC20 _rewardToken,\n IFlywheelRewards _flywheelRewards,\n IFlywheelBooster _flywheelBooster,\n address _owner,\n Authority _authority\n ) Auth(_owner, _authority) {\n rewardToken = _rewardToken;\n flywheelRewards = _flywheelRewards;\n flywheelBooster = _flywheelBooster;\n }\n\n /*///////////////////////////////////////////////////////////////\n ACCRUE/CLAIM LOGIC\n //////////////////////////////////////////////////////////////*/\n\n /** \n @notice Emitted when a user's rewards accrue to a given strategy.\n @param strategy the updated rewards strategy\n @param user the user of the rewards\n @param rewardsDelta how many new rewards accrued to the user\n @param rewardsIndex the market index for rewards per token accrued\n */\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\n\n /** \n @notice Emitted when a user claims accrued rewards.\n @param user the user of the rewards\n @param amount the amount of rewards claimed\n */\n event ClaimRewards(address indexed user, uint256 amount);\n\n /// @notice The accrued but not yet transferred rewards for each user\n mapping(address => uint256) public rewardsAccrued;\n\n /** \n @notice accrue rewards for a single user on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the user to be accrued\n @return the cumulative amount of rewards accrued to user (including prior)\n */\n function accrue(ERC20 strategy, address user) public returns (uint256) {\n RewardsState memory state = strategyState[strategy];\n\n if (state.index == 0) return 0;\n\n state = accrueStrategy(strategy, state);\n return accrueUser(strategy, user, state);\n }\n\n /** \n @notice accrue rewards for a two users on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the first user to be accrued\n @param user the second user to be accrued\n @return the cumulative amount of rewards accrued to the first user (including prior)\n @return the cumulative amount of rewards accrued to the second user (including prior)\n */\n function accrue(\n ERC20 strategy,\n address user,\n address secondUser\n ) public returns (uint256, uint256) {\n RewardsState memory state = strategyState[strategy];\n\n if (state.index == 0) return (0, 0);\n\n state = accrueStrategy(strategy, state);\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\n }\n\n /** \n @notice claim rewards for a given user\n @param user the user claiming rewards\n @dev this function is public, and all rewards transfer to the user\n */\n function claimRewards(address user) external {\n uint256 accrued = rewardsAccrued[user];\n\n if (accrued != 0) {\n rewardsAccrued[user] = 0;\n\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\n\n emit ClaimRewards(user, accrued);\n }\n }\n\n /*///////////////////////////////////////////////////////////////\n ADMIN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n /** \n @notice Emitted when a new strategy is added to flywheel by the admin\n @param newStrategy the new added strategy\n */\n event AddStrategy(address indexed newStrategy);\n\n /// @notice initialize a new strategy\n function addStrategyForRewards(ERC20 strategy) external requiresAuth {\n _addStrategyForRewards(strategy);\n }\n\n function _addStrategyForRewards(ERC20 strategy) internal {\n require(strategyState[strategy].index == 0, \"strategy\");\n strategyState[strategy] = RewardsState({index: ONE, lastUpdatedTimestamp: block.timestamp.safeCastTo32()});\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n\n function getAllStrategies() external view returns (ERC20[] memory) {\n return allStrategies;\n }\n\n /** \n @notice Emitted when the rewards module changes\n @param newFlywheelRewards the new rewards module\n */\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\n\n /// @notice swap out the flywheel rewards contract\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external requiresAuth {\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\n if (oldRewardBalance > 0) {\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\n }\n\n flywheelRewards = newFlywheelRewards;\n\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\n }\n\n /** \n @notice Emitted when the booster module changes\n @param newBooster the new booster module\n */\n event FlywheelBoosterUpdate(address indexed newBooster);\n\n /// @notice swap out the flywheel booster contract\n function setBooster(IFlywheelBooster newBooster) external requiresAuth {\n flywheelBooster = newBooster;\n\n emit FlywheelBoosterUpdate(address(newBooster));\n }\n\n /*///////////////////////////////////////////////////////////////\n INTERNAL ACCOUNTING LOGIC\n //////////////////////////////////////////////////////////////*/\n\n struct RewardsState {\n /// @notice The strategy's last updated index\n uint224 index;\n /// @notice The timestamp the index was last updated at\n uint32 lastUpdatedTimestamp;\n }\n\n /// @notice the fixed point factor of flywheel\n uint224 public constant ONE = 1e18;\n\n /// @notice The strategy index and last updated per strategy\n mapping(ERC20 => RewardsState) public strategyState;\n\n /// @notice user index per strategy\n mapping(ERC20 => mapping(address => uint224)) public userIndex;\n\n /// @notice accumulate global rewards on a strategy\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\n private\n returns (RewardsState memory rewardsState)\n {\n // calculate accrued rewards through module\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\n\n rewardsState = state;\n if (strategyRewardsAccrued > 0) {\n // use the booster or token supply to calculate reward index denominator\n uint256 supplyTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedTotalSupply(strategy)\n : strategy.totalSupply();\n\n uint224 deltaIndex;\n\n if (supplyTokens != 0) deltaIndex = ((strategyRewardsAccrued * ONE) / supplyTokens).safeCastTo224();\n\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\n rewardsState = RewardsState({\n index: state.index + deltaIndex,\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n strategyState[strategy] = rewardsState;\n }\n }\n\n /// @notice accumulate rewards on a strategy for a specific user\n function accrueUser(\n ERC20 strategy,\n address user,\n RewardsState memory state\n ) private returns (uint256) {\n // load indices\n uint224 strategyIndex = state.index;\n uint224 supplierIndex = userIndex[strategy][user];\n\n // sync user index to global\n userIndex[strategy][user] = strategyIndex;\n\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\n // zero balances will have no effect other than syncing to global index\n if (supplierIndex == 0) {\n supplierIndex = ONE;\n }\n\n uint224 deltaIndex = strategyIndex - supplierIndex;\n // use the booster or token balance to calculate reward balance multiplier\n uint256 supplierTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedBalanceOf(strategy, user)\n : strategy.balanceOf(user);\n\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\n uint256 supplierDelta = (supplierTokens * deltaIndex) / ONE;\n uint256 supplierAccrued = rewardsAccrued[user] + supplierDelta;\n\n rewardsAccrued[user] = supplierAccrued;\n\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\n\n return supplierAccrued;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IFlywheelBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/**\n @title Balance Booster Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\n \n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\n\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\n*/\ninterface IFlywheelBooster {\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IIonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ninterface IIonicFlywheel {\n function isRewardsDistributor() external returns (bool);\n\n function isFlywheel() external returns (bool);\n\n function flywheelPreSupplierAction(address market, address supplier) external;\n\n function flywheelPreBorrowerAction(address market, address borrower) external;\n\n function flywheelPreTransferAction(address market, address src, address dst) external;\n\n function compAccrued(address user) external view returns (uint256);\n\n function addMarketForRewards(ERC20 strategy) external;\n\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IIonicFlywheelBorrowBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\n/**\n @title Balance Booster Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\n \n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\n\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\n*/\ninterface IIonicFlywheelBorrowBooster {\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ICErc20 strategy) external view returns (uint256);\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ICErc20 strategy, address user) external view returns (uint256);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport \"./IIonicFlywheel.sol\";\n\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\n bool public constant isRewardsDistributor = true;\n bool public constant isFlywheel = true;\n\n function flywheelPreSupplierAction(address market, address supplier) external {\n accrue(ERC20(market), supplier);\n }\n\n function flywheelPreBorrowerAction(address market, address borrower) external {}\n\n function flywheelPreTransferAction(address market, address src, address dst) external {\n accrue(ERC20(market), src, dst);\n }\n\n function compAccrued(address user) external view returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n // TODO remove\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelBorrow.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport \"./IIonicFlywheel.sol\";\n\ncontract IonicFlywheelBorrow is IonicFlywheelCore, IIonicFlywheel {\n bool public constant isRewardsDistributor = true;\n bool public constant isFlywheel = true;\n\n function flywheelPreSupplierAction(address market, address supplier) external {}\n\n function flywheelPreBorrowerAction(address market, address borrower) external {\n accrue(ERC20(market), borrower);\n }\n\n function flywheelPreTransferAction(address market, address src, address dst) external {}\n\n function compAccrued(address user) external view returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n // TODO remove\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelBorrowBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport \"./IIonicFlywheelBorrowBooster.sol\";\n\ncontract IonicFlywheelBorrowBooster is IIonicFlywheelBorrowBooster {\n string public constant BOOSTER_TYPE = \"FlywheelBorrowBooster\";\n\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ICErc20 strategy) external view returns (uint256) {\n return strategy.totalBorrows();\n }\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ICErc20 strategy, address user) external view returns (uint256) {\n return strategy.borrowBalanceCurrent(user);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\nimport { SafeCastLib } from \"solmate/utils/SafeCastLib.sol\";\n\nimport { IFlywheelRewards } from \"./rewards/IFlywheelRewards.sol\";\nimport { IFlywheelBooster } from \"./IFlywheelBooster.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n /// @notice How much rewardsToken will be send to treasury\n uint256 public performanceFee;\n\n /// @notice Address that gets rewardsToken accrued by performanceFee\n address public feeRecipient;\n\n /// @notice The token to reward\n ERC20 public rewardToken;\n\n /// @notice append-only list of strategies added\n ERC20[] public allStrategies;\n\n /// @notice the rewards contract for managing streams\n IFlywheelRewards public flywheelRewards;\n\n /// @notice optional booster module for calculating virtual balances on strategies\n IFlywheelBooster public flywheelBooster;\n\n /// @notice The accrued but not yet transferred rewards for each user\n mapping(address => uint256) internal _rewardsAccrued;\n\n /// @notice The strategy index and last updated per strategy\n mapping(ERC20 => RewardsState) internal _strategyState;\n\n /// @notice user index per strategy\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\n\n constructor() {\n // prevents the misusage of the implementation contract\n _disableInitializers();\n }\n\n function initialize(\n ERC20 _rewardToken,\n IFlywheelRewards _flywheelRewards,\n IFlywheelBooster _flywheelBooster,\n address _owner\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n\n rewardToken = _rewardToken;\n flywheelRewards = _flywheelRewards;\n flywheelBooster = _flywheelBooster;\n\n _transferOwnership(_owner);\n\n performanceFee = 10e16; // 10%\n feeRecipient = _owner;\n }\n\n /*----------------------------------------------------------------\n ACCRUE/CLAIM LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a user's rewards accrue to a given strategy.\n @param strategy the updated rewards strategy\n @param user the user of the rewards\n @param rewardsDelta how many new rewards accrued to the user\n @param rewardsIndex the market index for rewards per token accrued\n */\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\n\n /** \n @notice Emitted when a user claims accrued rewards.\n @param user the user of the rewards\n @param amount the amount of rewards claimed\n */\n event ClaimRewards(address indexed user, uint256 amount);\n\n /** \n @notice accrue rewards for a single user on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the user to be accrued\n @return the cumulative amount of rewards accrued to user (including prior)\n */\n function accrue(ERC20 strategy, address user) public returns (uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return 0;\n\n state = accrueStrategy(strategy, state);\n return accrueUser(strategy, user, state);\n }\n\n /** \n @notice accrue rewards for a two users on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the first user to be accrued\n @param user the second user to be accrued\n @return the cumulative amount of rewards accrued to the first user (including prior)\n @return the cumulative amount of rewards accrued to the second user (including prior)\n */\n function accrue(\n ERC20 strategy,\n address user,\n address secondUser\n ) public returns (uint256, uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return (0, 0);\n\n state = accrueStrategy(strategy, state);\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\n }\n\n /** \n @notice claim rewards for a given user\n @param user the user claiming rewards\n @dev this function is public, and all rewards transfer to the user\n */\n function claimRewards(address user) external {\n uint256 accrued = rewardsAccrued(user);\n\n if (accrued != 0) {\n _rewardsAccrued[user] = 0;\n\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\n\n emit ClaimRewards(user, accrued);\n }\n }\n\n /*----------------------------------------------------------------\n ADMIN LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a new strategy is added to flywheel by the admin\n @param newStrategy the new added strategy\n */\n event AddStrategy(address indexed newStrategy);\n\n /// @notice initialize a new strategy\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n function _addStrategyForRewards(ERC20 strategy) internal {\n (uint224 index, ) = strategyState(strategy);\n require(index == 0, \"strategy\");\n _strategyState[strategy] = RewardsState({\n index: (10**rewardToken.decimals()).safeCastTo224(),\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n\n function getAllStrategies() external view returns (ERC20[] memory) {\n return allStrategies;\n }\n\n /** \n @notice Emitted when the rewards module changes\n @param newFlywheelRewards the new rewards module\n */\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\n\n /// @notice swap out the flywheel rewards contract\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\n if (address(flywheelRewards) != address(0)) {\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\n if (oldRewardBalance > 0) {\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\n }\n }\n\n flywheelRewards = newFlywheelRewards;\n\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\n }\n\n /** \n @notice Emitted when the booster module changes\n @param newBooster the new booster module\n */\n event FlywheelBoosterUpdate(address indexed newBooster);\n\n /// @notice swap out the flywheel booster contract\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\n flywheelBooster = newBooster;\n\n emit FlywheelBoosterUpdate(address(newBooster));\n }\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n * @dev Claim rewards first from the previous feeRecipient before changing it\n */\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\n _updateFeeSettings(_performanceFee, _feeRecipient);\n }\n\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\n\n if (feeRecipient != _feeRecipient) {\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\n _rewardsAccrued[feeRecipient] = 0;\n }\n performanceFee = _performanceFee;\n feeRecipient = _feeRecipient;\n }\n\n /*----------------------------------------------------------------\n INTERNAL ACCOUNTING LOGIC\n ----------------------------------------------------------------*/\n\n struct RewardsState {\n /// @notice The strategy's last updated index\n uint224 index;\n /// @notice The timestamp the index was last updated at\n uint32 lastUpdatedTimestamp;\n }\n\n /// @notice accumulate global rewards on a strategy\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\n private\n returns (RewardsState memory rewardsState)\n {\n // calculate accrued rewards through module\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\n\n rewardsState = state;\n\n if (strategyRewardsAccrued > 0) {\n // use the booster or token supply to calculate reward index denominator\n uint256 supplyTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedTotalSupply(strategy)\n : strategy.totalSupply();\n\n // 100% = 100e16\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\n\n _rewardsAccrued[feeRecipient] += accruedFees;\n strategyRewardsAccrued -= accruedFees;\n\n uint224 deltaIndex;\n\n if (supplyTokens != 0)\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\n\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\n rewardsState = RewardsState({\n index: state.index + deltaIndex,\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n _strategyState[strategy] = rewardsState;\n }\n }\n\n /// @notice accumulate rewards on a strategy for a specific user\n function accrueUser(\n ERC20 strategy,\n address user,\n RewardsState memory state\n ) private returns (uint256) {\n // load indices\n uint224 strategyIndex = state.index;\n uint224 supplierIndex = userIndex(strategy, user);\n\n // sync user index to global\n _userIndex[strategy][user] = strategyIndex;\n\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\n // zero balances will have no effect other than syncing to global index\n if (supplierIndex == 0) {\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\n }\n\n uint224 deltaIndex = strategyIndex - supplierIndex;\n // use the booster or token balance to calculate reward balance multiplier\n uint256 supplierTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedBalanceOf(strategy, user)\n : strategy.balanceOf(user);\n\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\n\n _rewardsAccrued[user] = supplierAccrued;\n\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\n\n return supplierAccrued;\n }\n\n function rewardsAccrued(address user) public virtual returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\n return _userIndex[strategy][user];\n }\n\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport { IonicComptroller } from \"../../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { PoolDirectory } from \"../../../PoolDirectory.sol\";\n\ninterface IPriceOracle_IFLR {\n function getUnderlyingPrice(ERC20 cToken) external view returns (uint256);\n\n function price(address underlying) external view returns (uint256);\n}\n\ncontract IonicFlywheelLensRouter {\n PoolDirectory public fpd;\n\n constructor(PoolDirectory _fpd) {\n fpd = _fpd;\n }\n\n struct MarketRewardsInfo {\n /// @dev comptroller oracle price of market underlying\n uint256 underlyingPrice;\n ICErc20 market;\n RewardsInfo[] rewardsInfo;\n }\n\n struct RewardsInfo {\n /// @dev rewards in `rewardToken` paid per underlying staked token in `market` per second\n uint256 rewardSpeedPerSecondPerToken;\n /// @dev comptroller oracle price of reward token\n uint256 rewardTokenPrice;\n /// @dev APR scaled by 1e18. Calculated as rewardSpeedPerSecondPerToken * rewardTokenPrice * 365.25 days / underlyingPrice * 1e18 / market.exchangeRate\n uint256 formattedAPR;\n address flywheel;\n address rewardToken;\n }\n\n function getPoolMarketRewardsInfo(IonicComptroller comptroller) external returns (MarketRewardsInfo[] memory) {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n return _getMarketRewardsInfo(markets, comptroller);\n }\n\n function getMarketRewardsInfo(ICErc20[] memory markets) external returns (MarketRewardsInfo[] memory) {\n IonicComptroller pool;\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 asMarket = ICErc20(address(markets[i]));\n if (address(pool) == address(0)) pool = asMarket.comptroller();\n else require(asMarket.comptroller() == pool);\n }\n return _getMarketRewardsInfo(markets, pool);\n }\n\n function _getMarketRewardsInfo(ICErc20[] memory markets, IonicComptroller comptroller)\n internal\n returns (MarketRewardsInfo[] memory)\n {\n if (address(comptroller) == address(0) || markets.length == 0) return new MarketRewardsInfo[](0);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n address[] memory rewardTokens = new address[](flywheels.length);\n uint256[] memory rewardTokenPrices = new uint256[](flywheels.length);\n uint256[] memory rewardTokenDecimals = new uint256[](flywheels.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n MarketRewardsInfo[] memory infoList = new MarketRewardsInfo[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n RewardsInfo[] memory rewardsInfo = new RewardsInfo[](flywheels.length);\n\n ICErc20 market = ICErc20(address(markets[i]));\n uint256 price = oracle.price(market.underlying()); // scaled to 1e18\n\n if (i == 0) {\n for (uint256 j = 0; j < flywheels.length; j++) {\n ERC20 rewardToken = IonicFlywheelCore(flywheels[j]).rewardToken();\n rewardTokens[j] = address(rewardToken);\n rewardTokenPrices[j] = oracle.price(address(rewardToken)); // scaled to 1e18\n rewardTokenDecimals[j] = uint256(rewardToken.decimals());\n }\n }\n\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n rewardTokenDecimals[j]\n );\n uint256 apr = getApr(\n rewardSpeedPerSecondPerToken,\n rewardTokenPrices[j],\n price, \n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n rewardsInfo[j] = RewardsInfo({\n rewardSpeedPerSecondPerToken: rewardSpeedPerSecondPerToken, // scaled in 1e18\n rewardTokenPrice: rewardTokenPrices[j],\n formattedAPR: apr, // scaled in 1e18\n flywheel: address(flywheel),\n rewardToken: rewardTokens[j]\n });\n }\n\n infoList[i] = MarketRewardsInfo({ market: market, rewardsInfo: rewardsInfo, underlyingPrice: price });\n }\n\n return infoList;\n }\n\n function scaleIndexDiff(uint256 indexDiff, uint256 decimals) internal pure returns (uint256) {\n return decimals <= 18 ? uint256(indexDiff) * (10**(18 - decimals)) : uint256(indexDiff) / (10**(decimals - 18));\n }\n\n function getRewardSpeedPerSecondPerToken(\n IonicFlywheelCore flywheel,\n ICErc20 market,\n uint256 decimals\n ) internal returns (uint256 rewardSpeedPerSecondPerToken) {\n ERC20 strategy = ERC20(address(market));\n (uint224 indexBefore, uint32 lastUpdatedTimestampBefore) = flywheel.strategyState(strategy);\n flywheel.accrue(strategy, address(0));\n (uint224 indexAfter, uint32 lastUpdatedTimestampAfter) = flywheel.strategyState(strategy);\n if (lastUpdatedTimestampAfter > lastUpdatedTimestampBefore) {\n rewardSpeedPerSecondPerToken =\n scaleIndexDiff((indexAfter - indexBefore), decimals) /\n (lastUpdatedTimestampAfter - lastUpdatedTimestampBefore);\n }\n }\n\n function getApr(\n uint256 rewardSpeedPerSecondPerToken,\n uint256 rewardTokenPrice,\n uint256 underlyingPrice,\n uint256 exchangeRate,\n bool isBorrow\n ) internal pure returns (uint256) {\n if (rewardSpeedPerSecondPerToken == 0) return 0;\n uint256 nativeSpeedPerSecondPerCToken = rewardSpeedPerSecondPerToken * rewardTokenPrice; // scaled to 1e36\n uint256 nativeSpeedPerYearPerCToken = nativeSpeedPerSecondPerCToken * 365.25 days; // scaled to 1e36\n uint256 assetSpeedPerYearPerCToken = nativeSpeedPerYearPerCToken / underlyingPrice; // scaled to 1e18\n uint256 assetSpeedPerYearPerCTokenScaled = assetSpeedPerYearPerCToken * 1e18; // scaled to 1e36\n uint256 apr = assetSpeedPerYearPerCTokenScaled;\n if (!isBorrow) {\n // if not borrowing, use exchange rate to scale\n apr = assetSpeedPerYearPerCTokenScaled / exchangeRate; // scaled to 1e18\n } else {\n apr = assetSpeedPerYearPerCTokenScaled / 1e18; // scaled to 1e18\n }\n return apr;\n }\n\n function getRewardsAprForMarket(ICErc20 market) internal returns (int256 totalMarketRewardsApr) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPrice = oracle.getUnderlyingPrice(market);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n ERC20 rewardToken = flywheel.rewardToken();\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n uint256(rewardToken.decimals())\n );\n\n uint256 marketApr = getApr(\n rewardSpeedPerSecondPerToken,\n oracle.price(address(rewardToken)),\n underlyingPrice,\n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n totalMarketRewardsApr += int256(marketApr);\n }\n }\n\n function getUserNetValueDeltaForMarket(\n address user,\n ICErc20 market,\n int256 offchainApr,\n int256 blocksPerYear\n ) internal returns (int256) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n int256 netApr = getRewardsAprForMarket(market) +\n getUserInterestAprForMarket(user, market, blocksPerYear) +\n offchainApr;\n return (netApr * int256(market.balanceOfUnderlying(user)) * int256(oracle.getUnderlyingPrice(market))) / 1e36;\n }\n\n function getUserInterestAprForMarket(\n address user,\n ICErc20 market,\n int256 blocksPerYear\n ) internal returns (int256) {\n uint256 borrows = market.borrowBalanceCurrent(user);\n uint256 supplied = market.balanceOfUnderlying(user);\n uint256 supplyRatePerBlock = market.supplyRatePerBlock();\n uint256 borrowRatePerBlock = market.borrowRatePerBlock();\n\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 assetPrice = oracle.getUnderlyingPrice(market);\n uint256 collateralValue = (supplied * assetPrice) / 1e18;\n uint256 borrowsValue = (borrows * assetPrice) / 1e18;\n\n uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;\n uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;\n\n if (collateralValue == 0) return 0;\n return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);\n }\n\n struct AdjustedUserNetAprVars {\n int256 userNetAssetsValue;\n int256 userNetValueDelta;\n BasePriceOracle oracle;\n ICErc20[] markets;\n IonicComptroller pool;\n }\n\n function getAdjustedUserNetApr(\n address user,\n int256 blocksPerYear,\n address[] memory offchainRewardsAprMarkets,\n int256[] memory offchainRewardsAprs\n ) public returns (int256) {\n AdjustedUserNetAprVars memory vars;\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n vars.oracle = pool.oracle();\n vars.markets = pool.getAllMarkets();\n for (uint256 j = 0; j < vars.markets.length; j++) {\n int256 offchainRewardsApr = 0;\n for (uint256 k = 0; k < offchainRewardsAprMarkets.length; k++) {\n if (offchainRewardsAprMarkets[k] == address(vars.markets[j])) offchainRewardsApr = offchainRewardsAprs[k];\n }\n vars.userNetAssetsValue +=\n int256(vars.markets[j].balanceOfUnderlying(user) * vars.oracle.getUnderlyingPrice(vars.markets[j])) /\n 1e18;\n vars.userNetValueDelta += getUserNetValueDeltaForMarket(\n user,\n vars.markets[j],\n offchainRewardsApr,\n blocksPerYear\n );\n }\n }\n\n if (vars.userNetAssetsValue == 0) return 0;\n else return (vars.userNetValueDelta * 1e18) / vars.userNetAssetsValue;\n }\n\n function getUserNetApr(address user, int256 blocksPerYear) external returns (int256) {\n address[] memory emptyAddrArray = new address[](0);\n int256[] memory emptyIntArray = new int256[](0);\n return getAdjustedUserNetApr(user, blocksPerYear, emptyAddrArray, emptyIntArray);\n }\n\n function getAllRewardTokens() public view returns (address[] memory uniqueRewardTokens) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n uint256 rewardTokensCounter;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n rewardTokensCounter += fws.length;\n }\n\n address[] memory rewardTokens = new address[](rewardTokensCounter);\n\n uint256 uniqueRewardTokensCounter = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n for (uint256 j = 0; j < fws.length; j++) {\n address rwToken = address(IonicFlywheelCore(fws[j]).rewardToken());\n if (rwToken == address(0)) break;\n\n bool added;\n for (uint256 k = 0; k < rewardTokens.length; k++) {\n if (rwToken == rewardTokens[k]) {\n added = true;\n break;\n }\n }\n if (!added) rewardTokens[uniqueRewardTokensCounter++] = rwToken;\n }\n }\n\n uniqueRewardTokens = new address[](uniqueRewardTokensCounter);\n for (uint256 i = 0; i < uniqueRewardTokensCounter; i++) {\n uniqueRewardTokens[i] = rewardTokens[i];\n }\n }\n\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory) {\n address[] memory rewardTokens = getAllRewardTokens();\n uint256[] memory rewardsClaimedForToken = new uint256[](rewardTokens.length);\n\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n rewardsClaimedForToken[i] = claimRewardsOfRewardToken(user, rewardTokens[i]);\n }\n\n return (rewardTokens, rewardsClaimedForToken);\n }\n\n function claimRewardsOfRewardToken(address user, address rewardToken) public returns (uint256 rewardsClaimed) {\n uint256 balanceBefore = ERC20(rewardToken).balanceOf(user);\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ERC20[] memory markets;\n {\n ICErc20[] memory cerc20s = pool.getAllMarkets();\n markets = new ERC20[](cerc20s.length);\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n }\n\n address[] memory flywheelAddresses = pool.getAccruingFlywheels();\n for (uint256 k = 0; k < flywheelAddresses.length; k++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);\n if (address(flywheel.rewardToken()) == rewardToken) {\n for (uint256 m = 0; m < markets.length; m++) {\n flywheel.accrue(markets[m], user);\n }\n flywheel.claimRewards(user);\n }\n }\n }\n\n uint256 balanceAfter = ERC20(rewardToken).balanceOf(user);\n return balanceAfter - balanceBefore;\n }\n\n function claimRewardsForMarket(\n address user,\n ERC20 market,\n IonicFlywheelCore[] calldata flywheels,\n bool[] calldata accrue\n )\n external\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n uint256 size = flywheels.length;\n rewards = new uint256[](size);\n rewardTokens = new address[](size);\n\n for (uint256 i = 0; i < size; i++) {\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n\n function claimRewardsForPool(address user, IonicComptroller comptroller)\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory,\n uint256[] memory\n )\n {\n ICErc20[] memory cerc20s = comptroller.getAllMarkets();\n ERC20[] memory markets = new ERC20[](cerc20s.length);\n address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();\n IonicFlywheelCore[] memory flywheels = new IonicFlywheelCore[](flywheelAddresses.length);\n bool[] memory accrue = new bool[](flywheelAddresses.length);\n\n for (uint256 j = 0; j < flywheelAddresses.length; j++) {\n flywheels[j] = IonicFlywheelCore(flywheelAddresses[j]);\n accrue[j] = true;\n }\n\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n\n return claimRewardsForMarkets(user, markets, flywheels, accrue);\n }\n\n function claimRewardsForMarkets(\n address user,\n ERC20[] memory markets,\n IonicFlywheelCore[] memory flywheels,\n bool[] memory accrue\n )\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n rewards = new uint256[](flywheels.length);\n rewardTokens = new address[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n for (uint256 j = 0; j < markets.length; j++) {\n ERC20 market = markets[j];\n\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n }\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicReplacingFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport \"./IonicFlywheel.sol\";\n\nimport { IFlywheelRewards } from \"./rewards/IFlywheelRewards.sol\";\nimport { IFlywheelBooster } from \"./IFlywheelBooster.sol\";\n\ncontract IonicReplacingFlywheel is IonicFlywheel {\n IonicFlywheelCore public flywheelToReplace;\n mapping(address => bool) private rewardsTransferred;\n\n function reinitialize(IonicFlywheelCore _flywheelToReplace) public onlyOwnerOrAdmin {\n flywheelToReplace = _flywheelToReplace;\n }\n\n function rewardsAccrued(address user) public override returns (uint256) {\n if (address(flywheelToReplace) != address(0)) {\n if (_rewardsAccrued[user] == 0 && !rewardsTransferred[user]) {\n uint256 oldStateRewardsAccrued = flywheelToReplace.rewardsAccrued(user);\n if (oldStateRewardsAccrued != 0) {\n rewardsTransferred[user] = true;\n _rewardsAccrued[user] = oldStateRewardsAccrued;\n }\n }\n }\n return _rewardsAccrued[user];\n }\n\n function strategyState(ERC20 strategy) public override returns (uint224, uint32) {\n if (address(flywheelToReplace) != address(0)) {\n RewardsState memory newStateStrategyState = _strategyState[strategy];\n if (newStateStrategyState.index == 0) {\n (uint224 index, uint32 ts) = flywheelToReplace.strategyState(strategy);\n if (index != 0) {\n _strategyState[strategy] = RewardsState(index, ts);\n }\n }\n }\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n\n function userIndex(ERC20 strategy, address user) public override returns (uint224) {\n if (address(flywheelToReplace) != address(0)) {\n if (_userIndex[strategy][user] == 0) {\n uint224 oldStateUserIndex = flywheelToReplace.userIndex(strategy, user);\n if (oldStateUserIndex != 0) {\n _userIndex[strategy][user] = oldStateUserIndex;\n }\n }\n }\n return _userIndex[strategy][user];\n }\n\n function addInitializedStrategy(ERC20 strategy) public onlyOwner {\n (uint224 index, ) = strategyState(strategy);\n if (index > 0) {\n ERC20[] memory strategies = this.getAllStrategies();\n for (uint8 i = 0; i < strategies.length; i++) {\n require(address(strategy) != address(strategies[i]), \"!added\");\n }\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/LooplessFlywheelBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport \"./IFlywheelBooster.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\ncontract LooplessFlywheelBooster is IFlywheelBooster {\n string public constant BOOSTER_TYPE = \"LooplessFlywheelBooster\";\n\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256) {\n return strategy.totalSupply();\n }\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256) {\n uint256 cTokensBalance = strategy.balanceOf(user);\n ICErc20 asMarket = ICErc20(address(strategy));\n uint256 cTokensBorrow = (asMarket.borrowBalanceCurrent(user) * 1e18) / asMarket.exchangeRateCurrent();\n return (cTokensBalance > cTokensBorrow) ? cTokensBalance - cTokensBorrow : 0;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/BaseFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IFlywheelRewards} from \"./IFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Reward Module\n @notice Determines how many rewards accrue to each strategy globally over a given time period.\n @dev approves the flywheel core for the reward token to allow balances to be managed by the module but claimed from core.\n*/\nabstract contract BaseFlywheelRewards is IFlywheelRewards {\n using SafeTransferLib for ERC20;\n\n /// @notice thrown when caller is not the flywheel\n error FlywheelError();\n\n /// @notice the reward token paid\n ERC20 public immutable override rewardToken;\n\n /// @notice the flywheel core contract\n IonicFlywheelCore public immutable override flywheel;\n\n constructor(IonicFlywheelCore _flywheel) {\n flywheel = _flywheel;\n ERC20 _rewardToken = _flywheel.rewardToken();\n rewardToken = _rewardToken;\n\n _rewardToken.safeApprove(address(_flywheel), type(uint256).max);\n }\n\n modifier onlyFlywheel() {\n if (msg.sender != address(flywheel)) revert FlywheelError();\n _;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelDynamicRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {SafeCastLib} from \"solmate/utils/SafeCastLib.sol\";\n\n/** \n @title Flywheel Dynamic Reward Stream\n @notice Determines rewards based on a dynamic reward stream.\n Rewards are transferred linearly over a \"rewards cycle\" to prevent gaming the reward distribution. \n The reward source can be arbitrary logic, but most common is to \"pass through\" rewards from some other source.\n The getNextCycleRewards() hook should also transfer the next cycle's rewards to this contract to ensure proper accounting.\n*/\nabstract contract FlywheelDynamicRewards is BaseFlywheelRewards {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n event NewRewardsCycle(uint32 indexed start, uint32 indexed end, uint192 reward);\n\n /// @notice the length of a rewards cycle\n uint32 public immutable rewardsCycleLength;\n\n struct RewardsCycle {\n uint32 start;\n uint32 end;\n uint192 reward;\n }\n\n mapping(ERC20 => RewardsCycle) public rewardsCycle;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _rewardsCycleLength) BaseFlywheelRewards(_flywheel) {\n rewardsCycleLength = _rewardsCycleLength;\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsCycle memory cycle = rewardsCycle[strategy];\n\n uint32 timestamp = block.timestamp.safeCastTo32();\n\n uint32 latest = timestamp >= cycle.end ? cycle.end : timestamp;\n uint32 earliest = lastUpdatedTimestamp <= cycle.start ? cycle.start : lastUpdatedTimestamp;\n if (cycle.end != 0) {\n amount = (cycle.reward * (latest - earliest)) / (cycle.end - cycle.start);\n assert(amount <= cycle.reward); // should never happen because latest <= cycle.end and earliest >= cycle.start\n }\n // if cycle has ended, reset cycle and transfer all available\n if (timestamp >= cycle.end) {\n uint32 end = ((timestamp + rewardsCycleLength) / rewardsCycleLength) * rewardsCycleLength;\n uint192 rewards = getNextCycleRewards(strategy);\n\n // reset for next cycle\n rewardsCycle[strategy] = RewardsCycle({start: timestamp, end: end, reward: rewards});\n\n emit NewRewardsCycle(timestamp, end, rewards);\n }\n }\n\n function getNextCycleRewards(ERC20 strategy) internal virtual returns (uint192);\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {Auth, Authority} from \"solmate/auth/Auth.sol\";\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Static Reward Stream\n @notice Determines rewards per strategy based on a fixed reward rate per second\n*/\ncontract FlywheelStaticRewards is Auth, BaseFlywheelRewards {\n event RewardsInfoUpdate(ERC20 indexed strategy, uint224 rewardsPerSecond, uint32 rewardsEndTimestamp);\n\n struct RewardsInfo {\n /// @notice Rewards per second\n uint224 rewardsPerSecond;\n /// @notice The timestamp the rewards end at\n /// @dev use 0 to specify no end\n uint32 rewardsEndTimestamp;\n }\n\n /// @notice rewards info per strategy\n mapping(ERC20 => RewardsInfo) public rewardsInfo;\n\n constructor(\n IonicFlywheelCore _flywheel,\n address _owner,\n Authority _authority\n ) Auth(_owner, _authority) BaseFlywheelRewards(_flywheel) {}\n\n /**\n @notice set rewards per second and rewards end time for Fei Rewards\n @param strategy the strategy to accrue rewards for\n @param rewards the rewards info for the strategy\n */\n function setRewardsInfo(ERC20 strategy, RewardsInfo calldata rewards) external requiresAuth {\n rewardsInfo[strategy] = rewards;\n emit RewardsInfoUpdate(strategy, rewards.rewardsPerSecond, rewards.rewardsEndTimestamp);\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @param lastUpdatedTimestamp the last updated time for strategy\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n view\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsInfo memory rewards = rewardsInfo[strategy];\n\n uint256 elapsed;\n if (rewards.rewardsEndTimestamp == 0 || rewards.rewardsEndTimestamp > block.timestamp) {\n elapsed = block.timestamp - lastUpdatedTimestamp;\n } else if (rewards.rewardsEndTimestamp > lastUpdatedTimestamp) {\n elapsed = rewards.rewardsEndTimestamp - lastUpdatedTimestamp;\n }\n\n amount = rewards.rewardsPerSecond * elapsed;\n }\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/**\n @title Rewards Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Rewards module is responsible for:\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\n * actually holding rewards that are yet to be claimed\n\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\n\n Different module strategies include:\n * a static reward rate per second\n * a decaying reward rate\n * a dynamic just-in-time reward stream\n * liquid governance reward delegation (Curve Gauge style)\n\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\n */\ninterface IFlywheelRewards {\n /**\n @notice calculate the rewards amount accrued to a strategy since the last update.\n @param strategy the strategy to accrue rewards for.\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\n @return rewards the amount of rewards accrued to the market\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\n\n /// @notice return the flywheel core address\n function flywheel() external view returns (IonicFlywheelCore);\n\n /// @notice return the reward token associated with flywheel core.\n function rewardToken() external view returns (ERC20);\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { FlywheelDynamicRewards } from \"./FlywheelDynamicRewards.sol\";\nimport { IonicFlywheelCore } from \"../IonicFlywheelCore.sol\";\nimport { SafeTransferLib, ERC20 } from \"solmate/utils/SafeTransferLib.sol\";\n\ncontract IonicFlywheelDynamicRewards is FlywheelDynamicRewards {\n using SafeTransferLib for ERC20;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)\n FlywheelDynamicRewards(_flywheel, _cycleLength)\n {}\n\n function getNextCycleRewards(ERC20 strategy)\n internal\n override\n returns (uint192)\n {\n uint256 rewardAmount = rewardToken.balanceOf(address(strategy));\n if (rewardAmount != 0) {\n rewardToken.safeTransferFrom(\n address(strategy),\n address(this),\n rewardAmount\n );\n }\n return uint192(rewardAmount);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport \"./FlywheelDynamicRewards.sol\";\n\ninterface ICERC20 {\n function plugin() external returns (address);\n}\n\ninterface IPlugin_FDR {\n function claimRewards() external;\n}\n\n/** \n @title Ionic Flywheel Dynamic Reward Stream\n @notice Determines rewards based on reward cycle\n Each cycle, claims rewards on the plugin before getting the reward amount\n*/\ncontract IonicFlywheelDynamicRewardsPlugin is FlywheelDynamicRewards {\n using SafeTransferLib for ERC20;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)\n FlywheelDynamicRewards(_flywheel, _cycleLength)\n {}\n\n function getNextCycleRewards(ERC20 strategy)\n internal\n override\n returns (uint192)\n {\n IPlugin_FDR plugin = IPlugin_FDR(ICERC20(address(strategy)).plugin());\n try plugin.claimRewards() {} catch {}\n\n uint256 rewardAmount = rewardToken.balanceOf(address(strategy));\n if (rewardAmount != 0) {\n rewardToken.safeTransferFrom(\n address(strategy),\n address(this),\n rewardAmount\n );\n }\n return uint192(rewardAmount);\n }\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/ReplacingFlywheelDynamicRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { FlywheelDynamicRewards } from \"./FlywheelDynamicRewards.sol\";\nimport { IonicFlywheelCore } from \"../IonicFlywheelCore.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { SafeTransferLib, ERC20 } from \"solmate/utils/SafeTransferLib.sol\";\n\ninterface ICERC20_RFDR {\n function plugin() external returns (address);\n}\n\ninterface IPlugin_RFDR {\n function claimRewards() external;\n}\n\ncontract ReplacingFlywheelDynamicRewards is FlywheelDynamicRewards {\n using SafeTransferLib for ERC20;\n\n IonicFlywheelCore public replacedFlywheel;\n\n constructor(\n IonicFlywheelCore _replacedFlywheel,\n IonicFlywheelCore _flywheel,\n uint32 _cycleLength\n ) FlywheelDynamicRewards(_flywheel, _cycleLength) {\n replacedFlywheel = _replacedFlywheel;\n // rewardToken.safeApprove(address(_replacedFlywheel), type(uint256).max);\n }\n\n function getNextCycleRewards(ERC20 strategy) internal override returns (uint192) {\n if (msg.sender == address(replacedFlywheel)) {\n return 0;\n } else {\n // make it work for both pulled (claimed) and pushed (transferred some other way) rewards\n try ICERC20_RFDR(address(strategy)).plugin() returns (address plugin) {\n try IPlugin_RFDR(plugin).claimRewards() {} catch {}\n } catch {}\n\n uint256 rewardAmount = rewardToken.balanceOf(address(strategy));\n if (rewardAmount != 0) {\n rewardToken.safeTransferFrom(address(strategy), address(this), rewardAmount);\n }\n return uint192(rewardAmount);\n }\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/ReplacingFlywheelStaticRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { FlywheelStaticRewards } from \"./FlywheelStaticRewards.sol\";\nimport { IonicFlywheelCore } from \"../IonicFlywheelCore.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { SafeTransferLib, ERC20 } from \"solmate/utils/SafeTransferLib.sol\";\n\ncontract ReplacingFlywheelStaticRewards is FlywheelStaticRewards {\n using SafeTransferLib for ERC20;\n\n IonicFlywheelCore public replacedFlywheel;\n\n constructor(\n IonicFlywheelCore _replacedFlywheel,\n IonicFlywheelCore _flywheel,\n address _owner,\n Authority _authority\n ) FlywheelStaticRewards(_flywheel, _owner, _authority) {\n ERC20 _rewardToken = _flywheel.rewardToken();\n _rewardToken.safeApprove(address(_replacedFlywheel), type(uint256).max);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/WithdrawableFlywheelStaticRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { FlywheelStaticRewards } from \"./FlywheelStaticRewards.sol\";\nimport { IonicFlywheelCore } from \"../IonicFlywheelCore.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { SafeTransferLib, ERC20 } from \"solmate/utils/SafeTransferLib.sol\";\n\ncontract WithdrawableFlywheelStaticRewards is FlywheelStaticRewards {\n using SafeTransferLib for ERC20;\n\n constructor(\n IonicFlywheelCore _flywheel,\n address _owner,\n Authority _authority\n ) FlywheelStaticRewards(_flywheel, _owner, _authority) {}\n\n function withdraw(uint256 amount) external {\n require(msg.sender == flywheel.owner());\n rewardToken.safeTransfer(address(flywheel.owner()), amount);\n }\n}\n" + }, + "contracts/ionic/strategies/IonicERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nimport { PausableUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol\";\nimport { ERC4626Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nabstract contract IonicERC4626 is SafeOwnableUpgradeable, PausableUpgradeable, ERC4626Upgradeable {\n using FixedPointMathLib for uint256;\n using SafeERC20Upgradeable for ERC20Upgradeable;\n\n /* ========== STATE VARIABLES ========== */\n\n uint256 public vaultShareHWM;\n uint256 public performanceFee;\n address public feeRecipient;\n\n /* ========== EVENTS ========== */\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /* ========== INITIALIZER ========== */\n\n function __IonicER4626_init(ERC20Upgradeable asset_) internal onlyInitializing {\n __SafeOwnable_init(msg.sender);\n __Pausable_init();\n __Context_init();\n __ERC20_init(\n string(abi.encodePacked(\"Ionic \", asset_.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", asset_.symbol()))\n );\n __ERC4626_init(asset_);\n\n vaultShareHWM = 10**asset_.decimals();\n feeRecipient = msg.sender;\n }\n\n function _asset() internal view returns (ERC20Upgradeable) {\n return ERC20Upgradeable(super.asset());\n }\n\n /* ========== DEPOSIT/WITHDRAW FUNCTIONS ========== */\n\n function deposit(uint256 assets, address receiver) public override whenNotPaused returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public override whenNotPaused returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public override returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public override returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n /* ========== FEE FUNCTIONS ========== */\n\n /**\n * @notice Take the performance fee that has accrued since last fee harvest.\n * @dev Performance fee is based on a vault share high water mark value. If vault share value has increased above the\n * HWM in a fee period, issue fee shares to the vault equal to the performance fee.\n */\n function takePerformanceFee() external onlyOwner {\n require(feeRecipient != address(0), \"fee recipient not initialized\");\n\n uint256 currentAssets = totalAssets();\n uint256 shareValue = convertToAssets(10**_asset().decimals());\n\n require(shareValue > vaultShareHWM, \"shareValue !> vaultShareHWM\");\n // cache value\n uint256 supply = totalSupply();\n\n uint256 accruedPerformanceFee = (performanceFee * (shareValue - vaultShareHWM) * supply) / 1e36;\n _mint(feeRecipient, accruedPerformanceFee.mulDivDown(supply, (currentAssets - accruedPerformanceFee)));\n\n vaultShareHWM = convertToAssets(10**_asset().decimals());\n }\n\n /**\n * @notice Transfer accrued fees to rewards manager contract. Caller must be a registered keeper.\n * @dev We must make sure that feeRecipient is not address(0) before withdrawing fees\n */\n function withdrawAccruedFees() external onlyOwner {\n redeem(balanceOf(feeRecipient), feeRecipient, feeRecipient);\n }\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n */\n function updateFeeSettings(uint256 newPerformanceFee, address newFeeRecipient) external onlyOwner {\n emit UpdatedFeeSettings(performanceFee, newPerformanceFee, feeRecipient, newFeeRecipient);\n\n performanceFee = newPerformanceFee;\n\n if (newFeeRecipient != feeRecipient) {\n if (feeRecipient != address(0)) {\n uint256 oldFees = balanceOf(feeRecipient);\n\n _burn(feeRecipient, oldFees);\n _approve(feeRecipient, owner(), 0);\n _mint(newFeeRecipient, oldFees);\n }\n\n _approve(newFeeRecipient, owner(), type(uint256).max);\n }\n\n feeRecipient = newFeeRecipient;\n }\n\n /* ========== EMERGENCY FUNCTIONS ========== */\n\n // Should withdraw all funds from the strategy and pause the contract\n function emergencyWithdrawAndPause() external virtual;\n\n function unpause() external virtual;\n\n function shutdown(address market) external onlyOwner whenPaused returns (uint256) {\n ERC20Upgradeable theAsset = _asset();\n uint256 endBalance = theAsset.balanceOf(address(this));\n theAsset.transfer(market, endBalance);\n return endBalance;\n }\n\n /* ========== INTERNAL HOOKS LOGIC ========== */\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual;\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual;\n}\n" + }, + "contracts/ionic/strategies/MockERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626 is ERC4626 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /**\n @notice Creates a new Vault that accepts a specific underlying token.\n @param _asset The ERC20 compliant token the Vault should accept.\n */\n constructor(ERC20 _asset)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {}\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/ionic/strategies/MockERC4626Dynamic.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IonicFlywheelCore } from \"./flywheel/IonicFlywheelCore.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626Dynamic is ERC4626 {\n using FixedPointMathLib for uint256;\n\n /* ========== STATE VARIABLES ========== */\n IonicFlywheelCore public immutable flywheel;\n\n /* ========== INITIALIZER ========== */\n\n /**\n @notice Initializes the Vault.\n @param _asset The ERC20 compliant token the Vault should accept.\n @param _flywheel Flywheel to pull in rewardsToken\n */\n constructor(ERC20 _asset, IonicFlywheelCore _flywheel)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {\n flywheel = _flywheel;\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/IonicLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./utils/IW_NATIVE.sol\";\n\nimport \"./external/uniswap/IUniswapV2Router02.sol\";\nimport \"./external/uniswap/IUniswapV2Pair.sol\";\nimport \"./external/uniswap/IUniswapV2Callee.sol\";\nimport \"./external/uniswap/UniswapV2Library.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicLiquidator\n * @author David Lucid (https://github.com/davidlucid)\n * @notice IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).\n * @dev Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.\n */\ncontract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, IExpressRelayFeeReceiver {\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n\n /**\n * @dev W_NATIVE contract address.\n */\n address public W_NATIVE_ADDRESS;\n\n /**\n * @dev UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)\n */\n IUniswapV2Router02 public UNISWAP_V2_ROUTER_02;\n\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n mapping(address => bool) public redemptionStrategiesWhitelist;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n /**\n * @dev Percentage of the flash swap fee, measured in basis points.\n */\n uint8 public flashSwapFee;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(\n address _wtoken,\n address _uniswapV2router,\n uint8 _flashSwapFee\n ) external initializer {\n __Ownable_init();\n require(_uniswapV2router != address(0), \"_uniswapV2router not defined.\");\n W_NATIVE_ADDRESS = _wtoken;\n UNISWAP_V2_ROUTER_02 = IUniswapV2Router02(_uniswapV2router);\n flashSwapFee = _flashSwapFee;\n }\n\n function _becomeImplementation(bytes calldata data) external {}\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @dev Internal function to approve\n */\n function justApprove(\n IERC20Upgradeable token,\n address to,\n uint256 amount\n ) private {\n token.approve(to, amount);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n justApprove(underlying, address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.\n * @param vars @see LiquidateToTokensWithFlashSwapVars.\n */\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n onlyLowHF(vars.borrower, vars.cTokenCollateral)\n returns (uint256)\n {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV2Pair flashSwapPair = IUniswapV2Pair(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPair.token0() == address(fundingToken);\n flashSwapPair.swap(\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n address(this),\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n function uniswapV2Call(\n address,\n uint256,\n uint256,\n bytes calldata data\n ) public override {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars);\n }\n\n /**\n * @dev Callback function for PCS flashloans.\n */\n function pancakeCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n function moraswapCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(LiquidateToTokensWithFlashSwapVars memory vars) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n justApprove(IERC20Upgradeable(underlyingBorrow), address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData\n ) private returns (address) {\n // Calculate flashloan return amount\n uint256 flashSwapReturnAmount = (_flashSwapAmount * 10000) / (10000 - flashSwapFee);\n if ((_flashSwapAmount * 10000) % (10000 - flashSwapFee) > 0) flashSwapReturnAmount++; // Round up if division resulted in a remainder\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n IUniswapV2Pair pair = IUniswapV2Pair(msg.sender);\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pair.token0() || address(underlyingCollateral) == pair.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay amount for the borrow side\n collateralRequired = flashSwapReturnAmount;\n } else {\n // repay amount for the non-borrow side\n collateralRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n _flashSwapAmount, //flashSwapReturnAmount,\n array(address(underlyingCollateral), _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n // Repay flashloan\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n require(\n underlyingCollateral.transfer(msg.sender, collateralRequired),\n \"Failed to repay token flashloan on borrow side.\"\n );\n\n return address(underlyingCollateral);\n } else {\n // exchange the collateral to W_NATIVE to repay the borrow side\n uint256 wethRequired;\n if (_flashSwapToken == W_NATIVE_ADDRESS) {\n wethRequired = flashSwapReturnAmount;\n } else {\n // Get W_NATIVE required to repay flashloan\n wethRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n flashSwapReturnAmount,\n array(W_NATIVE_ADDRESS, _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n if (address(underlyingCollateral) != W_NATIVE_ADDRESS) {\n // Approve to Uniswap router\n justApprove(underlyingCollateral, address(UNISWAP_V2_ROUTER_02), underlyingCollateralSeized);\n\n // Swap collateral tokens for W_NATIVE to be repaid via Uniswap router\n UNISWAP_V2_ROUTER_02.swapTokensForExactTokens(\n wethRequired,\n underlyingCollateralSeized,\n array(address(underlyingCollateral), W_NATIVE_ADDRESS),\n address(this),\n block.timestamp\n );\n }\n\n // Repay flashloan\n require(\n wethRequired <= IERC20Upgradeable(W_NATIVE_ADDRESS).balanceOf(address(this)),\n \"Not enough W_NATIVE exchanged from seized collateral to repay flashloan.\"\n );\n require(\n IW_NATIVE(W_NATIVE_ADDRESS).transfer(msg.sender, wethRequired),\n \"Failed to repay Uniswap flashloan with W_NATIVE exchanged from seized collateral.\"\n );\n\n // Return the profited token (underlying collateral if same as exchangeProfitTo; otherwise, W_NATIVE)\n return address(underlyingCollateral);\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external\n onlyOwner\n {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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 /**\n * @dev Returns an array containing the parameters supplied.\n */\n function array(address a, address b) private pure returns (address[] memory) {\n address[] memory arr = new address[](2);\n arr[0] = a;\n arr[1] = b;\n return arr;\n }\n}\n" + }, + "contracts/IonicUniV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./external/uniswap/IUniswapV3FlashCallback.sol\";\nimport \"./external/uniswap/IUniswapV3Pool.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\nimport { IUniswapV3Quoter } from \"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IFlashLoanReceiver } from \"./ionic/IFlashLoanReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicUniV3Liquidator\n * @author Veliko Minkov (https://github.com/vminkov)\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\n */\ncontract IonicUniV3Liquidator is\n OwnableUpgradeable,\n ILiquidator,\n IUniswapV3FlashCallback,\n IExpressRelayFeeReceiver,\n IFlashLoanReceiver\n{\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n\n address public W_NATIVE_ADDRESS;\n mapping(address => bool) public redemptionStrategiesWhitelist;\n IUniswapV3Quoter public quoter;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(address _wtoken, address _quoter) external initializer {\n __Ownable_init();\n W_NATIVE_ADDRESS = _wtoken;\n quoter = IUniswapV3Quoter(_quoter);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n underlying.approve(address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateToTokensWithFlashLoan(\n LiquidateToTokensWithFlashSwapVars calldata vars\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\n flashSwapPool.flash(\n address(this),\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(\n LiquidateToTokensWithFlashSwapVars memory vars,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\n uint256 flashSwapReturnAmount = _flashSwapAmount;\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\n flashSwapReturnAmount += fee0;\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\n flashSwapReturnAmount += fee1;\n } else {\n revert(\"wrong pool or _flashSwapToken\");\n }\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay the borrowed asset directly\n collateralRequired = flashSwapReturnAmount;\n\n // Repay flashloan\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\n } else {\n // TODO swap within the same pool and then repay the FL to the pool\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\n\n {\n collateralRequired = quoter.quoteExactOutputSingle(\n zeroForOne ? pool.token0() : pool.token1(),\n zeroForOne ? pool.token1() : pool.token0(),\n pool.fee(),\n _flashSwapAmount,\n 0 // sqrtPriceLimitX96\n );\n }\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n\n // Repay flashloan\n pool.swap(\n address(pool),\n zeroForOne,\n int256(collateralRequired),\n 0, // sqrtPriceLimitX96\n \"\"\n );\n }\n\n return address(underlyingCollateral);\n } else {\n revert(\"the redemptions strategy did not swap to the flash swapped pool assets\");\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n bool[] calldata whitelisted\n ) external onlyOwner {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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" + }, + "contracts/liquidators/AaveTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/compound/ICErc20.sol\";\nimport \"../external/aave/IAToken.sol\";\nimport \"../external/aave/ILendingPool.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title AaveTokenLiquidator\n * @notice Redeems seized Aave Market Tokens for underlying tokens for use as a step in a liquidation.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract AaveTokenLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n address _outputToken = abi.decode(strategyData, (address));\n\n IAToken aaveMarket = IAToken(address(inputToken));\n ILendingPool pool = aaveMarket.POOL();\n\n pool.withdraw(_outputToken, type(uint256).max, address(this));\n\n outputToken = IERC20Upgradeable(_outputToken);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"AaveTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AerodromeCLLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { ISwapRouter_Aerodrome } from \"../external/aerodrome/IAerodromeSwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\ncontract AerodromeCLLiquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n ,\n address _outputToken,\n ISwapRouter_Aerodrome swapRouter,\n address _unwrappedInput,\n address _unwrappedOutput,\n int24 _tickSpacing\n ) = abi.decode(strategyData, (address, address, ISwapRouter_Aerodrome, address, address, int24));\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(_outputToken);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n ISwapRouter_Aerodrome.ExactInputSingleParams(\n address(inputToken),\n address(outputToken),\n _tickSpacing,\n address(this),\n block.timestamp,\n inputAmount,\n 0,\n 0\n )\n );\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(_outputToken), outputAmount);\n IERC4626(_outputToken).deposit(outputAmount, address(this));\n outputAmount = IERC4626(_unwrappedOutput).balanceOf(address(this));\n outputToken = IERC20Upgradeable(_outputToken);\n }\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"AerodromeCLLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AerodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\n\n/**\n * @title AerodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Aerodrome V2 router for use as a step in a liquidation.\n */\ncontract AerodromeV2Liquidator {\n function _swap(IRouter_Aerodrome router, uint256 inputAmount, IRouter_Aerodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"AerodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Aerodrome router, IRouter_Aerodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Aerodrome, IRouter_Aerodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid AerodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/liquidators/AlgebraSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/algebra/ISwapRouter.sol\";\n\n/**\n * @title AlgebraSwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Algebra router for use as a step in a liquidation.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract AlgebraSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address _outputToken, IAlgebraSwapRouter swapRouter) = abi.decode(strategyData, (address, IAlgebraSwapRouter));\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n IAlgebraSwapRouter.ExactInputSingleParams memory params = IAlgebraSwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n address(this),\n block.timestamp,\n inputAmount,\n 0, // amountOutMinimum\n 0 // limitSqrtPrice\n );\n\n outputAmount = swapRouter.exactInputSingle(params);\n }\n\n function name() public pure returns (string memory) {\n return \"AlgebraSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AlphaHomoraV1BankLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/alpha/Bank.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title AlphaHomoraV1BankLiquidator\n * @notice Redeems seized Alpha Homora v1 ibETH (Bank) tokens for ETH for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract AlphaHomoraV1BankLiquidator is IRedemptionStrategy {\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem ibTokenV2 for underlying ETH token (and store output as new collateral)\n Bank bank = Bank(address(inputToken));\n bank.withdraw(inputAmount);\n outputToken = IERC20Upgradeable(address(0));\n outputAmount = address(this).balance;\n\n // Convert to W_NATIVE because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"AlphaHomoraV1BankLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AlphaHomoraV2SafeBoxETHLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/alpha/ISafeBoxETH.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title AlphaHomoraV2SafeBoxETHLiquidator\n * @notice Redeems seized Alpha Homora v2 \"ibETHv2\" (SafeBoxETH) tokens for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract AlphaHomoraV2SafeBoxETHLiquidator is IRedemptionStrategy {\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem ibTokenV2 for underlying ETH (and store output as new collateral)\n ISafeBoxETH safeBox = ISafeBoxETH(address(inputToken));\n safeBox.withdraw(inputAmount);\n outputToken = IERC20Upgradeable(address(0));\n outputAmount = address(this).balance;\n\n // Convert to W_NATIVE because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"AlphaHomoraV2SafeBoxETHLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AlphaHomoraV2SafeBoxLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/alpha/ISafeBox.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title AlphaHomoraV2SafeBoxLiquidator\n * @notice Redeems seized Alpha Homora v2 \"ibTokenV2\" or SafeBox tokens (e.g., ibDAIv2) for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract AlphaHomoraV2SafeBoxLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem ibTokenV2 for underlying ERC20 token (and store output as new collateral)\n ISafeBox safeBox = ISafeBox(address(inputToken));\n safeBox.withdraw(inputAmount);\n outputToken = IERC20Upgradeable(safeBox.uToken());\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"AlphaHomoraV2SafeBoxLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract BalancerLpTokenLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n IBalancerPool pool = IBalancerPool(address(inputToken));\n IBalancerVault vault = pool.getVault();\n bytes32 poolId = pool.getPoolId();\n (IERC20Upgradeable[] memory tokens, , ) = vault.getPoolTokens(poolId);\n\n uint256 outputTokenIndex = type(uint256).max;\n address outputTokenAddress = abi.decode(strategyData, (address));\n\n uint256 offset = 0;\n for (uint256 i = 0; i < tokens.length; i++) {\n if (address(tokens[i]) == outputTokenAddress) {\n outputTokenIndex = i;\n break;\n } else if (address(tokens[i]) == address(inputToken)) {\n offset = 1;\n }\n }\n\n uint256[] memory minAmountsOut = new uint256[](tokens.length);\n minAmountsOut[outputTokenIndex] = 1;\n outputToken = tokens[outputTokenIndex];\n\n bytes memory userData = abi.encode(ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, inputAmount, outputTokenIndex - offset);\n\n ExitPoolRequest memory request = ExitPoolRequest(\n tokens,\n minAmountsOut,\n userData,\n false //toInternalBalance\n );\n vault.exitPool(poolId, address(this), payable(address(this)), request);\n\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerPoolTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title BalancerPoolTokenLiquidator\n * @notice Exchanges seized Balancer Pool Token (BPT) collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract BalancerPoolTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(IERC20Upgradeable token, address to, uint256 minAmount) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(IERC20Upgradeable inputToken, uint256 inputAmount, bytes memory strategyData)\n external\n override\n returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Balancer pool\n IBalancerPool balancerPool = IBalancerPool(address(inputToken));\n address[] memory tokens = balancerPool.getFinalTokens();\n uint256[] memory minAmountsOut = new uint256[](tokens.length);\n balancerPool.exitPool(inputAmount, minAmountsOut);\n\n // Swap underlying tokens\n (IUniswapV2Router02 uniswapV2Router, address[][] memory swapPaths) = abi.decode(strategyData, (IUniswapV2Router02, address[][]));\n require(swapPaths.length == tokens.length, \"Swap paths array length must match the number of underlying tokens in the Balancer pool.\");\n for (uint256 i = 1; i < swapPaths.length; i++)\n require((swapPaths[0].length > 0 ? swapPaths[0][swapPaths[0].length - 1] : tokens[0]) == (swapPaths[i].length > 0 ? swapPaths[i][swapPaths[i].length - 1] : tokens[i]), \"All underlying token swap paths must output the same token.\");\n\n for (uint256 i = 0; i < swapPaths.length; i++) if (swapPaths[i].length > 0 && swapPaths[i][swapPaths[i].length - 1] != tokens[i]) {\n uint256 swapAmountIn = IERC20Upgradeable(tokens[i]).balanceOf(address(this));\n safeApprove(IERC20Upgradeable(tokens[i]), address(uniswapV2Router), swapAmountIn);\n uniswapV2Router.swapExactTokensForTokens(swapAmountIn, 0, swapPaths[i], address(this), block.timestamp);\n }\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPaths[0].length > 0 ? swapPaths[0][swapPaths[0].length - 1] : tokens[0]);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerPoolTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract BalancerSwapLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address outputTokenAddress, IBalancerPool pool) = abi.decode(strategyData, (address, IBalancerPool));\n\n IBalancerVault vault = pool.getVault();\n bytes32 poolId = pool.getPoolId();\n\n SingleSwap memory singleSwap = SingleSwap(\n poolId,\n SwapKind.GIVEN_IN,\n IAsset(address(inputToken)),\n IAsset(address(outputTokenAddress)),\n inputAmount,\n \"\"\n );\n\n FundManagement memory funds = FundManagement(\n address(this),\n false, // fromInternalBalance\n payable(address(this)),\n false // toInternalBalance\n );\n\n inputToken.approve(address(vault), inputAmount);\n vault.swap(singleSwap, funds, 0, block.timestamp + 10);\n outputAmount = IERC20Upgradeable(outputTokenAddress).balanceOf(address(this));\n return (IERC20Upgradeable(outputTokenAddress), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BaseUniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nabstract contract BaseUniswapV2Liquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2 && swapPath[0] == address(inputToken), \"Invalid UniswapLiquidator swap path.\");\n\n // Swap underlying tokens\n inputToken.approve(address(uniswapV2Router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(uniswapV2Router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1]);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal virtual;\n}\n" + }, + "contracts/liquidators/CErc20Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/compound/ICErc20.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CErc20Liquidator\n * @notice Redeems seized Compound/Cream/Ionic CErc20 cTokens for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CErc20Liquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem cErc20 for underlying ERC20 token (and store output as new collateral)\n ICErc20Compound cErc20 = ICErc20Compound(address(inputToken));\n uint256 redeemResult = cErc20.redeem(inputAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cErc20: error code not equal to 0\");\n outputToken = IERC20Upgradeable(cErc20.underlying());\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"CErc20Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveLiquidityGaugeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurveRegistry.sol\";\nimport \"../external/curve/ICurvePool.sol\";\nimport \"../external/curve/ICurveLiquidityGaugeV2.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLiquidityGaugeV2Liquidator\n * @notice Redeems seized Curve LiquidityGaugeV2 collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLiquidityGaugeV2Liquidator is IRedemptionStrategy {\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem Curve liquidity gauge V2 token for Curve pool LP token (and store output as new collateral)\n ICurveLiquidityGaugeV2 gauge = ICurveLiquidityGaugeV2(address(inputToken));\n gauge.withdraw(inputAmount);\n inputToken = IERC20Upgradeable(gauge.lp_token());\n\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(\n ICurveRegistry(0x7D86446dDb609eD0F5f8684AcF30380a356b2B4c).get_pool_from_lp_token(address(inputToken))\n );\n (uint8 curveCoinIndex, address underlying) = abi.decode(strategyData, (uint8, address));\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(curveCoinIndex)), 1);\n outputToken = IERC20Upgradeable(underlying == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ? address(0) : underlying);\n outputAmount = address(outputToken) == address(0) ? address(this).balance : outputToken.balanceOf(address(this));\n\n // Convert to W_NATIVE if ETH because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n if (address(outputToken) == address(0)) {\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLiquidityGaugeV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurveRegistry.sol\";\nimport \"../external/curve/ICurvePool.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLpTokenLiquidator\n * @notice Redeems seized Curve LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLpTokenLiquidator is IRedemptionStrategy {\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(\n ICurveRegistry(0x7D86446dDb609eD0F5f8684AcF30380a356b2B4c).get_pool_from_lp_token(address(inputToken))\n );\n (uint8 curveCoinIndex, address underlying) = abi.decode(strategyData, (uint8, address));\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(curveCoinIndex)), 1);\n outputToken = IERC20Upgradeable(underlying == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ? address(0) : underlying);\n outputAmount = address(outputToken) == address(0) ? address(this).balance : outputToken.balanceOf(address(this));\n\n // Convert to W_NATIVE if ETH because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n if (address(outputToken) == address(0)) {\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveLpTokenLiquidatorNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\nimport { WETH } from \"solmate/tokens/WETH.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLpTokenLiquidatorNoRegistry\n * @notice Redeems seized Curve LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLpTokenLiquidatorNoRegistry is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // TODO get the curvePool from the strategyData instead of the _oracle\n (address outputTokenAddress, address payable wtoken, address _oracle) = abi.decode(\n strategyData,\n (address, address, address)\n );\n // the oracle contains the pool registry\n CurveLpTokenPriceOracleNoRegistry oracle = CurveLpTokenPriceOracleNoRegistry(_oracle);\n\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(oracle.poolOf(address(inputToken)));\n\n uint8 outputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (outputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == outputTokenAddress) outputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(outputIndex)), 1);\n\n // better safe than sorry\n if (outputTokenAddress == address(0) || outputTokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n WETH(wtoken).deposit{ value: address(this).balance }();\n outputToken = IERC20Upgradeable(wtoken);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n outputAmount = outputToken.balanceOf(address(this));\n\n return (outputToken, outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenLiquidatorNoRegistry\";\n }\n}\n\ncontract CurveLpTokenWrapper is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (ICurvePool curvePool, address _outputTokenAddress) = abi.decode(strategyData, (ICurvePool, address));\n outputToken = IERC20Upgradeable(_outputTokenAddress);\n\n uint8 inputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (inputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == address(inputToken)) inputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n inputToken.approve(address(curvePool), inputAmount);\n uint256[2] memory amounts;\n amounts[inputIndex] = inputAmount;\n curvePool.add_liquidity(amounts, 1);\n\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/CurveMetapoolLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurveStableSwap.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveMetaPoolLpTokenLiquidator\n * @notice Redeems seized Curve Metapool LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveMetaPoolLpTokenLiquidator is IRedemptionStrategy {\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurveStableSwap curvePool = ICurveStableSwap(address(inputToken));\n (uint8 curveCoinIndex, address underlying) = abi.decode(strategyData, (uint8, address));\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(curveCoinIndex)), 1);\n outputToken = IERC20Upgradeable(underlying == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ? address(0) : underlying);\n outputAmount = address(outputToken) == address(0) ? address(this).balance : outputToken.balanceOf(address(this));\n\n // Convert to W_NATIVE if ETH because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n if (address(outputToken) == address(0)) {\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n }\n\n function name() public pure returns (string memory) {\n return \"CurveMetaPoolLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nimport \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\n/**\n * @title CurveSwapLiquidator\n * @notice Swaps seized token collateral via Curve as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable, uint256) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address outputTokenAddress,\n address _unwrappedInput,\n address _unwrappedOutput\n ) = abi.decode(strategyData, (CurveV2LpTokenPriceOracleNoRegistry, address, address, address));\n\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n address inputTokenAddress = address(inputToken);\n\n ICurvePool curvePool;\n int128 i;\n int128 j;\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, address(outputToken));\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n inputToken.approve(address(curvePool), inputAmount);\n outputAmount = curvePool.exchange(i, j, inputAmount, 0);\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(outputTokenAddress), outputAmount);\n IERC4626(outputTokenAddress).deposit(outputAmount, address(this));\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n outputAmount = outputToken.balanceOf(address(this));\n return (outputToken, outputAmount);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"CurveSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CurveSwapLiquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\n\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract CurveSwapLiquidatorFunder is CurveSwapLiquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable, uint256)\n {\n ICurvePool curvePool;\n int128 i;\n int128 j;\n {\n (\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle,\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address inputTokenAddress,\n address outputTokenAddress,\n\n ) = abi.decode(\n strategyData,\n (CurveLpTokenPriceOracleNoRegistry, CurveV2LpTokenPriceOracleNoRegistry, address, address, address)\n );\n\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n if (address(curvePool) == address(0)) {\n (curvePool, i, j) = curveV1Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n IERC20MetadataUpgradeable inputMetadataToken = IERC20MetadataUpgradeable(curvePool.coins(uint256(int256(i))));\n uint256 inputAmountGuesstimate = guesstimateInputAmount(curvePool, i, j, inputMetadataToken, outputAmount);\n uint256 inputAmount = binSearch(\n curvePool,\n i,\n j,\n (70 * inputAmountGuesstimate) / 100,\n (130 * inputAmountGuesstimate) / 100,\n outputAmount\n );\n\n return (inputMetadataToken, inputAmount);\n }\n\n function guesstimateInputAmount(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n IERC20MetadataUpgradeable inputMetadataToken,\n uint256 outputAmount\n ) internal view returns (uint256) {\n uint256 oneInputToken = 10**inputMetadataToken.decimals();\n uint256 outputTokensForOneInputToken = curvePool.get_dy(i, j, oneInputToken);\n // inputAmount / outputAmount = oneInputToken / outputTokensForOneInputToken\n uint256 inputAmount = (outputAmount * oneInputToken) / outputTokensForOneInputToken;\n return inputAmount;\n }\n\n function binSearch(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n uint256 low,\n uint256 high,\n uint256 value\n ) internal view returns (uint256) {\n if (low >= high) return low;\n\n uint256 mid = (low + high) / 2;\n uint256 outputAmount = curvePool.get_dy(i, j, mid);\n if (outputAmount == 0) revert(\"output amount 0\");\n // output can be up to 10% in excess\n if (outputAmount >= value && outputAmount <= (11 * value) / 10) return mid;\n else if (outputAmount > value) {\n return binSearch(curvePool, i, j, low, mid, value);\n } else {\n return binSearch(curvePool, i, j, mid, high, value);\n }\n }\n\n function name() public pure override(CurveSwapLiquidator, IRedemptionStrategy) returns (string memory) {\n return \"CurveSwapLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/CustomLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CustomLiquidator\n * @notice Redeems seized collateral tokens for the specified output token by calling the specified contract for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CustomLiquidator is IRedemptionStrategy {\n using AddressUpgradeable for address;\n\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Call arbitrary contract\n address target;\n bytes memory data;\n (target, data, outputToken) = abi.decode(strategyData, (address, bytes, IERC20Upgradeable));\n target.functionCall(data);\n outputAmount = address(outputToken) == address(0) ? address(this).balance : outputToken.balanceOf(address(this));\n\n // Convert to W_NATIVE if ETH because `IonicLiquidator.repayTokenFlashLoan` only supports tokens (not ETH) as output from redemptions (reverts on line 24 because `underlyingCollateral` is the zero address)\n if (address(outputToken) == address(0)) {\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n }\n\n function name() public pure returns (string memory) {\n return \"CustomLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/DolaStabilizerLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/inverse/Stabilizer.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title DolaStabilizerLiquidator\n * @notice Buys DOLA using DAI and sells DOLA for DAI using the Anchor Stabilizer contract as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract DolaStabilizerLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Anchor's Stabilizer contract for DOLA.\n */\n Stabilizer public STABILIZER = Stabilizer(0x7eC0D931AFFBa01b77711C2cD07c76B970795CDd);\n\n /**\n * @dev Stabilizer's fee denominator.\n */\n uint256 public constant FEE_DENOMINATOR = 10000;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Approve input token to Stabilizer\n safeApprove(inputToken, address(STABILIZER), inputAmount);\n\n // Buy or sell depending on if input is synth or reserve\n address synth = STABILIZER.synth();\n address reserve = STABILIZER.reserve();\n\n if (address(inputToken) == reserve) {\n // Buy DOLA with DAI\n outputAmount = (inputAmount * FEE_DENOMINATOR) / (FEE_DENOMINATOR + STABILIZER.buyFee());\n STABILIZER.buy(outputAmount);\n outputToken = IERC20Upgradeable(synth);\n } else if (address(inputToken) == synth) {\n // Sell DOLA for DAI\n STABILIZER.sell(inputAmount);\n outputToken = IERC20Upgradeable(reserve);\n outputAmount = outputToken.balanceOf(address(this));\n }\n }\n\n function name() public pure returns (string memory) {\n return \"DolaStabilizerLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/ERC4626Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\nimport { IUniswapV2Router02 } from \"../external/uniswap/IUniswapV2Router02.sol\";\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { ISwapRouter } from \"../external/uniswap/ISwapRouter.sol\";\nimport { Quoter } from \"../external/uniswap/quoter/Quoter.sol\";\n\n/**\n * @title ERC4626Liquidator\n * @notice Redeems ERC4626 assets and optionally swaps them via Uniswap V2 router for use as a step in a liquidation.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract ERC4626Liquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IERC20Upgradeable _outputToken, uint24 fee, ISwapRouter swapRouter, address[] memory underlyingTokens, ) = abi\n .decode(strategyData, (IERC20Upgradeable, uint24, ISwapRouter, address[], Quoter));\n\n if (underlyingTokens.length == 1) {\n // If there is only one underlying token, we can just redeem it directly\n require(\n address(_outputToken) == underlyingTokens[0],\n \"ERC4626Liquidator: output token does not match underlying token\"\n );\n\n IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n outputAmount = IERC20Upgradeable(_outputToken).balanceOf(address(this));\n\n return (_outputToken, outputAmount);\n } else {\n // NOTE: for Sommelier, the underlying tokens can be fetched from the Sommelier contract\n // E.g. https://etherscan.io/address/0x6b7f87279982d919bbf85182ddeab179b366d8f2#readContract#F20\n IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n\n // for each token, we need to swap it for the output token\n for (uint256 i = 0; i < underlyingTokens.length; i++) {\n // do nothing if the token is the output token\n if (underlyingTokens[i] == address(_outputToken)) {\n continue;\n }\n if (IERC20Upgradeable(underlyingTokens[i]).balanceOf(address(this)) == 0) {\n continue;\n }\n _swap(\n underlyingTokens[i],\n IERC20Upgradeable(underlyingTokens[i]).balanceOf(address(this)),\n address(_outputToken),\n swapRouter,\n fee\n );\n }\n outputAmount = _outputToken.balanceOf(address(this));\n return (_outputToken, outputAmount);\n }\n }\n\n function _swap(\n address inputToken,\n uint256 inputAmount,\n address outputToken,\n ISwapRouter swapRouter,\n uint24 fee\n ) internal returns (uint256 outputAmount) {\n IERC20Upgradeable(inputToken).approve(address(swapRouter), inputAmount);\n\n ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(\n address(inputToken),\n outputToken,\n fee,\n address(this),\n block.timestamp,\n inputAmount,\n 0,\n 0\n );\n outputAmount = swapRouter.exactInputSingle(params);\n }\n\n function name() public pure returns (string memory) {\n return \"ERC4626Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/gamma/GammaAlgebraLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../IRedemptionStrategy.sol\";\nimport { GammaLpTokenLiquidatorBase, GammaAlgebraLpTokenLiquidatorBase, GammaLpTokenWrapperBase } from \"./GammaLpTokenLiquidatorBase.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract GammaAlgebraLpTokenLiquidator is\n GammaLpTokenLiquidatorBase,\n GammaAlgebraLpTokenLiquidatorBase,\n IRedemptionStrategy\n{\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _redeem(inputToken, inputAmount, strategyData);\n }\n\n function name() public pure returns (string memory) {\n return \"GammaAlgebraLpTokenLiquidator\";\n }\n}\n\ncontract GammaAlgebraLpTokenWrapper is GammaLpTokenWrapperBase, GammaAlgebraLpTokenLiquidatorBase, IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _redeem(inputToken, inputAmount, strategyData);\n }\n\n function name() public pure returns (string memory) {\n return \"GammaAlgebraLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/gamma/GammaLpTokenLiquidatorBase.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../IRedemptionStrategy.sol\";\nimport { IHypervisor } from \"../../external/gamma/IHypervisor.sol\";\nimport { IUniProxy } from \"../../external/gamma/IUniProxy.sol\";\nimport { IUniswapV3Pool } from \"../../external/uniswap/IUniswapV3Pool.sol\";\nimport { IAlgebraSwapRouter } from \"../../external/algebra/ISwapRouter.sol\";\nimport { ISwapRouter as IUniswapSwapRouter } from \"../../external/uniswap/ISwapRouter.sol\";\nimport { IAlgebraPool } from \"../../external/algebra/IAlgebraPool.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nabstract contract GammaTokenLiquidatorAbstractBase {\n function getSqrtX96Price(address pool) public view virtual returns (uint160 sqrtPriceX96);\n\n function exactInputSingle(\n address swapRouter,\n address inputToken,\n address outputToken,\n IHypervisor vault,\n uint256 swapAmount\n ) public payable virtual returns (uint256);\n}\n\ncontract GammaAlgebraLpTokenLiquidatorBase is GammaTokenLiquidatorAbstractBase {\n function getSqrtX96Price(address pool) public view override returns (uint160 sqrtPriceX96) {\n (sqrtPriceX96, , , , , , ) = IAlgebraPool(pool).globalState();\n }\n\n function exactInputSingle(\n address swapRouter,\n address inputToken,\n address outputToken,\n IHypervisor vault,\n uint256 swapAmount\n ) public payable override returns (uint256) {\n if (outputToken == address(0)) {\n outputToken = inputToken == vault.token0() ? vault.token1() : vault.token0();\n }\n return\n IAlgebraSwapRouter(swapRouter).exactInputSingle(\n IAlgebraSwapRouter.ExactInputSingleParams(\n inputToken,\n outputToken,\n address(this),\n block.timestamp,\n swapAmount,\n 0, // amount out min\n 0 // limitSqrtPrice\n )\n );\n }\n}\n\ncontract GammaUniswapV3LpTokenLiquidatorBase is GammaTokenLiquidatorAbstractBase {\n function getSqrtX96Price(address pool) public view override returns (uint160 sqrtPriceX96) {\n (sqrtPriceX96, , , , , , ) = IUniswapV3Pool(pool).slot0();\n }\n\n function exactInputSingle(\n address swapRouter,\n address inputToken,\n address outputToken,\n IHypervisor vault,\n uint256 swapAmount\n ) public payable override returns (uint256) {\n IUniswapV3Pool pool = IUniswapV3Pool(vault.pool());\n if (outputToken == address(0)) {\n outputToken = inputToken == vault.token0() ? vault.token1() : vault.token0();\n }\n return\n IUniswapSwapRouter(swapRouter).exactInputSingle(\n IUniswapSwapRouter.ExactInputSingleParams(\n inputToken,\n outputToken,\n pool.fee(),\n address(this),\n block.timestamp,\n swapAmount,\n 0, // amount out min\n 0 // limitSqrtPrice\n )\n );\n }\n}\n\n/**\n * @title GammaLpTokenLiquidatorBase\n * @notice Exchanges seized Gamma LP token collateral for underlying tokens via an Algebra pool for use as a step in a liquidation.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\nabstract contract GammaLpTokenLiquidatorBase is GammaTokenLiquidatorAbstractBase {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n\n function _redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Gamma pool and underlying tokens\n IHypervisor vault = IHypervisor(address(inputToken));\n\n // First withdraw the underlying tokens\n uint256[4] memory minAmounts;\n vault.withdraw(inputAmount, address(this), address(this), minAmounts);\n\n // then swap one of the underlying for the other\n IERC20Upgradeable token0 = IERC20Upgradeable(vault.token0());\n IERC20Upgradeable token1 = IERC20Upgradeable(vault.token1());\n\n (address _outputToken, address swapRouter) = abi.decode(strategyData, (address, address));\n\n uint256 swapAmount;\n IERC20Upgradeable tokenToSwap;\n if (_outputToken == address(token1)) {\n swapAmount = token0.balanceOf(address(this));\n tokenToSwap = token0;\n } else {\n swapAmount = token1.balanceOf(address(this));\n tokenToSwap = token1;\n }\n\n tokenToSwap.approve(address(swapRouter), swapAmount);\n\n exactInputSingle(swapRouter, address(tokenToSwap), _outputToken, vault, swapAmount);\n\n outputToken = IERC20Upgradeable(_outputToken);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n\nabstract contract GammaLpTokenWrapperBase is GammaTokenLiquidatorAbstractBase {\n function _redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address swapRouter, IUniProxy proxy, IHypervisor vault) = abi.decode(\n strategyData,\n (address, IUniProxy, IHypervisor)\n );\n\n address token0 = vault.token0();\n address token1 = vault.token1();\n {\n uint256 swapAmount;\n {\n uint256 ratio;\n uint256 price;\n {\n uint256 token0Decimals = 10**ERC20Upgradeable(token0).decimals();\n uint256 token1Decimals = 10**ERC20Upgradeable(token1).decimals();\n {\n uint256 decimalsDiff = (1e18 * token0Decimals) / token1Decimals;\n uint256 decimalsDenominator = decimalsDiff > 1e12 ? 1e6 : 1;\n uint256 sqrtPriceX96 = getSqrtX96Price(vault.pool());\n price = ((sqrtPriceX96**2 * (decimalsDiff / decimalsDenominator)) / (2**192)) * decimalsDenominator;\n }\n (uint256 amountStart, uint256 amountEnd) = proxy.getDepositAmount(address(vault), token0, token0Decimals);\n uint256 amount1 = (((amountStart + amountEnd) / 2) * 1e18) / token1Decimals;\n ratio = (amount1 * 1e18) / price;\n }\n\n uint256 swap0 = (inputAmount * 1e18) / (ratio + 1e18);\n swapAmount = address(inputToken) == token0 ? inputAmount - swap0 : swap0;\n }\n\n inputToken.approve(swapRouter, inputAmount);\n exactInputSingle(swapRouter, address(inputToken), address(0), vault, swapAmount);\n }\n\n uint256 deposit0;\n uint256 deposit1;\n {\n deposit0 = IERC20Upgradeable(token0).balanceOf(address(this));\n deposit1 = IERC20Upgradeable(token1).balanceOf(address(this));\n IERC20Upgradeable(token0).approve(address(vault), deposit0);\n IERC20Upgradeable(token1).approve(address(vault), deposit1);\n }\n\n uint256[4] memory minIn;\n outputAmount = proxy.deposit(\n deposit0,\n deposit1,\n address(this), // to\n address(vault),\n minIn\n );\n\n outputToken = IERC20Upgradeable(address(vault));\n }\n}\n" + }, + "contracts/liquidators/gamma/GammaUniswapV3LpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../IRedemptionStrategy.sol\";\nimport { GammaLpTokenLiquidatorBase, GammaUniswapV3LpTokenLiquidatorBase, GammaLpTokenWrapperBase } from \"./GammaLpTokenLiquidatorBase.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract GammaUniswapV3LpTokenLiquidator is\n GammaLpTokenLiquidatorBase,\n GammaUniswapV3LpTokenLiquidatorBase,\n IRedemptionStrategy\n{\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _redeem(inputToken, inputAmount, strategyData);\n }\n\n function name() public pure returns (string memory) {\n return \"GammaUniswapV3LpTokenLiquidator\";\n }\n}\n\ncontract GammaUniswapV3LpTokenWrapper is\n GammaLpTokenWrapperBase,\n GammaUniswapV3LpTokenLiquidatorBase,\n IRedemptionStrategy\n{\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _redeem(inputToken, inputAmount, strategyData);\n }\n\n function name() public pure returns (string memory) {\n return \"GammaUniswapV3LpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/GelatoGUniLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"../external/gelato/GUniPool.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title GelatoGUniLiquidator\n * @notice Exchanges seized GelatoGUni token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract GelatoGUniLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit GUni pool\n GUniPool pool = GUniPool(address(inputToken));\n address token0 = pool.token0();\n address token1 = pool.token1();\n (uint256 amount0, uint256 amount1, ) = pool.burn(inputAmount, address(this));\n\n // Swap underlying tokens\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapToken0Path, address[] memory swapToken1Path) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[], address[])\n );\n require(\n (swapToken0Path.length > 0 ? swapToken0Path[swapToken0Path.length - 1] : token0) ==\n (swapToken1Path.length > 0 ? swapToken1Path[swapToken1Path.length - 1] : token1),\n \"Output of token0 swap path must equal output of token1 swap path.\"\n );\n\n if (swapToken0Path.length > 0 && swapToken0Path[swapToken0Path.length - 1] != token0) {\n safeApprove(IERC20Upgradeable(token0), address(uniswapV2Router), amount0);\n uniswapV2Router.swapExactTokensForTokens(amount0, 0, swapToken0Path, address(this), block.timestamp);\n }\n\n if (swapToken1Path.length > 0 && swapToken1Path[swapToken1Path.length - 1] != token1) {\n safeApprove(IERC20Upgradeable(token1), address(uniswapV2Router), amount1);\n uniswapV2Router.swapExactTokensForTokens(amount1, 0, swapToken1Path, address(this), block.timestamp);\n }\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapToken0Path.length > 0 ? swapToken0Path[swapToken0Path.length - 1] : token0);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"GelatoGUniLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/HarvestLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/harvest/IFarmVault.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title HarvestLiquidator\n * @notice Exchanges seized iFARM token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract HarvestLiquidator is IRedemptionStrategy {\n /**\n * @dev FARM ERC20 token contract.\n */\n IERC20Upgradeable public constant FARM = IERC20Upgradeable(0xa0246c9032bC3A600820415aE600c6388619A14D);\n\n /**\n * @dev iFARM ERC20 token contract.\n */\n IFarmVault public constant IFARM = IFarmVault(0x1571eD0bed4D987fe2b498DdBaE7DFA19519F651);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n if (address(inputToken) == address(IFARM)) {\n IFARM.withdrawAll();\n outputToken = FARM;\n outputAmount = outputToken.balanceOf(address(this));\n } else revert(\"Invalid token address passed to HarvestLiquidator.\");\n }\n\n function name() public pure returns (string memory) {\n return \"HarvestLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/IFundsConversionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFundsConversionStrategy is IRedemptionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\n}\n" + }, + "contracts/liquidators/IRedemptionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\n/**\n * @title IRedemptionStrategy\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function name() external view returns (string memory);\n}\n" + }, + "contracts/liquidators/JarvisLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { ISynthereumLiquidityPool } from \"../external/jarvis/ISynthereumLiquidityPool.sol\";\n\ncontract JarvisLiquidatorFunder is IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n\n // approve so the pool can pull out the input tokens\n inputToken.approve(address(pool), inputAmount);\n\n IERC20Upgradeable collateralToken = pool.collateralToken();\n IERC20Upgradeable syntheticToken = pool.syntheticToken();\n\n if (inputToken == syntheticToken) {\n outputToken = collateralToken;\n\n uint256 shutdownPrice = 0;\n // TODO figure out why this method was removed and what to use instead\n try pool.emergencyShutdownPrice() returns (uint256 price) {\n shutdownPrice = price;\n } catch {}\n\n if (shutdownPrice > 0) {\n // emergency shutdowns cannot be reverted, so this corner case must be covered\n (, uint256 collateralSettled) = pool.settleEmergencyShutdown();\n outputAmount = collateralSettled;\n // outputToken = collateralToken;\n } else {\n // redeem the underlying BUSD\n // fetch the estimated redeemable collateral in BUSD, less the fee paid\n (uint256 redeemableCollateralAmount, ) = pool.getRedeemTradeInfo(inputAmount);\n\n (uint256 collateralAmountReceived, ) = pool.redeem(\n ISynthereumLiquidityPool.RedeemParams(inputAmount, redeemableCollateralAmount, block.timestamp, address(this))\n );\n\n outputAmount = collateralAmountReceived;\n }\n } else if (inputToken == collateralToken) {\n outputToken = syntheticToken;\n\n // mint jBRL from the supplied bUSD\n (uint256 synthTokensReceived, ) = pool.getMintTradeInfo(inputAmount);\n\n (uint256 syntheticTokensMinted, ) = pool.mint(\n ISynthereumLiquidityPool.MintParams(synthTokensReceived, inputAmount, block.timestamp, address(this))\n );\n\n outputAmount = syntheticTokensMinted;\n } else {\n revert(\"unknown input token\");\n }\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address inputTokenAddress, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n\n inputToken = IERC20Upgradeable(inputTokenAddress);\n\n uint8 decimals = 18;\n try IERC20MetadataUpgradeable(inputTokenAddress).decimals() returns (uint8 dec) {\n decimals = dec;\n } catch {}\n uint256 ONE = 10**decimals;\n\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n if (inputToken == pool.syntheticToken()) {\n // collateralAmountReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / collateralAmountReceived\n (uint256 collateralAmountReceived, ) = ISynthereumLiquidityPool(poolAddress).getRedeemTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, collateralAmountReceived);\n } else if (inputToken == pool.collateralToken()) {\n // synthTokensReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / synthTokensReceived\n (uint256 synthTokensReceived, ) = ISynthereumLiquidityPool(poolAddress).getMintTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, synthTokensReceived);\n } else {\n revert(\"unknown input token\");\n }\n }\n\n function name() public pure returns (string memory) {\n return \"JarvisLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/KimUniV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\ncontract KimUniV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(\n inputAmount,\n 0,\n swapPath,\n address(this),\n address(0), // referrer\n block.timestamp\n );\n }\n\n function name() public pure virtual returns (string memory) {\n return \"KimUniV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/MStableLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/mstable/IMasset.sol\";\nimport \"../external/mstable/ISavingsContractV2.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title MStableLiquidator\n * @notice Redeems mUSD, imUSD, mBTC, and imBTC for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract MStableLiquidator is IRedemptionStrategy {\n /**\n * @dev mStable imUSD ERC20 token contract object.\n */\n IMasset public constant MUSD = IMasset(0xe2f2a5C287993345a840Db3B0845fbC70f5935a5);\n\n /**\n * @dev mStable mUSD ERC20 token contract object.\n */\n ISavingsContractV2 public constant IMUSD = ISavingsContractV2(0x30647a72Dc82d7Fbb1123EA74716aB8A317Eac19);\n\n /**\n * @dev mStable mBTC ERC20 token contract object.\n */\n IMasset public constant MBTC = IMasset(0x945Facb997494CC2570096c74b5F66A3507330a1);\n\n /**\n * @dev mStable imBTC ERC20 token contract object.\n */\n ISavingsContractV2 public constant IMBTC = ISavingsContractV2(0x17d8CBB6Bce8cEE970a4027d1198F6700A7a6c24);\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get output token\n if (strategyData.length > 0) (outputToken) = abi.decode(strategyData, (IERC20Upgradeable));\n\n // TODO: Choose asset to redeem dynamically\n if (address(inputToken) == address(MUSD)) {\n // Redeem mUSD for USDC\n if (address(outputToken) == address(0))\n outputToken = IERC20Upgradeable(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // Output USDC by default\n outputAmount = MUSD.redeem(address(outputToken), inputAmount, 1, address(this));\n } else if (address(inputToken) == address(IMUSD)) {\n // Redeem imUSD for mUSD\n uint256 mAssetReturned = IMUSD.redeemCredits(inputAmount);\n require(mAssetReturned > 0, \"Error calling redeem on mStable savings contract: no mUSD returned.\");\n\n // Redeem mUSD for USDC\n if (address(outputToken) == address(0))\n outputToken = IERC20Upgradeable(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // Output USDC by default\n outputAmount = MUSD.redeem(address(outputToken), mAssetReturned, 1, address(this));\n } else if (address(inputToken) == address(MBTC)) {\n // Redeem mUSD for USDC\n if (address(outputToken) == address(0))\n outputToken = IERC20Upgradeable(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); // Output WBTC by default\n outputAmount = MBTC.redeem(address(outputToken), inputAmount, 1, address(this));\n } else if (address(inputToken) == address(IMBTC)) {\n // Redeem imUSD for mUSD\n uint256 mAssetReturned = IMBTC.redeemCredits(inputAmount);\n require(mAssetReturned > 0, \"Error calling redeem on mStable savings contract: no mUSD returned.\");\n\n // Redeem mUSD for USDC\n if (address(outputToken) == address(0))\n outputToken = IERC20Upgradeable(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); // Output WBTC by default\n outputAmount = MBTC.redeem(address(outputToken), mAssetReturned, 1, address(this));\n }\n }\n\n function name() public pure returns (string memory) {\n return \"MStableLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/registry/ILiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILiquidatorsRegistryStorage {\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\n\n function redemptionStrategiesByTokens(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy);\n\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\n\n function owner() external view returns (address);\n\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\n\n function customUniV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (address);\n}\n\ninterface ILiquidatorsRegistryExtension {\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\n\n function getAllRedemptionStrategies() external view returns (address[] memory);\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage);\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256);\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage);\n}\n\ninterface ILiquidatorsRegistrySecondExtension {\n function getAllPairsStrategies()\n external\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n );\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool);\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool);\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool);\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external;\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external;\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external;\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external;\n\n function optimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IERC20Upgradeable[] memory);\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external;\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\n}\n\ninterface ILiquidatorsRegistry is\n ILiquidatorsRegistryExtension,\n ILiquidatorsRegistrySecondExtension,\n ILiquidatorsRegistryStorage\n{}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\nimport \"./LiquidatorsRegistryExtension.sol\";\n\ncontract LiquidatorsRegistry is LiquidatorsRegistryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n constructor(AddressesProvider _ap) SafeOwnable() {\n ap = _ap;\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function asExtension() public view returns (LiquidatorsRegistryExtension) {\n return LiquidatorsRegistryExtension(address(this));\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../IRedemptionStrategy.sol\";\nimport \"../../ionic/DiamondExtension.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \"../../external/aerodrome/IAerodromeRouter.sol\";\nimport { IRouter_Velodrome as IVelodromeV2Router } from \"../../external/velodrome/IVelodromeRouter.sol\";\nimport { IRouter } from \"../../external/solidly/IRouter.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error NoRedemptionPath();\n error OutputTokenMismatch();\n\n event SlippageUpdated(\n IERC20Upgradeable indexed from,\n IERC20Upgradeable indexed to,\n uint256 prevValue,\n uint256 newValue\n );\n\n // @notice maximum slippage in swaps, in bps\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 7;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\n functionSelectors[--fnsCount] = this.swap.selector;\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\n functionSelectors[--fnsCount] = this.getSlippage.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage) {\n slippage = conversionSlippage[inputToken][outputToken];\n // TODO slippage == 0 should be allowed\n if (slippage == 0) return MAX_SLIPPAGE;\n }\n\n function getAllRedemptionStrategies() public view returns (address[] memory) {\n return redemptionStrategies.values();\n }\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage) {\n if (inputAmount == 0) return (0, 0);\n\n outputAmount = swap(inputToken, inputAmount, outputToken);\n if (outputAmount == 0) return (0, 0);\n\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n uint256 inputTokenPrice = mpo.price(address(inputToken));\n uint256 outputTokenPrice = mpo.price(address(outputToken));\n\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\n\n if (outputTokensValue < inputTokensValue) {\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\n }\n // min slippage should be non-zero\n // just in case of rounding errors\n slippage += 1;\n\n // cache the slippage\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\n\n conversionSlippage[inputToken][outputToken] = slippage;\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\n }\n }\n\n /// @dev returns price scaled to 1e36 - decimals\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\n return\n tokenDecimals <= 18\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\n }\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) public returns (uint256 outputAmount) {\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\n outputAmount = convertAllTo(inputToken, outputToken);\n outputToken.safeTransfer(msg.sender, outputAmount);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\n inputToken,\n outputToken\n );\n\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\n\n IERC20Upgradeable swapInputToken = inputToken;\n uint256 swapInputAmount = inputAmount;\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\n swapInputToken,\n swapInputAmount,\n redemptionStrategy,\n strategyData\n );\n swapInputAmount = swapOutputAmount;\n swapInputToken = swapOutputToken;\n }\n\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\n return outputToken.balanceOf(address(this));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\n return inputTokensByOutputToken[outputToken].values();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n IERC20Upgradeable tokenToRedeem = inputToken;\n IERC20Upgradeable targetOutputToken = outputToken;\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\n bytes[] memory strategiesDataTemp = new bytes[](10);\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\n uint256 optimalPathIterator = 0;\n\n uint256 k = 0;\n while (tokenToRedeem != targetOutputToken) {\n IERC20Upgradeable nextRedeemedToken;\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\n if (address(directStrategy) != address(0)) {\n nextRedeemedToken = targetOutputToken;\n } else {\n // check if an optimal path is preconfigured\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\n }\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\n nextRedeemedToken = optimalPath[optimalPathIterator++];\n } else {\n // else if no optimal path is available, use the default\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\n }\n }\n\n // check if going in an endless loop\n for (uint256 i = 0; i < tokenPath.length; i++) {\n if (nextRedeemedToken == tokenPath[i]) break;\n }\n\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\n tokenToRedeem,\n nextRedeemedToken\n );\n if (address(strategy) == address(0)) break;\n\n strategiesTemp[k] = strategy;\n strategiesDataTemp[k] = strategyData;\n tokenPath[k] = nextRedeemedToken;\n tokenToRedeem = nextRedeemedToken;\n\n k++;\n if (k == 10) break;\n }\n\n strategies = new IRedemptionStrategy[](k);\n strategiesData = new bytes[](k);\n\n for (uint8 i = 0; i < k; i++) {\n strategies[i] = strategiesTemp[i];\n strategiesData[i] = strategiesDataTemp[i];\n }\n }\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\n\n if (isStrategy(strategy, \"UniswapV2LiquidatorFunder\") || isStrategy(strategy, \"KimUniV2Liquidator\")) {\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"UniswapV3LiquidatorFunder\")) {\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AlgebraSwapLiquidator\")) {\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeV2Liquidator\")) {\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeCLLiquidator\")) {\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"CurveSwapLiquidator\")) {\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"VelodromeV2Liquidator\")) {\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\n } else {\n revert(\"no strategy data\");\n }\n }\n\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\n }\n\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\n }\n address wnative = ap.getAddress(\"wtoken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wnative) return wnative;\n }\n address stableToken = ap.getAddress(\"stableToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == stableToken) return stableToken;\n }\n address wbtc = ap.getAddress(\"wBTCToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wbtc) return wbtc;\n }\n return tokens[0];\n }\n\n function getUniswapV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (address) {\n address customRouter = customUniV3Router[inputToken][outputToken];\n if (customRouter == address(0)) {\n customRouter = customUniV3Router[outputToken][inputToken];\n }\n\n if (customRouter != address(0)) {\n return customRouter;\n } else {\n // get asset specific router or default\n return ap.getAddress(\"UNISWAP_V3_ROUTER\");\n }\n }\n\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"IUniswapV2Router02\");\n }\n\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_V2_ROUTER\");\n }\n\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_CL_ROUTER\");\n }\n\n function uniswapV3LiquidatorFunderData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\n if (fee == 0) fee = 500;\n\n address router = getUniswapV3Router(inputToken, outputToken);\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\"Quoter\"));\n }\n\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\n return _wrappedToUnwrapped4626[address(inputToken)];\n }\n\n function getAeroCLTickSpacing(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (int24) {\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\n if (tickSpacing == 0) {\n tickSpacing = 1;\n }\n return tickSpacing;\n }\n\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\n }\n\n function uniswapV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\n swapPath[0] = inputToken;\n swapPath[1] = outputToken;\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\n }\n\n function aerodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\n swapPath[0] = IAerodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken),\n factory: ap.getAddress(\"AERODROME_V2_FACTORY\")\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n\n function aerodromeCLLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n inputToken,\n outputToken,\n getAerodromeCLRouter(inputToken),\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken),\n getAeroCLTickSpacing(inputToken, outputToken)\n );\n }\n\n function algebraSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(outputToken, ap.getAddress(\"ALGEBRA_SWAP_ROUTER\"));\n }\n\n function curveSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n ap.getAddress(\"CURVE_V2_ORACLE_NO_REGISTRY\"),\n outputToken,\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken)\n );\n }\n\n function velodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\n swapPath[0] = IVelodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken)\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../../ionic/DiamondExtension.sol\";\n\ncontract LiquidatorsRegistrySecondExtension is\n LiquidatorsRegistryStorage,\n DiamondExtension,\n ILiquidatorsRegistrySecondExtension\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 20;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getAllPairsStrategies.selector;\n functionSelectors[--fnsCount] = this.pairsStrategiesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsFeesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsRoutersMatch.selector;\n functionSelectors[--fnsCount] = this._setSlippages.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Fees.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Routers.selector;\n functionSelectors[--fnsCount] = this._setDefaultOutputToken.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this._removeRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._resetRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.optimalSwapPath.selector;\n functionSelectors[--fnsCount] = this._setOptimalSwapPath.selector;\n functionSelectors[--fnsCount] = this.wrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this.aeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this.aeroV2IsStable.selector;\n functionSelectors[--fnsCount] = this._setWrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this._setAeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this._setAeroV2IsStable.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external onlyOwner {\n require(slippages.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < slippages.length; i++) {\n conversionSlippage[inputTokens[i]][outputTokens[i]] = slippages[i];\n }\n }\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external onlyOwner {\n require(fees.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < fees.length; i++) {\n uniswapV3Fees[inputTokens[i]][outputTokens[i]] = fees[i];\n }\n }\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external onlyOwner {\n require(routers.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < routers.length; i++) {\n customUniV3Router[inputTokens[i]][outputTokens[i]] = routers[i];\n }\n }\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external onlyOwner {\n defaultOutputToken[inputToken] = outputToken;\n }\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public onlyOwner {\n string memory name = strategy.name();\n IRedemptionStrategy oldStrategy = redemptionStrategiesByName[name];\n\n redemptionStrategiesByTokens[inputToken][outputToken] = strategy;\n redemptionStrategiesByName[name] = strategy;\n\n redemptionStrategies.remove(address(oldStrategy));\n redemptionStrategies.add(address(strategy));\n\n if (defaultOutputToken[inputToken] == IERC20Upgradeable(address(0))) {\n defaultOutputToken[inputToken] = outputToken;\n }\n inputTokensByOutputToken[outputToken].add(address(inputToken));\n outputTokensSet.add(address(outputToken));\n }\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n // empty the input/output token mappings/sets\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n outputTokensSet.remove(_outputTokens[i]);\n }\n\n // empty the strategies mappings/sets\n address[] memory _currentStrategies = redemptionStrategies.values();\n for (uint256 i = 0; i < _currentStrategies.length; i++) {\n IRedemptionStrategy _currentStrategy = IRedemptionStrategy(_currentStrategies[i]);\n string memory _name = _currentStrategy.name();\n redemptionStrategiesByName[_name] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(_currentStrategies[i]);\n }\n\n // write the new strategies and their tokens configs\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external onlyOwner {\n // check all the input/output tokens if they match the strategy to remove\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n IRedemptionStrategy _currentStrategy = redemptionStrategiesByTokens[_inputToken][_outputToken];\n\n // only nullify the input/output tokens config if the strategy matches\n if (_currentStrategy == strategyToRemove) {\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n if (defaultOutputToken[_inputToken] == _outputToken) {\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n }\n }\n if (inputTokensByOutputToken[_outputToken].length() == 0) {\n outputTokensSet.remove(address(_outputToken));\n }\n }\n\n redemptionStrategiesByName[strategyToRemove.name()] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(address(strategyToRemove));\n }\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool) {\n // find a match for each config fee\n for (uint256 i = 0; i < configFees.length; i++) {\n if (uniswapV3Fees[configInputTokens[i]][configOutputTokens[i]] != configFees[i]) return false;\n }\n\n return true;\n }\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool) {\n // find a match for each config router\n for (uint256 i = 0; i < configRouters.length; i++) {\n if (customUniV3Router[configInputTokens[i]][configOutputTokens[i]] != configRouters[i]) return false;\n }\n\n return true;\n }\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool) {\n (\n IRedemptionStrategy[] memory onChainStrategies,\n IERC20Upgradeable[] memory onChainInputTokens,\n IERC20Upgradeable[] memory onChainOutputTokens\n ) = getAllPairsStrategies();\n // find a match for each config strategy\n for (uint256 i = 0; i < configStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < onChainStrategies.length; j++) {\n if (\n onChainStrategies[j] == configStrategies[i] &&\n onChainInputTokens[j] == configInputTokens[i] &&\n onChainOutputTokens[j] == configOutputTokens[i]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n // find a match for each on-chain strategy\n for (uint256 i = 0; i < onChainStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < configStrategies.length; j++) {\n if (\n onChainStrategies[i] == configStrategies[j] &&\n onChainInputTokens[i] == configInputTokens[j] &&\n onChainOutputTokens[i] == configOutputTokens[j]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n return true;\n }\n\n function getAllPairsStrategies()\n public\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n )\n {\n address[] memory _outputTokens = outputTokensSet.values();\n uint256 pairsCounter = 0;\n\n {\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n pairsCounter += _inputTokens.length;\n }\n\n strategies = new IRedemptionStrategy[](pairsCounter);\n inputTokens = new IERC20Upgradeable[](pairsCounter);\n outputTokens = new IERC20Upgradeable[](pairsCounter);\n }\n\n pairsCounter = 0;\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n strategies[pairsCounter] = redemptionStrategiesByTokens[_inputToken][_outputToken];\n inputTokens[pairsCounter] = _inputToken;\n outputTokens[pairsCounter] = _outputToken;\n pairsCounter++;\n }\n }\n }\n\n function optimalSwapPath(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IERC20Upgradeable[] memory)\n {\n return _optimalSwapPath[inputToken][outputToken];\n }\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external onlyOwner {\n _optimalSwapPath[inputToken][outputToken] = optimalPath;\n }\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address) {\n return _wrappedToUnwrapped4626[wrapped];\n }\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24) {\n return _aeroCLTickSpacings[inputToken][outputToken];\n }\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool) {\n return _aeroV2IsStable[inputToken][outputToken];\n }\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external onlyOwner {\n _wrappedToUnwrapped4626[wrapped] = unwrapped;\n }\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external onlyOwner {\n _aeroCLTickSpacings[inputToken][outputToken] = tickSpacing;\n }\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external onlyOwner {\n _aeroV2IsStable[inputToken][outputToken] = isStable;\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../IRedemptionStrategy.sol\";\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\n AddressesProvider public ap;\n\n EnumerableSet.AddressSet internal redemptionStrategies;\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\n EnumerableSet.AddressSet internal outputTokensSet;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\n mapping(address => address) internal _wrappedToUnwrapped4626;\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\n}\n" + }, + "contracts/liquidators/SaddleLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"../external/saddle/ISwap.sol\";\nimport { SaddleLpPriceOracle } from \"../oracles/default/SaddleLpPriceOracle.sol\";\nimport { WETH } from \"solmate/tokens/WETH.sol\";\n\ncontract SaddleLpTokenLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address outputTokenAddress, SaddleLpPriceOracle oracle, address payable wtoken) = abi.decode(\n strategyData,\n (address, SaddleLpPriceOracle, address)\n );\n\n ISwap pool = ISwap(oracle.poolOf(address(inputToken)));\n uint8 index = pool.getTokenIndex(outputTokenAddress);\n\n outputAmount = pool.removeLiquidityOneToken(inputAmount, index, 1, block.timestamp);\n\n // Convert to W_NATIVE if ETH\n if (outputTokenAddress == address(0) || outputTokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n WETH(wtoken).deposit{ value: outputAmount }();\n outputToken = IERC20Upgradeable(wtoken);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n function name() public pure returns (string memory) {\n return \"SaddleLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/SOhmLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/olympus/sOlympus.sol\";\nimport \"../external/olympus/OlympusStaking.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SOhmLiquidator\n * @notice Redeems sOHM for underlying assets for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract SOhmLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Unstake sOHM (and store output OHM as new collateral)\n sOlympus token = sOlympus(address(inputToken));\n OlympusStaking staking = OlympusStaking(token.stakingContract());\n safeApprove(inputToken, address(staking), inputAmount);\n staking.unstake(inputAmount, false);\n outputToken = IERC20Upgradeable(staking.OHM());\n outputAmount = inputAmount;\n }\n\n function name() public pure returns (string memory) {\n return \"SOhmLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/SolidlyLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/solidly/IRouter.sol\";\nimport \"../external/solidly/IPair.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlyLpTokenLiquidator\n * @notice Exchanges seized Solidly LP token collateral for underlying tokens for use as a step in a liquidation.\n */\ncontract SolidlyLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) internal {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Uniswap pool\n IPair pair = IPair(address(inputToken));\n bool stable = pair.stable();\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n pair.transfer(address(pair), inputAmount);\n (uint256 amount0, uint256 amount1) = pair.burn(address(this));\n\n // Swap underlying tokens\n (IRouter solidlyRouter, address tokenTo) = abi.decode(strategyData, (IRouter, address));\n\n if (tokenTo != token0) {\n safeApprove(IERC20Upgradeable(token0), address(solidlyRouter), amount0);\n solidlyRouter.swapExactTokensForTokensSimple(amount0, 0, token0, tokenTo, stable, address(this), block.timestamp);\n } else {\n safeApprove(IERC20Upgradeable(token1), address(solidlyRouter), amount1);\n solidlyRouter.swapExactTokensForTokensSimple(amount1, 0, token1, tokenTo, stable, address(this), block.timestamp);\n }\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenLiquidator\";\n }\n}\n\ncontract SolidlyLpTokenWrapper is IRedemptionStrategy {\n struct WrapSolidlyLpTokenVars {\n uint256 amountToSwapOfToken0ForToken1;\n uint256 amountToSwapOfToken1ForToken0;\n IRouter solidlyRouter;\n IERC20Upgradeable token0;\n IERC20Upgradeable token1;\n bool stable;\n IPair pair;\n IRouter.Route[] swapPath0;\n IRouter.Route[] swapPath1;\n uint256 ratio;\n }\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n WrapSolidlyLpTokenVars memory vars;\n (vars.solidlyRouter, vars.pair, vars.swapPath0, vars.swapPath1) = abi.decode(\n strategyData,\n (IRouter, IPair, IRouter.Route[], IRouter.Route[])\n );\n vars.token0 = IERC20Upgradeable(vars.pair.token0());\n vars.token1 = IERC20Upgradeable(vars.pair.token1());\n vars.stable = vars.pair.stable();\n\n // calculate the amount for token0 or token1 that needs to be swapped for the other\n {\n vars.amountToSwapOfToken1ForToken0 = inputAmount / 2;\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n if (vars.token0 == inputToken) {\n uint256 out1 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken0ForToken1, vars.swapPath0)[\n vars.swapPath0.length\n ];\n // price1For0 is scaled to 18 + token1.decimals - token0.decimals\n uint256 price1For0 = (out1 * 1e18) / vars.amountToSwapOfToken0ForToken1;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n vars.amountToSwapOfToken1ForToken0,\n out1\n );\n\n vars.ratio = (amount1 * 1e36) / (amount0 * price1For0);\n }\n\n if (vars.token1 == inputToken) {\n uint256 out0 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken1ForToken0, vars.swapPath1)[\n vars.swapPath1.length\n ];\n // price0For1 is scaled to 18 + token0.decimals - token1.decimals\n uint256 price0For1 = (out0 * 1e18) / vars.amountToSwapOfToken1ForToken0;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n out0,\n vars.amountToSwapOfToken0ForToken1\n );\n\n vars.ratio = (amount1 * price0For1) / amount0;\n }\n\n // recalculate the amounts to swap based on the ratio of the value of the required input amounts\n vars.amountToSwapOfToken1ForToken0 = (inputAmount * 1e18) / (vars.ratio + 1e18);\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n }\n\n // swap a part of the input token amount for the other token\n if (vars.token0 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken0ForToken1);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken0ForToken1,\n 0,\n vars.swapPath0,\n address(this),\n block.timestamp\n );\n }\n if (vars.token1 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken1ForToken0);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken1ForToken0,\n 0,\n vars.swapPath1,\n address(this),\n block.timestamp\n );\n }\n\n // provide the liquidity\n uint256 token0Balance = vars.token0.balanceOf(address(this));\n uint256 token1Balance = vars.token1.balanceOf(address(this));\n\n vars.token0.approve(address(vars.solidlyRouter), token0Balance);\n vars.token1.approve(address(vars.solidlyRouter), token1Balance);\n vars.solidlyRouter.addLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n token0Balance,\n token1Balance,\n 1,\n 1,\n address(this),\n block.timestamp\n );\n\n outputToken = IERC20Upgradeable(address(vars.pair));\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/SolidlySwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { IRouter } from \"../external/solidly/IRouter.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlySwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Solidly router for use as a step in a liquidation.\n */\ncontract SolidlySwapLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Solidly router and path\n (IRouter solidlyRouter, address tokenTo, bool stable) = abi.decode(strategyData, (IRouter, address, bool));\n\n // Swap underlying tokens\n inputToken.approve(address(solidlyRouter), inputAmount);\n solidlyRouter.swapExactTokensForTokensSimple(\n inputAmount,\n 0,\n address(inputToken),\n tokenTo,\n stable,\n address(this),\n block.timestamp\n );\n\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlySwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/SushiBarLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/sushi/SushiBar.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SushiBarLiquidator\n * @notice Redeems SushiBar (xSUSHI) for underlying SUSHI for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract SushiBarLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Unstake sOHM (and store output OHM as new collateral)\n SushiBar sushiBar = SushiBar(address(inputToken));\n sushiBar.leave(inputAmount);\n outputToken = IERC20Upgradeable(sushiBar.sushi());\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SushiBarLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title UniswapLpTokenLiquidator\n * @notice Exchanges seized Uniswap V2 LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) internal {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Uniswap pool\n IUniswapV2Pair pair = IUniswapV2Pair(address(inputToken));\n address token0 = pair.token0();\n address token1 = pair.token1();\n pair.transfer(address(pair), inputAmount);\n (uint256 amount0, uint256 amount1) = pair.burn(address(this));\n\n // Swap underlying tokens\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapToken0Path, address[] memory swapToken1Path) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[], address[])\n );\n require(\n (swapToken0Path.length > 0 ? swapToken0Path[swapToken0Path.length - 1] : token0) ==\n (swapToken1Path.length > 0 ? swapToken1Path[swapToken1Path.length - 1] : token1),\n \"Output of token0 swap path must equal output of token1 swap path.\"\n );\n\n if (swapToken0Path.length > 0 && swapToken0Path[swapToken0Path.length - 1] != token0) {\n safeApprove(IERC20Upgradeable(token0), address(uniswapV2Router), amount0);\n uniswapV2Router.swapExactTokensForTokens(amount0, 0, swapToken0Path, address(this), block.timestamp);\n }\n\n if (swapToken1Path.length > 0 && swapToken1Path[swapToken1Path.length - 1] != token1) {\n safeApprove(IERC20Upgradeable(token1), address(uniswapV2Router), amount1);\n uniswapV2Router.swapExactTokensForTokens(amount1, 0, swapToken1Path, address(this), block.timestamp);\n }\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapToken0Path.length > 0 ? swapToken0Path[swapToken0Path.length - 1] : token0);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"UniswapLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV1Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV1Exchange.sol\";\nimport \"../external/uniswap/IUniswapV1Factory.sol\";\n\nimport \"../utils/IW_NATIVE.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title UniswapV1Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Uniswap V1 pool for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapV1Liquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev The V1 Uniswap factory contract.\n */\n IUniswapV1Factory private constant UNISWAP_V1_FACTORY = IUniswapV1Factory(0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95);\n\n /**\n * @dev W_NATIVE contract object.\n */\n IW_NATIVE private constant W_NATIVE = IW_NATIVE(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap exchange\n IUniswapV1Exchange uniswapV1Exchange = IUniswapV1Exchange(UNISWAP_V1_FACTORY.getExchange(address(inputToken)));\n\n // Swap underlying tokens\n safeApprove(inputToken, address(uniswapV1Exchange), inputAmount);\n uniswapV1Exchange.tokenToEthSwapInput(inputAmount, 1, block.timestamp);\n\n // Get new collateral\n outputAmount = address(this).balance;\n W_NATIVE.deposit{ value: outputAmount }();\n return (IERC20Upgradeable(address(W_NATIVE)), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"UniswapV1Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\n/**\n * @title UniswapV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Uniswap V2 router for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"UniswapV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { UniswapV2Liquidator } from \"./UniswapV2Liquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\ncontract UniswapV2LiquidatorFunder is UniswapV2Liquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2, \"Invalid UniswapLiquidator swap path.\");\n\n uint256[] memory amounts = uniswapV2Router.getAmountsIn(outputAmount, swapPath);\n\n inputAmount = amounts[0];\n inputToken = IERC20Upgradeable(swapPath[0]);\n }\n\n function name() public pure override(UniswapV2Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV2LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { IV3SwapRouter } from \"../external/uniswap/IV3SwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract UniswapV3Liquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address _outputToken, uint24 fee, IV3SwapRouter swapRouter, ) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, address)\n );\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n IV3SwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n fee,\n address(this),\n inputAmount,\n 0,\n 0\n )\n );\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"UniswapV3Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport \"./UniswapV3Liquidator.sol\";\n\nimport { Quoter } from \"../external/uniswap/quoter/Quoter.sol\";\n\ncontract UniswapV3LiquidatorFunder is UniswapV3Liquidator, IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address _inputToken, address _outputToken, uint24 fee, , Quoter quoter) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, Quoter)\n );\n\n inputAmount = quoter.estimateMinSwapUniswapV3(_inputToken, _outputToken, outputAmount, fee);\n inputToken = IERC20Upgradeable(_inputToken);\n }\n\n function name() public pure override(UniswapV3Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV3LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/VelodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\n\n/**\n * @title VelodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Velodrome V2 router for use as a step in a liquidation.\n */\ncontract VelodromeV2Liquidator {\n function _swap(IRouter_Velodrome router, uint256 inputAmount, IRouter_Velodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"VelodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Velodrome router, IRouter_Velodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Velodrome, IRouter_Velodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid VelodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/liquidators/WombatLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\ninterface IWombatPool {\n function withdraw(\n address token,\n uint256 liquidity,\n uint256 minimumAmount,\n address to,\n uint256 deadline\n ) external returns (uint256 amount);\n}\n\ncontract WombatLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address poolAddress, address _outputToken) = abi.decode(strategyData, (address, address));\n\n safeApprove(inputToken, poolAddress, inputAmount);\n\n outputAmount = IWombatPool(poolAddress).withdraw(_outputToken, inputAmount, 0, address(this), block.timestamp);\n outputToken = IERC20Upgradeable(_outputToken);\n }\n\n function name() public pure returns (string memory) {\n return \"WombatLpTokenLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/WSTEthLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/lido/IWstETH.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title WSTEthLiquidator\n * @notice Redeems wstETH for underlying stETH for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract WSTEthLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Unwrap wstETH (and store output stETH as new collateral)\n IWstETH token = IWstETH(address(inputToken));\n token.unwrap(inputAmount);\n outputToken = IERC20Upgradeable(token.stETH());\n outputAmount = inputAmount;\n }\n\n function name() public pure returns (string memory) {\n return \"WSTEthLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/XBombLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../external/bomb/IXBomb.sol\";\nimport \"./IRedemptionStrategy.sol\";\nimport \"./IFundsConversionStrategy.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n\n/**\n * @title XBombLiquidatorFunder\n * @notice Exchanges seized xBOMB collateral for underlying BOMB tokens for use as a step in a liquidation.\n * @author Veliko Minkov \n */\ncontract XBombLiquidatorFunder is IFundsConversionStrategy {\n /**\n * @notice Redeems xBOMB for the underlying BOMB reward tokens.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address inputTokenAddress, address xbomb, IERC20Upgradeable bomb, IERC20Upgradeable _outputToken) = abi.decode(\n strategyData,\n (address, address, IERC20Upgradeable, IERC20Upgradeable)\n );\n if (inputTokenAddress == xbomb) {\n // burns the xBOMB and returns the underlying BOMB to the liquidator\n inputToken.approve(address(xbomb), inputAmount);\n IXBomb(xbomb).leave(inputAmount);\n\n outputToken = _outputToken;\n outputAmount = outputToken.balanceOf(address(this));\n } else if (inputTokenAddress == address(bomb)) {\n // mints xBOMB\n inputToken.approve(address(xbomb), inputAmount);\n IXBomb(xbomb).enter(inputAmount);\n\n outputToken = _outputToken;\n outputAmount = outputToken.balanceOf(address(this));\n } else {\n revert(\"unknown input token\");\n }\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable, uint256)\n {\n (address inputTokenAddress, address xbomb, IERC20Upgradeable bomb, ) = abi.decode(\n strategyData,\n (address, address, IERC20Upgradeable, IERC20Upgradeable)\n );\n if (inputTokenAddress == xbomb) {\n // what amount of staked/xbomb equals the desired output amount of bomb?\n return (IERC20Upgradeable(inputTokenAddress), IXBomb(xbomb).toSTAKED(outputAmount));\n } else if (inputTokenAddress == address(bomb)) {\n // what amount of reward/bomb equals the desired output amount of xbomb?\n return (IERC20Upgradeable(inputTokenAddress), IXBomb(xbomb).toREWARD(outputAmount));\n } else {\n revert(\"unknown input token\");\n }\n }\n\n function name() public pure returns (string memory) {\n return \"XBombLiquidatorFunder\";\n }\n}\n\ncontract XBombSwap {\n IERC20Upgradeable public testingBomb;\n IERC20Upgradeable public testingStable;\n MasterPriceOracle public oracle;\n\n constructor(\n IERC20Upgradeable _testingBomb,\n IERC20Upgradeable _testingStable,\n MasterPriceOracle _oracle\n ) {\n testingBomb = _testingBomb;\n testingStable = _testingStable;\n oracle = _oracle;\n }\n\n function leave(uint256 _share) external {\n testingBomb.transferFrom(msg.sender, address(this), _share);\n testingStable.transfer(msg.sender, toREWARD(_share));\n }\n\n function enter(uint256 _amount) external {\n testingStable.transferFrom(msg.sender, address(this), _amount);\n testingBomb.transfer(msg.sender, toSTAKED(_amount));\n }\n\n function getExchangeRate() external view returns (uint256) {\n return 1e18;\n }\n\n function toREWARD(uint256 stakedAmount) public view returns (uint256) {\n uint256 bombPrice = oracle.price(address(testingBomb));\n uint256 stablePrice = oracle.price(address(testingStable));\n return (stakedAmount * bombPrice) / stablePrice;\n }\n\n function toSTAKED(uint256 rewardAmount) public view returns (uint256) {\n uint256 bombPrice = oracle.price(address(testingBomb));\n uint256 stablePrice = oracle.price(address(testingStable));\n return (rewardAmount * stablePrice) / bombPrice;\n }\n}\n" + }, + "contracts/liquidators/YearnYVaultV1Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/yearn/IVault.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title YearnYVaultV1Liquidator\n * @notice Exchanges seized Yearn yVault V1 token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract YearnYVaultV1Liquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem yVault token for underlying token (and store output as new collateral)\n IVault yVault = IVault(address(inputToken));\n yVault.withdraw(inputAmount);\n outputToken = IERC20Upgradeable(yVault.token());\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"YearnYVaultV1Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/YearnYVaultV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/yearn/IVaultV2.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title YearnYVaultV2Liquidator\n * @notice Exchanges seized Yearn yVault V2 token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract YearnYVaultV2Liquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Redeem yVault token for underlying token (and store output as new collateral)\n IVaultV2 yVault = IVaultV2(address(inputToken));\n outputAmount = yVault.withdraw(inputAmount);\n outputToken = IERC20Upgradeable(yVault.token());\n }\n\n function name() public pure returns (string memory) {\n return \"YearnYVaultV2Liquidator\";\n }\n}\n" + }, + "contracts/oracles/1337/MockPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/chainlink/AggregatorV3Interface.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title MockPriceOracle\n * @notice Returns mocked prices from a Chainlink-like oracle. Used for local dev only\n * @dev Implements `PriceOracle`.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract MockPriceOracle is BasePriceOracle {\n /**\n * @notice The maximum number of seconds elapsed since the round was last updated before the price is considered stale. If set to 0, no limit is enforced.\n */\n uint256 public maxSecondsBeforePriceIsStale;\n\n /**\n * @dev Constructor to set `maxSecondsBeforePriceIsStale` as well as all Chainlink price feeds.\n */\n constructor(uint256 _maxSecondsBeforePriceIsStale) {\n // Set maxSecondsBeforePriceIsStale\n maxSecondsBeforePriceIsStale = _maxSecondsBeforePriceIsStale;\n }\n\n /**\n * @dev Returns a boolean indicating if a price feed exists for the underlying asset.\n */\n\n function hasPriceFeed(address underlying) external pure returns (bool) {\n return true;\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n */\n\n function random() private view returns (uint256) {\n uint256 r = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 99;\n r = r + 1;\n return r;\n }\n\n function _price(address underlying) internal view returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) return 1e18;\n\n int256 tokenEthPrice = 1;\n uint256 r = random();\n\n return ((uint256(tokenEthPrice) * 1e18) / r) / 1e18;\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n return 1e18;\n }\n}\n" + }, + "contracts/oracles/1337/MockRevertPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title MockRevertPriceOracle\n * @notice Mocks a failing price oracle. Used for testing purposes only\n * @author Jourdan Dunkley (https://github.com/jourdanDunkley)\n */\ncontract MockRevertPriceOracle is BasePriceOracle {\n constructor() {}\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n revert(\"MockPriceOracle: price function is failing.\");\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n revert(\"MockPriceOracle: getUnderlyingPrice function is failing.\");\n }\n}\n" + }, + "contracts/oracles/BasePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../compound/CTokenInterfaces.sol\";\n\n/**\n * @title BasePriceOracle\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\n * @dev Implements the `PriceOracle` interface.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface BasePriceOracle {\n /**\n * @notice Get the price of an underlying asset.\n * @param underlying The underlying asset to get the price of.\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function price(address underlying) external view returns (uint256);\n\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\n}\n" + }, + "contracts/oracles/default/AerodromePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ninterface BasePrices {\n function getManyRatesWithConnectors(\n uint8 src_len,\n address[] memory connectors\n ) external view returns (uint256[] memory rates);\n}\n\ncontract AerodromePriceOracle is BasePriceOracle {\n BasePrices immutable prices;\n address constant WETH = 0x4200000000000000000000000000000000000006;\n\n constructor(address _prices) {\n prices = BasePrices(_prices);\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n address[] memory connectors = new address[](2);\n connectors[0] = token;\n connectors[1] = WETH;\n return prices.getManyRatesWithConnectors(1, connectors)[0];\n }\n}\n" + }, + "contracts/oracles/default/AlgebraPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"./ConcentratedLiquidityBasePriceOracle.sol\";\nimport { IAlgebraPool } from \"../../external/algebra/IAlgebraPool.sol\";\n\nimport \"../../external/uniswap/TickMath.sol\";\nimport \"../../external/uniswap/FullMath.sol\";\n\n/**\n * @title UniswapV3PriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice AlgebraPriceOracle is a price oracle for Algebra pairs.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract AlgebraPriceOracle is ConcentratedLiquidityBasePriceOracle {\n /**\n * @dev Fetches the price for a token from Algebra pools\n */\n function _price(address token) internal view override returns (uint256) {\n uint32[] memory secondsAgos = new uint32[](2);\n uint256 twapWindow = poolFeeds[token].twapWindow;\n address baseToken = poolFeeds[token].baseToken;\n\n secondsAgos[0] = uint32(twapWindow);\n secondsAgos[1] = 0;\n\n IAlgebraPool pool = IAlgebraPool(poolFeeds[token].poolAddress);\n (int56[] memory tickCumulatives, , , ) = pool.getTimepoints(secondsAgos);\n\n int24 tick = int24((tickCumulatives[1] - tickCumulatives[0]) / int56(int256(twapWindow)));\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(tick);\n\n uint256 tokenPrice = getPriceX96FromSqrtPriceX96(pool.token0(), token, sqrtPriceX96);\n return scalePrices(baseToken, token, tokenPrice);\n }\n}\n" + }, + "contracts/oracles/default/AnkrCertificateTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { IStakeManager } from \"../../external/stader/IStakeManager.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title AnkrCertificateTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice AnkrCertificateTokenPriceOracle is a price oracle for Ankr Certificate liquid staked tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\n\ninterface IAnkrCertificate {\n function ratio() external view returns (uint256);\n}\n\ncontract AnkrCertificateTokenPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n IAnkrCertificate public aTokenCertificate;\n\n function initialize(address ankrCertificateToken) public initializer {\n __SafeOwnable_init(msg.sender);\n aTokenCertificate = IAnkrCertificate(ankrCertificateToken);\n }\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n require(underlying == address(aTokenCertificate), \"Invalid underlying\");\n\n // no need to scale as Ankr Ceritificate Token has 18 decimals\n return _price();\n }\n\n function price(address underlying) external view override returns (uint256) {\n require(underlying == address(aTokenCertificate), \"Invalid underlying\");\n return _price();\n }\n\n function _price() internal view returns (uint256) {\n uint256 ONE = 1e18;\n\n // Returns the aXXXb / aXXXc ratio\n // Ankr Ceritificate Token Rebasing token is pegged to 1 BNB\n uint256 exchangeRate = aTokenCertificate.ratio();\n return (ONE * ONE) / exchangeRate;\n }\n}\n" + }, + "contracts/oracles/default/API3PriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IProxy } from \"../../external/api3/IProxy.sol\";\n\nimport \"../BasePriceOracle.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title API3PriceOracle\n * @notice Returns prices from Api3.\n * @dev Implements `PriceOracle`.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract API3PriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @notice Maps ERC20 token addresses to ETH-based Chainlink price feed contracts.\n */\n mapping(address => IProxy) public proxies;\n\n /**\n * @notice Chainlink NATIVE/USD price feed contracts.\n */\n address public NATIVE_TOKEN_USD_PRICE_FEED;\n\n /**\n * @notice The USD Token of the chain\n */\n address public USD_TOKEN;\n\n /**\n * @dev Constructor to set wtoken address and native token USD price feed address\n * @param _usdToken The Wrapped native asset address\n * @param nativeTokenUsd Will this oracle return prices denominated in USD or in the native token.\n */\n function initialize(address _usdToken, address nativeTokenUsd) public initializer {\n __SafeOwnable_init(msg.sender);\n USD_TOKEN = _usdToken;\n NATIVE_TOKEN_USD_PRICE_FEED = nativeTokenUsd;\n }\n\n /**\n * @dev Constructor to set wtoken address and native token USD price feed address\n * @param _usdToken The Wrapped native asset address\n * @param nativeTokenUsd Will this oracle return prices denominated in USD or in the native token.\n */\n function reinitialize(address _usdToken, address nativeTokenUsd) public onlyOwnerOrAdmin {\n USD_TOKEN = _usdToken;\n NATIVE_TOKEN_USD_PRICE_FEED = nativeTokenUsd;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feeds The Chainlink price feed contract addresses for each of `underlyings`.\n */\n function setPriceFeeds(address[] memory underlyings, address[] memory feeds) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feeds.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set feed and base currency\n proxies[underlying] = IProxy(feeds[i]);\n }\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev If the oracle got constructed with `nativeTokenUsd` = TRUE this will return a price denominated in USD otherwise in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n IProxy proxy = proxies[underlying];\n require(address(proxy) != address(0), \"No API3 price feed found for this underlying ERC20 token.\");\n\n uint256 nativeTokenUsdPrice;\n\n if (NATIVE_TOKEN_USD_PRICE_FEED == address(0)) {\n // get the USDX/USD price from the MPO\n uint256 usdNativeTokenPrice = BasePriceOracle(msg.sender).price(USD_TOKEN);\n nativeTokenUsdPrice = 1e36 / usdNativeTokenPrice; // 18 decimals\n } else {\n (int224 nativeTokenUsdPrice224, ) = IProxy(NATIVE_TOKEN_USD_PRICE_FEED).read();\n if (nativeTokenUsdPrice224 <= 0) {\n revert(\"API3PriceOracle: native token price <= 0\");\n }\n nativeTokenUsdPrice = uint256(uint224(nativeTokenUsdPrice224));\n }\n (int224 tokenUsdPrice, ) = proxy.read();\n\n if (tokenUsdPrice <= 0) {\n revert(\"API3PriceOracle: token price <= 0\");\n }\n\n return (uint256(uint224(tokenUsdPrice)) * 1e18) / nativeTokenUsdPrice;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in USD or the native token (implements `BasePriceOracle`).\n * @dev If the oracle got constructed with `nativeTokenUsd` = TRUE this will return a price denominated in USD otherwise in the native token\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/BalancerLpLinearPoolPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IBalancerLinearPool } from \"../../external/balancer/IBalancerLinearPool.sol\";\nimport { IBalancerVault } from \"../../external/balancer/IBalancerVault.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\n/**\n * @title BalancerLpLinearPoolPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BalancerLpLinearPoolPriceOracle is a price oracle for Balancer LP tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\n\ncontract BalancerLpLinearPoolPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n address[] public underlyings;\n bytes32 internal constant REENTRANCY_ERROR_HASH = keccak256(abi.encodeWithSignature(\"Error(string)\", \"BAL#400\"));\n\n function initialize(address[] memory _underlyings) public initializer {\n __SafeOwnable_init(msg.sender);\n underlyings = _underlyings;\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Balancer, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BalancerPairOracle.sol\n */\n function _price(address underlying) internal view virtual returns (uint256) {\n IBalancerLinearPool pool = IBalancerLinearPool(underlying);\n IBalancerVault vault = pool.getVault();\n address mainToken = pool.getMainToken();\n\n // read-only re-entracy protection - this call is always unsuccessful\n (, bytes memory revertData) = address(vault).staticcall{ gas: 5000 }(\n abi.encodeWithSelector(vault.manageUserBalance.selector, new address[](0))\n );\n require(keccak256(revertData) != REENTRANCY_ERROR_HASH, \"Balancer vault view reentrancy\");\n\n // Returns the BLP Token / Main Token rate (1e18)\n uint256 rate = pool.getRate();\n\n // get main token's price (1e18)\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(mainToken);\n return (rate * baseTokenPrice) / 1e18;\n }\n\n /**\n * @dev Register the an underlying.\n * @param _underlying Underlying token for which to add an oracle.\n */\n function registerToken(address _underlying) external onlyOwner {\n bool skip = false;\n for (uint256 j = 0; j < underlyings.length; j++) {\n if (underlyings[j] == _underlying) {\n skip = true;\n break;\n }\n }\n if (!skip) {\n underlyings.push(_underlying);\n }\n }\n\n function getAllUnderlyings() external view returns (address[] memory) {\n return underlyings;\n }\n}\n" + }, + "contracts/oracles/default/BalancerLpStablePoolPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IBalancerStablePool } from \"../../external/balancer/IBalancerStablePool.sol\";\nimport { IBalancerVault } from \"../../external/balancer/IBalancerVault.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\n/**\n * @title BalancerLpStablePoolPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BalancerLpStablePoolPriceOracle is a price oracle for Balancer LP tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\n\ncontract BalancerLpStablePoolPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n bytes32 internal constant REENTRANCY_ERROR_HASH = keccak256(abi.encodeWithSignature(\"Error(string)\", \"BAL#400\"));\n\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Balancer, with 18 decimals of precision.\n */\n function _price(address underlying) internal view virtual returns (uint256) {\n IBalancerStablePool pool = IBalancerStablePool(underlying);\n IBalancerVault vault = pool.getVault();\n\n // read-only re-entrancy protection - this call is always unsuccessful but we need to make sure\n // it didn't fail due to a re-entrancy attack\n (, bytes memory revertData) = address(vault).staticcall{ gas: 50000 }(\n abi.encodeWithSelector(vault.manageUserBalance.selector, new address[](0))\n );\n require(keccak256(revertData) != REENTRANCY_ERROR_HASH, \"Balancer vault view reentrancy\");\n\n bytes32 poolId = pool.getPoolId();\n (IERC20Upgradeable[] memory tokens, , ) = vault.getPoolTokens(poolId);\n uint256 bptIndex = pool.getBptIndex();\n\n uint256 minPrice = type(uint256).max;\n\n for (uint256 i = 0; i < tokens.length; i++) {\n if (i == bptIndex) {\n continue;\n }\n // Get the price of each of the base tokens in ETH\n // This also includes the price of the nested LP tokens, if they are e.g. LinearPools\n // The only requirement is that the nested LP tokens have a price oracle registered\n // See BalancerLpLinearPoolPriceOracle.sol for an example, as well as the relevant tests\n uint256 marketTokenPrice = BasePriceOracle(msg.sender).price(address(tokens[i]));\n uint256 depositTokenPrice = pool.getTokenRate(address(tokens[i]));\n uint256 finalPrice = (marketTokenPrice * 1e18) / depositTokenPrice;\n if (finalPrice < minPrice) {\n minPrice = finalPrice;\n }\n }\n // Multiply the value of each of the base tokens' share in ETH by the rate of the pool\n // pool.getRate() is the rate of the pool, scaled by 1e18\n return (minPrice * pool.getRate()) / 1e18;\n }\n}\n" + }, + "contracts/oracles/default/BalancerLpTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/balancer/IBalancerPool.sol\";\nimport \"../../external/balancer/IBalancerVault.sol\";\nimport \"../../external/balancer/BNum.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\n/**\n * @title BalancerLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BalancerLpTokenPriceOracle is a price oracle for Balancer LP tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract BalancerLpTokenPriceOracle is SafeOwnableUpgradeable, BasePriceOracle, BNum {\n /**\n * @notice MasterPriceOracle for backup for USD price.\n */\n MasterPriceOracle public masterPriceOracle;\n\n function initialize(MasterPriceOracle _masterPriceOracle) public initializer {\n __SafeOwnable_init(msg.sender);\n masterPriceOracle = _masterPriceOracle;\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Balancer, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BalancerPairOracle.sol\n */\n function _price(address underlying) internal view virtual returns (uint256) {\n IBalancerPool pool = IBalancerPool(underlying);\n bytes32 poolId = pool.getPoolId();\n IBalancerVault vault = pool.getVault();\n (IERC20Upgradeable[] memory tokens, uint256[] memory balances, ) = vault.getPoolTokens(poolId);\n\n require(tokens.length == 2, \"Oracle suitable only for Balancer Pools of 2 tokens\");\n\n address tokenA = address(tokens[0]);\n address tokenB = address(tokens[1]);\n\n uint256[] memory weights = pool.getNormalizedWeights();\n\n uint256 pxA = masterPriceOracle.price(tokenA);\n uint256 pxB = masterPriceOracle.price(tokenB);\n\n uint8 decimalsA = ERC20Upgradeable(tokenA).decimals();\n uint8 decimalsB = ERC20Upgradeable(tokenB).decimals();\n\n if (decimalsA < 18) pxA = pxA * (10**(18 - uint256(decimalsA)));\n if (decimalsA > 18) pxA = pxA / (10**(uint256(decimalsA) - 18));\n if (decimalsB < 18) pxB = pxB * (10**(18 - uint256(decimalsB)));\n if (decimalsB > 18) pxB = pxB / (10**(uint256(decimalsB) - 18));\n (uint256 fairResA, uint256 fairResB) = computeFairReserves(\n balances[0],\n balances[1],\n weights[0],\n weights[1],\n pxA,\n pxB\n );\n // use fairReserveA and fairReserveB to compute LP token price\n // LP price = (fairResA * pxA + fairResB * pxB) / totalLPSupply\n return ((fairResA * pxA) + (fairResB * pxB)) / pool.totalSupply();\n }\n\n /// @dev Return fair reserve amounts given spot reserves, weights, and fair prices.\n /// @param resA Reserve of the first asset\n /// @param resB Reserve of the second asset\n /// @param wA Weight of the first asset\n /// @param wB Weight of the second asset\n /// @param pxA Fair price of the first asset\n /// @param pxB Fair price of the second asset\n function computeFairReserves(\n uint256 resA,\n uint256 resB,\n uint256 wA,\n uint256 wB,\n uint256 pxA,\n uint256 pxB\n ) internal pure returns (uint256 fairResA, uint256 fairResB) {\n // NOTE: wA + wB = 1 (normalize weights)\n // constant product = resA^wA * resB^wB\n // constraints:\n // - fairResA^wA * fairResB^wB = constant product\n // - fairResA * pxA / wA = fairResB * pxB / wB\n // Solving equations:\n // --> fairResA^wA * (fairResA * (pxA * wB) / (wA * pxB))^wB = constant product\n // --> fairResA / r1^wB = constant product\n // --> fairResA = resA^wA * resB^wB * r1^wB\n // --> fairResA = resA * (resB/resA)^wB * r1^wB = resA * (r1/r0)^wB\n uint256 r0 = bdiv(resA, resB);\n uint256 r1 = bdiv(bmul(wA, pxB), bmul(wB, pxA));\n // fairResA = resA * (r1 / r0) ^ wB\n // fairResB = resB * (r0 / r1) ^ wA\n if (r0 > r1) {\n uint256 ratio = bdiv(r1, r0);\n fairResA = bmul(resA, bpow(ratio, wB));\n fairResB = bdiv(resB, bpow(ratio, wA));\n } else {\n uint256 ratio = bdiv(r0, r1);\n fairResA = bdiv(resA, bpow(ratio, wB));\n fairResB = bmul(resB, bpow(ratio, wA));\n }\n }\n}\n" + }, + "contracts/oracles/default/BalancerLpTokenPriceOracleNTokens.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../../external/balancer/IBalancerPool.sol\";\nimport \"../../external/balancer/IBalancerVault.sol\";\nimport \"../../external/balancer/BNum.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\n/**\n * @title BalancerLpTokenPriceOracleNTokens\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BalancerLpTokenPriceOracle is a price oracle for Balancer LP tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n This implementation generalises the BalancerLpTokenPriceOracle to allow for >= 2 tokens.\n */\ncontract BalancerLpTokenPriceOracleNTokens is SafeOwnableUpgradeable, BasePriceOracle, BNum {\n /**\n * @notice MasterPriceOracle for backup for USD price.\n */\n MasterPriceOracle public masterPriceOracle;\n\n function initialize(MasterPriceOracle _masterPriceOracle) public initializer {\n __SafeOwnable_init(msg.sender);\n masterPriceOracle = _masterPriceOracle;\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Balancer, with 18 decimals of precision.\n */\n function _price(address underlying) internal view virtual returns (uint256) {\n IBalancerPool pool = IBalancerPool(underlying);\n bytes32 poolId = pool.getPoolId();\n IBalancerVault vault = IBalancerVault(address(pool.getVault()));\n (IERC20Upgradeable[] memory tokens, uint256[] memory reserves, ) = vault.getPoolTokens(poolId);\n\n uint256 nTokens = tokens.length;\n uint256[] memory weights = pool.getNormalizedWeights();\n\n require(nTokens == weights.length, \"nTokens != nWeights\");\n\n uint256[] memory prices = new uint256[](nTokens);\n\n for (uint256 i = 0; i < nTokens; i++) {\n uint256 tokenPrice = masterPriceOracle.price(address(tokens[i]));\n uint256 decimals = ERC20Upgradeable(address(tokens[i])).decimals();\n if (decimals < 18) {\n reserves[i] = reserves[i] * (10**(18 - decimals));\n } else if (decimals > 18) {\n reserves[i] = reserves[i] / (10**(decimals - 18));\n } else {\n reserves[i] = reserves[i];\n }\n prices[i] = tokenPrice;\n }\n\n uint256[] memory fairRes = computeFairReserves(reserves, weights, prices);\n // use fairReserveA and fairReserveB to compute LP token price\n // LP price = (fairRes[i] * px[i] + ... + fairRes[n] * px[n]) / totalLPSupply\n uint256 fairResSum = 0;\n for (uint256 i = 0; i < fairRes.length; i++) {\n fairResSum = fairResSum + (fairRes[i] * prices[i]);\n }\n\n return fairResSum / pool.totalSupply();\n }\n\n /// @dev Return fair reserve amounts given spot reserves, weights, and fair prices.\n /// @param reserves Reserves of the assets\n /// @param weights Weights of the assets\n /// @param prices Fair prices of the assets\n function computeFairReserves(\n uint256[] memory reserves,\n uint256[] memory weights,\n uint256[] memory prices\n ) internal pure returns (uint256[] memory fairReserves) {\n // NOTE: wA + ... + wN = 1 (normalize weights)\n // K = resA^wA * resB^wB\n // constraints:\n // - fairResA^wA * .. * fairResN^wN = K\n // - fairResA * pxA / wA = ... = fairResN * pxN / wN\n // define:\n // - r0_AB = resA / resB ... r0_AN = resA / resN\n // - r1_AB = (Wa / Pa) * (Pb / Wb) ... r1_AN = (Wa / Pa) * (Pn / Wn)\n\n // Solving equations:\n // --> fairResA^wA * (fairResA * (pxA * wB) / (wA * pxB))^wB * ... * (fairResA * (pxA * wN) / (wA * pxN))^wN = K\n // --> fairResA^(wA + ... + wN) * (r1_AB)^-wB * ... * (r1_AN)^-wN = K\n // --> fairResA = resA^wA * ... * resN^wN * (r1_AB)^wB * ... * (r1_AN)^wN\n // --> fairResA = resA * ((resB * r1_AB ) / resA)^wB * ... * ((resN * r1_AN ) / resA)^wN\n // --> fairResA = resA * (r1_AB / r0_AB)^wB * ... * (r1_AN / r1_AN)^wN\n\n // Generalising:\n // --> fairResB = (r1_BA / r0_BA)^wA * resB * ... * (r1_BN / r1_BN)^wN\n // ...\n // --> fairResN = (r1_NA / r0_NA)^wA * ... * (r1_N(N-1) / r1_N(N-1))^w(N-1) * resN\n\n uint256[] memory fairReservesArray = new uint256[](reserves.length);\n\n for (uint256 i = 0; i < reserves.length; i++) {\n uint256[] memory r0array = new uint256[](reserves.length);\n uint256[] memory r1array = new uint256[](reserves.length);\n for (uint256 j = 0; j < reserves.length; j++) {\n if (i == j) {\n r0array[j] = 1;\n r1array[j] = 1;\n } else {\n r0array[j] = bdiv(reserves[i], reserves[j]);\n r1array[j] = bdiv(bmul(weights[i], prices[j]), bmul(weights[j], prices[i]));\n }\n }\n uint256 init = reserves[i];\n for (uint256 k = 0; k < r0array.length; k++) {\n uint256 r0 = r0array[k];\n uint256 r1 = r1array[k];\n\n if (r0 > r1) {\n uint256 ratio = bdiv(r1, r0);\n init = bmul(init, bpow(ratio, weights[k]));\n } else {\n uint256 ratio = bdiv(r0, r1);\n init = bmul(init, bpow(ratio, weights[k]));\n }\n }\n fairReservesArray[i] = init;\n }\n return fairReservesArray;\n }\n}\n" + }, + "contracts/oracles/default/BalancerRateProviderOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { IRateProvider } from \"../../external/balancer/IRateProvider.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\n\n/**\n * @title BalancerRateProviderOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BalancerRateProviderOracle is a price oracle for tokens that have a Balancer rate provider.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\n\ncontract BalancerRateProviderOracle is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps underlying token addresses to rate providers.\n */\n mapping(address => IRateProvider) public rateProviders;\n\n /**\n * @dev Maps underlying token addresses to base token.\n */\n mapping(address => address) public baseTokens;\n\n address[] public underlyings;\n\n function initialize(\n address[] memory _rateProviders,\n address[] memory _baseTokens,\n address[] memory _underlyings\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n require(\n _rateProviders.length == _baseTokens.length && _baseTokens.length == _underlyings.length,\n \"Array lengths not equal.\"\n );\n underlyings = _underlyings;\n // set the other variables\n for (uint256 i = 0; i < _rateProviders.length; i++) {\n rateProviders[_underlyings[i]] = IRateProvider(_rateProviders[i]);\n baseTokens[_underlyings[i]] = _baseTokens[i];\n }\n }\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n // check if the underlying is supported\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n function _price(address underlying) internal view returns (uint256) {\n // throw if not supported\n require(baseTokens[underlying] != address(0), \"Unsupported underlying\");\n\n // Rate is always 1e18 based\n // ER = TOKEN/BASE\n uint256 exchangeRate = rateProviders[underlying].getRate();\n\n // get the base token price, denomimated in NATIVE (1e18)\n // BP = BASE/NATIVE\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseTokens[underlying]);\n\n // ER * BP = TOKEN/NATIVE\n return (exchangeRate * baseTokenPrice) / 1e18;\n }\n\n function getAllUnderlyings() public view returns (address[] memory) {\n return underlyings;\n }\n\n /**\n * @dev Register the pool given underlying, base token and rate provider addresses.\n * @param _rateProvider Rate provider address for the underlying token.\n * @param _baseToken Base token for the underlying token.\n * @param _underlying Underlying token for which to add an oracle.\n */\n function registerToken(\n address _rateProvider,\n address _baseToken,\n address _underlying\n ) external onlyOwner {\n bool skip = false;\n for (uint256 j = 0; j < underlyings.length; j++) {\n if (underlyings[j] == _underlying) {\n skip = true;\n break;\n }\n }\n if (!skip) {\n underlyings.push(_underlying);\n }\n baseTokens[_underlying] = _baseToken;\n rateProviders[_underlying] = IRateProvider(_rateProvider);\n }\n}\n" + }, + "contracts/oracles/default/BNBxPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { IStakeManager } from \"../../external/stader/IStakeManager.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title BNBxPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice BNBxPriceOracle is a price oracle for BNBx liquid staked tokens.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\n\ncontract BNBxPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n IStakeManager public stakeManager;\n address public BNBx;\n\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n stakeManager = IStakeManager(0x7276241a669489E4BBB76f63d2A43Bfe63080F2F);\n (, address _bnbX, , ) = stakeManager.getContracts();\n BNBx = _bnbX;\n }\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n require(underlying == BNBx, \"Invalid underlying\");\n // no need to scale as BNBx has 18 decimals\n return _price();\n }\n\n function price(address underlying) external view override returns (uint256) {\n require(underlying == BNBx, \"Invalid underlying\");\n return _price();\n }\n\n function _price() internal view returns (uint256) {\n uint256 oneBNB = 1e18;\n uint256 exchangeRate = stakeManager.convertBnbXToBnb(oneBNB);\n return exchangeRate;\n }\n}\n" + }, + "contracts/oracles/default/ChainlinkPriceOracleV2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/chainlink/AggregatorV3Interface.sol\";\n\nimport \"../BasePriceOracle.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title ChainlinkPriceOracleV2\n * @notice Returns prices from Chainlink.\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract ChainlinkPriceOracleV2 is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @notice Maps ERC20 token addresses to ETH-based Chainlink price feed contracts.\n */\n mapping(address => AggregatorV3Interface) public priceFeeds;\n\n /**\n * @notice Maps ERC20 token addresses to enums indicating the base currency of the feed.\n */\n mapping(address => FeedBaseCurrency) public feedBaseCurrencies;\n\n /**\n * @notice Enum indicating the base currency of a Chainlink price feed.\n * @dev ETH is interchangeable with the nativeToken of the current chain.\n */\n enum FeedBaseCurrency {\n ETH,\n USD\n }\n\n /**\n * @notice Chainlink NATIVE/USD price feed contracts.\n */\n address public NATIVE_TOKEN_USD_PRICE_FEED;\n\n /**\n * @notice The USD Token of the chain\n */\n address public USD_TOKEN;\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n * @param _usdToken The Wrapped native asset address\n * @param nativeTokenUsd Will this oracle return prices denominated in USD or in the native token.\n */\n function initialize(address _usdToken, address nativeTokenUsd) public initializer {\n __SafeOwnable_init(msg.sender);\n USD_TOKEN = _usdToken;\n NATIVE_TOKEN_USD_PRICE_FEED = nativeTokenUsd;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feeds The Chainlink price feed contract addresses for each of `underlyings`.\n * @param baseCurrency The currency in which `feeds` are based.\n */\n function setPriceFeeds(\n address[] memory underlyings,\n address[] memory feeds,\n FeedBaseCurrency baseCurrency\n ) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feeds.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set feed and base currency\n priceFeeds[underlying] = AggregatorV3Interface(feeds[i]);\n feedBaseCurrencies[underlying] = baseCurrency;\n }\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev If the oracle got constructed with `nativeTokenUsd` = TRUE this will return a price denominated in USD otherwise in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // Get token/ETH price from Chainlink\n AggregatorV3Interface feed = priceFeeds[underlying];\n require(address(feed) != address(0), \"No Chainlink price feed found for this underlying ERC20 token.\");\n FeedBaseCurrency baseCurrency = feedBaseCurrencies[underlying];\n\n if (baseCurrency == FeedBaseCurrency.ETH) {\n (, int256 tokenEthPrice, , , ) = feed.latestRoundData();\n return tokenEthPrice >= 0 ? (uint256(tokenEthPrice) * 1e18) / (10**uint256(feed.decimals())) : 0;\n } else if (baseCurrency == FeedBaseCurrency.USD) {\n int256 nativeTokenUsdPrice;\n uint8 usdPriceDecimals;\n\n if (NATIVE_TOKEN_USD_PRICE_FEED == address(0)) {\n uint256 usdNativeTokenPrice = BasePriceOracle(msg.sender).price(USD_TOKEN);\n nativeTokenUsdPrice = int256(1e36 / usdNativeTokenPrice); // 18 decimals\n usdPriceDecimals = 18;\n } else {\n (, nativeTokenUsdPrice, , , ) = AggregatorV3Interface(NATIVE_TOKEN_USD_PRICE_FEED).latestRoundData();\n if (nativeTokenUsdPrice <= 0) return 0;\n usdPriceDecimals = AggregatorV3Interface(NATIVE_TOKEN_USD_PRICE_FEED).decimals();\n }\n (, int256 tokenUsdPrice, , , ) = feed.latestRoundData();\n\n return\n tokenUsdPrice >= 0\n ? ((uint256(tokenUsdPrice) * 1e18 * (10**uint256(usdPriceDecimals))) / (10**uint256(feed.decimals()))) /\n uint256(nativeTokenUsdPrice)\n : 0;\n } else {\n revert(\"unknown base currency\");\n }\n }\n\n /**\n * @notice Returns the price in of `underlying` either in USD or the native token (implements `BasePriceOracle`).\n * @dev If the oracle got constructed with `nativeTokenUsd` = TRUE this will return a price denominated in USD otherwise in the native token\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/ConcentratedLiquidityBasePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"../../external/uniswap/FullMath.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title ConcentratedLiquidityBasePriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice ConcentratedLiquidityBasePriceOracle is an abstract price oracle for concentrated liquidty (UniV3-like) pairs.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\nabstract contract ConcentratedLiquidityBasePriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\n /**\n * @notice Maps ERC20 token addresses to asset configs.\n */\n mapping(address => AssetConfig) public poolFeeds;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool public canAdminOverwrite;\n\n struct AssetConfig {\n address poolAddress;\n uint256 twapWindow;\n address baseToken;\n }\n\n address public WTOKEN;\n address[] public SUPPORTED_BASE_TOKENS;\n\n function initialize(address _wtoken, address[] memory _supportedBaseTokens) public initializer {\n __SafeOwnable_init(msg.sender);\n WTOKEN = _wtoken;\n SUPPORTED_BASE_TOKENS = _supportedBaseTokens;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param assetConfig The asset configuration which includes pool address and twap window.\n */\n function setPoolFeeds(address[] memory underlyings, AssetConfig[] memory assetConfig) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == assetConfig.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/config\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set asset config for underlying\n require(\n assetConfig[i].baseToken == WTOKEN || _isBaseTokenSupported(assetConfig[i].baseToken),\n \"Base token must be supported\"\n );\n poolFeeds[underlying] = assetConfig[i];\n }\n }\n\n /**\n * @notice Get the token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for WTOKEN)\n * @return Price denominated in NATIVE (scaled by 1e18)\n */\n function price(address underlying) external view returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in NATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in NATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) public view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the price for a token from Uniswap v3\n */\n function _price(address token) internal view virtual returns (uint256);\n\n function getPriceX96FromSqrtPriceX96(\n address token0,\n address priceToken,\n uint160 sqrtPriceX96\n ) public pure returns (uint256 price_) {\n price_ = FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, uint256(2**(96 * 2)) / 1e18);\n if (token0 != priceToken) price_ = 1e36 / price_;\n }\n\n function _isBaseTokenSupported(address token) internal view returns (bool) {\n for (uint256 i = 0; i < SUPPORTED_BASE_TOKENS.length; i++) {\n if (SUPPORTED_BASE_TOKENS[i] == token) {\n return true;\n }\n }\n return false;\n }\n\n function _setSupportedBaseTokens(address[] memory _supportedBaseTokens) external onlyOwner {\n SUPPORTED_BASE_TOKENS = _supportedBaseTokens;\n }\n\n function getSupportedBaseTokens() external view returns (address[] memory) {\n return SUPPORTED_BASE_TOKENS;\n }\n\n function scalePrices(\n address baseToken,\n address token,\n uint256 tokenPrice\n ) internal view returns (uint256) {\n uint256 baseTokenDecimals;\n uint256 tokenPriceScaled;\n\n if (baseToken == address(0) || baseToken == WTOKEN) {\n baseTokenDecimals = 18;\n } else {\n baseTokenDecimals = uint256(ERC20Upgradeable(baseToken).decimals());\n }\n\n uint256 baseNativePrice = BasePriceOracle(msg.sender).price(baseToken);\n\n // scale tokenPrice by 1e18\n uint256 tokenDecimals = uint256(ERC20Upgradeable(token).decimals());\n if (baseTokenDecimals > tokenDecimals) {\n tokenPriceScaled = tokenPrice / (10**(baseTokenDecimals - tokenDecimals));\n } else if (baseTokenDecimals < tokenDecimals) {\n tokenPriceScaled = tokenPrice * (10**(tokenDecimals - baseTokenDecimals));\n } else {\n tokenPriceScaled = tokenPrice;\n }\n return (tokenPriceScaled * baseNativePrice) / 1e18;\n }\n}\n" + }, + "contracts/oracles/default/CurveLpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/curve/ICurvePool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracleNoRegistry\n * @author David Lucid (https://github.com/davidlucid)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract CurveLpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Curve LP token addresses to underlying token addresses.\n */\n mapping(address => address[]) public underlyingTokens;\n\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n * @param _poolUnderlyings The underlying token addresses of a pool\n */\n function initialize(\n address[] memory _lpTokens,\n address[] memory _pools,\n address[][] memory _poolUnderlyings\n ) public initializer {\n require(\n _lpTokens.length == _pools.length && _lpTokens.length == _poolUnderlyings.length,\n \"No LP tokens supplied or array lengths not equal.\"\n );\n\n __SafeOwnable_init(msg.sender);\n for (uint256 i = 0; i < _lpTokens.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n underlyingTokens[_lpTokens[i]] = _poolUnderlyings[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), 0, 0);\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Curve, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/CurveOracle.sol\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(pool != address(0), \"LP token is not registered.\");\n address[] memory tokens = underlyingTokens[lpToken];\n uint256 minPx = type(uint256).max;\n uint256 n = tokens.length;\n\n for (uint256 i = 0; i < n; i++) {\n address ulToken = tokens[i];\n uint256 tokenPx = BasePriceOracle(msg.sender).price(ulToken);\n if (tokenPx < minPx) minPx = tokenPx;\n }\n\n require(minPx != type(uint256).max, \"No minimum underlying token price found.\");\n return (minPx * ICurvePool(pool).get_virtual_price()) / 1e18; // Use min underlying token prices\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n * @param _underlyings Underlying addresses.\n */\n function registerPool(\n address _lpToken,\n address _pool,\n address[] memory _underlyings\n ) external onlyOwner {\n poolOf[_lpToken] = _pool;\n underlyingTokens[_lpToken] = _underlyings;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n\n /**\n * @dev getter for the underlying tokens\n * @param lpToken the LP token address.\n * @return _underlyings Underlying addresses.\n */\n function getUnderlyingTokens(address lpToken) public view returns (address[] memory) {\n return underlyingTokens[lpToken];\n }\n}\n" + }, + "contracts/oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\nimport \"../../external/curve/ICurveV2Pool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve V2 LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract CurveV2LpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n address public usdToken;\n MasterPriceOracle public masterPriceOracle;\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n */\n function initialize(address[] memory _lpTokens, address[] memory _pools) public initializer {\n require(_lpTokens.length == _pools.length, \"No LP tokens supplied or array lengths not equal.\");\n __SafeOwnable_init(msg.sender);\n\n for (uint256 i = 0; i < _pools.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), int128(0), int128(0));\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token price from Curve, with 18 decimals of precision.\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(address(pool) != address(0), \"LP token is not registered.\");\n\n address baseToken = ICurvePool(pool).coins(0);\n uint256 lpPrice = ICurveV2Pool(pool).lp_price();\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n return (lpPrice * baseTokenPrice) / 10**18;\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n */\n function registerPool(address _lpToken, address _pool) external onlyOwner {\n address pool = poolOf[_lpToken];\n require(pool == address(0), \"This LP token is already registered.\");\n poolOf[_lpToken] = _pool;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n}\n" + }, + "contracts/oracles/default/CurveV2PriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/curve/ICurveV2Pool.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve V2 LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract CurveV2PriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolFor;\n\n address[] public tokens;\n\n /**\n * @dev Initializes an array of tokens and pools if desired.\n * @param _tokens Array of token addresses.\n * @param _pools Array of pool addresses.\n */\n function initialize(address[] memory _tokens, address[] memory _pools) public initializer {\n require(_tokens.length == _pools.length, \"No LP tokens supplied or array lengths not equal.\");\n __SafeOwnable_init(msg.sender);\n\n for (uint256 i = 0; i < _pools.length; i++) {\n try ICurvePool(_pools[i]).coins(2) returns (address) {\n revert(\"!only two token pools\");\n } catch {\n // ignore error\n }\n\n poolFor[_tokens[i]] = _pools[i];\n }\n }\n\n function getAllSupportedTokens() public view returns (address[] memory) {\n return tokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < tokens.length; i++) {\n ICurvePool pool = ICurvePool(poolFor[tokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), int128(0), int128(0));\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token price from Curve, with 18 decimals of precision.\n * @param token The LP token contract address for price retrieval.\n */\n function _price(address token) internal view returns (uint256) {\n address pool = poolFor[token];\n require(address(pool) != address(0), \"Token is not registered.\");\n\n address baseToken;\n // Returns always coin(1) / coin(0) [ e.g. USDC (1) / eUSDC (1) ]\n uint256 exchangeRate = ICurveV2Pool(pool).price_oracle();\n\n if (ICurvePool(pool).coins(0) == token) {\n baseToken = ICurvePool(pool).coins(1);\n // USDC / ETH\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n // USDC / ETH * eUSDC / USDC = eUSDC / ETH\n return (baseTokenPrice * 10**18) / exchangeRate;\n } else {\n // if coin(1) is eUSDC, exchangeRate is USDC / eUSDC\n baseToken = ICurvePool(pool).coins(0);\n // USDC / ETH\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n // (USDC / ETH) * (1 / (USDC / eUSDC)) = eUSDC / ETH\n return (baseTokenPrice * exchangeRate) / 10**18;\n }\n }\n\n /**\n * @dev Register the pool given token address and set the pool info.\n * @param _token token to find the corresponding pool.\n * @param _pool Pool address.\n */\n function registerPool(address _token, address _pool) external onlyOwner {\n try ICurvePool(_pool).coins(2) returns (address) {\n revert(\"!only two token pools\");\n } catch {\n // ignore error\n }\n\n address pool = poolFor[_token];\n require(pool == address(0), \"This LP token is already registered.\");\n poolFor[_token] = _pool;\n\n bool skip = false;\n for (uint256 j = 0; j < tokens.length; j++) {\n if (tokens[j] == _token) {\n skip = true;\n break;\n }\n }\n if (!skip) tokens.push(_token);\n }\n}\n" + }, + "contracts/oracles/default/DiaPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IPriceOracle } from \"../../external/compound/IPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\n\ninterface DIAOracleV2 {\n function getValue(string memory key) external view returns (uint128, uint128);\n}\n\n/**\n * @title DiaPriceOracle\n * @notice Returns prices from DIA.\n * @dev Implements `PriceOracle`.\n * @author Rahul Sethuram (https://github.com/rhlsthrm)\n */\ncontract DiaPriceOracle is BasePriceOracle {\n struct DiaOracle {\n DIAOracleV2 feed;\n string key;\n }\n\n /**\n * @notice Maps ERC20 token addresses to ETH-based Chainlink price feed contracts.\n */\n mapping(address => DiaOracle) public priceFeeds;\n\n /**\n * @dev The administrator of this `MasterPriceOracle`.\n */\n address public admin;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool public immutable CAN_ADMIN_OVERWRITE;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public immutable WTOKEN;\n\n /**\n * @notice DIA NATIVE/USD price feed contracts.\n */\n DIAOracleV2 public immutable NATIVE_TOKEN_USD_PRICE_FEED;\n string public NATIVE_TOKEN_USD_KEY;\n\n /**\n * @notice MasterPriceOracle for backup for USD price.\n */\n MasterPriceOracle public immutable MASTER_PRICE_ORACLE;\n address public immutable USD_TOKEN; // token to use as USD price (i.e. USDC)\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n constructor(\n address _admin,\n bool canAdminOverwrite,\n address wtoken,\n DIAOracleV2 nativeTokenUsd,\n string memory nativeTokenUsdKey,\n MasterPriceOracle masterPriceOracle,\n address usdToken\n ) {\n admin = _admin;\n CAN_ADMIN_OVERWRITE = canAdminOverwrite;\n WTOKEN = wtoken;\n NATIVE_TOKEN_USD_PRICE_FEED = nativeTokenUsd;\n NATIVE_TOKEN_USD_KEY = nativeTokenUsdKey;\n MASTER_PRICE_ORACLE = masterPriceOracle;\n USD_TOKEN = usdToken;\n }\n\n /**\n * @dev Changes the admin and emits an event.\n */\n function changeAdmin(address newAdmin) external onlyAdmin {\n address oldAdmin = admin;\n admin = newAdmin;\n emit NewAdmin(oldAdmin, newAdmin);\n }\n\n /**\n * @dev Event emitted when `admin` is changed.\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @dev Modifier that checks if `msg.sender == admin`.\n */\n modifier onlyAdmin() {\n require(msg.sender == admin, \"Sender is not the admin.\");\n _;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feeds The DIA price feed contract addresses for each of `underlyings`.\n * @param keys The keys for each of `underlyings`, in the format \"ETH/USD\" for example\n */\n function setPriceFeeds(\n address[] memory underlyings,\n DIAOracleV2[] memory feeds,\n string[] memory keys\n ) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feeds.length && underlyings.length == keys.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n\n // Check for existing oracle if !canAdminOverwrite\n if (!CAN_ADMIN_OVERWRITE)\n require(\n address(priceFeeds[underlying].feed) == address(0),\n \"Admin cannot overwrite existing assignments of price feeds to underlying tokens.\"\n );\n\n // Set feed and base currency\n priceFeeds[underlying] = DiaOracle({ feed: feeds[i], key: keys[i] });\n }\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n * Assumes price feeds are 8 decimals!\n */\n function _price(address underlying) internal view returns (uint256) {\n // Return 1e18 for WTOKEN\n if (underlying == WTOKEN || underlying == address(0)) return 1e18;\n\n // Get token/Native price from Oracle\n DiaOracle memory feed = priceFeeds[underlying];\n require(address(feed.feed) != address(0), \"No oracle price feed found for this underlying ERC20 token.\");\n\n if (address(NATIVE_TOKEN_USD_PRICE_FEED) == address(0)) {\n // Get price from MasterPriceOracle\n uint256 usdNativeTokenPrice = MASTER_PRICE_ORACLE.price(USD_TOKEN);\n uint256 nativeTokenUsdPrice = 1e36 / usdNativeTokenPrice; // 18 decimals\n (uint128 tokenUsdPrice, ) = feed.feed.getValue(feed.key); // 8 decimals\n return tokenUsdPrice >= 0 ? (uint256(tokenUsdPrice) * 1e28) / uint256(nativeTokenUsdPrice) : 0;\n } else {\n (uint128 nativeTokenUsdPrice, ) = NATIVE_TOKEN_USD_PRICE_FEED.getValue(NATIVE_TOKEN_USD_KEY);\n if (nativeTokenUsdPrice <= 0) return 0;\n (uint128 tokenUsdPrice, ) = feed.feed.getValue(feed.key); // 8 decimals\n return tokenUsdPrice >= 0 ? (uint256(tokenUsdPrice) * 1e18) / uint256(nativeTokenUsdPrice) : 0;\n }\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n // Get price\n uint256 oraclePrice = _price(underlying);\n\n // Format and return price\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/ERC4626Oracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IERC4626 } from \"../../compound/IERC4626.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract ERC4626Oracle is SafeOwnableUpgradeable, BasePriceOracle {\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n }\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Balancer, with 18 decimals of precision.\n */\n function _price(address underlying) internal view virtual returns (uint256) {\n IERC4626 vault = IERC4626(underlying);\n address asset = vault.asset();\n uint256 redeemAmount = vault.previewRedeem(10**vault.decimals());\n uint256 underlyingPrice = BasePriceOracle(msg.sender).price(asset);\n return (redeemAmount * underlyingPrice) / 10**ERC20Upgradeable(asset).decimals();\n }\n}\n" + }, + "contracts/oracles/default/FixedNativePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title FixedEthPriceOracle\n * @notice Returns fixed prices of 1 denominated in the chain's native token for all tokens (expected to be used under a `MasterPriceOracle`).\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract FixedNativePriceOracle is BasePriceOracle {\n /**\n * @dev Returns the price in native token of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return 1e18;\n }\n\n /**\n * @notice Returns the price in native token of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in native token of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n return 1e18;\n }\n}\n" + }, + "contracts/oracles/default/FixedTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title FixedTokenPriceOracle\n * @notice Returns token prices using the prices for another token.\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract FixedTokenPriceOracle is BasePriceOracle {\n /**\n * @dev The token to base prices on.\n */\n address public immutable baseToken;\n\n /**\n * @dev Sets the token to base prices on.\n */\n constructor(address _baseToken) {\n baseToken = _baseToken;\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n return BasePriceOracle(msg.sender).price(baseToken);\n }\n}\n" + }, + "contracts/oracles/default/GammaPoolPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\nimport { LiquidityAmounts } from \"../../external/uniswap/LiquidityAmounts.sol\";\nimport { TickMath } from \"../../external/uniswap/TickMath.sol\";\nimport { IUniswapV3Pool } from \"../../external/uniswap/IUniswapV3Pool.sol\";\nimport { IAlgebraPool } from \"../../external/algebra/IAlgebraPool.sol\";\nimport { IHypervisor } from \"../../external/gamma/IHypervisor.sol\";\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\n\n/**\n * @title GammaPoolBasePriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice GammaPoolBasePriceOracle is a base price oracle for Gamma wrapped LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\n\nabstract contract GammaPoolBasePriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\n /**\n * @dev The Wrapped native asset address.\n */\n address public WTOKEN;\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n\n function initialize(address _wtoken) public initializer {\n __SafeOwnable_init(msg.sender);\n WTOKEN = _wtoken;\n }\n\n /**\n * @dev Fetches the price for a token from Uniswap v3\n */\n function _price(address token) internal view virtual returns (uint256);\n\n /**\n * @notice Get the token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for WTOKEN)\n * @return Price denominated in NATIVE (scaled by 1e18)\n */\n function price(address underlying) external view returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in NATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in NATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) public view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fast square root function.\n * Implementation from: https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0\n * Original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687\n */\n function sqrt(uint256 x) internal pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n\n /**\n * @dev Converts uint256 to uint160.\n */\n function toUint160(uint256 x) internal pure returns (uint160 z) {\n require((z = uint160(x)) == x, \"Overflow when converting uint256 into uint160.\");\n }\n\n function _amountsForLiquidityAtPrice(\n int24 tickLower,\n int24 tickUpper,\n uint128 liquidity,\n uint160 sqrtRatioX96\n ) internal pure returns (uint256, uint256) {\n return\n LiquidityAmounts.getAmountsForLiquidity(\n sqrtRatioX96,\n TickMath.getSqrtRatioAtTick(tickLower),\n TickMath.getSqrtRatioAtTick(tickUpper),\n liquidity\n );\n }\n\n function _getTotalAmountsAtPrice(\n uint160 sqrtRatioX96,\n int24 limitLower,\n int24 limitUpper,\n int24 baseLower,\n int24 baseUpper,\n address token,\n address pool\n ) internal view returns (uint256 total0, uint256 total1) {\n (uint256 base0, uint256 base1) = _getPositionAtPrice(baseLower, baseUpper, sqrtRatioX96, token, pool);\n (uint256 limit0, uint256 limit1) = _getPositionAtPrice(limitLower, limitUpper, sqrtRatioX96, token, pool);\n return (base0 + limit0, base1 + limit1);\n }\n\n function _position(\n address pool,\n address token,\n int24 lowerTick,\n int24 upperTick\n )\n internal\n view\n virtual\n returns (\n uint128 liquidity,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n\n function _getPositionAtPrice(\n int24 tickLower,\n int24 tickUpper,\n uint160 sqrtRatioX96,\n address token,\n address pool\n ) public view returns (uint256 amount0, uint256 amount1) {\n (uint128 positionLiquidity, uint128 tokensOwed0, uint128 tokensOwed1) = _position(\n pool,\n token,\n tickLower,\n tickUpper\n );\n (amount0, amount1) = _amountsForLiquidityAtPrice(tickLower, tickUpper, positionLiquidity, sqrtRatioX96);\n amount0 = amount0 + uint256(tokensOwed0);\n amount1 = amount1 + uint256(tokensOwed1);\n }\n}\n\n/**\n * @title GammaPoolAlgebraPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice GammaPoolAlgebraPriceOracle is a price oracle for Gelato Gamma wrapped Algebra LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\n\ncontract GammaPoolAlgebraPriceOracle is GammaPoolBasePriceOracle {\n /**\n * @dev Fetches the fair LP token/ETH price from Uniswap, with 18 decimals of precision.\n */\n function _price(address token) internal view override returns (uint256) {\n // Get Gamma pool and underlying tokens\n IHypervisor pool = IHypervisor(token);\n ERC20Upgradeable token0 = ERC20Upgradeable(pool.token0());\n ERC20Upgradeable token1 = ERC20Upgradeable(pool.token1());\n\n // Get underlying token prices\n uint256 p0 = BasePriceOracle(msg.sender).price(address(token0)); // * 10**uint256(18 - token0.decimals());\n uint256 p1 = BasePriceOracle(msg.sender).price(address(token1)); // * 10**uint256(18 - token1.decimals());\n\n uint160 sqrtPriceX96 = toUint160(\n sqrt((p0 * (10**token0.decimals()) * (1 << 96)) / (p1 * (10**token1.decimals()))) << 48\n );\n\n // Get balances of the tokens in the pool given fair underlying token prices\n (uint256 basePlusLimit0, uint256 basePlusLimit1) = _getTotalAmountsAtPrice(\n sqrtPriceX96,\n pool.limitLower(),\n pool.limitUpper(),\n pool.baseLower(),\n pool.baseUpper(),\n token,\n pool.pool()\n );\n\n uint256 r0 = token0.balanceOf(address(token)) + basePlusLimit0;\n uint256 r1 = token1.balanceOf(address(token)) + basePlusLimit1;\n\n r0 = r0 * 10**(18 - uint256(token0.decimals()));\n r1 = r1 * 10**(18 - uint256(token1.decimals()));\n\n require(r0 > 0 || r1 > 0, \"Gamma underlying token balances not both greater than 0.\");\n\n // Add the total value of each token together and divide by the totalSupply to get the unit price\n return (p0 * r0 + p1 * r1) / ERC20Upgradeable(token).totalSupply();\n }\n\n function _position(\n address pool,\n address token,\n int24 lowerTick,\n int24 upperTick\n )\n internal\n view\n override\n returns (\n uint128 liquidity,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n )\n {\n bytes32 positionKey;\n assembly {\n positionKey := or(shl(24, or(shl(24, token), and(lowerTick, 0xFFFFFF))), and(upperTick, 0xFFFFFF))\n }\n (liquidity, , , , tokensOwed0, tokensOwed1) = IAlgebraPool(pool).positions(positionKey);\n }\n}\n\ncontract GammaPoolUniswapV3PriceOracle is GammaPoolBasePriceOracle {\n /**\n * @dev Fetches the fair LP token/ETH price from Uniswap, with 18 decimals of precision.\n */\n function _price(address token) internal view override returns (uint256) {\n // Get Gamma pool and underlying tokens\n IHypervisor pool = IHypervisor(token);\n ERC20Upgradeable token0 = ERC20Upgradeable(pool.token0());\n ERC20Upgradeable token1 = ERC20Upgradeable(pool.token1());\n\n // Get underlying token prices\n uint256 p0 = BasePriceOracle(msg.sender).price(address(token0)); // * 10**uint256(18 - token0.decimals());\n uint256 p1 = BasePriceOracle(msg.sender).price(address(token1)); // * 10**uint256(18 - token1.decimals());\n\n uint160 sqrtPriceX96 = toUint160(\n sqrt((p0 * (10**token0.decimals()) * (1 << 96)) / (p1 * (10**token1.decimals()))) << 48\n );\n\n // Get balances of the tokens in the pool given fair underlying token prices\n (uint256 basePlusLimit0, uint256 basePlusLimit1) = _getTotalAmountsAtPrice(\n sqrtPriceX96,\n pool.limitLower(),\n pool.limitUpper(),\n pool.baseLower(),\n pool.baseUpper(),\n token,\n pool.pool()\n );\n\n uint256 r0 = token0.balanceOf(address(token)) + basePlusLimit0;\n uint256 r1 = token1.balanceOf(address(token)) + basePlusLimit1;\n\n r0 = r0 * 10**(18 - uint256(token0.decimals()));\n r1 = r1 * 10**(18 - uint256(token1.decimals()));\n\n require(r0 > 0 || r1 > 0, \"Gamma underlying token balances not both greater than 0.\");\n\n // Add the total value of each token together and divide by the totalSupply to get the unit price\n return (p0 * r0 + p1 * r1) / ERC20Upgradeable(token).totalSupply();\n }\n\n // see: https://polygonscan.com/address/0xe058e1ffff9b13d3fcd4803fdb55d1cc2fe07ddc#code\n function _position(\n address pool,\n address token,\n int24 lowerTick,\n int24 upperTick\n )\n internal\n view\n override\n returns (\n uint128 liquidity,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n )\n {\n bytes32 positionKey = keccak256(abi.encodePacked(token, lowerTick, upperTick));\n (liquidity, , , tokensOwed0, tokensOwed1) = IUniswapV3Pool(pool).positions(positionKey);\n }\n}\n" + }, + "contracts/oracles/default/GelatoGUniPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/gelato/GUniPool.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title GelatoGUniPriceOracle\n * @author David Lucid (https://github.com/davidlucid)\n * @notice GelatoGUniPriceOracle is a price oracle for Gelato G-UNI wrapped Uniswap V3 LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract GelatoGUniPriceOracle is BasePriceOracle {\n /**\n * @dev The Wrapped native asset address.\n */\n address public immutable WTOKEN;\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n constructor(address wtoken) {\n WTOKEN = wtoken;\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH)\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Uniswap, with 18 decimals of precision.\n */\n function _price(address token) internal view virtual returns (uint256) {\n // Get G-UNI pool and underlying tokens\n GUniPool pool = GUniPool(token);\n address token0 = pool.token0();\n address token1 = pool.token1();\n\n // Get underlying token prices\n uint256 p0 = token0 == WTOKEN ? 1e18 : BasePriceOracle(msg.sender).price(token0);\n require(p0 > 0, \"Failed to retrieve price for G-UNI underlying token0.\");\n uint256 p1 = token1 == WTOKEN ? 1e18 : BasePriceOracle(msg.sender).price(token1);\n require(p1 > 0, \"Failed to retrieve price for G-UNI underlying token1.\");\n\n // Get conversion factors\n uint256 dec0 = uint256(ERC20Upgradeable(token0).decimals());\n require(dec0 <= 18, \"G-UNI underlying token0 decimals greater than 18.\");\n uint256 to18Dec0 = 10**(18 - dec0);\n uint256 dec1 = uint256(ERC20Upgradeable(token1).decimals());\n require(dec1 <= 18, \"G-UNI underlying token1 decimals greater than 18.\");\n uint256 to18Dec1 = 10**(18 - dec1);\n\n // Get square root of underlying token prices\n // token1/token0\n // = (p0 / 10^dec0) / (p1 / 10^dec1)\n // = (p0 * 10^dec1) / (p1 * 10^dec0)\n // [From Uniswap's definition] sqrtPriceX96\n // = sqrt(token1/token0) * 2^96\n // = sqrt((p0 * 10^dec1) / (p1 * 10^dec0)) * 2^96\n // = sqrt((p0 * 10^dec1) / (p1 * 10^dec0)) * 2^48 * 2^48\n // = sqrt((p0 * 10^dec1 * 2^96) / (p1 * 10^dec0)) * 2^48\n uint160 sqrtPriceX96 = toUint160(sqrt((p0 * (10**dec1) * (1 << 96)) / (p1 * (10**dec0))) << 48);\n\n // Get balances of the tokens in the pool given fair underlying token prices\n (uint256 r0, uint256 r1) = pool.getUnderlyingBalancesAtPrice(sqrtPriceX96);\n require(r0 > 0 || r1 > 0, \"G-UNI underlying token balances not both greater than 0.\");\n\n // Add the total value of each token together and divide by the totalSupply to get the unit price\n return (p0 * r0 * to18Dec0 + p1 * r1 * to18Dec1) / ERC20Upgradeable(token).totalSupply();\n }\n\n /**\n * @dev Fast square root function.\n * Implementation from: https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0\n * Original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687\n */\n function sqrt(uint256 x) internal pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n\n /**\n * @dev Converts uint256 to uint160.\n */\n function toUint160(uint256 x) internal pure returns (uint160 z) {\n require((z = uint160(x)) == x, \"Overflow when converting uint256 into uint160.\");\n }\n}\n" + }, + "contracts/oracles/default/KyberSwapPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IPool } from \"../../external/kyber/IPool.sol\";\nimport { IPoolOracle } from \"../../external/kyber/IPoolOracle.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"./ConcentratedLiquidityBasePriceOracle.sol\";\n\nimport \"../../external/uniswap/TickMath.sol\";\nimport \"../../external/uniswap/FullMath.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title KyberSwapPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice KyberSwapPriceOracle is a price oracle for Kybet-style pairs.\n * @dev Implements the `BasePriceOracle` interface used by Ionic pools (and Compound v2).\n */\n\ncontract KyberSwapPriceOracle is ConcentratedLiquidityBasePriceOracle {\n /**\n * @dev Fetches the price for a token from Algebra pools.\n */\n\n function _price(address token) internal view override returns (uint256) {\n uint32[] memory secondsAgos = new uint32[](2);\n uint256 twapWindow = poolFeeds[token].twapWindow;\n address baseToken = poolFeeds[token].baseToken;\n\n secondsAgos[0] = 0;\n secondsAgos[1] = uint32(twapWindow);\n\n IPool pool = IPool(poolFeeds[token].poolAddress);\n IPoolOracle poolOracle = IPoolOracle(pool.poolOracle());\n\n int56[] memory tickCumulatives = poolOracle.observeFromPool(address(pool), secondsAgos);\n\n int24 tick = int24((tickCumulatives[1] - tickCumulatives[0]) / int56(int256(twapWindow)));\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(tick);\n\n uint256 baseTokenDecimals = uint256(ERC20Upgradeable(baseToken).decimals());\n uint256 tokenDecimals = uint256(ERC20Upgradeable(token).decimals());\n\n uint256 tokenPrice = getPriceX96FromSqrtPriceX96(baseToken, token, sqrtPriceX96);\n uint256 tokenPriceScaled;\n\n if (baseTokenDecimals > tokenDecimals) {\n tokenPriceScaled = tokenPrice / (10**(baseTokenDecimals - tokenDecimals));\n } else if (baseTokenDecimals < tokenDecimals) {\n tokenPriceScaled = tokenPrice / (10**(tokenDecimals - baseTokenDecimals));\n } else {\n tokenPriceScaled = tokenPrice;\n }\n\n uint256 baseNativePrice = BasePriceOracle(msg.sender).price(baseToken);\n return (tokenPriceScaled * baseNativePrice) / 1e18;\n }\n}\n" + }, + "contracts/oracles/default/PreferredPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\nimport \"../MasterPriceOracle.sol\";\nimport \"../default/ChainlinkPriceOracleV2.sol\";\n\n/**\n * @title PreferredPriceOracle\n * @notice Returns prices from MasterPriceOracle, ChainlinkPriceOracleV2, or prices from a tertiary oracle (in order of preference).\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract PreferredPriceOracle is BasePriceOracle {\n /**\n * @dev The primary `MasterPriceOracle`.\n */\n MasterPriceOracle public masterOracle;\n\n /**\n * @dev The secondary `ChainlinkPriceOracleV2`.\n */\n ChainlinkPriceOracleV2 public chainlinkOracleV2;\n\n /**\n * @dev The tertiary `PriceOracle`.\n */\n BasePriceOracle public tertiaryOracle;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public wtoken;\n\n /**\n * @dev Constructor to set the primary `MasterPriceOracle`, the secondary `ChainlinkPriceOracleV2`, and the tertiary `PriceOracle`.\n */\n constructor(\n MasterPriceOracle _masterOracle,\n ChainlinkPriceOracleV2 _chainlinkOracleV2,\n BasePriceOracle _tertiaryOracle,\n address _wtoken\n ) {\n require(address(_masterOracle) != address(0), \"MasterPriceOracle not set.\");\n require(address(_chainlinkOracleV2) != address(0), \"ChainlinkPriceOracleV2 not set.\");\n require(address(_tertiaryOracle) != address(0), \"Tertiary price oracle not set.\");\n masterOracle = _masterOracle;\n chainlinkOracleV2 = _chainlinkOracleV2;\n tertiaryOracle = _tertiaryOracle;\n wtoken = _wtoken;\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n // Return 1e18 for wtoken\n if (underlying == wtoken) return 1e18;\n\n // Try to get MasterPriceOracle price\n if (address(masterOracle.oracles(underlying)) != address(0)) return masterOracle.price(underlying);\n\n // Try to get ChainlinkPriceOracleV2 price\n if (address(chainlinkOracleV2.priceFeeds(underlying)) != address(0)) return chainlinkOracleV2.price(underlying);\n\n // Otherwise, get price from tertiary oracle\n return BasePriceOracle(address(tertiaryOracle)).price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = cToken.underlying();\n\n // Return 1e18 for wtoken\n if (underlying == wtoken) return 1e18;\n\n // Try to get MasterPriceOracle price\n if (address(masterOracle.oracles(underlying)) != address(0)) return masterOracle.getUnderlyingPrice(cToken);\n\n // Try to get ChainlinkPriceOracleV2 price\n if (address(chainlinkOracleV2.priceFeeds(underlying)) != address(0))\n return chainlinkOracleV2.getUnderlyingPrice(cToken);\n\n // Otherwise, get price from tertiary oracle\n return tertiaryOracle.getUnderlyingPrice(cToken);\n }\n}\n" + }, + "contracts/oracles/default/PythPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\nimport { IPyth } from \"@pythnetwork/pyth-sdk-solidity/IPyth.sol\";\nimport { PythStructs } from \"@pythnetwork/pyth-sdk-solidity/PythStructs.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title PythPriceOracle\n * @notice Returns prices from Pyth.\n * @dev Implements `PriceOracle`.\n * @author Rahul Sethuram (https://github.com/rhlsthrm)\n */\ncontract PythPriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\n /**\n * @notice Maps ERC20 token addresses to Pyth price IDs.\n */\n mapping(address => bytes32) public priceFeedIds;\n\n /**\n * @notice DIA NATIVE/USD price feed contracts.\n */\n bytes32 public NATIVE_TOKEN_USD_FEED;\n\n /**\n * @notice MasterPriceOracle for backup for USD price.\n */\n address public USD_TOKEN; // token to use as USD price (i.e. USDC)\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n\n IPyth public PYTH;\n\n function initialize(\n address pythAddress,\n bytes32 nativeTokenUsdFeed,\n address usdToken\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n NATIVE_TOKEN_USD_FEED = nativeTokenUsdFeed;\n USD_TOKEN = usdToken;\n PYTH = IPyth(pythAddress);\n }\n\n function reinitialize(\n address pythAddress,\n bytes32 nativeTokenUsdFeed,\n address usdToken\n ) public onlyOwnerOrAdmin {\n NATIVE_TOKEN_USD_FEED = nativeTokenUsdFeed;\n USD_TOKEN = usdToken;\n PYTH = IPyth(pythAddress);\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feedIds The Pyth Network feed IDs`.\n */\n function setPriceFeeds(address[] memory underlyings, bytes32[] memory feedIds) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feedIds.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set feed and base currency\n priceFeedIds[underlying] = feedIds[i];\n }\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n * Assumes price feeds are 8 decimals (TODO: doublecheck)\n */\n function _price(address underlying) internal view returns (uint256) {\n // Get token/native price from Oracle\n bytes32 feed = priceFeedIds[underlying];\n require(feed != \"\", \"No oracle price feed found for this underlying ERC20 token.\");\n\n if (NATIVE_TOKEN_USD_FEED == \"\") {\n // Get price from MasterPriceOracle\n uint256 usdNativeTokenPrice = BasePriceOracle(msg.sender).price(USD_TOKEN);\n uint256 nativeTokenUsdPrice = 1e36 / usdNativeTokenPrice; // 18 decimals -- TODO: doublecheck\n PythStructs.Price memory tokenUsdPrice = PYTH.getPriceUnsafe(feed); // 8 decimals --- TODO: doublecheck\n return\n tokenUsdPrice.price >= 0 ? (uint256(uint64(tokenUsdPrice.price)) * 1e28) / uint256(nativeTokenUsdPrice) : 0;\n } else {\n uint128 nativeTokenUsdPrice = uint128(uint64(PYTH.getPriceUnsafe(NATIVE_TOKEN_USD_FEED).price));\n if (nativeTokenUsdPrice <= 0) return 0;\n uint128 tokenUsdPrice = uint128(uint64(PYTH.getPriceUnsafe(feed).price));\n return tokenUsdPrice >= 0 ? (uint256(tokenUsdPrice) * 1e18) / uint256(nativeTokenUsdPrice) : 0;\n }\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n // Get price\n uint256 oraclePrice = _price(underlying);\n\n // Format and return price\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/PythPriceOracleDmBTC.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\nimport { IPyth } from \"@pythnetwork/pyth-sdk-solidity/IPyth.sol\";\nimport { PythStructs } from \"@pythnetwork/pyth-sdk-solidity/PythStructs.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title PythPriceOracle\n * @notice Returns prices from Pyth.\n * @dev Implements `PriceOracle`.\n * @author Rahul Sethuram (https://github.com/rhlsthrm)\n */\ncontract PythPriceOracleDmBTC is BasePriceOracle, SafeOwnableUpgradeable {\n /**\n * @notice Maps ERC20 token addresses to Pyth price IDs.\n */\n mapping(address => bytes32) public priceFeedIds;\n\n /**\n * @notice DIA NATIVE/USD price feed contracts.\n */\n bytes32 public NATIVE_TOKEN_USD_FEED;\n\n /**\n * @notice MasterPriceOracle for backup for USD price.\n */\n address public USD_TOKEN; // token to use as USD price (i.e. USDC)\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n\n IPyth public PYTH;\n\n address public DMBTC;\n\n function initialize(\n address pythAddress,\n bytes32 nativeTokenUsdFeed,\n address usdToken,\n address dmBTC\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n NATIVE_TOKEN_USD_FEED = nativeTokenUsdFeed;\n USD_TOKEN = usdToken;\n PYTH = IPyth(pythAddress);\n DMBTC = dmBTC;\n }\n\n function reinitialize(\n address pythAddress,\n bytes32 nativeTokenUsdFeed,\n address usdToken,\n address dmBTC\n ) public onlyOwnerOrAdmin {\n NATIVE_TOKEN_USD_FEED = nativeTokenUsdFeed;\n USD_TOKEN = usdToken;\n PYTH = IPyth(pythAddress);\n DMBTC = dmBTC;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feedIds The Pyth Network feed IDs`.\n */\n function setPriceFeeds(address[] memory underlyings, bytes32[] memory feedIds) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feedIds.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set feed and base currency\n priceFeedIds[underlying] = feedIds[i];\n }\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n * Assumes price feeds are 8 decimals (TODO: doublecheck)\n */\n function _price(address underlying) internal view returns (uint256) {\n // Get token/native price from Oracle\n bytes32 feed = priceFeedIds[underlying];\n require(feed != \"\", \"No oracle price feed found for this underlying ERC20 token.\");\n uint256 normalizedPrice;\n if (NATIVE_TOKEN_USD_FEED == \"\") {\n // Get price from MasterPriceOracle\n uint256 usdNativeTokenPrice = BasePriceOracle(msg.sender).price(USD_TOKEN);\n uint256 nativeTokenUsdPrice = 1e36 / usdNativeTokenPrice; // 18 decimals -- TODO: doublecheck\n PythStructs.Price memory tokenUsdPrice = PYTH.getPriceUnsafe(feed); // 8 decimals --- TODO: doublecheck\n normalizedPrice = tokenUsdPrice.price >= 0 ? (uint256(uint64(tokenUsdPrice.price)) * 1e28) / uint256(nativeTokenUsdPrice) : 0;\n } else {\n uint128 nativeTokenUsdPrice = uint128(uint64(PYTH.getPriceUnsafe(NATIVE_TOKEN_USD_FEED).price));\n if (nativeTokenUsdPrice <= 0) return 0;\n uint128 tokenUsdPrice = uint128(uint64(PYTH.getPriceUnsafe(feed).price));\n normalizedPrice = tokenUsdPrice >= 0 ? (uint256(tokenUsdPrice) * 1e18) / uint256(nativeTokenUsdPrice) : 0;\n }\n if (underlying == DMBTC) {\n return normalizedPrice / 100000;\n }\n return normalizedPrice;\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n // Get price\n uint256 oraclePrice = _price(underlying);\n\n // Format and return price\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RecursivePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../../external/compound/IPriceOracle.sol\";\nimport \"../../external/compound/ICToken.sol\";\nimport \"../../external/compound/ICErc20.sol\";\nimport \"../../external/compound/IComptroller.sol\";\n\n/**\n * @title RecursivePriceOracle\n * @notice Returns prices from other cTokens (from Ionic).\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract RecursivePriceOracle is IPriceOracle {\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICToken cToken) external view override returns (uint256) {\n // Get cToken's underlying cToken\n ICToken underlying = ICToken(ICErc20Compound(address(cToken)).underlying());\n\n // Get Comptroller\n IComptroller comptroller = IComptroller(underlying.comptroller());\n\n // If cETH, return cETH/ETH exchange rate\n if (underlying.isCEther()) {\n return underlying.exchangeRateStored();\n }\n\n // Ionic cTokens: cToken/token price * token/ETH price = cToken/ETH price\n return (underlying.exchangeRateStored() * comptroller.oracle().getUnderlyingPrice(underlying)) / 1e18;\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracle is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWeETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWeETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A) {\n underlying = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWrsETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWrsETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd) {\n underlying = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/SaddleLpPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/saddle/ISwap.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title SaddleLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice SaddleLpPriceOracle is a price oracle for Saddle LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract SaddleLpPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Saddle LP token addresses to underlying token addresses.\n */\n mapping(address => address[]) public underlyingTokens;\n\n /**\n * @dev Maps Saddle LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n * @param _poolUnderlyings The underlying token addresses of a pool\n */\n function initialize(\n address[] memory _lpTokens,\n address[] memory _pools,\n address[][] memory _poolUnderlyings\n ) public initializer {\n require(\n _lpTokens.length == _pools.length && _lpTokens.length == _poolUnderlyings.length,\n \"No LP tokens supplied or array lengths not equal.\"\n );\n\n __SafeOwnable_init(msg.sender);\n for (uint256 i = 0; i < _lpTokens.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n underlyingTokens[_lpTokens[i]] = _poolUnderlyings[i];\n }\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Saddle, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/CurveOracle.sol\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(pool != address(0), \"LP token is not registered.\");\n address[] memory tokens = underlyingTokens[lpToken];\n uint256 minPx = type(uint256).max;\n uint256 n = tokens.length;\n\n for (uint256 i = 0; i < n; i++) {\n address ulToken = tokens[i];\n uint256 tokenPx = BasePriceOracle(msg.sender).price(ulToken);\n if (tokenPx < minPx) minPx = tokenPx;\n }\n\n require(minPx != type(uint256).max, \"No minimum underlying token price found.\");\n return (minPx * ISwap(pool).getVirtualPrice()) / 1e18; // Use min underlying token prices\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n * @param _underlyings Underlying addresses.\n */\n function registerPool(\n address _lpToken,\n address _pool,\n address[] memory _underlyings\n ) external onlyOwner {\n // require(pool == address(0), \"This LP token is already registered.\");\n poolOf[_lpToken] = _pool;\n underlyingTokens[_lpToken] = _underlyings;\n }\n\n /**\n * @dev getter for the underlying tokens\n * @param lpToken the LP token address.\n * @return _underlyings Underlying addresses.\n */\n function getUnderlyingTokens(address lpToken) public view returns (address[] memory) {\n return underlyingTokens[lpToken];\n }\n}\n" + }, + "contracts/oracles/default/SimplePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract SimplePriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\n mapping(address => uint256) prices;\n event PricePosted(\n address asset,\n uint256 previousPriceMantissa,\n uint256 requestedPriceMantissa,\n uint256 newPriceMantissa\n );\n\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n }\n\n function getUnderlyingPrice(ICErc20 cToken) public view override returns (uint256) {\n if (compareStrings(cToken.symbol(), \"cETH\")) {\n return 1e18;\n } else {\n address underlying = ICErc20(address(cToken)).underlying();\n uint256 oraclePrice = prices[underlying];\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n }\n\n function setUnderlyingPrice(ICErc20 cToken, uint256 underlyingPriceMantissa) public onlyOwner {\n address asset = ICErc20(address(cToken)).underlying();\n emit PricePosted(asset, prices[asset], underlyingPriceMantissa, underlyingPriceMantissa);\n prices[asset] = underlyingPriceMantissa;\n }\n\n function setDirectPrice(address asset, uint256 _price) public onlyOwner {\n emit PricePosted(asset, prices[asset], _price, _price);\n prices[asset] = _price;\n }\n\n function price(address underlying) external view returns (uint256) {\n return prices[address(underlying)];\n }\n\n // v1 price oracle interface for use as backing of proxy\n function assetPrices(address asset) external view returns (uint256) {\n return prices[asset];\n }\n\n function compareStrings(string memory a, string memory b) internal pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n}\n" + }, + "contracts/oracles/default/SolidlyLpTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\nimport { UniswapLikeLpTokenPriceOracle } from \"./UniswapLikeLpTokenPriceOracle.sol\";\n\n/**\n * @title SolidlyLpTokenPriceOracle\n * @author Carlo Mazzaferro, David Lucid (https://github.com/davidlucid)\n * @notice SolidlyLpTokenPriceOracle is a price oracle for Solidly LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract SolidlyLpTokenPriceOracle is UniswapLikeLpTokenPriceOracle {\n /**\n * @dev Fetches the fair LP token/ETH price from Uniswap, with 18 decimals of precision.\n */\n constructor(address _wtoken) UniswapLikeLpTokenPriceOracle(_wtoken) {}\n\n // Same implementation as UniswapLpTokenPriceOracle\n function _priceVolatile(address token) internal view virtual returns (uint256) {\n IPair pair = IPair(token);\n uint256 t_s = pair.totalSupply();\n if (t_s == 0) return 0;\n (uint256 r0, uint256 r1, ) = pair.getReserves();\n\n r0 = r0 * 10**(18 - uint256(ERC20Upgradeable(pair.token0()).decimals()));\n r1 = r1 * 10**(18 - uint256(ERC20Upgradeable(pair.token1()).decimals()));\n\n address x = pair.token0();\n address y = pair.token1();\n\n // Get fair price of non-WETH token (underlying the pair) in terms of ETH\n uint256 P_x = x == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(x);\n uint256 P_y = y == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(y);\n\n // Implementation from https://github.com/AlphaFinanceLab/homora-v2/blob/e643392d582c81f6695136971cff4b685dcd2859/contracts/oracle/UniswapV2Oracle.sol#L18\n uint256 sqrtK = (sqrt(r0 * r1) * (2**112)) / t_s;\n return (((sqrtK * 2 * sqrt(P_x)) / (2**56)) * sqrt(P_y)) / (2**56);\n }\n\n // Derivation: [...]\n function _priceStable(address token) internal view virtual returns (uint256) {\n IPair pair = IPair(token);\n uint256 t_s = pair.totalSupply();\n\n if (t_s == 0) return 0;\n (uint256 r0, uint256 r1, ) = pair.getReserves();\n\n r0 = r0 * 10**(18 - uint256(ERC20Upgradeable(pair.token0()).decimals()));\n r1 = r1 * 10**(18 - uint256(ERC20Upgradeable(pair.token1()).decimals()));\n\n // Get fair price of non-WETH token (underlying the pair) in terms of ETH\n uint256 P_x = pair.token0() == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(pair.token0());\n uint256 P_y = pair.token1() == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(pair.token1());\n\n uint256 sqrt4K = _sqrt4k(r0, r1, t_s);\n\n uint256 denomFirstTerm = (P_x**2) * P_y + P_y**3;\n uint256 denomSecondTerm = (P_y**2) * P_x + P_x**3;\n\n // scale numerator up by sqrt(sqrt(10**16)) = 10**4 to avoid rounding errors\n uint256 firstTerm = (P_x * sqrt(sqrt((10**16 * P_x**3) / denomFirstTerm))) / 10**4;\n uint256 secondTerm = (P_y * sqrt(sqrt((10**16 * P_y**3) / denomSecondTerm))) / 10**4;\n\n return (sqrt4K * (firstTerm + secondTerm)) / 1e18;\n }\n\n function _sqrt4k(\n uint256 r0,\n uint256 r1,\n uint256 t_s\n ) public pure returns (uint256) {\n // sqrt4K = sqrt(sqrt((r0**3) * r1 + (r0**3) * r1)) / t_s;\n uint256 r03r1 = ((((r0**2 / 10**18) * r0) / 10**18) * r1);\n uint256 r13r0 = ((((r1**2 / 10**18) * r1) / 10**18) * r0);\n uint256 sqrtK = 10**18 * sqrt(r03r1 + r13r0);\n return (sqrt(sqrtK) * 1e18) / t_s;\n }\n\n function _price(address token) internal view virtual override returns (uint256) {\n IPair pair = IPair(token);\n\n if (pair.stable()) {\n return _priceStable(token);\n } else {\n return _priceVolatile(token);\n }\n }\n}\n" + }, + "contracts/oracles/default/SolidlyPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title SolidlyOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice SolidlyOracle is a price oracle for Solidly-style pairs.\n * @dev Implements the `BasePriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract SolidlyPriceOracle is BasePriceOracle, SafeOwnableUpgradeable {\n /**\n * @notice Maps ERC20 token addresses to UniswapV3Pool addresses.\n */\n mapping(address => AssetConfig) public poolFeeds;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool public canAdminOverwrite;\n\n struct AssetConfig {\n address poolAddress;\n address baseToken;\n }\n\n address public WTOKEN;\n address[] public SUPPORTED_BASE_TOKENS;\n\n function initialize(address _wtoken, address[] memory _supportedBaseTokens) public initializer {\n __SafeOwnable_init(msg.sender);\n WTOKEN = _wtoken;\n SUPPORTED_BASE_TOKENS = _supportedBaseTokens;\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param assetConfig The asset configuration which includes pool address and twap window.\n */\n function setPoolFeeds(address[] memory underlyings, AssetConfig[] memory assetConfig) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == assetConfig.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/config\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set asset config for underlying\n require(\n assetConfig[i].baseToken == WTOKEN || _isBaseTokenSupported(assetConfig[i].baseToken),\n \"Underlying token must be supported\"\n );\n poolFeeds[underlying] = assetConfig[i];\n }\n }\n\n /**\n * @notice Get the token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for WTOKEN)\n * @return Price denominated in NATIVE (scaled by 1e18)\n */\n function price(address underlying) external view returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in NATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in NATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) public view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the price for a token from Solidly Pair\n */\n function _price(address token) internal view virtual returns (uint256) {\n address baseToken = poolFeeds[token].baseToken;\n IPair pair = IPair(poolFeeds[token].poolAddress);\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n\n address quoteToken;\n\n baseToken == token0 ? quoteToken = token1 : quoteToken = token0;\n\n // get how many baseTokens (WNATIVE or STABLE) are needed to get us 1 quote token\n // i.e: the ration X/WNATIVE or X/STABLE\n uint256 baseTokensPerQuoteToken = pair.current(quoteToken, 10**uint256(ERC20Upgradeable(quoteToken).decimals()));\n if (baseToken == WTOKEN) {\n // No need to scale either, because WNATIVE is always 1e18\n return baseTokensPerQuoteToken;\n } else {\n // base token is USD or another token\n uint256 baseTokenNativePrice = BasePriceOracle(msg.sender).price(baseToken);\n // scale tokenPrice by 1e18\n uint256 baseTokenDecimals = uint256(ERC20Upgradeable(baseToken).decimals());\n uint256 tokenPriceScaled;\n\n if (baseTokenDecimals > 18) {\n tokenPriceScaled = baseTokensPerQuoteToken / (10**(baseTokenDecimals - 18));\n } else {\n tokenPriceScaled = baseTokensPerQuoteToken * (10**(18 - baseTokenDecimals));\n }\n\n return (tokenPriceScaled * baseTokenNativePrice) / 1e18;\n }\n }\n\n function _isBaseTokenSupported(address token) internal view returns (bool) {\n for (uint256 i = 0; i < SUPPORTED_BASE_TOKENS.length; i++) {\n if (SUPPORTED_BASE_TOKENS[i] == token) {\n return true;\n }\n }\n return false;\n }\n\n function _setSupportedBaseTokens(address[] memory _supportedBaseTokens) external onlyOwner {\n SUPPORTED_BASE_TOKENS = _supportedBaseTokens;\n }\n\n function getSupportedBaseTokens() external view returns (address[] memory) {\n return SUPPORTED_BASE_TOKENS;\n }\n}\n" + }, + "contracts/oracles/default/StkBNBPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IStakePool, ExchangeRateData } from \"../../external/pstake/IStakePool.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\n\ncontract StkBNBPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n IStakePool public stakingPool;\n address public stkBnb;\n\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n stakingPool = IStakePool(0xC228CefDF841dEfDbD5B3a18dFD414cC0dbfa0D8);\n stkBnb = 0xc2E9d07F66A89c44062459A47a0D2Dc038E4fb16;\n }\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n require(underlying == stkBnb, \"Invalid underlying\");\n // no need to scale as stkBNB has 18 decimals\n return _price();\n }\n\n function price(address underlying) external view override returns (uint256) {\n require(underlying == stkBnb, \"Invalid underlying\");\n return _price();\n }\n\n function _price() internal view returns (uint256) {\n // 1 stkBNB = (totalWei / poolTokenSupply) BNB\n ExchangeRateData memory exchangeRate = stakingPool.exchangeRate();\n uint256 stkBNBPrice = (exchangeRate.totalWei * 1e18) / exchangeRate.poolTokenSupply;\n return stkBNBPrice;\n }\n}\n" + }, + "contracts/oracles/default/SushiBarPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/sushi/SushiBar.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title SushiBarPriceOracle\n * @notice Returns prices for SushiBar (xSUSHI).\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract SushiBarPriceOracle is BasePriceOracle {\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n SushiBar sushiBar = SushiBar(token);\n IERC20Upgradeable sushi = sushiBar.sushi();\n uint256 sushiEthPrice = BasePriceOracle(msg.sender).price(address(sushi));\n return (sushi.balanceOf(token) * sushiEthPrice) / sushiBar.totalSupply();\n }\n}\n" + }, + "contracts/oracles/default/UmbrellaPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IUmbrellaFeeds } from \"../../external/umbrella/IUmbrellaFeeds.sol\";\nimport { IRegistry } from \"../../external/umbrella/IRegistry.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\nimport { BasePriceOracle, ICErc20 } from \"../BasePriceOracle.sol\";\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title UmbrellaPriceOracle\n * @notice Returns prices from Umbrella Network.\n * @dev Implements `PriceOracle`.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract UmbrellaPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @notice Maps ERC20 token addresses to ETH-based Flux price feed contracts.\n */\n mapping(address => string) public priceFeeds;\n\n /**\n * @notice Umbrella's NATIVE/USD price feed contracts.\n */\n string public NATIVE_TOKEN_USD_KEY;\n\n /**\n * @notice IUmbrellaFeeds address\n */\n\n IUmbrellaFeeds public UMBRELLA_FEEDS_ADDRESS;\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n function initialize(string memory nativeTokenUsd, IRegistry registry) public initializer {\n __SafeOwnable_init(msg.sender);\n NATIVE_TOKEN_USD_KEY = nativeTokenUsd;\n address umbrellaFeeds = registry.getAddressByString(\"UmbrellaFeeds\");\n require(umbrellaFeeds != address(0), \"UmbrellaFeeds address not found\");\n UMBRELLA_FEEDS_ADDRESS = IUmbrellaFeeds(umbrellaFeeds);\n }\n\n function reinitialize(string memory nativeTokenUsd, IRegistry registry) public onlyOwnerOrAdmin {\n NATIVE_TOKEN_USD_KEY = nativeTokenUsd;\n address umbrellaFeeds = registry.getAddressByString(\"UmbrellaFeeds\");\n require(umbrellaFeeds != address(0), \"UmbrellaFeeds address not found\");\n UMBRELLA_FEEDS_ADDRESS = IUmbrellaFeeds(umbrellaFeeds);\n }\n\n /**\n * @dev Admin-only function to set price feeds.\n * @param underlyings Underlying token addresses for which to set price feeds.\n * @param feeds The Oracle price feed contract addresses for each of `underlyings`.\n */\n function setPriceFeeds(address[] memory underlyings, string[] memory feeds) external onlyOwner {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == feeds.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // For each token/feed\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n // Set feed and base currency\n priceFeeds[underlying] = feeds[i];\n }\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n * Assumes price feeds are 8 decimals!\n * https://docs.fluxprotocol.org/docs/live-data-feeds/fpo-live-networks-and-pairs#mainnet-2\n */\n function _price(address underlying) internal view returns (uint256) {\n // Get token/ETH price from feed\n string memory feed = priceFeeds[underlying];\n require(bytes(feed).length != 0, \"No Umbrella price feed found for this underlying ERC20 token.\");\n\n // Get the NATIVE/USD price feed from Native Price Feed\n // 8 decimals are used\n IUmbrellaFeeds.PriceData memory nativeTokenUsdPriceData = UMBRELLA_FEEDS_ADDRESS.getPriceDataByName(\n NATIVE_TOKEN_USD_KEY\n );\n uint256 nativeTokenUsdPrice = uint256(nativeTokenUsdPriceData.price);\n\n if (nativeTokenUsdPriceData.price == 0) return 0;\n // 8 decimals are used\n IUmbrellaFeeds.PriceData memory priceData = UMBRELLA_FEEDS_ADDRESS.getPriceDataByName(feed);\n // Umbrella price feed is 8 decimals:\n return (uint256(priceData.price) * 1e18) / uint256(nativeTokenUsdPrice);\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n // Get price\n uint256 oraclePrice = _price(underlying);\n\n // Format and return price\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/UniswapLikeLpTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title UniswapLpTokenPriceOracle\n * @author David Lucid (https://github.com/davidlucid)\n * @notice UniswapLpTokenPriceOracle is a price oracle for Uniswap (and SushiSwap) LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\nabstract contract UniswapLikeLpTokenPriceOracle is BasePriceOracle {\n /**\n * @dev wtoken contract address.\n */\n address public immutable wtoken;\n\n /**\n * @dev Constructor to set admin and canAdminOverwrite, wtoken address and native token USD price feed address\n */\n constructor(address _wtoken) {\n wtoken = _wtoken;\n }\n\n function _price(address token) internal view virtual returns (uint256);\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @dev Fast square root function.\n * Implementation from: https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0\n * Original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687\n */\n function sqrt(uint256 x) internal pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n}\n" + }, + "contracts/oracles/default/UniswapLpTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"../BasePriceOracle.sol\";\nimport { UniswapLikeLpTokenPriceOracle } from \"./UniswapLikeLpTokenPriceOracle.sol\";\n\n/**\n * @title UniswapLpTokenPriceOracle\n * @author David Lucid (https://github.com/davidlucid)\n * @notice UniswapLpTokenPriceOracle is a price oracle for Uniswap (and SushiSwap) LP tokens.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract UniswapLpTokenPriceOracle is UniswapLikeLpTokenPriceOracle {\n /**\n * @dev Fetches the fair LP token/ETH price from Uniswap, with 18 decimals of precision.\n */\n constructor(address _wtoken) UniswapLikeLpTokenPriceOracle(_wtoken) {}\n\n function _price(address token) internal view virtual override returns (uint256) {\n IUniswapV2Pair pair = IUniswapV2Pair(token);\n uint256 totalSupply = pair.totalSupply();\n if (totalSupply == 0) return 0;\n (uint256 r0, uint256 r1, ) = pair.getReserves();\n\n r0 = r0 * 10**(18 - uint256(ERC20Upgradeable(pair.token0()).decimals()));\n r1 = r1 * 10**(18 - uint256(ERC20Upgradeable(pair.token1()).decimals()));\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n\n // Get fair price of non-WETH token (underlying the pair) in terms of ETH\n uint256 token0FairPrice = token0 == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(token0);\n uint256 token1FairPrice = token1 == wtoken ? 1e18 : BasePriceOracle(msg.sender).price(token1);\n\n // Implementation from https://github.com/AlphaFinanceLab/homora-v2/blob/e643392d582c81f6695136971cff4b685dcd2859/contracts/oracle/UniswapV2Oracle.sol#L18\n uint256 sqrtK = (sqrt(r0 * r1) * (2**112)) / totalSupply;\n return (((sqrtK * 2 * sqrt(token0FairPrice)) / (2**56)) * sqrt(token1FairPrice)) / (2**56);\n }\n}\n" + }, + "contracts/oracles/default/UniswapTwapPriceOracleV2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\nimport \"./UniswapTwapPriceOracleV2Root.sol\";\n\n/**\n * @title UniswapTwapPriceOracleV2\n * @notice Stores cumulative prices and returns TWAPs for assets on Uniswap V2 pairs.\n * @dev Implements `PriceOracle` and `BasePriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapTwapPriceOracleV2 is Initializable, BasePriceOracle {\n /**\n * @dev wtoken token contract address.\n */\n address public wtoken;\n\n /**\n * @dev UniswapTwapPriceOracleV2Root contract address.\n */\n UniswapTwapPriceOracleV2Root public rootOracle;\n\n /**\n * @dev UniswapV2Factory contract address.\n */\n address public uniswapV2Factory;\n\n /**\n * @dev The token on which to base TWAPs (its price must be available via `msg.sender`).\n */\n address public baseToken;\n\n /**\n * @dev Initalize that sets the UniswapTwapPriceOracleV2Root, UniswapV2Factory, and base token.\n * @param _rootOracle Sets `UniswapTwapPriceOracleV2Root`\n * @param _uniswapV2Factory Sets `UniswapV2Factory`\n * @param _baseToken The token on which to base TWAPs (its price must be available via `msg.sender`).\n * @param _wtoken The Wrapped native asset address\n */\n function initialize(\n address _rootOracle,\n address _uniswapV2Factory,\n address _baseToken,\n address _wtoken\n ) external initializer {\n require(_rootOracle != address(0), \"UniswapTwapPriceOracleV2Root not defined.\");\n require(_uniswapV2Factory != address(0), \"UniswapV2Factory not defined.\");\n rootOracle = UniswapTwapPriceOracleV2Root(_rootOracle);\n uniswapV2Factory = _uniswapV2Factory;\n wtoken = _wtoken;\n baseToken = _baseToken == address(0) ? address(wtoken) : _baseToken;\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = cToken.underlying();\n\n // Get price, format, and return\n uint256 baseUnit = 10**uint256(ERC20Upgradeable(underlying).decimals());\n return (_price(underlying) * 1e18) / baseUnit;\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n */\n function _price(address underlying) internal view returns (uint256) {\n // Return 1e18 for wtoken\n if (underlying == wtoken) return 1e18;\n\n // Return root oracle ERC20/ETH TWAP\n uint256 twap = rootOracle.price(underlying, baseToken, uniswapV2Factory);\n return\n baseToken == address(wtoken)\n ? twap\n : (twap * BasePriceOracle(msg.sender).price(baseToken)) / (10**uint256(ERC20Upgradeable(baseToken).decimals()));\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n}\n" + }, + "contracts/oracles/default/UniswapTwapPriceOracleV2Factory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/ClonesUpgradeable.sol\";\n\nimport \"./UniswapTwapPriceOracleV2.sol\";\n\n/**\n * @title UniswapTwapPriceOracleV2Factory\n * @notice Deploys and catalogs UniswapTwapPriceOracleV2 contracts.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapTwapPriceOracleV2Factory {\n /**\n * @dev WETH token contract address.\n */\n address public immutable wtoken;\n\n /**\n * @dev `UniswapTwapPriceOracleV2Root` contract address.\n */\n address public immutable rootOracle;\n\n /**\n * @dev Implementation address for the `UniswapV3TwapPriceOracleV2`.\n */\n address public immutable logic;\n\n /**\n * @notice Maps `UniswapV2Factory` contracts to base tokens to `UniswapTwapPriceOracleV2` contract addresses.\n */\n mapping(address => mapping(address => UniswapTwapPriceOracleV2)) public oracles;\n\n /**\n * @dev Constructor that sets the `UniswapTwapPriceOracleV2Root` and `UniswapTwapPriceOracleV2` implementation contract.\n */\n constructor(\n address _rootOracle,\n address _logic,\n address _wtoken\n ) {\n require(_rootOracle != address(0), \"UniswapTwapPriceOracleV2Root not defined.\");\n require(_logic != address(0), \"UniswapTwapPriceOracleV2 implementation/logic contract not defined.\");\n rootOracle = _rootOracle;\n logic = _logic;\n wtoken = _wtoken;\n }\n\n /**\n * @notice Deploys a `UniswapTwapPriceOracleV2`.\n * @param uniswapV2Factory The `UniswapV2Factory` contract of the pairs for which this oracle will be used.\n * @param baseToken The base token of the pairs for which this oracle will be used.\n */\n function deploy(address uniswapV2Factory, address baseToken) external returns (address) {\n // Input validation\n if (baseToken == address(0)) baseToken = address(wtoken);\n\n // Return existing oracle if present\n address currentOracle = address(oracles[uniswapV2Factory][baseToken]);\n if (currentOracle != address(0)) return currentOracle;\n\n // Deploy oracle\n bytes32 salt = keccak256(abi.encodePacked(uniswapV2Factory, baseToken));\n address oracle = ClonesUpgradeable.cloneDeterministic(logic, salt);\n UniswapTwapPriceOracleV2(oracle).initialize(rootOracle, uniswapV2Factory, baseToken, wtoken);\n\n // Set oracle in state\n oracles[uniswapV2Factory][baseToken] = UniswapTwapPriceOracleV2(oracle);\n\n // Return oracle address\n return oracle;\n }\n}\n" + }, + "contracts/oracles/default/UniswapTwapPriceOracleV2Resolver.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IResolver } from \"ops/interfaces/IResolver.sol\";\nimport { UniswapTwapPriceOracleV2Root } from \"./UniswapTwapPriceOracleV2Root.sol\";\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract UniswapTwapPriceOracleV2Resolver is IResolver, Ownable {\n struct PairConfig {\n address pair;\n address baseToken;\n uint256 minPeriod;\n uint256 deviationThreshold;\n }\n\n // need to store as arrays for the UniswapTwapPriceOracleV2Root workable functions\n address[] pairs;\n address[] baseTokens;\n uint256[] minPeriods;\n uint256[] deviationThresholds;\n\n UniswapTwapPriceOracleV2Root public root;\n uint256 public lastUpdate;\n\n constructor(PairConfig[] memory _pairConfigs, UniswapTwapPriceOracleV2Root _root) {\n for (uint256 i = 0; i < _pairConfigs.length; i++) {\n pairs[i] = _pairConfigs[i].pair;\n baseTokens[i] = _pairConfigs[i].baseToken;\n minPeriods[i] = _pairConfigs[i].minPeriod;\n deviationThresholds[i] = _pairConfigs[i].deviationThreshold;\n }\n root = _root;\n }\n\n function getPairs() external view returns (PairConfig[] memory) {\n PairConfig[] memory pairConfigs = new PairConfig[](pairs.length);\n for (uint256 i = 0; i < pairs.length; i++) {\n PairConfig memory pairConfig = PairConfig({\n pair: pairs[i],\n baseToken: baseTokens[i],\n minPeriod: minPeriods[i],\n deviationThreshold: deviationThresholds[i]\n });\n pairConfigs[i] = pairConfig;\n }\n return pairConfigs;\n }\n\n function changeRoot(UniswapTwapPriceOracleV2Root _root) external onlyOwner {\n root = _root;\n }\n\n function removeFromPairs(uint256 index) external onlyOwner {\n if (index >= pairs.length) return;\n\n for (uint256 i = index; i < pairs.length - 1; i++) {\n pairs[i] = pairs[i + 1];\n baseTokens[i] = baseTokens[i + 1];\n minPeriods[i] = minPeriods[i + 1];\n deviationThresholds[i] = deviationThresholds[i + 1];\n }\n pairs.pop();\n baseTokens.pop();\n minPeriods.pop();\n deviationThresholds.pop();\n }\n\n function addPair(PairConfig calldata pair) external onlyOwner {\n pairs.push(pair.pair);\n baseTokens.push(pair.baseToken);\n minPeriods.push(pair.minPeriod);\n deviationThresholds.push(pair.deviationThreshold);\n }\n\n function getWorkablePairs() public view returns (address[] memory) {\n bool[] memory workable = root.workable(pairs, baseTokens, minPeriods, deviationThresholds);\n uint256 workableCount = 0;\n for (uint256 i = 0; i < workable.length; i += 1) {\n if (workable[i]) {\n workableCount += 1;\n }\n }\n\n address[] memory workablePairs = new address[](workableCount);\n uint256 j = 0;\n\n for (uint256 i = 0; i < workable.length; i++) {\n if (workable[i]) {\n workablePairs[j++] = pairs[i];\n }\n }\n return workablePairs;\n }\n\n function updatePairs(address[] calldata workablePairs) external {\n if (workablePairs.length == 0) return;\n root.update(workablePairs);\n }\n\n function checker() external view override returns (bool canExec, bytes memory execPayload) {\n address[] memory workablePairs = getWorkablePairs();\n if (workablePairs.length == 0) {\n return (false, bytes(\"No workable pairs\"));\n }\n\n canExec = true;\n execPayload = abi.encodeWithSelector(this.updatePairs.selector, workablePairs);\n }\n}\n" + }, + "contracts/oracles/default/UniswapTwapPriceOracleV2Root.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport \"../../external/uniswap/IUniswapV2Factory.sol\";\n\n/**\n * @title UniswapTwapPriceOracleV2Root\n * @notice Stores cumulative prices and returns TWAPs for assets on Uniswap V2 pairs.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapTwapPriceOracleV2Root {\n /**\n * @dev wtoken token contract address.\n */\n address public immutable wtoken;\n\n /**\n * @dev Minimum TWAP interval.\n */\n uint256 public constant MIN_TWAP_TIME = 15 minutes;\n\n /**\n * @dev Constructor to set wtoken address\n */\n constructor(address _wtoken) {\n wtoken = _wtoken;\n }\n\n /**\n * @dev Return the TWAP value price0. Revert if TWAP time range is not within the threshold.\n * Copied from: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BaseKP3ROracle.sol\n * @param pair The pair to query for price0.\n */\n function price0TWAP(address pair) internal view returns (uint256) {\n uint256 length = observationCount[pair];\n require(length > 0, \"No length-1 TWAP observation.\");\n Observation memory lastObservation = observations[pair][(length - 1) % OBSERVATION_BUFFER];\n if (lastObservation.timestamp > block.timestamp - MIN_TWAP_TIME) {\n require(length > 1, \"No length-2 TWAP observation.\");\n lastObservation = observations[pair][(length - 2) % OBSERVATION_BUFFER];\n }\n uint256 elapsedTime = block.timestamp - lastObservation.timestamp;\n require(elapsedTime >= MIN_TWAP_TIME, \"Bad TWAP time.\");\n uint256 currPx0Cumu = currentPx0Cumu(pair);\n unchecked {\n return (currPx0Cumu - lastObservation.price0Cumulative) / (block.timestamp - lastObservation.timestamp); // overflow is desired\n }\n }\n\n /**\n * @dev Return the TWAP value price1. Revert if TWAP time range is not within the threshold.\n * Copied from: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BaseKP3ROracle.sol\n * @param pair The pair to query for price1.\n */\n function price1TWAP(address pair) internal view returns (uint256) {\n uint256 length = observationCount[pair];\n require(length > 0, \"No length-1 TWAP observation.\");\n Observation memory lastObservation = observations[pair][(length - 1) % OBSERVATION_BUFFER];\n if (lastObservation.timestamp > block.timestamp - MIN_TWAP_TIME) {\n require(length > 1, \"No length-2 TWAP observation.\");\n lastObservation = observations[pair][(length - 2) % OBSERVATION_BUFFER];\n }\n uint256 elapsedTime = block.timestamp - lastObservation.timestamp;\n require(elapsedTime >= MIN_TWAP_TIME, \"Bad TWAP time.\");\n uint256 currPx1Cumu = currentPx1Cumu(pair);\n unchecked {\n return (currPx1Cumu - lastObservation.price1Cumulative) / (block.timestamp - lastObservation.timestamp); // overflow is desired\n }\n }\n\n /**\n * @dev Return the current price0 cumulative value on Uniswap.\n * Copied from: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BaseKP3ROracle.sol\n * @param pair The uniswap pair to query for price0 cumulative value.\n */\n function currentPx0Cumu(address pair) internal view returns (uint256 px0Cumu) {\n uint32 currTime = uint32(block.timestamp);\n px0Cumu = IUniswapV2Pair(pair).price0CumulativeLast();\n (uint256 reserve0, uint256 reserve1, uint32 lastTime) = IUniswapV2Pair(pair).getReserves();\n if (lastTime != block.timestamp) {\n unchecked {\n uint32 timeElapsed = currTime - lastTime; // overflow is desired\n px0Cumu += uint256((reserve1 << 112) / reserve0) * timeElapsed; // overflow is desired\n }\n }\n }\n\n /**\n * @dev Return the current price1 cumulative value on Uniswap.\n * Copied from: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/BaseKP3ROracle.sol\n * @param pair The uniswap pair to query for price1 cumulative value.\n */\n function currentPx1Cumu(address pair) internal view returns (uint256 px1Cumu) {\n uint32 currTime = uint32(block.timestamp);\n px1Cumu = IUniswapV2Pair(pair).price1CumulativeLast();\n (uint256 reserve0, uint256 reserve1, uint32 lastTime) = IUniswapV2Pair(pair).getReserves();\n if (lastTime != currTime) {\n unchecked {\n uint32 timeElapsed = currTime - lastTime; // overflow is desired\n px1Cumu += uint256((reserve0 << 112) / reserve1) * timeElapsed; // overflow is desired\n }\n }\n }\n\n /**\n * @dev Returns the price of `underlying` in terms of `baseToken` given `factory`.\n */\n function price(\n address underlying,\n address baseToken,\n address factory\n ) external view returns (uint256) {\n // Return ERC20/ETH TWAP\n address pair = IUniswapV2Factory(factory).getPair(underlying, baseToken);\n uint256 baseUnit = 10**uint256(ERC20Upgradeable(underlying).decimals());\n return (((underlying < baseToken ? price0TWAP(pair) : price1TWAP(pair)) / (2**56)) * baseUnit) / (2**56); // Scaled by 1e18, not 2 ** 112\n }\n\n /**\n * @dev Struct for cumulative price observations.\n */\n struct Observation {\n uint32 timestamp;\n uint256 price0Cumulative;\n uint256 price1Cumulative;\n }\n\n /**\n * @dev Length after which observations roll over to index 0.\n */\n uint8 public constant OBSERVATION_BUFFER = 4;\n\n /**\n * @dev Total observation count for each pair.\n */\n mapping(address => uint256) public observationCount;\n\n /**\n * @dev Array of cumulative price observations for each pair.\n */\n mapping(address => Observation[OBSERVATION_BUFFER]) public observations;\n\n /// @notice Get pairs for token combinations.\n function pairsFor(\n address[] calldata tokenA,\n address[] calldata tokenB,\n address factory\n ) external view returns (address[] memory) {\n require(\n tokenA.length > 0 && tokenA.length == tokenB.length,\n \"Token array lengths must be equal and greater than 0.\"\n );\n address[] memory pairs = new address[](tokenA.length);\n for (uint256 i = 0; i < tokenA.length; i++) pairs[i] = IUniswapV2Factory(factory).getPair(tokenA[i], tokenB[i]);\n return pairs;\n }\n\n /// @notice Check which of multiple pairs are workable/updatable.\n function workable(\n address[] calldata pairs,\n address[] calldata baseTokens,\n uint256[] calldata minPeriods,\n uint256[] calldata deviationThresholds\n ) external view returns (bool[] memory) {\n require(\n pairs.length > 0 &&\n pairs.length == baseTokens.length &&\n pairs.length == minPeriods.length &&\n pairs.length == deviationThresholds.length,\n \"Array lengths must be equal and greater than 0.\"\n );\n bool[] memory answers = new bool[](pairs.length);\n for (uint256 i = 0; i < pairs.length; i++)\n answers[i] = _workable(pairs[i], baseTokens[i], minPeriods[i], deviationThresholds[i]);\n return answers;\n }\n\n /// @dev Internal function to check if a pair is workable (updateable AND reserves have changed AND deviation threshold is satisfied).\n function _workable(\n address pair,\n address baseToken,\n uint256 minPeriod,\n uint256 deviationThreshold\n ) internal view returns (bool) {\n // Workable if:\n // 1) We have no observations\n // 2) The elapsed time since the last observation is > minPeriod AND reserves have changed AND deviation threshold is satisfied\n // Note that we loop observationCount[pair] around OBSERVATION_BUFFER so we don't waste gas on new storage slots\n if (observationCount[pair] <= 0) return true;\n (, , uint32 lastTime) = IUniswapV2Pair(pair).getReserves();\n return\n (block.timestamp - observations[pair][(observationCount[pair] - 1) % OBSERVATION_BUFFER].timestamp) >\n (minPeriod >= MIN_TWAP_TIME ? minPeriod : MIN_TWAP_TIME) &&\n lastTime != observations[pair][(observationCount[pair] - 1) % OBSERVATION_BUFFER].timestamp &&\n _deviation(pair, baseToken) >= deviationThreshold;\n }\n\n /// @dev Internal function to check if a pair's spot price's deviation from its TWAP price as a ratio scaled by 1e18\n function _deviation(address pair, address baseToken) internal view returns (uint256) {\n // Get token base unit\n address token0 = IUniswapV2Pair(pair).token0();\n bool useToken0Price = token0 != baseToken;\n address underlying = useToken0Price ? token0 : IUniswapV2Pair(pair).token1();\n uint256 baseUnit = 10**uint256(ERC20Upgradeable(underlying).decimals());\n\n // Get TWAP price\n uint256 twapPrice = (((useToken0Price ? price0TWAP(pair) : price1TWAP(pair)) / (2**56)) * baseUnit) / (2**56); // Scaled by 1e18, not 2 ** 112\n\n // Get spot price\n (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pair).getReserves();\n uint256 spotPrice = useToken0Price ? (reserve1 * baseUnit) / reserve0 : (reserve0 * baseUnit) / reserve1;\n\n // Get ratio and return deviation\n uint256 ratio = (spotPrice * 1e18) / twapPrice;\n return ratio >= 1e18 ? ratio - 1e18 : 1e18 - ratio;\n }\n\n /// @dev Internal function to check if a pair is updatable at all.\n function _updateable(address pair) internal view returns (bool) {\n // Updateable if:\n // 1) We have no observations\n // 2) The elapsed time since the last observation is > MIN_TWAP_TIME\n // Note that we loop observationCount[pair] around OBSERVATION_BUFFER so we don't waste gas on new storage slots\n return\n observationCount[pair] <= 0 ||\n (block.timestamp - observations[pair][(observationCount[pair] - 1) % OBSERVATION_BUFFER].timestamp) >\n MIN_TWAP_TIME;\n }\n\n /// @notice Update one pair.\n function update(address pair) external {\n require(_update(pair), \"Failed to update pair.\");\n }\n\n /// @notice Update multiple pairs at once.\n function update(address[] calldata pairs) external {\n bool worked = false;\n for (uint256 i = 0; i < pairs.length; i++) if (_update(pairs[i])) worked = true;\n require(worked, \"No pairs can be updated (yet).\");\n }\n\n /// @dev Internal function to update a single pair.\n function _update(address pair) internal returns (bool) {\n // Check if workable\n if (!_updateable(pair)) return false;\n\n // Get cumulative price(s)\n uint256 price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();\n uint256 price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();\n\n // Loop observationCount[pair] around OBSERVATION_BUFFER so we don't waste gas on new storage slots\n (, , uint32 lastTime) = IUniswapV2Pair(pair).getReserves();\n observations[pair][observationCount[pair] % OBSERVATION_BUFFER] = Observation(\n lastTime,\n price0Cumulative,\n price1Cumulative\n );\n observationCount[pair]++;\n return true;\n }\n}\n" + }, + "contracts/oracles/default/UniswapV3PriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../BasePriceOracle.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"./ConcentratedLiquidityBasePriceOracle.sol\";\n\nimport \"../../external/uniswap/TickMath.sol\";\nimport \"../../external/uniswap/FullMath.sol\";\nimport \"../../external/uniswap/IUniswapV3Pool.sol\";\n\n/**\n * @title UniswapV3PriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice UniswapV3PriceOracle is a price oracle for Uniswap V3 pairs.\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract UniswapV3PriceOracle is ConcentratedLiquidityBasePriceOracle {\n /**\n * @dev Fetches the price for a token from Algebra pools.\n */\n\n function _price(address token) internal view override returns (uint256) {\n uint32[] memory secondsAgos = new uint32[](2);\n uint256 twapWindow = poolFeeds[token].twapWindow;\n address baseToken = poolFeeds[token].baseToken;\n\n secondsAgos[0] = uint32(twapWindow);\n secondsAgos[1] = 0;\n\n IUniswapV3Pool pool = IUniswapV3Pool(poolFeeds[token].poolAddress);\n (int56[] memory tickCumulatives, ) = pool.observe(secondsAgos);\n\n int24 tick = int24((tickCumulatives[1] - tickCumulatives[0]) / int56(int256(twapWindow)));\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(tick);\n\n uint256 tokenPrice = getPriceX96FromSqrtPriceX96(pool.token0(), token, sqrtPriceX96);\n return scalePrices(baseToken, token, tokenPrice);\n }\n}\n" + }, + "contracts/oracles/default/VelodromePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../BasePriceOracle.sol\";\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ninterface Prices {\n function getRateToEth(address srcToken, bool useSrcWrappers) external view returns (uint256 weightedRate);\n}\n\ncontract VelodromePriceOracle is BasePriceOracle {\n Prices immutable prices;\n\n constructor(address _prices) {\n prices = Prices(_prices);\n }\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n return prices.getRateToEth(token, false);\n }\n}\n" + }, + "contracts/oracles/default/WombatLpTokenPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\ninterface IWombatLpAsset {\n function cash() external view returns (uint256);\n\n function underlyingTokenBalance() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function underlyingToken() external view returns (address);\n\n function pool() external view returns (address);\n\n function liability() external view returns (uint256);\n}\n\ncontract WombatLpTokenPriceOracle is BasePriceOracle {\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address asset = cToken.underlying();\n\n uint256 oraclePrice = _price(asset);\n\n uint256 assetDecimals = uint256(ERC20Upgradeable(asset).decimals());\n\n return\n assetDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - assetDecimals))\n : uint256(oraclePrice) / (10**(assetDecimals - 18));\n }\n\n function _price(address asset) internal view returns (uint256) {\n // total supply of vault token\n uint256 assetTotalSupply = IWombatLpAsset(asset).totalSupply();\n\n if (assetTotalSupply == 0) return 0;\n\n address underlying = IWombatLpAsset(asset).underlyingToken();\n\n // balance of underlying asset that vault contains\n uint256 underlyingLiability = IWombatLpAsset(asset).liability();\n\n uint256 underlyingPrice = BasePriceOracle(msg.sender).price(underlying);\n\n return (underlyingPrice * underlyingLiability) / assetTotalSupply;\n }\n\n function price(address asset) external view override returns (uint256) {\n return _price(asset);\n }\n}\n" + }, + "contracts/oracles/default/WSTEthPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IWstETH } from \"../../external/lido/IWstETH.sol\";\n\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title WSTEthPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice WSTEthPriceOracle is a price oracle for wstETH.\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract WSTEthPriceOracle is SafeOwnableUpgradeable, BasePriceOracle {\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n * @param underlying The underlying token address for which to get the price.\n * @return Price denominated in ETH (scaled by 1e18)\n */\n\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(ERC20Upgradeable(underlying).decimals()));\n }\n\n /**\n * @notice Fetches the token/ETH price, with 18 decimals of precision.\n */\n function _price(address token) internal view returns (uint256) {\n // (stETH / ETH) * (wstETH / stETH) = token / ETH\n // From https://github.com/lidofinance/wsteth-eth-price-feed/blob/main/contracts/AAVECompatWstETHToETHPriceFeed.sol\n return (BasePriceOracle(msg.sender).price(IWstETH(token).stETH()) * IWstETH(token).stEthPerToken()) / 1e18;\n }\n}\n" + }, + "contracts/oracles/MasterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BasePriceOracle } from \"./BasePriceOracle.sol\";\n\n/**\n * @title MasterPriceOracle\n * @notice Use a combination of price oracles.\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public oracles;\n\n /**\n * @dev Default/fallback `PriceOracle`.\n */\n BasePriceOracle public defaultOracle;\n\n /**\n * @dev The administrator of this `MasterPriceOracle`.\n */\n address public admin;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool internal noAdminOverwrite;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public wtoken;\n\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public fallbackOracles;\n\n /**\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n function canAdminOverwrite() external view returns (bool) {\n return !noAdminOverwrite;\n }\n\n /**\n * @dev Event emitted when `admin` is changed.\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @dev Event emitted when the default oracle is changed.\n */\n event NewDefaultOracle(address oldOracle, address newOracle);\n\n /**\n * @dev Event emitted when an underlying token's oracle is changed.\n */\n event NewOracle(address underlying, address oldOracle, address newOracle);\n\n /**\n * @dev Initialize state variables.\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\n * @param _defaultOracle The default `PriceOracle` contract to use.\n * @param _admin The admin who can assign oracles to underlying tokens.\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n * @param _wtoken The Wrapped native asset address\n */\n function initialize(\n address[] memory underlyings,\n BasePriceOracle[] memory _oracles,\n BasePriceOracle _defaultOracle,\n address _admin,\n bool _canAdminOverwrite,\n address _wtoken\n ) external initializer {\n // Input validation\n require(underlyings.length == _oracles.length, \"Lengths of both arrays must be equal.\");\n\n // Initialize state variables\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, address(0), address(newOracle));\n }\n\n defaultOracle = _defaultOracle;\n admin = _admin;\n noAdminOverwrite = !_canAdminOverwrite;\n wtoken = _wtoken;\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(oracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(fallbackOracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n fallbackOracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Changes the default price oracle\n */\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\n BasePriceOracle oldOracle = defaultOracle;\n defaultOracle = newOracle;\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\n }\n\n /**\n * @dev Changes the admin and emits an event.\n */\n function changeAdmin(address newAdmin) external onlyAdmin {\n address oldAdmin = admin;\n admin = newAdmin;\n emit NewAdmin(oldAdmin, newAdmin);\n }\n\n /**\n * @dev Modifier that checks if `msg.sender == admin`.\n */\n modifier onlyAdmin() {\n require(msg.sender == admin, \"Sender is not the admin.\");\n _;\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = address(ICErc20(address(cToken)).underlying());\n\n if (underlying == wtoken) return 1e18;\n\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n\n /**\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) public view override returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == wtoken) return 1e18;\n\n // Get underlying price from assigned oracle\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n}\n" + }, + "contracts/PoolDirectory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./compound/Unitroller.sol\";\nimport \"./ionic/SafeOwnableUpgradeable.sol\";\nimport \"./ionic/DiamondExtension.sol\";\n\n/**\n * @title PoolDirectory\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\n */\ncontract PoolDirectory is SafeOwnableUpgradeable {\n /**\n * @dev Initializes a deployer whitelist if desired.\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\n */\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\n __SafeOwnable_init(msg.sender);\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\n }\n\n /**\n * @dev Struct for a Ionic interest rate pool.\n */\n struct Pool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n /**\n * @dev Array of Ionic interest rate pools.\n */\n Pool[] public pools;\n\n /**\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\n */\n mapping(address => uint256[]) private _poolsByAccount;\n\n /**\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\n */\n mapping(address => bool) public poolExists;\n\n /**\n * @dev Emitted when a new Ionic pool is added to the directory.\n */\n event PoolRegistered(uint256 index, Pool pool);\n\n /**\n * @dev Booleans indicating if the deployer whitelist is enforced.\n */\n bool public enforceDeployerWhitelist;\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\n */\n mapping(address => bool) public deployerWhitelist;\n\n /**\n * @dev Controls if the deployer whitelist is to be enforced.\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\n */\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\n enforceDeployerWhitelist = enforce;\n }\n\n /**\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\n * @param deployers Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\n require(deployers.length > 0, \"No deployers supplied.\");\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\n }\n\n /**\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\n * @param name The name of the pool.\n * @param comptroller The pool's Comptroller proxy contract address.\n * @return The index of the registered Ionic pool.\n */\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\n require(!poolExists[comptroller], \"Pool already exists in the directory.\");\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \"Sender is not on deployer whitelist.\");\n require(bytes(name).length <= 100, \"No pool name supplied.\");\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\n pools.push(pool);\n _poolsByAccount[msg.sender].push(pools.length - 1);\n poolExists[comptroller] = true;\n emit PoolRegistered(pools.length - 1, pool);\n return pools.length - 1;\n }\n\n function _deprecatePool(address comptroller) external onlyOwner {\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller == comptroller) {\n _deprecatePool(i);\n break;\n }\n }\n }\n\n function _deprecatePool(uint256 index) public onlyOwner {\n Pool storage ionicPool = pools[index];\n\n require(ionicPool.comptroller != address(0), \"pool already deprecated\");\n\n // swap with the last pool of the creator and delete\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\n for (uint256 i = 0; i < creatorPools.length; i++) {\n if (creatorPools[i] == index) {\n creatorPools[i] = creatorPools[creatorPools.length - 1];\n creatorPools.pop();\n break;\n }\n }\n\n // leave it to true to deny the re-registering of the same pool\n poolExists[ionicPool.comptroller] = true;\n\n // nullify the storage\n ionicPool.comptroller = address(0);\n ionicPool.creator = address(0);\n ionicPool.name = \"\";\n ionicPool.blockPosted = 0;\n ionicPool.timestampPosted = 0;\n }\n\n /**\n * @dev Deploys a new Ionic pool and adds to the directory.\n * @param name The name of the pool.\n * @param implementation The Comptroller implementation contract address.\n * @param constructorData Encoded construction data for `Unitroller constructor()`\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\n * @param closeFactor The pool's close factor (scaled by 1e18).\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\n * @param priceOracle The pool's PriceOracle contract address.\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\n */\n function deployPool(\n string memory name,\n address implementation,\n bytes calldata constructorData,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive,\n address priceOracle\n ) external returns (uint256, address) {\n // Input validation\n require(implementation != address(0), \"No Comptroller implementation contract address specified.\");\n require(priceOracle != address(0), \"No PriceOracle contract address specified.\");\n\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(\n 0,\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\n unitrollerCreationCode\n );\n\n // Setup the pool\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\n // Set up the extensions\n comptrollerProxy._upgrade();\n\n // Set pool parameters\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \"Failed to set pool close factor.\");\n require(\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\n \"Failed to set pool liquidation incentive.\"\n );\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \"Failed to set pool price oracle.\");\n\n // Whitelist\n if (enforceWhitelist)\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \"Failed to enforce supplier/borrower whitelist.\");\n\n // Make msg.sender the admin\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \"Failed to set pending admin on Unitroller.\");\n\n // Register the pool with this PoolDirectory\n return (_registerPool(name, proxy), proxy);\n }\n\n /**\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory activePools = new Pool[](count);\n uint256[] memory poolIds = new uint256[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n poolIds[index] = i;\n activePools[index] = pools[i];\n index++;\n }\n }\n\n return (poolIds, activePools);\n }\n\n /**\n * @notice Returns arrays of all Ionic pools' data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getAllPools() public view returns (Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory result = new Pool[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n result[index++] = pools[i];\n }\n }\n\n return result;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n indexes[index] = i;\n poolsOfUser[index] = activePools[i];\n index++;\n }\n\n return (indexes, poolsOfUser);\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\n */\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\n (, Pool[] memory activePools) = getActivePools();\n\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\n indexes[i] = _poolsByAccount[account][i];\n accountPools[i] = activePools[_poolsByAccount[account][i]];\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Modify existing Ionic pool name.\n */\n function setPoolName(uint256 index, string calldata name) external {\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\n require(\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\n \"!permission\"\n );\n pools[index].name = name;\n }\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\n */\n mapping(address => bool) public adminWhitelist;\n\n /**\n * @dev used as salt for the creation of new pools\n */\n uint256 public poolsCounter;\n\n /**\n * @dev Event emitted when the admin whitelist is updated.\n */\n event AdminWhitelistUpdated(address[] admins, bool status);\n\n /**\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\n * @param admins Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\n require(admins.length > 0, \"No admins supplied.\");\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\n emit AdminWhitelistUpdated(admins, status);\n }\n\n /**\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getVerifiedPoolsOfWhitelistedAccount(address account)\n external\n view\n returns (uint256[] memory, Pool[] memory)\n {\n uint256 arrayLength = 0;\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n indexes[index] = i;\n accountWhitelistedPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, accountWhitelistedPools);\n }\n}\n" + }, + "contracts/PoolLens.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"./oracles/MasterPriceOracle.sol\";\n\n/**\n * @title PoolLens\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLens is Initializable {\n error ComptrollerError(uint256 errCode);\n\n /**\n * @notice Initialize the `PoolDirectory` contract object.\n * @param _directory The PoolDirectory\n * @param _name Name for the nativeToken\n * @param _symbol Symbol for the nativeToken\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\n * @param _hardcodedNames Harcoded name for these tokens\n * @param _hardcodedSymbols Harcoded symbol for these tokens\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\n */\n function initialize(\n PoolDirectory _directory,\n string memory _name,\n string memory _symbol,\n address[] memory _hardcodedAddresses,\n string[] memory _hardcodedNames,\n string[] memory _hardcodedSymbols,\n string[] memory _uniswapLPTokenNames,\n string[] memory _uniswapLPTokenSymbols,\n string[] memory _uniswapLPTokenDisplayNames\n ) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n require(\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\n \"Hardcoded addresses lengths not equal.\"\n );\n require(\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\n \"Uniswap LP token names lengths not equal.\"\n );\n\n directory = _directory;\n name = _name;\n symbol = _symbol;\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\n }\n\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\n uniswapData.push(\n UniswapData({\n name: _uniswapLPTokenNames[i],\n symbol: _uniswapLPTokenSymbols[i],\n displayName: _uniswapLPTokenDisplayNames[i]\n })\n );\n }\n }\n\n string public name;\n string public symbol;\n\n struct TokenData {\n string name;\n string symbol;\n }\n mapping(address => TokenData) hardcoded;\n\n struct UniswapData {\n string name; // ie \"Uniswap V2\" or \"SushiSwap LP Token\"\n string symbol; // ie \"UNI-V2\" or \"SLP\"\n string displayName; // ie \"SushiSwap\" or \"Uniswap\"\n }\n UniswapData[] uniswapData;\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @dev Struct for Ionic pool summary data.\n */\n struct IonicPoolData {\n uint256 totalSupply;\n uint256 totalBorrow;\n address[] underlyingTokens;\n string[] underlyingSymbols;\n bool whitelistedAdmin;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsWithData()\n external\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\n {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsByVerificationWithData(\n bool whitelistedAdmin\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\n whitelistedAdmin\n );\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsOIonicrWithData(\n address user\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\n return (indexes, userPools, data, errored);\n }\n\n /**\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\n bool[] memory errored = new bool[](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\n uint256 _totalSupply,\n uint256 _totalBorrow,\n address[] memory _underlyingTokens,\n string[] memory _underlyingSymbols,\n bool _whitelistedAdmin\n ) {\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\n } catch {\n errored[i] = true;\n }\n }\n\n return (data, errored);\n }\n\n /**\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\n */\n function getPoolSummary(\n IonicComptroller comptroller\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\n uint256 totalBorrow = 0;\n uint256 totalSupply = 0;\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n address[] memory underlyingTokens = new address[](cTokens.length);\n string[] memory underlyingSymbols = new string[](cTokens.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n cToken.accrueInterest();\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\n uint256 assetTotalSupply = cToken.getCash() +\n assetTotalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\n\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\n }\n\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\n }\n\n /**\n * @dev Struct for a Ionic pool asset.\n */\n struct PoolAsset {\n address cToken;\n address underlyingToken;\n string underlyingName;\n string underlyingSymbol;\n uint256 underlyingDecimals;\n uint256 underlyingBalance;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 totalSupply;\n uint256 totalBorrow;\n uint256 supplyBalance;\n uint256 borrowBalance;\n uint256 liquidity;\n bool membership;\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\n address oracle;\n uint256 collateralFactor;\n uint256 reserveFactor;\n uint256 adminFee;\n uint256 ionicFee;\n bool borrowGuardianPaused;\n bool mintGuardianPaused;\n }\n\n /**\n * @notice Returns data on the specified assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\n * @param cTokens The cToken contract addresses of the assets to query.\n * @param user The user for which to get account data.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(\n IonicComptroller comptroller,\n ICErc20[] memory cTokens,\n address user\n ) internal returns (PoolAsset[] memory) {\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\n if (isListed) arrayLength++;\n }\n\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\n uint256 index = 0;\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n // Check if market is listed and get collateral factor\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\n if (!isListed) continue;\n\n // Start adding data to PoolAsset\n PoolAsset memory asset;\n ICErc20 cToken = cTokens[i];\n asset.cToken = address(cToken);\n\n cToken.accrueInterest();\n\n // Get underlying asset data\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\n asset.underlyingDecimals = underlying.decimals();\n asset.underlyingBalance = underlying.balanceOf(user);\n\n // Get cToken data\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\n asset.liquidity = cToken.getCash();\n asset.totalBorrow = cToken.totalBorrowsCurrent();\n asset.totalSupply =\n asset.liquidity +\n asset.totalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\n asset.membership = comptroller.checkMembership(user, cToken);\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\n\n // Get oracle for this cToken\n asset.oracle = address(oracle);\n\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\n asset.oracle = address(_oracle);\n } catch {}\n\n // More cToken data\n asset.collateralFactor = collateralFactorMantissa;\n asset.reserveFactor = cToken.reserveFactorMantissa();\n asset.adminFee = cToken.adminFeeMantissa();\n asset.ionicFee = cToken.ionicFeeMantissa();\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\n\n // Add to assets array and increment index\n detailedAssets[index] = asset;\n index++;\n }\n\n return (detailedAssets);\n }\n\n function getBorrowCapsPerCollateral(\n ICErc20 borrowedAsset,\n IonicComptroller comptroller\n )\n internal\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsAgainstCollateral,\n bool[] memory borrowingBlacklistedAgainstCollateral\n )\n {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n collateral = new address[](poolMarkets.length);\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\n\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n address collateralAddress = address(poolMarkets[i]);\n if (collateralAddress != address(borrowedAsset)) {\n collateral[i] = collateralAddress;\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\n address(borrowedAsset),\n collateralAddress\n );\n }\n }\n }\n\n /**\n * @notice Returns the `name` and `symbol` of `token`.\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\n * @param token An ERC20 token contract object.\n * @return The `name` and `symbol`.\n */\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\n // i.e. MKR is a DSToken and uses bytes32\n if (bytes(hardcoded[token].symbol).length != 0) {\n return (hardcoded[token].name, hardcoded[token].symbol);\n }\n\n // Get name and symbol from token contract\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\n string memory _name = tokenContract.name();\n string memory _symbol = tokenContract.symbol();\n\n return (_name, _symbol);\n }\n\n /**\n * @notice Returns the assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\n }\n\n /**\n * @dev Struct for a Ionic pool user.\n */\n struct IonicPoolUser {\n address account;\n uint256 totalBorrow;\n uint256 totalCollateral;\n uint256 health;\n }\n\n /**\n * @notice Returns arrays of PoolAsset for a specific user\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\n return assets;\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n }\n\n return (assets, supplyCapsPerAsset);\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsDataForPool(\n IonicComptroller comptroller\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\n }\n\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\n }\n\n /**\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n }\n\n /**\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsDataForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap,\n uint256 nonWhitelistedTotalBorrows\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n uint256 totalBorrows = asset.totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\n * Note that the whitelist does not have to be enforced.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getWhitelistedPoolsByAccount(\n address account\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) {\n indexes[index] = i;\n accountPools[index] = pools[i];\n index++;\n break;\n }\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getWhitelistedPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\n }\n\n function getHealthFactorHypothetical(\n IonicComptroller pool,\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\n account,\n cTokenModify,\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n\n if (err != 0) revert ComptrollerError(err);\n\n if (shortfall > 0) {\n // HF < 1.0\n return (collateralValue * 1e18) / (collateralValue + shortfall);\n } else {\n // HF >= 1.0\n if (collateralValue <= liquidity) return type(uint256).max;\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\n }\n }\n}\n" + }, + "contracts/PoolLensSecondary.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"./external/uniswap/IUniswapV2Pair.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\n\ninterface IRewardsDistributor_PLS {\n function rewardToken() external view returns (address);\n\n function compSupplySpeeds(address) external view returns (uint256);\n\n function compBorrowSpeeds(address) external view returns (uint256);\n\n function compAccrued(address) external view returns (uint256);\n\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n}\n\n/**\n * @title PoolLensSecondary\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLensSecondary is Initializable {\n /**\n * @notice Constructor to set the `PoolDirectory` contract object.\n */\n function initialize(PoolDirectory _directory) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n directory = _directory;\n }\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @notice Struct for ownership over a CToken.\n */\n struct CTokenOwnership {\n address cToken;\n address admin;\n bool adminHasRights;\n bool ionicAdminHasRights;\n }\n\n /**\n * @notice Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolOwnership(IonicComptroller comptroller)\n external\n view\n returns (\n address,\n bool,\n bool,\n CTokenOwnership[] memory\n )\n {\n // Get pool ownership\n address comptrollerAdmin = comptroller.admin();\n bool comptrollerAdminHasRights = comptroller.adminHasRights();\n bool comptrollerIonicAdminHasRights = comptroller.ionicAdminHasRights();\n\n // Get cToken ownership\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) arrayLength++;\n }\n\n CTokenOwnership[] memory outliers = new CTokenOwnership[](arrayLength);\n uint256 arrayIndex = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array and increment array index\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) {\n outliers[arrayIndex] = CTokenOwnership(\n address(cToken),\n cTokenAdmin,\n cTokenAdminHasRights,\n cTokenIonicAdminHasRights\n );\n arrayIndex++;\n }\n }\n\n return (comptrollerAdmin, comptrollerAdminHasRights, comptrollerIonicAdminHasRights, outliers);\n }\n\n /**\n * @notice Determine the maximum redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum redeem amount.\n */\n function getMaxRedeem(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, false);\n }\n\n /**\n * @notice Determine the maximum borrow amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow amount.\n */\n function getMaxBorrow(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, true);\n }\n\n /**\n * @dev Internal function to determine the maximum borrow/redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow/redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow/redeem amount.\n */\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal returns (uint256) {\n IonicComptroller comptroller = IonicComptroller(cTokenModify.comptroller());\n return comptroller.getMaxRedeemOrBorrow(account, cTokenModify, isBorrow);\n }\n\n /**\n * @notice Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptroller The Ionic pool Comptroller to check.\n */\n function getRewardSpeedsByPool(IonicComptroller comptroller)\n public\n view\n returns (\n ICErc20[] memory,\n address[] memory,\n address[] memory,\n uint256[][] memory,\n uint256[][] memory\n )\n {\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n address[] memory distributors;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors = _distributors;\n } catch {\n distributors = new address[](0);\n }\n\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[][] memory supplySpeeds = new uint256[][](allMarkets.length);\n uint256[][] memory borrowSpeeds = new uint256[][](allMarkets.length);\n\n // Get reward tokens for each distributor\n for (uint256 i = 0; i < distributors.length; i++) {\n rewardTokens[i] = IRewardsDistributor_PLS(distributors[i]).rewardToken();\n }\n\n // Get reward speeds for each market for each distributor\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address cToken = address(allMarkets[i]);\n supplySpeeds[i] = new uint256[](distributors.length);\n borrowSpeeds[i] = new uint256[](distributors.length);\n\n for (uint256 j = 0; j < distributors.length; j++) {\n IRewardsDistributor_PLS distributor = IRewardsDistributor_PLS(distributors[j]);\n supplySpeeds[i][j] = distributor.compSupplySpeeds(cToken);\n borrowSpeeds[i][j] = distributor.compBorrowSpeeds(cToken);\n }\n }\n\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptrollers The Ionic pool Comptrollers to check.\n */\n function getRewardSpeedsByPools(IonicComptroller[] memory comptrollers)\n external\n view\n returns (\n ICErc20[][] memory,\n address[][] memory,\n address[][] memory,\n uint256[][][] memory,\n uint256[][][] memory\n )\n {\n ICErc20[][] memory allMarkets = new ICErc20[][](comptrollers.length);\n address[][] memory distributors = new address[][](comptrollers.length);\n address[][] memory rewardTokens = new address[][](comptrollers.length);\n uint256[][][] memory supplySpeeds = new uint256[][][](comptrollers.length);\n uint256[][][] memory borrowSpeeds = new uint256[][][](comptrollers.length);\n for (uint256 i = 0; i < comptrollers.length; i++)\n (allMarkets[i], distributors[i], rewardTokens[i], supplySpeeds[i], borrowSpeeds[i]) = getRewardSpeedsByPool(\n comptrollers[i]\n );\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice Returns unaccrued rewards by `holder` from `cToken` on `distributor`.\n * @param holder The address to check.\n * @param distributor The RewardsDistributor to check.\n * @param cToken The CToken to check.\n * @return Unaccrued (unclaimed) supply-side rewards and unaccrued (unclaimed) borrow-side rewards.\n */\n function getUnaccruedRewards(\n address holder,\n IRewardsDistributor_PLS distributor,\n ICErc20 cToken\n ) internal returns (uint256, uint256) {\n // Get unaccrued supply rewards\n uint256 compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreSupplierAction(address(cToken), holder);\n uint256 supplyRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Get unaccrued borrow rewards\n compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreBorrowerAction(address(cToken), holder);\n uint256 borrowRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Return both\n return (supplyRewardsUnaccrued, borrowRewardsUnaccrued);\n }\n\n /**\n * @notice Returns all unclaimed rewards accrued by the `holder` on `distributors`.\n * @param holder The address to check.\n * @param distributors The `RewardsDistributor` contracts to check.\n * @return For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\n */\n function getUnclaimedRewardsByDistributors(address holder, IRewardsDistributor_PLS[] memory distributors)\n external\n returns (\n address[] memory,\n uint256[] memory,\n ICErc20[][] memory,\n uint256[2][][] memory,\n uint256[] memory\n )\n {\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[] memory compUnclaimedTotal = new uint256[](distributors.length);\n ICErc20[][] memory allMarkets = new ICErc20[][](distributors.length);\n uint256[2][][] memory rewardsUnaccrued = new uint256[2][][](distributors.length);\n uint256[] memory distributorFunds = new uint256[](distributors.length);\n\n for (uint256 i = 0; i < distributors.length; i++) {\n IRewardsDistributor_PLS distributor = distributors[i];\n rewardTokens[i] = distributor.rewardToken();\n allMarkets[i] = distributor.getAllMarkets();\n rewardsUnaccrued[i] = new uint256[2][](allMarkets[i].length);\n for (uint256 j = 0; j < allMarkets[i].length; j++)\n (rewardsUnaccrued[i][j][0], rewardsUnaccrued[i][j][1]) = getUnaccruedRewards(\n holder,\n distributor,\n allMarkets[i][j]\n );\n compUnclaimedTotal[i] = distributor.compAccrued(holder);\n distributorFunds[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(distributor));\n }\n\n return (rewardTokens, compUnclaimedTotal, allMarkets, rewardsUnaccrued, distributorFunds);\n }\n\n /**\n * @notice Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getRewardsDistributorsBySupplier(address supplier)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n // Get array length\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n try IonicComptroller(pools[i].comptroller).suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) arrayLength++;\n } catch {}\n }\n\n // Build array\n uint256[] memory indexes = new uint256[](arrayLength);\n IonicComptroller[] memory comptrollers = new IonicComptroller[](arrayLength);\n address[][] memory distributors = new address[][](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n try comptroller.suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) {\n indexes[index] = i;\n comptrollers[index] = comptroller;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors[index] = _distributors;\n } catch {}\n\n index++;\n }\n } catch {}\n }\n\n // Return distributors\n return (indexes, comptrollers, distributors);\n }\n\n /**\n * @notice The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getFlywheelsToClaim(address user)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n\n IonicComptroller[] memory comptrollers = new IonicComptroller[](pools.length);\n address[][] memory distributors = new address[][](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n comptrollers[i] = comptroller;\n distributors[i] = flywheelsWithRewardsForPoolUser(user, _distributors);\n } catch {}\n }\n\n return (poolIds, comptrollers, distributors);\n }\n\n function flywheelsWithRewardsForPoolUser(address user, address[] memory _distributors)\n internal\n view\n returns (address[] memory)\n {\n address[] memory distributors = new address[](_distributors.length);\n for (uint256 j = 0; j < _distributors.length; j++) {\n if (IRewardsDistributor_PLS(_distributors[j]).compAccrued(user) > 0) {\n distributors[j] = _distributors[j];\n }\n }\n\n return distributors;\n }\n}\n" + }, + "contracts/security/OracleRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\ncontract OracleRegistry is Ownable2Step {\n bytes32 private constant HYPERNATIVE_ORACLE_STORAGE_SLOT =\n bytes32(uint256(keccak256(\"eip1967.hypernative.oracle\")) - 1);\n bytes32 private constant HYPERNATIVE_MODE_STORAGE_SLOT =\n bytes32(uint256(keccak256(\"eip1967.hypernative.is_strict_mode\")) - 1);\n\n event OracleAdminChanged(address indexed previousAdmin, address indexed newAdmin);\n event OracleAddressChanged(address indexed previousOracle, address indexed newOracle);\n\n constructor() Ownable2Step() {}\n\n function oracleRegister(address _account) public {\n address oracleAddress = _getAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT);\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n if (hypernativeOracleIsStrictMode()) {\n oracle.registerStrict(_account);\n } else {\n oracle.register(_account);\n }\n }\n\n function setOracle(address _oracle) public onlyOwner {\n _setOracle(_oracle);\n }\n\n function setIsStrictMode(bool _mode) public onlyOwner {\n _setIsStrictMode(_mode);\n }\n\n function hypernativeOracleIsStrictMode() public view returns (bool) {\n return _getValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT) == 1;\n }\n\n function hypernativeOracle() public view returns (address) {\n return _getAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT);\n }\n\n /**\n * @dev Admin only function, sets new oracle admin. set to address(0) to revoke oracle\n */\n function _setOracle(address _oracle) internal {\n address oldOracle = hypernativeOracle();\n _setAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT, _oracle);\n emit OracleAddressChanged(oldOracle, _oracle);\n }\n\n function _setIsStrictMode(bool _mode) internal {\n _setValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT, _mode ? 1 : 0);\n }\n\n function _setAddressBySlot(bytes32 slot, address newAddress) internal {\n assembly {\n sstore(slot, newAddress)\n }\n }\n\n function _setValueBySlot(bytes32 _slot, uint256 _value) internal {\n assembly {\n sstore(_slot, _value)\n }\n }\n\n function _getAddressBySlot(bytes32 slot) internal view returns (address addr) {\n assembly {\n addr := sload(slot)\n }\n }\n\n function _getValueBySlot(bytes32 _slot) internal view returns (uint256 _value) {\n assembly {\n _value := sload(_slot)\n }\n }\n}\n" + }, + "contracts/test/abstracts/AbstractAssetTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { AbstractERC4626Test } from \"./AbstractERC4626Test.sol\";\nimport { ITestConfigStorage } from \"./ITestConfigStorage.sol\";\n\ncontract AbstractAssetTest is BaseTest {\n AbstractERC4626Test public test;\n ITestConfigStorage public testConfigStorage;\n\n function setUpTestContract(bytes calldata testConfig) public virtual {\n // test._setUp(MockERC20(address(IBeefyVault(testConfig.beefyVault).want())).symbol(), testConfig);\n }\n\n function runTest(function() external testFn) public {\n if (shouldRunForChain(block.chainid)) {\n for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n this.setUpTestContract(testConfigStorage.getTestConfig(i));\n testFn();\n }\n }\n }\n\n function testInitializedValues() public virtual {\n // for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n // this.setUpTestContract(testConfigs[i]);\n // test.testInitializedValues(asset.name(), asset.symbol());\n // }\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n this.runTest(test.testPreviewDepositAndMintReturnTheSameValue);\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n this.runTest(test.testPreviewWithdrawAndRedeemReturnTheSameValue);\n }\n\n function testDeposit() public {\n this.runTest(test.testDeposit);\n }\n\n function testDepositWithIncreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithIncreasedVaultValue);\n }\n\n function testDepositWithDecreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithDecreasedVaultValue);\n }\n\n function testMultipleDeposit() public {\n this.runTest(test.testMultipleDeposit);\n }\n\n function testMint() public {\n this.runTest(test.testMint);\n }\n\n function testMultipleMint() public {\n this.runTest(test.testMultipleMint);\n }\n\n function testWithdraw() public {\n this.runTest(test.testWithdraw);\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithIncreasedVaultValue);\n }\n\n function testWithdrawWithDecreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithDecreasedVaultValue);\n }\n\n function testMultipleWithdraw() public {\n this.runTest(test.testMultipleWithdraw);\n }\n\n function testRedeem() public {\n this.runTest(test.testRedeem);\n }\n\n function testMultipleRedeem() public {\n this.runTest(test.testMultipleRedeem);\n }\n\n function testPauseContract() public {\n this.runTest(test.testPauseContract);\n }\n\n function testEmergencyWithdrawAndPause() public {\n this.runTest(test.testEmergencyWithdrawAndPause);\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n this.runTest(test.testEmergencyWithdrawAndRedeem);\n }\n}\n" + }, + "contracts/test/abstracts/AbstractERC4626Test.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../helpers/WithPool.sol\";\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { IonicERC4626 } from \"../../ionic/strategies/IonicERC4626.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Authority } from \"solmate/auth/Auth.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nabstract contract AbstractERC4626Test is WithPool {\n using FixedPointMathLib for uint256;\n\n IonicERC4626 plugin;\n\n string testPreFix;\n\n uint256 public depositAmount = 100e18;\n uint256 BPS_DENOMINATOR = 10_000;\n\n uint256 initialStrategyBalance;\n uint256 initialStrategySupply;\n\n constructor() {\n _forkAtBlock(uint128(block.chainid), block.number);\n }\n\n function _setUp(string memory _testPreFix, bytes calldata data) public virtual;\n\n function deposit(address _owner, uint256 amount) public {\n vm.startPrank(_owner);\n underlyingToken.approve(address(plugin), amount);\n plugin.deposit(amount, _owner);\n vm.stopPrank();\n }\n\n function sendUnderlyingToken(uint256 amount, address recipient) public {\n deal(address(underlyingToken), recipient, amount);\n }\n\n function increaseAssetsInVault() public virtual {}\n\n function decreaseAssetsInVault() public virtual {}\n\n function getDepositShares() public view virtual returns (uint256);\n\n function getStrategyBalance() public view virtual returns (uint256);\n\n function getExpectedDepositShares() public view virtual returns (uint256);\n\n function testInitializedValues(string memory assetName, string memory assetSymbol) public virtual {\n assertEq(\n plugin.name(),\n string(abi.encodePacked(\"Midas \", assetName, \" Vault\")),\n string(abi.encodePacked(\"!name \", testPreFix))\n );\n assertEq(\n plugin.symbol(),\n string(abi.encodePacked(\"mv\", assetSymbol)),\n string(abi.encodePacked(\"!symbol \", testPreFix))\n );\n assertEq(address(plugin.asset()), address(underlyingToken), string(abi.encodePacked(\"!asset \", testPreFix)));\n // assertEq(\n // address(BeefyERC4626(address(plugin)).beefyVault()),\n // address(beefyVault),\n // string(abi.encodePacked(\"!beefyVault \", testPreFix))\n // );\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n uint256 returnedShares = plugin.previewDeposit(depositAmount);\n assertApproxEqAbs(\n plugin.previewMint(returnedShares),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewMint \", testPreFix))\n );\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 reqShares = plugin.previewWithdraw(withdrawalAmount);\n assertApproxEqAbs(\n plugin.previewRedeem(reqShares),\n withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewRedeem \", testPreFix))\n );\n }\n\n function testDeposit() public virtual {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShares \", testPreFix))\n );\n }\n\n function testDepositWithIncreasedVaultValue() public {\n // lpDepositor just mints the exact amount of depositShares as the user deposits in assets\n uint256 oldExpectedDepositShare = this.getExpectedDepositShares();\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n oldExpected4626Shares + previewErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == oldExpectedShares \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n previewErc4626Shares,\n oldExpected4626Shares,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n assertApproxEqAbs(\n previewErc4626Shares,\n expected4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == expectedShares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n oldExpectedDepositShare + expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n }\n\n function testDepositWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n uint256 oldExpecteDepositShares = depositAmount;\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n deposit(address(this), depositAmount);\n // Decrease the share price\n decreaseAssetsInVault();\n uint256 expectedDepositShare = depositAmount;\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n // Test that we minted the correct amount of token\n assertApproxEqAbs(plugin.balanceOf(address(this)), oldExpected4626Shares + previewErc4626Shares);\n // Test that we got less shares on the second mint after assets in the vault increased\n assertGt(previewErc4626Shares, oldExpected4626Shares, \"!new shares > old Shares\");\n assertApproxEqAbs(previewErc4626Shares, expected4626Shares, \"!previewShares == expectedShares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(this.getDepositShares(), oldExpecteDepositShares + expectedDepositShare);\n */\n }\n\n function testMultipleDeposit() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount * 2,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount * 2,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"Total Assets should be same as sum of deposited amounts \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(this) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(1) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares * 2,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n // DotDot ERC4626 should not have underlyingToken after deposit\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testMultipleMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n vm.startPrank(address(1));\n underlyingToken.approve(address(plugin), depositAmount);\n sendUnderlyingToken(depositAmount, address(1));\n plugin.mint(mintAmount, address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount + depositAmount,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"!2.totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"!2.balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount + mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!2.depositShare \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n uint256(2),\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n vm.stopPrank();\n }\n\n function testWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n assertTrue(underlyingToken.balanceOf(address(plugin)) <= 1, string(abi.encodePacked(\"!0 \", testPreFix)));\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n uint256 depositShareBal = this.getExpectedDepositShares();\n\n deposit(address(this), depositAmount);\n\n uint256 withdrawalAmount = 10e18;\n\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n expectedErc4626SharesNeeded,\n oldExpectedErc4626SharesNeeded,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + ExpectedDepositSharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testWithdrawWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n sendUnderlyingToken(depositAmount, address(this));\n uint256 depositShares = this.getExpectedDepositShares();\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Increase the share price\n decreaseAssetsInVault();\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded)\n );\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(expectedErc4626SharesNeeded, oldExpectedErc4626SharesNeeded, \"!new shares < old Shares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + expectedDepositSharesNeeded)\n );\n */\n }\n\n function testMultipleWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal\", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n depositAmount * 2 - expectedErc4626SharesNeeded,\n plugin.totalSupply(),\n 10,\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 1,\n 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - expectedErc4626SharesNeeded;\n depositShares = depositShares - ExpectedDepositSharesNeeded;\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testMultipleRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount * 2 - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - redeemAmount;\n depositShares -= ExpectedDepositSharesNeeded;\n redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testPauseContract() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n underlyingToken.approve(address(plugin), depositAmount);\n vm.expectRevert(\"Pausable: paused\");\n plugin.deposit(depositAmount, address(this));\n\n vm.expectRevert(\"Pausable: paused\");\n plugin.mint(depositAmount, address(this));\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndPause() public virtual {\n deposit(address(this), depositAmount);\n\n uint256 expectedBal = plugin.previewRedeem(depositAmount);\n assertEq(underlyingToken.balanceOf(address(plugin)), 0, string(abi.encodePacked(\"!init 0 \", testPreFix)));\n\n plugin.emergencyWithdrawAndPause();\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!withdraws underlying \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalAssets(),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets == expectedBal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n}\n" + }, + "contracts/test/abstracts/ITestConfigStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface ITestConfigStorage {\n function getTestConfig(uint256 i) external view returns (bytes memory);\n\n function getTestConfigLength() external view returns (uint256);\n}\n" + }, + "contracts/test/AccountLiquidityTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract AccountLiquidityTest is UpgradesBaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n } else {\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testUserMaxWithdraw() public debuggingOnly forkAtBlock(MODE_MAINNET, 5890823) {\n address user = 0xBf891E7eFCC98A8239385D3172bA10AD593c7886;\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n _upgradePoolWithExtension(asUnitroller);\n\n {\n _testAccountLiquidity(user);\n\n uint256 maxRedeem = lens2.getMaxRedeem(user, wethMarket);\n emit log_named_uint(\"maxRedeem\", maxRedeem);\n\n bool isMember = pool.checkMembership(user, wethMarket);\n emit log(isMember ? \"is member\" : \"NOT A MEMBER\");\n }\n //vm.rollFork(5891795);\n // redeemed before liquidation at 5890822\n\n // before withdraw call at block 5890821\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 156238264982770748812\n // liquidity: 16428491404549045373\n // maxRedeem: 23469273435070064818\n // is member\n\n // user calls withdraw with max(uint256) at block 5890822\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 139809773853485792955\n // SHORTFALL: 257892668904\n // maxRedeem: 0\n // is member\n\n // liquidated at 5890902\n // https://explorer.mode.network/tx/0x424fd0504e7afb00382c6dcd25a2efdefd96c005c2333112be450fc7bd98cc88\n }\n}\n" + }, + "contracts/test/AccrueInterestTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\n\nstruct AccrualDiff {\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n}\n\ncontract AccrueInterestTest is UpgradesBaseTest {\n // fork before the accrue interest refactoring\n function testAccrueInterest() public debuggingOnly forkAtBlock(BSC_MAINNET, 26032460) {\n address busdMarketAddress = 0xa7213deB44f570646Ea955771Cc7f39B58841363;\n address wbnbMarketAddress = 0x57a64a77f8E4cFbFDcd22D5551F52D675cc5A956;\n\n _testAccrueInterest(wbnbMarketAddress);\n }\n\n function _testAccrueInterest(address marketAddress) internal {\n //CErc20Delegate market = CErc20Delegate(marketAddress);\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(marketAddress);\n ICErc20 market = ICErc20(marketAddress);\n\n uint256 adminFeeMantissa = market.adminFeeMantissa();\n uint256 ionicFeeMantissa = market.ionicFeeMantissa();\n uint256 reserveFactorMantissa = market.reserveFactorMantissa();\n\n // test with the logic before the refactoring\n\n AccrualDiff memory diffBefore;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index old impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows old impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves old impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees old impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees old impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply old impl\");\n\n diffBefore.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffBefore.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffBefore.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffBefore.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffBefore.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n // test with the logic after the refactoring\n vm.rollFork(26032460);\n afterForkSetUp();\n _upgradeMarketWithExtension(market);\n\n AccrualDiff memory diffAfter;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index new impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows new impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves new impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees new impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees new impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply new impl\");\n\n diffAfter.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffAfter.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffAfter.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffAfter.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffAfter.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n assertEq(diffBefore.borrowIndex, diffAfter.borrowIndex, \"!borrowIndexDiff\");\n assertEq(diffBefore.totalBorrows, diffAfter.totalBorrows, \"!totalBorrowsDiff\");\n assertEq(diffBefore.totalReserves, diffAfter.totalReserves, \"!totalReservesDiff\");\n assertEq(diffBefore.totalIonicFees, diffAfter.totalIonicFees, \"!totalIonicFeesDiff\");\n assertEq(diffBefore.totalAdminFees, diffAfter.totalAdminFees, \"!totalAdminFeesDiff\");\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testMintGated() public fork(POLYGON_MAINNET) {\n address newMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address assetWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n // approve spending\n vm.startPrank(assetWhale);\n IERC20Upgradeable(CErc20Delegate(newMarket).underlying()).approve(newMarket, 1e6);\n require(CErc20Delegate(newMarket).mint(1e6) == 0, \"!mint failed\");\n vm.stopPrank();\n }\n\n function testDeployCToken() public debuggingOnly fork(POLYGON_MAINNET) {\n CErc20Delegate cErc20Delegate = new CErc20Delegate();\n IonicComptroller pool = IonicComptroller(0x69617fE545804BcDfE853626B4C8EF23475Ac54B);\n emit log_named_address(\"admin\", pool.admin());\n pool.adminHasRights();\n vm.startPrank(0x9308dddeC9B5cCd8a2685A46E913C892FE31C826);\n pool._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(0xb5DFABd7fF7F83BAB83995E72A52B97ABb7bcf63),\n 0x69617fE545804BcDfE853626B4C8EF23475Ac54B,\n payable(address(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c)),\n InterestRateModel(address(0xA433B7d3a8A87D8fd40dA68A424007Dd8a21Ce41)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(0),\n uint256(0)\n ),\n \"\",\n 0.72e18\n );\n vm.stopPrank();\n // _functionCall(0xC40119C7269A5FA813d878BF83d14E3462fC8Fde, hex\"8f93bfba\", \"raw liquidation failed\");\n }\n\n function testDeployNeonPool() public debuggingOnly fork(NEON_MAINNET) {\n PoolDirectory poolDirectory = PoolDirectory(0x297a15F615aCdf87580af1Fc497EE57424975Dae);\n FeeDistributor ionicAdmin = FeeDistributor(payable(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c));\n Comptroller tempComptroller = new Comptroller();\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n vm.prank(ionicAdmin.owner());\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))), // FD\n false,\n 0.1e18,\n 1.1e18,\n 0xBAAb9986A7002ad67cb5a9C1761210C2Cdd98BFa // MPO\n );\n }\n}\n" + }, + "contracts/test/AnyLiquidationTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { IonicLiquidator, ILiquidator } from \"../IonicLiquidator.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { CurveLpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { ICurvePool } from \"../external/curve/ICurvePool.sol\";\nimport { IFundsConversionStrategy } from \"../liquidators/IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { IUniswapV2Router02 } from \"../external/uniswap/IUniswapV2Router02.sol\";\nimport { IUniswapV2Pair } from \"../external/uniswap/IUniswapV2Pair.sol\";\nimport { IUniswapV2Factory } from \"../external/uniswap/IUniswapV2Factory.sol\";\n\ncontract AnyLiquidationTest is BaseTest {\n IonicLiquidator fsl;\n address uniswapRouter;\n mapping(address => address) assetSpecificRouters;\n\n IFundsConversionStrategy[] fundingStrategies;\n bytes[] fundingDatas;\n\n IRedemptionStrategy[] redemptionStrategies;\n bytes[] redemptionDatas;\n\n IUniswapV2Pair mostLiquidPair1;\n IUniswapV2Pair mostLiquidPair2;\n\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle;\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle;\n\n function upgradeAp() internal {\n AddressesProvider newImpl = new AddressesProvider();\n newImpl.initialize(address(this));\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ap)));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uniswapRouter = ap.getAddress(\"IUniswapV2Router02\");\n curveV1Oracle = CurveLpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveLpTokenPriceOracleNoRegistry\"));\n curveV2Oracle = CurveV2LpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveV2LpTokenPriceOracleNoRegistry\"));\n\n if (block.chainid == BSC_MAINNET) {\n mostLiquidPair1 = IUniswapV2Pair(0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16); // WBNB-BUSD\n mostLiquidPair2 = IUniswapV2Pair(0x61EB789d75A95CAa3fF50ed7E47b96c132fEc082); // WBNB-BTCB\n fsl = IonicLiquidator(payable(ap.getAddress(\"IonicLiquidator\")));\n // fsl = new IonicLiquidator();\n // fsl.initialize(\n // ap.getAddress(\"wtoken\"),\n // uniswapRouter,\n // ap.getAddress(\"stableToken\"),\n // ap.getAddress(\"wBTCToken\"),\n // \"0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5\",\n // 25\n // );\n\n // TODO configure in the AP?\n address bnbx = 0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275;\n address apeSwapRouter = 0xcF0feBd3f17CEf5b47b0cD257aCf6025c5BFf3b7;\n assetSpecificRouters[bnbx] = apeSwapRouter;\n } else if (block.chainid == POLYGON_MAINNET) {\n mostLiquidPair1 = IUniswapV2Pair(0x6e7a5FAFcec6BB1e78bAE2A1F0B612012BF14827); // USDC/WMATIC\n mostLiquidPair2 = IUniswapV2Pair(0x369582d2010B6eD950B571F4101e3bB9b554876F); // SAND/WMATIC\n fsl = IonicLiquidator(payable(ap.getAddress(\"IonicLiquidator\")));\n // fsl = new IonicLiquidator();\n // fsl.initialize(\n // ap.getAddress(\"wtoken\"),\n // uniswapRouter,\n // ap.getAddress(\"stableToken\"),\n // ap.getAddress(\"wBTCToken\"),\n // \"0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\",\n // 30\n // );\n }\n }\n\n function testSpecificRandom() public debuggingOnly {\n testPolygonAnyLiquidation(14341);\n // testPolygonAnyLiquidation(101);\n }\n\n function testBscAnyLiquidation(uint256 random) public fork(BSC_MAINNET) {\n vm.assume(random > 100 && random < type(uint64).max);\n doTestAnyLiquidation(random);\n }\n\n function testPolygonAnyLiquidation(uint256 random) public fork(POLYGON_MAINNET) {\n vm.assume(random > 100 && random < type(uint64).max);\n doTestAnyLiquidation(random);\n }\n\n struct LiquidationData {\n IRedemptionStrategy[] strategies;\n bytes[] redemptionDatas;\n ICErc20[] markets;\n address[] borrowers;\n IonicLiquidator liquidator;\n IFundsConversionStrategy[] fundingStrategies;\n bytes[] fundingDatas;\n ICErc20 debtMarket;\n ICErc20 collateralMarket;\n IonicComptroller comptroller;\n address borrower;\n uint256 repayAmount;\n address flashSwapFundingToken;\n IUniswapV2Pair flashSwapPair;\n }\n\n function getPoolAndBorrower(uint256 random, PoolDirectory.Pool[] memory pools)\n internal\n view\n returns (IonicComptroller, address)\n {\n if (pools.length == 0) revert(\"no pools to pick from\");\n\n uint256 i = random % pools.length; // random pool\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n address bscBombPool = 0x5373C052Df65b317e48D6CAD8Bb8AC50995e9459;\n if (address(comptroller) == bscBombPool) {\n // we don't want to deal with the bomb liquidations\n return (IonicComptroller(address(0)), address(0));\n }\n\n address[] memory borrowers = comptroller.getAllBorrowers();\n\n if (borrowers.length == 0) {\n return (IonicComptroller(address(0)), address(0));\n } else {\n uint256 k = random % borrowers.length; // random borrower\n address borrower = borrowers[k];\n\n return (comptroller, borrower);\n }\n }\n\n function setUpDebtAndCollateralMarkets(uint256 random, LiquidationData memory vars)\n internal\n returns (\n ICErc20 debtMarket,\n ICErc20 collateralMarket,\n uint256 borrowAmount\n )\n {\n // find a debt market in which the borrower has borrowed\n for (uint256 m = 0; m < vars.markets.length; m++) {\n uint256 marketIndexWithOffset = (random + m) % vars.markets.length;\n ICErc20 randomMarket = vars.markets[marketIndexWithOffset];\n borrowAmount = randomMarket.borrowBalanceCurrent(vars.borrower);\n if (borrowAmount > 0) {\n debtMarket = ICErc20(address(randomMarket));\n break;\n }\n }\n\n if (address(debtMarket) != address(0)) {\n emit log(\"debt market is\");\n emit log_address(address(debtMarket));\n\n uint256 shortfall = 0;\n // reduce the price of the collateral for each market where the borrower has supplied\n // until there is shortfall for which to be liquidated\n for (uint256 m = 0; m < vars.markets.length; m++) {\n uint256 marketIndexWithOffset = (random - m) % vars.markets.length;\n ICErc20 randomMarket = vars.markets[marketIndexWithOffset];\n uint256 borrowerCollateral = randomMarket.balanceOf(vars.borrower);\n if (borrowerCollateral > 0) {\n if (address(randomMarket) == address(debtMarket)) continue;\n\n // the collateral prices change\n BasePriceOracle mpo = vars.comptroller.oracle();\n uint256 priceCollateral = mpo.getUnderlyingPrice(randomMarket);\n vm.mockCall(\n address(mpo),\n abi.encodeWithSelector(mpo.getUnderlyingPrice.selector, randomMarket),\n abi.encode(priceCollateral / 5)\n );\n\n uint256 collateralValue = borrowerCollateral * (priceCollateral / 5);\n uint256 borrowValue = borrowAmount * mpo.getUnderlyingPrice(debtMarket);\n\n if (collateralValue < borrowValue) {\n emit log(\"collateral position too small\");\n continue;\n }\n\n (, , , shortfall) = vars.comptroller.getAccountLiquidity(vars.borrower);\n if (shortfall == 0) {\n emit log(\"collateral still enough\");\n continue;\n } else {\n emit log(\"has shortfall\");\n collateralMarket = ICErc20(address(randomMarket));\n break;\n }\n }\n }\n if (shortfall == 0) {\n return (ICErc20(address(0)), ICErc20(address(0)), 0);\n }\n }\n }\n\n function doTestAnyLiquidation(uint256 random) internal {\n LiquidationData memory vars;\n vars.liquidator = fsl;\n\n (, PoolDirectory.Pool[] memory pools) = PoolDirectory(ap.getAddress(\"PoolDirectory\")).getActivePools();\n\n uint256 initRandom = random;\n while (true) {\n // get a random pool and a random borrower from it\n (vars.comptroller, vars.borrower) = getPoolAndBorrower(random, pools);\n\n if (address(vars.comptroller) != address(0) && vars.borrower != address(0)) {\n // find a market in which the borrower has debt and reduce his collateral price\n vars.markets = vars.comptroller.getAllMarkets();\n (vars.debtMarket, vars.collateralMarket, vars.repayAmount) = setUpDebtAndCollateralMarkets(random, vars);\n\n if (address(vars.debtMarket) != address(0) && address(vars.collateralMarket) != address(0)) {\n if (vars.debtMarket.underlying() != ap.getAddress(\"wtoken\")) {\n emit log(\"found testable markets at random number\");\n emit log_uint(random);\n break;\n }\n }\n }\n // fail gracefully when there are no positions to liquidate\n if (random - initRandom < 100) return;\n random++;\n }\n\n vars.repayAmount = vars.repayAmount / 100;\n liquidateSpecificPosition(vars);\n }\n\n function liquidateSpecificPosition(LiquidationData memory vars) internal {\n emit log(\"debt and collateral markets\");\n emit log_address(address(vars.debtMarket));\n emit log_address(address(vars.collateralMarket));\n\n // prepare the liquidation\n\n // add funding strategies\n {\n address debtTokenToFund = vars.debtMarket.underlying();\n uint256 i = 0;\n while (true) {\n emit log(\"funding token\");\n emit log_address(debtTokenToFund);\n if (i++ > 10) revert(\"endless loop bad\");\n\n AddressesProvider.FundingStrategy memory strategy = ap.getFundingStrategy(debtTokenToFund);\n if (strategy.addr == address(0)) break;\n\n debtTokenToFund = addFundingStrategy(\n vars,\n IFundsConversionStrategy(strategy.addr),\n debtTokenToFund,\n strategy.contractInterface,\n strategy.inputToken\n );\n }\n\n vars.flashSwapFundingToken = debtTokenToFund;\n if (vars.flashSwapFundingToken != ap.getAddress(\"wtoken\")) {\n IUniswapV2Router02 router = IUniswapV2Router02(uniswapRouter);\n address pairAddress = IUniswapV2Factory(router.factory()).getPair(\n vars.flashSwapFundingToken,\n ap.getAddress(\"wtoken\")\n );\n if (pairAddress != address(0)) {\n vars.flashSwapPair = IUniswapV2Pair(pairAddress);\n } else {\n revert(\"no pair for flash swap funding\");\n }\n } else {\n vars.flashSwapPair = IUniswapV2Pair(mostLiquidPair1);\n }\n\n vars.fundingStrategies = fundingStrategies;\n vars.fundingDatas = fundingDatas;\n }\n\n emit log(\"flash swap funding token is\");\n emit log_address(vars.flashSwapFundingToken);\n\n address exchangeCollateralTo = vars.flashSwapFundingToken;\n\n // add the redemption strategies\n if (exchangeCollateralTo != address(0)) {\n address collateralTokenToRedeem = vars.collateralMarket.underlying();\n while (collateralTokenToRedeem != exchangeCollateralTo) {\n // TODO\n AddressesProvider.RedemptionStrategy memory strategy = ap.getRedemptionStrategy(collateralTokenToRedeem);\n if (strategy.addr == address(0)) break;\n collateralTokenToRedeem = addRedemptionStrategy(\n vars,\n IRedemptionStrategy(strategy.addr),\n strategy.contractInterface,\n collateralTokenToRedeem,\n strategy.outputToken\n );\n }\n vars.redemptionDatas = redemptionDatas;\n vars.strategies = redemptionStrategies;\n }\n\n // liquidate\n vm.prank(ap.owner());\n try\n vars.liquidator.safeLiquidateToTokensWithFlashLoan(\n ILiquidator.LiquidateToTokensWithFlashSwapVars(\n vars.borrower,\n vars.repayAmount,\n ICErc20(address(vars.debtMarket)),\n ICErc20(address(vars.collateralMarket)),\n address(vars.flashSwapPair),\n 0,\n vars.strategies,\n vars.redemptionDatas,\n vars.fundingStrategies,\n vars.fundingDatas\n )\n )\n {\n // noop\n } catch Error(string memory reason) {\n if (compareStrings(reason, \"Number of tokens less than minimum limit\")) {\n emit log(\"jarvis pool failing, that's ok\");\n } else {\n revert(reason);\n }\n }\n }\n\n function getUniswapV2Router(address inputToken) internal view returns (address) {\n address router = assetSpecificRouters[inputToken];\n return router != address(0) ? router : uniswapRouter;\n }\n\n function toggleFlashSwapPair(LiquidationData memory vars) internal view {\n if (address(vars.flashSwapPair) == address(mostLiquidPair1)) {\n vars.flashSwapPair = mostLiquidPair2;\n } else {\n vars.flashSwapPair = mostLiquidPair1;\n }\n }\n\n function addRedemptionStrategy(\n LiquidationData memory vars,\n IRedemptionStrategy strategy,\n string memory strategyContract,\n address inputToken,\n address strategyOutputToken\n ) internal returns (address) {\n address outputToken;\n bytes memory strategyData;\n\n if (compareStrings(strategyContract, \"CurveLpTokenLiquidatorNoRegistry\")) {\n address[] memory underlyingTokens = curveV1Oracle.getUnderlyingTokens(inputToken);\n (address preferredOutputToken, uint8 outputTokenIndex) = pickPreferredToken(\n underlyingTokens,\n strategyOutputToken\n );\n emit log(\"preferred token\");\n emit log_address(preferredOutputToken);\n emit log_uint(outputTokenIndex);\n outputToken = preferredOutputToken;\n if (outputToken == address(0) || outputToken == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n outputToken = ap.getAddress(\"wtoken\");\n }\n\n strategyData = abi.encode(preferredOutputToken, ap.getAddress(\"wtoken\"), address(curveV1Oracle));\n } else if (compareStrings(strategyContract, \"SaddleLpTokenLiquidator\")) {\n address[] memory underlyingTokens = curveV1Oracle.getUnderlyingTokens(inputToken);\n (address preferredOutputToken, ) = pickPreferredToken(underlyingTokens, strategyOutputToken);\n outputToken = preferredOutputToken;\n if (outputToken == address(0) || outputToken == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n outputToken = ap.getAddress(\"wtoken\");\n }\n strategyData = abi.encode(preferredOutputToken, curveV1Oracle, ap.getAddress(\"wtoken\"));\n } else if (\n compareStrings(strategyContract, \"UniswapLpTokenLiquidator\") ||\n compareStrings(strategyContract, \"GelatoGUniLiquidator\")\n ) {\n IUniswapV2Pair pair = IUniswapV2Pair(inputToken);\n address[] memory swapToken0Path;\n address[] memory swapToken1Path;\n\n if (pair.token0() == strategyOutputToken) {\n swapToken0Path = new address[](0);\n swapToken1Path = new address[](2);\n\n swapToken1Path[0] = pair.token1();\n swapToken1Path[1] = pair.token0();\n outputToken = swapToken1Path[1];\n } else {\n swapToken0Path = new address[](2);\n swapToken1Path = new address[](0);\n\n swapToken0Path[0] = pair.token0();\n swapToken0Path[1] = pair.token1();\n outputToken = swapToken0Path[1];\n }\n\n strategyData = abi.encode(uniswapRouter, swapToken0Path, swapToken1Path);\n\n if (address(vars.flashSwapPair) == address(pair)) {\n emit log(\"toggling the flashswap pair\");\n emit log_address(address(pair));\n toggleFlashSwapPair(vars);\n }\n } else if (compareStrings(strategyContract, \"UniswapV2LiquidatorFunder\")) {\n outputToken = strategyOutputToken;\n\n address[] memory swapPath = new address[](2);\n swapPath[0] = inputToken;\n swapPath[1] = outputToken;\n\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\n } else if (compareStrings(strategyContract, \"JarvisLiquidatorFunder\")) {\n AddressesProvider.JarvisPool[] memory pools = ap.getJarvisPools();\n for (uint256 i = 0; i < pools.length; i++) {\n AddressesProvider.JarvisPool memory pool = pools[i];\n if (pool.syntheticToken == inputToken) {\n strategyData = abi.encode(pool.syntheticToken, pool.liquidityPool, pool.expirationTime);\n outputToken = pool.collateralToken;\n break;\n }\n }\n } else if (compareStrings(strategyContract, \"CurveSwapLiquidator\")) {\n outputToken = strategyOutputToken;\n strategyData = abi.encode(curveV1Oracle, curveV2Oracle, inputToken, outputToken, ap.getAddress(\"wtoken\"));\n } else if (compareStrings(strategyContract, \"BalancerLpTokenLiquidator\")) {\n outputToken = strategyOutputToken;\n strategyData = abi.encode(outputToken);\n } else if (compareStrings(strategyContract, \"XBombLiquidatorFunder\")) {\n outputToken = strategyOutputToken;\n address xbomb = inputToken;\n address bomb = outputToken;\n strategyData = abi.encode(inputToken, xbomb, bomb);\n } else if (compareStrings(strategyContract, \"AlgebraSwapLiquidator\")) {\n address ALGEBRA_SWAP_ROUTER = 0x327Dd3208f0bCF590A66110aCB6e5e6941A4EfA0;\n outputToken = strategyOutputToken;\n strategyData = abi.encode(outputToken, ALGEBRA_SWAP_ROUTER);\n } else {\n emit log(strategyContract);\n emit log_address(address(strategy));\n revert(\"unknown collateral\");\n }\n\n vm.prank(vars.liquidator.owner());\n vars.liquidator._whitelistRedemptionStrategy(strategy, true);\n redemptionStrategies.push(strategy);\n redemptionDatas.push(strategyData);\n\n assertEq(outputToken, strategyOutputToken, \"!expected output token\");\n return outputToken;\n }\n\n // function getCurvePoolUnderlyingTokens(address lpTokenAddress) internal view returns (address[] memory) {\n // ICurvePool curvePool = ICurvePool(lpTokenAddress);\n // uint8 i = 0;\n // while (true) {\n // try curvePool.coins(i) {\n // i++;\n // } catch {\n // break;\n // }\n // }\n // address[] memory tokens = new address[](i);\n // for (uint8 j = 0; j < i; j++) {\n // tokens[j] = curvePool.coins(j);\n // }\n // return tokens;\n // }\n\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken)\n internal\n view\n returns (address, uint8)\n {\n address wtoken = ap.getAddress(\"wtoken\");\n address stable = ap.getAddress(\"stableToken\");\n address wbtc = ap.getAddress(\"wBTCToken\");\n\n for (uint8 i = 0; i < tokens.length; i++) {\n if (tokens[i] == strategyOutputToken) return (strategyOutputToken, i);\n }\n for (uint8 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wtoken) return (wtoken, i);\n }\n for (uint8 i = 0; i < tokens.length; i++) {\n if (tokens[i] == stable) return (stable, i);\n }\n for (uint8 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wbtc) return (wbtc, i);\n }\n return (tokens[0], 0);\n }\n\n function addFundingStrategy(\n LiquidationData memory vars,\n IFundsConversionStrategy strategy,\n address debtToken,\n string memory strategyContract,\n address strategyInputToken\n ) internal returns (address) {\n address inputToken;\n bytes memory strategyData;\n\n if (compareStrings(strategyContract, \"JarvisLiquidatorFunder\")) {\n AddressesProvider.JarvisPool[] memory pools = ap.getJarvisPools();\n for (uint256 i = 0; i < pools.length; i++) {\n AddressesProvider.JarvisPool memory pool = pools[i];\n if (pool.syntheticToken == debtToken) {\n strategyData = abi.encode(pool.collateralToken, pool.liquidityPool, pool.expirationTime);\n inputToken = pool.collateralToken;\n break;\n }\n }\n\n // } else if (compareStrings(strategyContract, \"SomeOtherFunder\")) {\n // bytes memory strategyData = abi.encode(strategySpecificParams);\n // (IERC20Upgradeable inputToken, uint256 inputAmount) = IFundsConversionStrategy(addr).estimateInputAmount(10**(debtToken.decimals()), strategyData);\n // fundingStrategies.push(new SomeOtherFunder());\n // return inputToken;\n } else if (compareStrings(strategyContract, \"CurveSwapLiquidatorFunder\")) {\n inputToken = strategyInputToken;\n strategyData = abi.encode(curveV1Oracle, curveV2Oracle, inputToken, debtToken, ap.getAddress(\"wtoken\"));\n } else if (compareStrings(strategyContract, \"UniswapV3LiquidatorFunder\")) {\n inputToken = strategyInputToken;\n\n uint24 fee = 1000;\n address quoter = ap.getAddress(\"Quoter\");\n address swapRouter;\n {\n // TODO\n // polygon config // 0x1F98431c8aD98523631AE4a59f267346ea31F984\n address polygonSwapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n\n swapRouter = polygonSwapRouter;\n fee = 500;\n }\n\n strategyData = abi.encode(inputToken, debtToken, fee, swapRouter, quoter);\n } else {\n emit log(strategyContract);\n emit log_address(debtToken);\n revert(\"unknown debt token\");\n }\n\n fundingDatas.push(strategyData);\n\n vm.prank(vars.liquidator.owner());\n vars.liquidator._whitelistRedemptionStrategy(strategy, true);\n fundingStrategies.push(strategy);\n\n assertEq(strategyInputToken, inputToken, \"!expected input token\");\n return inputToken;\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testRawLiquidation() public debuggingOnly fork(MODE_MAINNET) {\n vm.prank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n _functionCall(\n 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A,\n hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000fda4ac09a12c10fae30e429f4d6b47c9a83c87e00000000000000000000000000000000000000000000000001797af2fe6e167700000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005ca3fd2c285c4138185ef1bda7573d415020f3c80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n \"raw liquidation failed\"\n );\n }\n}\n" + }, + "contracts/test/AuthoritiesRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport \"../ionic/AuthoritiesRegistry.sol\";\nimport \"./helpers/WithPool.sol\";\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\ncontract AuthoritiesRegistryTest is WithPool {\n AuthoritiesRegistry registry;\n\n function afterForkSetUp() internal override {\n registry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n if (address(registry) == address(0)) {\n address proxyAdmin = address(999);\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), proxyAdmin, \"\");\n registry = AuthoritiesRegistry(address(proxy));\n registry.initialize(address(1023));\n }\n\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n setUpPool(\"auth-reg-test\", false, 0.1e18, 1.1e18);\n }\n\n function testRegistry() public fork(POLYGON_MAINNET) {\n PoolRolesAuthority auth;\n\n vm.prank(address(555));\n vm.expectRevert(\"Ownable: caller is not the owner\");\n auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n auth = registry.createPoolAuthority(address(comptroller));\n\n assertEq(auth.owner(), registry.owner(), \"!same owner\");\n }\n\n function testAuthReconfigurePermissions() public fork(POLYGON_MAINNET) {\n vm.prank(registry.owner());\n PoolRolesAuthority auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(address(8283));\n vm.expectRevert(\"not owner or pool\");\n registry.reconfigureAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n registry.reconfigureAuthority(address(comptroller));\n }\n\n function upgradeRegistry() internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(registry)));\n AuthoritiesRegistry newImpl = new AuthoritiesRegistry();\n vm.startPrank(dpa.owner());\n dpa.upgradeAndCall(\n proxy,\n address(newImpl),\n abi.encodeWithSelector(AuthoritiesRegistry.reinitialize.selector, registry.leveredPositionsFactory())\n );\n vm.stopPrank();\n }\n\n function upgradeAuth(PoolRolesAuthority auth) internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n PoolRolesAuthority newImpl = new PoolRolesAuthority();\n vm.prank(dpa.owner());\n dpa.upgrade(proxy, address(newImpl));\n }\n\n function testAuthPermissions() public debuggingOnly fork(BSC_CHAPEL) {\n address pool = 0xa4bc2fCF2F9d87EB349f74f8729024F92A030330;\n registry = AuthoritiesRegistry(0xa5E190Fa38F325617381e835da8b2DB2D12cE5eb);\n //upgradeRegistry();\n\n PoolRolesAuthority auth = PoolRolesAuthority(0xFe5AfFFC8b55A2d139cb2ef76699C8B58c1EA299);\n //upgradeAuth(auth);\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n\n vm.prank(address(dpa));\n emit log_named_address(\"proxy.implementation\", proxy.implementation());\n\n emit log_named_address(\"registry.poolAuthLogic\", address(registry.poolAuthLogic()));\n //vm.prank(registry.owner());\n //registry.reconfigureAuthority(pool);\n\n bool isReg = auth.doesUserHaveRole(address(registry), auth.REGISTRY_ROLE());\n assertEq(isReg, true, \"!not registry role\");\n\n bool canCall = auth.canCall(address(registry), address(auth), RolesAuthority.setUserRole.selector);\n assertEq(canCall, true, \"!cannot call setUserRol\");\n }\n}\n" + }, + "contracts/test/caps/AdrastiaPrudentiaCapsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { ComptrollerPrudentiaCapsExt, DiamondExtension } from \"../../compound/ComptrollerPrudentiaCapsExt.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { ComptrollerV4Storage } from \"../../compound/ComptrollerStorage.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\nimport { PrudentiaLib } from \"../../adrastia/PrudentiaLib.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MockPriceOracle } from \"../../oracles/1337/MockPriceOracle.sol\";\n\nimport \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\nabstract contract HistoricalRates is IHistoricalRates {\n struct BufferMetadata {\n uint8 start;\n uint8 end;\n uint8 size;\n uint8 maxSize;\n bool pauseUpdates; // Note: this is left for extentions, but is not used in this contract.\n }\n\n /// @notice Event emitted when a rate buffer's capacity is increased past the initial capacity.\n /// @dev Buffer initialization does not emit an event.\n /// @param token The token for which the rate buffer's capacity was increased.\n /// @param oldCapacity The previous capacity of the rate buffer.\n /// @param newCapacity The new capacity of the rate buffer.\n event RatesCapacityIncreased(address indexed token, uint256 oldCapacity, uint256 newCapacity);\n\n /// @notice Event emitted when a rate buffer's capacity is initialized.\n /// @param token The token for which the rate buffer's capacity was initialized.\n /// @param capacity The capacity of the rate buffer.\n event RatesCapacityInitialized(address indexed token, uint256 capacity);\n\n /// @notice Event emitted when a new rate is pushed to the rate buffer.\n /// @param token The token for which the rate was pushed.\n /// @param target The target rate.\n /// @param current The current rate, which may be different from the target rate if the rate change is capped.\n /// @param timestamp The timestamp at which the rate was pushed.\n event RateUpdated(address indexed token, uint256 target, uint256 current, uint256 timestamp);\n\n /// @notice An error that is thrown if we try to initialize a rate buffer that has already been initialized.\n /// @param token The token for which we tried to initialize the rate buffer.\n error BufferAlreadyInitialized(address token);\n\n /// @notice An error that is thrown if we try to retrieve a rate at an invalid index.\n /// @param token The token for which we tried to retrieve the rate.\n /// @param index The index of the rate that we tried to retrieve.\n /// @param size The size of the rate buffer.\n error InvalidIndex(address token, uint256 index, uint256 size);\n\n /// @notice An error that is thrown if we try to decrease the capacity of a rate buffer.\n /// @param token The token for which we tried to decrease the capacity of the rate buffer.\n /// @param amount The capacity that we tried to decrease the rate buffer to.\n /// @param currentCapacity The current capacity of the rate buffer.\n error CapacityCannotBeDecreased(address token, uint256 amount, uint256 currentCapacity);\n\n /// @notice An error that is thrown if we try to increase the capacity of a rate buffer past the maximum capacity.\n /// @param token The token for which we tried to increase the capacity of the rate buffer.\n /// @param amount The capacity that we tried to increase the rate buffer to.\n /// @param maxCapacity The maximum capacity of the rate buffer.\n error CapacityTooLarge(address token, uint256 amount, uint256 maxCapacity);\n\n /// @notice An error that is thrown if we try to retrieve more rates than are available in the rate buffer.\n /// @param token The token for which we tried to retrieve the rates.\n /// @param size The size of the rate buffer.\n /// @param minSizeRequired The minimum size of the rate buffer that we require.\n error InsufficientData(address token, uint256 size, uint256 minSizeRequired);\n\n /// @notice The initial capacity of the rate buffer.\n uint8 internal immutable initialBufferCardinality;\n\n /// @notice Maps a token to its metadata.\n mapping(address => BufferMetadata) internal rateBufferMetadata;\n\n /// @notice Maps a token to a buffer of rates.\n mapping(address => RateLibrary.Rate[]) internal rateBuffers;\n\n /**\n * @notice Constructs the HistoricalRates contract with a specified initial buffer capacity.\n * @param initialBufferCardinality_ The initial capacity of the rate buffer.\n */\n constructor(uint8 initialBufferCardinality_) {\n initialBufferCardinality = initialBufferCardinality_;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRateAt(address token, uint256 index) external view virtual override returns (RateLibrary.Rate memory) {\n BufferMetadata memory meta = rateBufferMetadata[token];\n\n if (index >= meta.size) {\n revert InvalidIndex(token, index, meta.size);\n }\n\n uint256 bufferIndex = meta.end < index ? meta.end + meta.size - index : meta.end - index;\n\n return rateBuffers[token][bufferIndex];\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(address token, uint256 amount) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, 0, 1);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, offset, increment);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCount(address token) external view override returns (uint256) {\n return rateBufferMetadata[token].size;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCapacity(address token) external view virtual override returns (uint256) {\n uint256 maxSize = rateBufferMetadata[token].maxSize;\n if (maxSize == 0) return initialBufferCardinality;\n\n return maxSize;\n }\n\n /// @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n /// less than 256.\n /// @inheritdoc IHistoricalRates\n function setRatesCapacity(address token, uint256 amount) external virtual {\n _setRatesCapacity(token, amount);\n }\n\n /**\n * @dev Internal function to set the capacity of the rate buffer for a token.\n * @param token The token for which to set the new capacity.\n * @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n * less than 256.\n */\n function _setRatesCapacity(address token, uint256 amount) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (amount < meta.maxSize) revert CapacityCannotBeDecreased(token, amount, meta.maxSize);\n if (amount > type(uint8).max) revert CapacityTooLarge(token, amount, type(uint8).max);\n\n RateLibrary.Rate[] storage rateBuffer = rateBuffers[token];\n\n // Add new slots to the buffer\n uint256 capacityToAdd = amount - meta.maxSize;\n for (uint256 i = 0; i < capacityToAdd; ++i) {\n // Push a dummy rate with non-zero values to put most of the gas cost on the caller\n rateBuffer.push(RateLibrary.Rate({ target: 1, current: 1, timestamp: 1 }));\n }\n\n if (meta.maxSize != amount) {\n emit RatesCapacityIncreased(token, meta.maxSize, amount);\n\n // Update the metadata\n meta.maxSize = uint8(amount);\n }\n }\n\n /**\n * @dev Internal function to get historical rates with specified amount, offset, and increment.\n * @param token The token for which to retrieve the rates.\n * @param amount The number of historical rates to retrieve.\n * @param offset The number of rates to skip before starting to collect the rates.\n * @param increment The step size between the rates to collect.\n * @return observations An array of Rate structs containing the retrieved historical rates.\n */\n function _getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) internal view virtual returns (RateLibrary.Rate[] memory) {\n if (amount == 0) return new RateLibrary.Rate[](0);\n\n BufferMetadata memory meta = rateBufferMetadata[token];\n if (meta.size <= (amount - 1) * increment + offset)\n revert InsufficientData(token, meta.size, (amount - 1) * increment + offset + 1);\n\n RateLibrary.Rate[] memory observations = new RateLibrary.Rate[](amount);\n\n uint256 count = 0;\n\n for (\n uint256 i = meta.end < offset ? meta.end + meta.size - offset : meta.end - offset;\n count < amount;\n i = (i < increment) ? (i + meta.size) - increment : i - increment\n ) {\n observations[count++] = rateBuffers[token][i];\n }\n\n return observations;\n }\n\n /**\n * @dev Internal function to initialize rate buffers for a token.\n * @param token The token for which to initialize the rate buffer.\n */\n function initializeBuffers(address token) internal virtual {\n if (rateBuffers[token].length != 0) {\n revert BufferAlreadyInitialized(token);\n }\n\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n // Initialize the buffers\n RateLibrary.Rate[] storage observationBuffer = rateBuffers[token];\n\n for (uint256 i = 0; i < initialBufferCardinality; ++i) {\n observationBuffer.push();\n }\n\n // Initialize the metadata\n meta.start = 0;\n meta.end = 0;\n meta.size = 0;\n meta.maxSize = initialBufferCardinality;\n meta.pauseUpdates = false;\n\n emit RatesCapacityInitialized(token, meta.maxSize);\n }\n\n /**\n * @dev Internal function to push a new rate data into the rate buffer and update metadata accordingly.\n * @param token The token for which to push the new rate data.\n * @param rate The Rate struct containing target rate, current rate, and timestamp data to be pushed.\n */\n function push(address token, RateLibrary.Rate memory rate) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (meta.size == 0) {\n if (meta.maxSize == 0) {\n // Initialize the buffers\n initializeBuffers(token);\n }\n } else {\n meta.end = (meta.end + 1) % meta.maxSize;\n }\n\n rateBuffers[token][meta.end] = rate;\n\n emit RateUpdated(token, rate.target, rate.current, block.timestamp);\n\n if (meta.size < meta.maxSize && meta.end == meta.size) {\n // We are at the end of the array and we have not yet filled it\n meta.size++;\n } else {\n // start was just overwritten\n meta.start = (meta.start + 1) % meta.size;\n }\n }\n}\n\ncontract PrudentiaStub is HistoricalRates {\n constructor() HistoricalRates(2) {}\n\n function stubPush(address underlyingToken, uint64 rate) public {\n push(underlyingToken, RateLibrary.Rate({ target: rate, current: rate, timestamp: uint32(block.timestamp) }));\n }\n}\n\ncontract AdrastiaPrudentiaCapsTest is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicComptroller comptroller;\n\n InterestRateModel interestModel;\n MockPriceOracle priceOracle;\n\n MockERC20 underlyingToken1;\n ICErc20 cToken1;\n\n MockERC20 underlyingToken2;\n ICErc20 cToken2;\n\n MockERC20 underlyingToken3;\n ICErc20 cToken3;\n\n CErc20Delegate cErc20Delegate;\n\n PrudentiaStub prudentia;\n\n function setUp() public {\n // Deploy admin contracts\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n // Deploy comptroller logic\n Comptroller comptrollerLogic = new Comptroller();\n\n // Deploy underlying tokens\n underlyingToken1 = new MockERC20(\"UnderlyingToken1\", \"UT1\", 18);\n underlyingToken1.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken2 = new MockERC20(\"UnderlyingToken2\", \"UT2\", 18);\n underlyingToken2.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken3 = new MockERC20(\"UnderlyingToken3\", \"UT3\", 6);\n underlyingToken3.mint(address(this), 1000000e6); // 1M tokens\n\n // Deploy cToken delegates\n cErc20Delegate = new CErc20Delegate();\n\n // Deploy price oracle\n priceOracle = new MockPriceOracle(10);\n\n // Deploy IRM\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n\n // Deploy comptroller\n address[] memory unitroller = new address[](1);\n unitroller[0] = address(comptrollerLogic);\n address[] memory addressZero = new address[](1);\n addressZero[0] = address(0);\n bool[] memory boolTrue = new bool[](1);\n boolTrue[0] = true;\n bool[] memory boolFalse = new bool[](1);\n boolFalse[0] = false;\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(comptrollerLogic));\n DiamondExtension[] memory extensions = new DiamondExtension[](3);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = new ComptrollerPrudentiaCapsExt();\n extensions[2] = comptrollerLogic;\n ionicAdmin._setComptrollerExtensions(address(comptrollerLogic), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\", // name\n address(comptrollerLogic), // implementation address\n abi.encode(payable(address(ionicAdmin))), // constructor args\n false, // whitelist enforcement\n 0.1e18, // close factor = 10%\n 1.1e18, // liquidation incentive = 110%\n address(priceOracle) // price oracle\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n\n // Setup CErc20Delegate whitelist\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](1);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n address[] memory oldCErc20Implementations = new address[](1);\n oldCErc20Implementations[0] = address(0);\n address[] memory newCErc20Implementations = new address[](1);\n newCErc20Implementations[0] = address(cErc20Delegate);\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n // Deploy cToken1\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken1), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 1\", // cToken name\n \"CT1\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken2\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken2), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 2\", // cToken name\n \"CT2\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken3\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken3), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 3\", // cToken name\n \"CT3\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Store the cToken addresses\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n assertEq(allMarkets.length, 3);\n cToken1 = allMarkets[0];\n cToken2 = allMarkets[1];\n cToken3 = allMarkets[2];\n\n // Deploy Prudentia\n prudentia = new PrudentiaStub();\n }\n\n function test_NativeCaps_UnrestrictedSupply() public {\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), 0); // No supply cap set (unrestricted)\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n }\n\n function test_NativeCaps_RestrictedSupply() public {\n uint256 cap = 9999e18; // supply cap of 9,999\n uint256 mintAmount = 10000e18; // mint of 10,000\n\n // Set a native supply cap for cToken1\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = cap;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cTokens[0])), supplyCaps[0]);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_NativeCaps_UnrestrictedBorrow() public {\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // No borrow cap set (unrestricted)\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n cToken2.borrow(1000e18); // Borrow 1,000 cToken2\n }\n\n function test_NativeCaps_RestrictedBorrow() public {\n uint256 cap = 999e18; // borrow cap of 999\n uint256 borrowAmount = 1000e18; // borrow of 1,000\n\n // Set a native borrow cap for cToken2\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = cap;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cTokens[0])), borrowCaps[0]);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0\n */\n\n function test_Prudentia_Supply_Unrestricted() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Supply cap\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken2\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted supply cap for cToken2\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken2)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken1\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted borrow cap for cToken1\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftPos1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftNeg1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and using a cToken with the underlying token having 6 decimals\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // Unrestricted cap at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_Offset1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_Offset1() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n Additional ComptrollerPrudentiaCapsExt tests\n */\n\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n function test_Prudentia_SupplyCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewSupplyCapConfig(oldConfig, newConfig);\n\n // Set supply cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n\n // Get the supply cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getSupplyCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_BorrowCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewBorrowCapConfig(oldConfig, newConfig);\n\n // Set borrow cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n\n // Get the borrow cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getBorrowCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_SetSupplyCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n }\n\n function test_Prudentia_SetBorrowCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n }\n}\n" + }, + "contracts/test/CollateralSwapTest.t.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CollateralSwap } from \"../ionic/CollateralSwap.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\n\ncontract CollateralSwapTest is UpgradesBaseTest {\n ICErc20 wethMarket = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3);\n ICErc20 usdcMarket = ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0);\n ICErc20 ezETHMarket = ICErc20(0x079f84161642D81aaFb67966123C9949F9284bf5);\n ICErc20 cbETHMarket = ICErc20(0x9c201024A62466F9157b2dAaDda9326207ADDd29);\n PoolLens lens = PoolLens(0x6ec80f9aCd960b568932696C0F0bE06FBfCd175a);\n CollateralSwap swap;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n _upgradeMarketWithExtension(wethMarket);\n _upgradeMarketWithExtension(ezETHMarket);\n _upgradeMarketWithExtension(cbETHMarket);\n _upgradeMarketWithExtension(usdcMarket);\n swap = new CollateralSwap(0, msg.sender, address(wethMarket.comptroller()), new address[](0));\n emit log_named_address(\"swap address: \", address(swap));\n }\n\n function test_collateralSwap_works_noBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20754244) {\n address ionwethWhale = 0x753E909D68921388b8fB4E471D155ff73c735ebC;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n uint256 healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n bytes memory swapData = abi.encodePacked(\n hex\"5fd9ae2ea41bd686f6e5326450d10ac2dc733b837ae20fb0aaf871e87b4a9227171918ab00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0cb889707d426a7a386870a03bc70d1b0697598000000000000000000000000000000000000000000000000000000001d42cce300000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000005696f6e6963000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000002d02dd2e34e182400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000084eedd56e100000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000b85da6a0970f0000000000000000000000000000000000000000000000000001ccea209179a9000000000000000000000000d5ee82d18f63f0b82df91a6ae73b74cfda57144e000000000000000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000002cda88b1c1c076b00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000000000000000000000000000000000001d42cce3000000000000000000000000000000000000000000000000000000001d68714c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004d69971ccd4a636c403a3c1b00c85e99bb9b5606000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e4200000000000000000000000000000000000006000064b79dd08ea68a908a97220c76d19a6aa9cbde437600002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000000c1a09d5d0445047da3ab4994262b22404288a3b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002eb79dd08ea68a908a97220c76d19a6aa9cbde4376000001833589fcd6edb6e08f4c7c32d4f71b54bda029130000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a0000000000000000000000000000000000000000000000000000000001d68714c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n vm.startPrank(ionwethWhale);\n wethMarket.approve(address(swap), 1e18);\n swap.swapCollateral(1e18, wethMarket, usdcMarket, swapTarget, swapData);\n vm.stopPrank();\n healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n }\n\n function test_collateralSwap_worksWithBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20874971) {\n address ionezEthWhale = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n bytes memory swapData = abi.encodePacked(\n hex\"4666fc80a7f78b3a1e00f74ab91e766714a7b7390c173e43f2f65d7c74bda18ff1e067dd00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000d6bbde9174b1cdaa358d2cf4d57d1a9f7178fbff000000000000000000000000000000000000000000000000003625685b773877000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000000000000000000000000000000039afc19de8c3ba00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000000000000000000000000000003625685b77387700000000000000000000000000000000000000000000000000366b101e2d34e40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004c98e9c2439c0d4621c62fee2fed6d042fa8c57000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e2416092f143378750bb29b79ed961ab195cceea5000064420000000000000000000000000000000000000600000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000257fcbae4ac6b26a02e4fc5e1a11e4174b5ce39500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e42000000000000000000000000000000000000060000642ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a000000000000000000000000000000000000000000000000000366b101e2d34e400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f8654220000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec2200000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f990000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n (uint256 error, uint256 balance, uint256 borrowBalance, uint256 exchangeRateMantissa) = ezETHMarket\n .getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n vm.startPrank(ionezEthWhale);\n ezETHMarket.approve(address(swap), type(uint256).max);\n uint256 healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n swap.swapCollateral(16237319785333690, ezETHMarket, cbETHMarket, swapTarget, swapData);\n healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n vm.stopPrank();\n\n (error, balance, borrowBalance, exchangeRateMantissa) = ezETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n }\n}\n" + }, + "contracts/test/ComptrollerTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract ComptrollerTest is BaseTest {\n IonicComptroller internal comptroller;\n IonicFlywheel internal flywheel;\n address internal nonOwner = address(0x2222);\n\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n function setUp() public {\n {\n Unitroller proxy = new Unitroller(payable(address(this)));\n proxy._registerExtension(new Comptroller(), DiamondExtension(address(0)));\n comptroller = IonicComptroller(address(proxy));\n }\n {\n ERC20 rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, IFlywheelRewards(address(2)), IFlywheelBooster(address(3)), address(this));\n }\n }\n\n function test__setFlywheel() external {\n vm.prank(comptroller.admin());\n comptroller._addRewardsDistributor(address(flywheel));\n assertEq(comptroller.rewardsDistributors(0), address(flywheel));\n }\n\n function test__setFlywheelRevertsIfNonOwner() external {\n vm.startPrank(nonOwner);\n vm.expectRevert(\"!admin\");\n comptroller._addRewardsDistributor(address(flywheel));\n }\n\n function testBscInflationProtection() public debuggingOnly fork(BSC_MAINNET) {\n _testInflationProtection();\n }\n\n function testPolygonInflationProtection() public debuggingOnly fork(POLYGON_MAINNET) {\n _testInflationProtection();\n }\n\n function testModeInflationProtection() public debuggingOnly fork(MODE_MAINNET) {\n _testInflationProtection();\n }\n\n function _testInflationProtection() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n PoolDirectory.Pool[] memory pools = fpd.getAllPools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n uint256 totalSupply = market.totalSupply();\n if (totalSupply > 0) {\n if (totalSupply < 1000) {\n emit log_named_address(\"low ts market\", address(markets[j]));\n emit log_named_uint(\"ts\", totalSupply);\n } else {\n assertEq(\n pool.redeemAllowed(address(markets[j]), address(0), totalSupply - 980),\n uint256(ComptrollerErrorReporter.Error.REJECTION),\n \"low ts not rejected\"\n );\n }\n }\n }\n }\n }\n}\n" + }, + "contracts/test/config/BaseTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\nimport \"forge-std/Test.sol\";\nimport \"forge-std/console.sol\";\n\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\nabstract contract BaseTest is Test {\n uint128 constant ETHEREUM_MAINNET = 1;\n uint128 constant BSC_MAINNET = 56;\n uint128 constant POLYGON_MAINNET = 137;\n uint128 constant ARBITRUM_ONE = 42161;\n\n uint128 constant BSC_CHAPEL = 97;\n uint128 constant NEON_MAINNET = 245022934;\n uint128 constant LINEA_MAINNET = 59144;\n uint128 constant ZKEVM_MAINNET = 1101;\n uint128 constant MODE_MAINNET = 34443;\n uint128 constant BASE_MAINNET = 8453;\n\n // taken from ERC1967Upgrade\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n AddressesProvider public ap;\n ProxyAdmin public dpa;\n\n mapping(uint128 => uint256) private forkIds;\n\n constructor() {\n configureAddressesProvider(0);\n }\n\n uint256 constant CRITICAL = 100;\n uint256 constant NORMAL = 90;\n uint256 constant LOW = 80;\n\n modifier importance(uint256 testImportance) {\n uint256 runLevel = NORMAL;\n\n try vm.envUint(\"TEST_RUN_LEVEL\") returns (uint256 level) {\n runLevel = level;\n } catch {\n emit log(\"failed to get env param TEST_RUN_LEVEL\");\n }\n\n if (testImportance >= runLevel) {\n _;\n } else {\n emit log(\"not running the test\");\n }\n }\n\n modifier debuggingOnly() {\n try vm.envBool(\"LOCAL_FORGE_ENV\") returns (bool run) {\n if (run) _;\n } catch {\n emit log(\"skipping this test in the CI/CD - add LOCAL_FORGE_ENV=true to your .env file to run locally\");\n }\n }\n\n modifier fork(uint128 chainid) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, 0);\n _;\n }\n }\n\n modifier forkAtBlock(uint128 chainid, uint256 blockNumber) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, blockNumber);\n _;\n }\n }\n\n modifier whenForking() {\n try vm.activeFork() returns (uint256) {\n _;\n } catch {}\n }\n\n function shouldRunForChain(uint256 chainid) internal returns (bool) {\n bool run = true;\n try vm.envUint(\"TEST_RUN_CHAINID\") returns (uint256 envChainId) {\n run = envChainId == chainid;\n } catch {\n emit log(\"failed to get env param TEST_RUN_CHAINID\");\n }\n return run;\n }\n\n function _forkAtBlock(uint128 chainid, uint256 blockNumber) internal {\n if (block.chainid != chainid) {\n if (blockNumber != 0) {\n vm.selectFork(getArchiveForkId(chainid));\n vm.rollFork(blockNumber);\n } else {\n vm.selectFork(getForkId(chainid));\n }\n }\n configureAddressesProvider(chainid);\n afterForkSetUp();\n }\n\n function getForkId(uint128 chainid, bool archive) private returns (uint256) {\n return archive ? getForkId(chainid) : getArchiveForkId(chainid);\n }\n\n function getForkId(uint128 chainid) private returns (uint256) {\n if (forkIds[chainid] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc_chapel\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"polygon\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"neon\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"arbitrum\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"ethereum\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"linea\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"zkevm\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"mode\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"base\")) + 100;\n }\n }\n\n return forkIds[chainid] - 100;\n }\n\n function getArchiveForkId(uint128 chainid) private returns (uint256) {\n // store the archive rpc urls in the forkIds mapping at an offset\n uint128 chainidWithOffset = chainid + type(uint64).max;\n if (forkIds[chainidWithOffset] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_archive\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_chapel_archive\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"polygon_archive\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"neon_archive\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"arbitrum_archive\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"ethereum_archive\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"linea_archive\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"zkevm_archive\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"mode_archive\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"base_archive\")) + 100;\n }\n }\n return forkIds[chainidWithOffset] - 100;\n }\n\n function afterForkSetUp() internal virtual {}\n\n function configureAddressesProvider(uint128 chainid) private {\n if (chainid == BSC_MAINNET) {\n ap = AddressesProvider(address(0));\n } else if (chainid == BSC_CHAPEL) {\n ap = AddressesProvider(0x3dc8CE9f581e49B9E5304CF580940ad341F64c3f);\n } else if (block.chainid == POLYGON_MAINNET) {\n ap = AddressesProvider(0xE31baC0B582AA248c0017F87F24087cEa7A55E26);\n } else if (chainid == NEON_MAINNET) {\n ap = AddressesProvider(0xF4C60F6ac6b3AF54044757a1a54D76EEe28244CE);\n } else if (chainid == ARBITRUM_ONE) {\n ap = AddressesProvider(0x3B12BA992259Fb3855C4E1D452a754dCa2E276fC);\n } else if (chainid == LINEA_MAINNET) {\n ap = AddressesProvider(0x914694DA0bED80e74ef1a28029f016119782C0f1);\n } else if (chainid == ZKEVM_MAINNET) {\n ap = AddressesProvider(0x27aA55A3D55959261e119d75256aadAB79aE897C);\n } else if (chainid == MODE_MAINNET) {\n ap = AddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n } else if (chainid == BASE_MAINNET) {\n ap = AddressesProvider(0xcD4D7c8e2bA627684a9B18F7fe88239341D3ba5c);\n } else {\n dpa = new ProxyAdmin();\n AddressesProvider logic = new AddressesProvider();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(logic),\n address(dpa),\n abi.encodeWithSelector(ap.initialize.selector, address(this))\n );\n ap = AddressesProvider(address(proxy));\n ap.setAddress(\"DefaultProxyAdmin\", address(dpa));\n }\n dpa = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n if (ap.owner() == address(0)) {\n ap.initialize(address(this));\n }\n if (ap.getAddress(\"deployer\") == address(0)) {\n vm.prank(ap.owner());\n ap.setAddress(\"deployer\", 0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n }\n\n function diff(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n } else {\n return b - a;\n }\n }\n\n function compareStrings(string memory a, string memory b) public pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function asArray(address value) public pure returns (address[] memory) {\n address[] memory array = new address[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(address value0, address value1) public pure returns (address[] memory) {\n address[] memory array = new address[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n address value0,\n address value1,\n address value2\n ) public pure returns (address[] memory) {\n address[] memory array = new address[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function asArray(bool value) public pure returns (bool[] memory) {\n bool[] memory array = new bool[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(uint256 value0, uint256 value1) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(uint256 value) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value0, bytes memory value1) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n bytes memory value0,\n bytes memory value1,\n bytes memory value2\n ) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function sqrt(uint256 x) public pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n}\n" + }, + "contracts/test/config/MarketsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./BaseTest.t.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../../compound/CErc20RewardsDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { DiamondExtension } from \"../../ionic/DiamondExtension.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MarketsTest is BaseTest {\n FeeDistributor internal ffd;\n\n CErc20Delegate internal cErc20Delegate;\n CErc20PluginDelegate internal cErc20PluginDelegate;\n CErc20RewardsDelegate internal cErc20RewardsDelegate;\n CErc20PluginRewardsDelegate internal cErc20PluginRewardsDelegate;\n CTokenFirstExtension internal newCTokenExtension;\n\n address payable internal latestComptrollerImplementation;\n ComptrollerFirstExtension internal comptrollerExtension;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n upgradeFfd();\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20RewardsDelegate = new CErc20RewardsDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n newCTokenExtension = new CTokenFirstExtension();\n\n comptrollerExtension = new ComptrollerFirstExtension();\n Comptroller newComptrollerImplementation = new Comptroller();\n latestComptrollerImplementation = payable(address(newComptrollerImplementation));\n }\n\n function upgradeFfd() internal {\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffd)));\n bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n if (address(ffd.authoritiesRegistry()) == address(0)) {\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n vm.prank(ffd.owner());\n ffd.reinitialize(newAr);\n }\n }\n\n function _prepareCTokenUpgrade(ICErc20 market) internal returns (address) {\n address implBefore = market.implementation();\n //emit log(\"implementation before\");\n //emit log_address(implBefore);\n\n CErc20Delegate newImpl;\n if (market.delegateType() == 1) {\n newImpl = cErc20Delegate;\n } else if (market.delegateType() == 2) {\n newImpl = cErc20PluginDelegate;\n } else if (market.delegateType() == 3) {\n newImpl = cErc20RewardsDelegate;\n } else {\n newImpl = cErc20PluginRewardsDelegate;\n }\n\n // set the new ctoken delegate as the latest\n uint8 delegateType = market.delegateType();\n vm.prank(ffd.owner());\n ffd._setLatestCErc20Delegate(delegateType, address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = DiamondExtension(newImpl);\n cErc20DelegateExtensions[1] = newCTokenExtension;\n vm.prank(ffd.owner());\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n\n return address(newImpl);\n }\n\n function _upgradeMarket(ICErc20 market) internal {\n address newDelegate = _prepareCTokenUpgrade(market);\n\n bytes memory becomeImplData = (address(newDelegate) == address(cErc20Delegate))\n ? bytes(\"\")\n : abi.encode(address(0));\n vm.prank(market.ionicAdmin());\n market._setImplementationSafe(newDelegate, becomeImplData);\n }\n\n function _prepareComptrollerUpgrade(address oldCompImpl) internal {\n vm.startPrank(ffd.owner());\n ffd._setLatestComptrollerImplementation(oldCompImpl, latestComptrollerImplementation);\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = comptrollerExtension;\n extensions[1] = Comptroller(latestComptrollerImplementation);\n ffd._setComptrollerExtensions(latestComptrollerImplementation, extensions);\n vm.stopPrank();\n }\n\n function _upgradeExistingPool(address poolAddress) internal {\n Unitroller asUnitroller = Unitroller(payable(poolAddress));\n // change the implementation to the new that can add extensions\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n _prepareComptrollerUpgrade(oldComptrollerImplementation);\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n}\n" + }, + "contracts/test/ContractsUpgradesTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ComptrollerFirstExtension, DiamondExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract ContractsUpgradesTest is BaseTest {\n function testPoolDirectoryUpgrade() public fork(BSC_MAINNET) {\n address contractToTest = ap.getAddress(\"PoolDirectory\"); // PoolDirectory proxy\n\n // before upgrade\n PoolDirectory fpdBefore = PoolDirectory(contractToTest);\n PoolDirectory.Pool[] memory poolsBefore = fpdBefore.getAllPools();\n address ownerBefore = fpdBefore.owner();\n emit log_address(ownerBefore);\n\n uint256 lenBefore = poolsBefore.length;\n emit log_uint(lenBefore);\n\n // upgrade\n {\n PoolDirectory newImpl = new PoolDirectory();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(contractToTest));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n PoolDirectory fpd = PoolDirectory(contractToTest);\n address ownerAfter = fpd.owner();\n emit log_address(ownerAfter);\n\n (, PoolDirectory.Pool[] memory poolsAfter) = fpd.getActivePools();\n uint256 lenAfter = poolsAfter.length;\n emit log_uint(poolsAfter.length);\n\n assertEq(lenBefore, lenAfter, \"pools count does not match\");\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testFeeDistributorUpgrade() public fork(BSC_MAINNET) {\n // TODO use an already deployed market\n CErc20Delegate oldCercDelegate = new CErc20Delegate();\n\n // before upgrade\n FeeDistributor ffdProxy = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n uint256 marketsCounterBefore = ffdProxy.marketsCounter();\n address ownerBefore = ffdProxy.owner();\n\n (address latestCErc20DelegateBefore, ) = ffdProxy.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterBefore);\n emit log_address(ownerBefore);\n\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffdProxy)));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n FeeDistributor ffd = FeeDistributor(payable(address(ffdProxy)));\n\n uint256 marketsCounterAfter = ffd.marketsCounter();\n address ownerAfter = ffd.owner();\n (address latestCErc20DelegateAfter, ) = ffd.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterAfter);\n emit log_address(ownerAfter);\n\n assertEq(latestCErc20DelegateBefore, latestCErc20DelegateAfter, \"latest delegates do not match\");\n assertEq(marketsCounterBefore, marketsCounterAfter, \"markets counter does not match\");\n\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testMarketsLatestImplementationsChapel() public fork(BSC_CHAPEL) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsBsc() public fork(BSC_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsPolygon() public fork(POLYGON_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsArbitrum() public fork(ARBITRUM_ONE) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsEth() public fork(ETHEREUM_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function _testMarketsLatestImplementations() internal {\n FeeDistributor ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n if (address(fpd) != address(0)) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n\n uint8 currentDelegateType = market.delegateType();\n (address upgradeToImpl, ) = ffd.latestCErc20Delegate(currentDelegateType);\n\n address currentImpl = market.implementation();\n if (currentImpl != upgradeToImpl) emit log_address(address(market));\n assertEq(currentImpl, upgradeToImpl, \"market needs to be upgraded\");\n\n DiamondBase asBase = DiamondBase(address(markets[j]));\n try asBase._listExtensions() returns (address[] memory extensions) {\n assertEq(extensions.length, 2, \"market is missing an extension\");\n } catch {\n emit log(\"market that is not yet upgraded to the extensions upgrade\");\n emit log_address(address(market));\n emit log(\"implementation\");\n emit log_address(currentImpl);\n emit log(\"pool\");\n emit log_address(pools[i].comptroller);\n emit log(\"\");\n }\n }\n }\n }\n }\n\n function testPauseGuardiansBsc() public debuggingOnly fork(BSC_MAINNET) {\n _testPauseGuardians();\n }\n\n // TODO redeploy to polygon to fix\n function testPauseGuardiansPolygon() public debuggingOnly fork(POLYGON_MAINNET) {\n _testPauseGuardians();\n }\n\n function _testPauseGuardians() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n address deployer = ap.getAddress(\"deployer\");\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address pauseGuardian = pool.pauseGuardian();\n if (pauseGuardian != address(0) && pauseGuardian != deployer) {\n emit log_named_address(\"pool\", address(pool));\n emit log_named_address(\"unknown pause guardian\", pauseGuardian);\n emit log(\"\");\n }\n }\n }\n}\n" + }, + "contracts/test/DeployMarkets.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Test.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { IonicFlywheelDynamicRewardsPlugin } from \"../ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20, ICErc20Plugin, ICErc20PluginRewards } from \"../compound/CTokenInterfaces.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { MockERC4626 } from \"../ionic/strategies/MockERC4626.sol\";\nimport { MockERC4626Dynamic } from \"../ionic/strategies/MockERC4626Dynamic.sol\";\n\ncontract DeployMarketsTest is Test {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n MockERC4626 mockERC4626;\n MockERC4626Dynamic mockERC4626Dynamic;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheelDynamicRewardsPlugin rewards;\n\n address[] markets;\n bool[] t;\n bool[] f;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts() public {\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", 18);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n }\n\n function setUpExtensions() public {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = cErc20Delegate;\n cErc20DelegateExtensions[1] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(0), cErc20DelegateExtensions);\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n }\n\n function setUpPool() public {\n underlyingToken.mint(address(this), 100e36);\n\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n }\n\n function setUp() public {\n setUpBaseContracts();\n setUpPool();\n setUpExtensions();\n vm.roll(1);\n }\n\n function testDeployCErc20Delegate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n require(cToken.mint(10e18) == 0, \"mint failed\");\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(underlyingToken.balanceOf(address(cToken)), 10e18);\n }\n\n function testDeployCErc20PluginDelegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10e18);\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(mockERC4626.balanceOf(address(cToken)), 10e18);\n assertEq(underlyingToken.balanceOf(address(mockERC4626)), 10e18);\n }\n\n function testDeployCErc20PluginRewardsDelegate() public {\n IonicFlywheelCore impl = new IonicFlywheelCore();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n IonicFlywheelCore flywheel = IonicFlywheelCore(address(proxy));\n flywheel.initialize(underlyingToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n IonicFlywheelCore asFlywheelCore = IonicFlywheelCore(address(flywheel));\n rewards = new IonicFlywheelDynamicRewardsPlugin(asFlywheelCore, 1);\n flywheel.setFlywheelRewards(rewards);\n\n mockERC4626Dynamic = new MockERC4626Dynamic(ERC20(address(underlyingToken)), asFlywheelCore);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(address(mockERC4626Dynamic), address(flywheel), address(underlyingToken)),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20PluginRewards cToken = ICErc20PluginRewards(address(allMarkets[allMarkets.length - 1]));\n\n flywheel.addStrategyForRewards(ERC20(address(cToken)));\n\n assertEq(address(cToken.plugin()), address(mockERC4626Dynamic), \"!plugin == erc4626\");\n assertEq(underlyingToken.allowance(address(cToken), address(mockERC4626Dynamic)), type(uint256).max);\n assertEq(underlyingToken.allowance(address(cToken), address(flywheel)), 0);\n\n cToken.approve(address(rewardToken), address(flywheel));\n assertEq(rewardToken.allowance(address(cToken), address(flywheel)), type(uint256).max);\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10000000);\n assertEq(cToken.totalSupply(), 10000000 * 5);\n assertEq(mockERC4626Dynamic.balanceOf(address(cToken)), 10000000);\n assertEq(underlyingToken.balanceOf(address(mockERC4626Dynamic)), 10000000);\n }\n\n function testAutoImplementationCErc20Delegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n address implBefore = cToken.implementation();\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n cToken.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address implAfter = cToken.implementation();\n\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testAutoImplementationPlugin() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n ionicAdmin._upgradePluginToLatestImplementation(address(cToken));\n address pluginImplAfter = address(cToken.plugin());\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n }\n\n function testAutoImplementationCErc20PluginDelegate() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n address implBefore = cToken.implementation();\n uint8 delegateType = cToken.delegateType();\n\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n delegateType,\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address pluginImplAfter = address(cToken.plugin());\n address implAfter = cToken.implementation();\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testInflateExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint just 2 wei\n underlyingToken.approve(address(cToken), 1e36);\n cToken.mint(2);\n assertEq(cToken.totalSupply(), 10);\n assertEq(underlyingToken.balanceOf(address(cToken)), 2, \"!total supply 2\");\n\n uint256 exchRateBefore = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate\", exchRateBefore);\n assertEq(exchRateBefore, 2e17, \"!default exch rate\");\n\n // donate\n underlyingToken.transfer(address(cToken), 1e36);\n\n uint256 exchRateAfter = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate after\", exchRateAfter);\n assertGt(exchRateAfter, 1e30, \"!inflated exch rate\");\n\n // the market should own 1e36 + 2 underlying assets\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e36 + 2, \"!total underlying\");\n\n // 50% + 1\n uint256 errCode = cToken.redeemUnderlying(0.5e36 + 2);\n assertEq(errCode, 0, \"!redeem underlying\");\n\n assertEq(cToken.totalSupply(), 0, \"!should have redeemed all ctokens for 50% + 1 of the underlying\");\n }\n\n function testSupplyCapInflatedExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint 1e18\n underlyingToken.approve(address(cToken), 1e18);\n cToken.mint(1e18);\n assertEq(cToken.totalSupply(), 5 * 1e18, \"!total supply 5\");\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e18, \"!market underlying balance 1\");\n\n (, , uint256 liqBefore, uint256 sfBefore) = comptroller.getAccountLiquidity(address(this));\n\n uint256[] memory caps = new uint256[](1);\n caps[0] = 25e18;\n ICErc20[] memory marketArray = new ICErc20[](1);\n marketArray[0] = cToken;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(marketArray, caps);\n\n // donate 100e18\n underlyingToken.transfer(address(cToken), 100e18);\n assertEq(underlyingToken.balanceOf(address(cToken)), 101e18, \"!market balance 101\");\n assertEq(cToken.balanceOfUnderlying(address(this)), 101e18, \"!user balance 101\");\n\n (, , uint256 liqAfter, uint256 sfAfter) = comptroller.getAccountLiquidity(address(this));\n emit log_named_uint(\"liqBefore\", liqBefore);\n emit log_named_uint(\"liqAfter\", liqAfter);\n\n assertEq(liqAfter / liqBefore, 25, \"liquidity should increase only 25x\");\n }\n}\n" + }, + "contracts/test/DevTesting.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport \"./config/BaseTest.t.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ISwapRouter } from \"../external/uniswap/ISwapRouter.sol\";\nimport { RedstoneAdapterPriceOracle } from \"../oracles/default/RedstoneAdapterPriceOracle.sol\";\nimport { RedstoneAdapterPriceOracleWrsETH } from \"../oracles/default/RedstoneAdapterPriceOracleWrsETH.sol\";\nimport { RedstoneAdapterPriceOracleWeETH } from \"../oracles/default/RedstoneAdapterPriceOracleWeETH.sol\";\nimport { MasterPriceOracle, BasePriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { LeveredPositionFactory } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { LeveredPositionStorage } from \"../ionic/levered/LeveredPositionStorage.sol\";\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle_IFLR } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { CurveSwapLiquidator } from \"../liquidators/CurveSwapLiquidator.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\nimport { VelodromeV2Liquidator } from \"../liquidators/VelodromeV2Liquidator.sol\";\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport \"forge-std/console.sol\";\n\nstruct HealthFactorVars {\n uint256 usdcSupplied;\n uint256 wethSupplied;\n uint256 ezEthSuppled;\n uint256 stoneSupplied;\n uint256 wbtcSupplied;\n uint256 weEthSupplied;\n uint256 merlinBTCSupplied;\n uint256 usdcBorrowed;\n uint256 wethBorrowed;\n uint256 ezEthBorrowed;\n uint256 stoneBorrowed;\n uint256 wbtcBorrowed;\n uint256 weEthBorrowed;\n uint256 merlinBTCBorrowed;\n ICErc20 testCToken;\n address testUnderlying;\n uint256 amountBorrow;\n}\n\ncontract DevTesting is BaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n LeveredPositionsLens levPosLens;\n\n address deployer = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n ICErc20 ezEthMarket;\n ICErc20 stoneMarket;\n ICErc20 weEthMarket;\n ICErc20 merlinBTCMarket;\n\n // mode mainnet assets\n address WETH = 0x4200000000000000000000000000000000000006;\n address USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address USDT = 0xf0F161fDA2712DB8b566946122a5af183995e2eD;\n address WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;\n address UNI = 0x3e7eF8f50246f725885102E8238CBba33F276747;\n address SNX = 0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3;\n address LINK = 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb;\n address DAI = 0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea;\n address BAL = 0xD08a2917653d4E460893203471f0000826fb4034;\n address AAVE = 0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2;\n address weETH = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n address merlinBTC = 0x59889b7021243dB5B1e065385F918316cD90D46c;\n IERC20Upgradeable wsuperOETH = IERC20Upgradeable(0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6);\n IERC20Upgradeable superOETH = IERC20Upgradeable(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n ezEthMarket = ICErc20(0x59e710215d45F584f44c0FEe83DA6d43D762D857);\n stoneMarket = ICErc20(0x959FA710CCBb22c7Ce1e59Da82A247e686629310);\n weEthMarket = ICErc20(0xA0D844742B4abbbc43d8931a6Edb00C56325aA18);\n merlinBTCMarket = ICErc20(0x19F245782b1258cf3e11Eda25784A378cC18c108);\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n } else {}\n levPosLens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testModePoolBorrowers() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_array(\"borrowers\", pool.getAllBorrowers());\n }\n\n function testModeLiquidationShortfall() public debuggingOnly fork(MODE_MAINNET) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(\n 0xa75F9C8246f7269279bE4c969e7Bc6Eb619cC204\n );\n\n emit log_named_uint(\"err\", err);\n emit log_named_uint(\"collateralValue\", collateralValue);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n }\n\n function testModeHealthFactor() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n\n uint256 wethSupplied = wethMarket.balanceOfUnderlying(rahul);\n uint256 usdcSupplied = usdcMarket.balanceOfUnderlying(rahul);\n uint256 usdtSupplied = usdtMarket.balanceOfUnderlying(rahul);\n uint256 wbtcSupplied = wbtcMarket.balanceOfUnderlying(rahul);\n // emit log_named_uint(\"wethSupplied\", wethSupplied);\n emit log_named_uint(\"usdcSupplied\", usdcSupplied);\n emit log_named_uint(\"usdtSupplied\", usdtSupplied);\n emit log_named_uint(\"wbtcSupplied\", wbtcSupplied);\n emit log_named_uint(\"value of wethSupplied\", wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n emit log_named_uint(\"value of usdcSupplied\", usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n emit log_named_uint(\"value of usdtSupplied\", usdtSupplied * pool.oracle().getUnderlyingPrice(usdtMarket));\n emit log_named_uint(\"value of wbtcSupplied\", wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n PoolLens newImpl = new PoolLens();\n // TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(lens)));\n // vm.prank(dpa.owner());\n // proxy.upgradeTo(address(newImpl));\n\n uint256 hf = newImpl.getHealthFactor(rahul, pool);\n\n emit log_named_uint(\"hf\", hf);\n }\n\n function testNetAprMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 8479829) {\n address user = 0x30D5047e839f079bDE1Ab16b34668f57391DacB3;\n int256 blocks = 30 * 24 * 365 * 60;\n IonicFlywheelLensRouter lensRouter = new IonicFlywheelLensRouter(\n PoolDirectory(0x39C353Cf9041CcF467A04d0e78B63d961E81458a)\n );\n int256 apr = lensRouter.getUserNetApr(user, blocks);\n\n emit log_named_int(\"apr\", apr);\n }\n\n function testModeUsdcBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdcMarket);\n }\n\n function testHypotheticalPosition() public debuggingOnly forkAtBlock(MODE_MAINNET, 8028296) {\n HealthFactorVars memory vars;\n\n address wolfy = 0x7d922bf0975424b3371074f54cC784AF738Dac0D;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n address wbtcWhale = 0xBD8CCf3ebE4CC2D57962cdC2756B143ce0135a6B;\n address wethWhale = 0xD746A2a6048C5D3AFF5766a8c4A0C8cFD2311745;\n\n address whale = wbtcWhale;\n vars.testCToken = wethMarket;\n vars.testUnderlying = WETH;\n vars.amountBorrow = 1e18 / 2;\n\n address[] memory cTokens = new address[](1);\n\n vm.startPrank(usdcWhale);\n ERC20(USDC).transfer(wolfy, ERC20(USDC).balanceOf(usdcWhale));\n vm.stopPrank();\n\n vm.startPrank(wbtcWhale);\n ERC20(WBTC).transfer(wolfy, ERC20(WBTC).balanceOf(wbtcWhale));\n vm.stopPrank();\n\n vm.startPrank(wethWhale);\n ERC20(WETH).transfer(wolfy, ERC20(WETH).balanceOf(wethWhale));\n vm.stopPrank();\n\n // emit log_named_uint(\"USDC balance\", ERC20(USDC).balanceOf(wolfy));\n // emit log_named_uint(\"WBTC balance\", ERC20(WBTC).balanceOf(wolfy));\n // emit log_named_uint(\"WETH balance\", ERC20(WETH).balanceOf(wolfy));\n\n vm.startPrank(wolfy);\n\n ERC20(USDC).approve(address(usdcMarket), ERC20(USDC).balanceOf(wolfy));\n usdcMarket.mint(ERC20(USDC).balanceOf(wolfy));\n cTokens[0] = address(usdcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WBTC).approve(address(wbtcMarket), ERC20(WBTC).balanceOf(wolfy));\n wbtcMarket.mint(ERC20(WBTC).balanceOf(wolfy));\n cTokens[0] = address(wbtcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WETH).approve(address(wethMarket), ERC20(WETH).balanceOf(wolfy));\n wethMarket.mint(ERC20(WETH).balanceOf(wolfy));\n cTokens[0] = address(wethMarket);\n pool.enterMarkets(cTokens);\n\n wethMarket.borrow(1e18);\n\n vm.stopPrank();\n\n vars.usdcSupplied = usdcMarket.balanceOfUnderlying(wolfy);\n vars.wethSupplied = wethMarket.balanceOfUnderlying(wolfy);\n vars.ezEthSuppled = ezEthMarket.balanceOfUnderlying(wolfy);\n vars.stoneSupplied = stoneMarket.balanceOfUnderlying(wolfy);\n vars.wbtcSupplied = wbtcMarket.balanceOfUnderlying(wolfy);\n vars.weEthSupplied = weEthMarket.balanceOfUnderlying(wolfy);\n vars.merlinBTCSupplied = merlinBTCMarket.balanceOfUnderlying(wolfy);\n\n vars.usdcBorrowed = usdcMarket.borrowBalanceCurrent(wolfy);\n vars.wethBorrowed = wethMarket.borrowBalanceCurrent(wolfy);\n vars.ezEthBorrowed = ezEthMarket.borrowBalanceCurrent(wolfy);\n vars.stoneBorrowed = stoneMarket.borrowBalanceCurrent(wolfy);\n vars.wbtcBorrowed = wbtcMarket.borrowBalanceCurrent(wolfy);\n vars.weEthBorrowed = weEthMarket.borrowBalanceCurrent(wolfy);\n vars.merlinBTCBorrowed = merlinBTCMarket.borrowBalanceCurrent(wolfy);\n\n emit log_named_uint(\"usdcSupplied\", vars.usdcSupplied);\n emit log_named_uint(\"wethSupplied\", vars.wethSupplied);\n emit log_named_uint(\"ezEthSupplied\", vars.ezEthSuppled);\n emit log_named_uint(\"stoneSupplied\", vars.stoneSupplied);\n emit log_named_uint(\"wbtcSupplied\", vars.wbtcSupplied);\n emit log_named_uint(\"weEthSupplied\", vars.weEthSupplied);\n emit log_named_uint(\"merlinBTCSupplied\", vars.merlinBTCSupplied);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"usdcBorrowed\", vars.usdcBorrowed);\n emit log_named_uint(\"wethBorrowed\", vars.wethBorrowed);\n emit log_named_uint(\"ezEthBorrowed\", vars.ezEthBorrowed);\n emit log_named_uint(\"stoneBorrowed\", vars.stoneBorrowed);\n emit log_named_uint(\"wbtcBorrowed\", vars.wbtcBorrowed);\n emit log_named_uint(\"weEthBorrowed\", vars.weEthBorrowed);\n emit log_named_uint(\"merlinBTCBorrowed\", vars.merlinBTCBorrowed);\n\n // emit log_named_uint(\"value of usdcSupplied\", vars.usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethSupplied\", vars.wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthSupplied\", vars.ezEthSuppled * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneSupplied\", vars.stoneSupplied * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcSupplied\", vars.wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n // emit log_named_uint(\"value of usdcBorrowed\", vars.usdcBorrowed * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethBorrowed\", vars.wethBorrowed * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthBorrowed\", vars.ezEthBorrowed * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneBorrowed\", vars.stoneBorrowed * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcBorrowed\", vars.wbtcBorrowed * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n vm.startPrank(whale);\n ERC20(vars.testUnderlying).transfer(wolfy, ERC20(vars.testUnderlying).balanceOf(whale));\n vm.stopPrank();\n\n uint256 hf = lens.getHealthFactor(wolfy, pool);\n uint256 hypothetical = lens.getHealthFactorHypothetical(\n pool,\n wolfy,\n address(vars.testCToken),\n 0,\n 0,\n vars.amountBorrow\n );\n\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value Before\", collateralValue);\n emit log_named_uint(\"Liquidity Before\", liquidity);\n emit log_named_uint(\"hf before\", hf);\n emit log_named_uint(\"hypothetical hf\", hypothetical);\n\n vm.startPrank(wolfy);\n ERC20(vars.testUnderlying).approve(address(vars.testCToken), vars.amountBorrow);\n vars.testCToken.repayBorrow(vars.amountBorrow);\n vm.stopPrank();\n\n uint256 hfAfter = lens.getHealthFactor(wolfy, pool);\n (err, collateralValue, liquidity, shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value After\", collateralValue);\n emit log_named_uint(\"Liquidity After\", liquidity);\n emit log_named_uint(\"hf after\", hfAfter);\n emit log_named_uint(\"user balance after\", ERC20(vars.testUnderlying).balanceOf(wolfy));\n emit log_named_uint(\"new borrow balance after repay\", vars.testCToken.borrowBalanceCurrent(wolfy));\n }\n\n function testModeUsdtBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdtMarket);\n }\n\n function testModeWethBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(wethMarket);\n wethMarket.accrueInterest();\n _testModeBorrowCaps(wethMarket);\n }\n\n function _testModeBorrowCaps(ICErc20 market) internal {\n uint256 borrowCapUsdc = pool.borrowCaps(address(market));\n uint256 totalBorrowsCurrent = market.totalBorrowsCurrent();\n\n uint256 wethBorrowAmount = 154753148031252;\n console.log(\"borrowCapUsdc %e\", borrowCapUsdc);\n console.log(\"totalBorrowsCurrent %e\", totalBorrowsCurrent);\n console.log(\"new totalBorrowsCurrent %e\", totalBorrowsCurrent + wethBorrowAmount);\n }\n\n function testMarketMember() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; i++) {\n if (pool.checkMembership(rahul, markets[i])) {\n emit log(\"is a member\");\n } else {\n emit log(\"NOT a member\");\n }\n }\n }\n\n function testGetCashError() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20 market = ICErc20(0x49950319aBE7CE5c3A6C90698381b45989C99b46);\n market.getCash();\n }\n\n function testWrsEthBalanceOfError() public debuggingOnly fork(MODE_MAINNET) {\n address wrsEthMarketAddress = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ERC20 wrsEth = ERC20(0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd);\n wrsEth.balanceOf(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n\n function testModeRepay() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0x1A3C4E9B49e4fc595fB7e5f723159bA73a9426e7;\n ICErc20 market = usdcMarket;\n ERC20 asset = ERC20(market.underlying());\n\n uint256 borrowBalance = market.borrowBalanceCurrent(user);\n emit log_named_uint(\"borrowBalance\", borrowBalance);\n\n vm.startPrank(user);\n asset.approve(address(market), borrowBalance);\n uint256 err = market.repayBorrow(borrowBalance / 2);\n\n emit log_named_uint(\"error\", err);\n }\n\n function testAssetsPrices() public debuggingOnly fork(MODE_MAINNET) {\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n emit log_named_uint(\"WETH price\", mpo.price(WETH));\n emit log_named_uint(\"USDC price\", mpo.price(USDC));\n emit log_named_uint(\"USDT price\", mpo.price(USDT));\n emit log_named_uint(\"UNI price\", mpo.price(UNI));\n emit log_named_uint(\"SNX price\", mpo.price(SNX));\n emit log_named_uint(\"LINK price\", mpo.price(LINK));\n emit log_named_uint(\"DAI price\", mpo.price(DAI));\n emit log_named_uint(\"BAL price\", mpo.price(BAL));\n emit log_named_uint(\"AAVE price\", mpo.price(AAVE));\n emit log_named_uint(\"WBTC price\", mpo.price(WBTC));\n }\n\n function testDeployedMarkets() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n emit log_named_address(\"market\", address(markets[i]));\n emit log(markets[i].symbol());\n emit log(markets[i].name());\n }\n }\n\n function testDisableCollateralUsdc() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0xF70CBE91fB1b1AfdeB3C45Fb8CDD2E1249b5b75E;\n address usdcMarketAddr = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n\n vm.startPrank(user);\n\n uint256 borrowed = ICErc20(usdcMarketAddr).borrowBalanceCurrent(user);\n\n emit log_named_uint(\"borrowed\", borrowed);\n\n pool.exitMarket(usdcMarketAddr);\n }\n\n function testBorrowRateAtRatio() public debuggingOnly fork(MODE_MAINNET) {\n uint256 rate = levPosLens.getBorrowRateAtRatio(wethMarket, ezEthMarket, 9988992945501686, 2e18);\n emit log_named_uint(\"borrow rate at ratio\", rate);\n }\n\n function testAssetAsCollateralCap() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ezEthWhale = 0x2344F131B07E6AFd943b0901C55898573F0d1561;\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_EZETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Renzo Restaked ETH\",\n \"ionezETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 ezEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(ezEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(ezEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(ezEthWhale);\n ERC20(MODE_EZETH).approve(address(ezEthMarket), 1e36);\n errCode = ezEthMarket.mint(1e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testNewStoneMarketCapped() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_STONE = 0x80137510979822322193FC997d400D5A6C747bf7;\n address stoneWhale = 0x76486cbED5216C82d26Ee60113E48E06C189541A;\n\n address redstoneOracleAddress = 0x63A1531a06F0Ac597a0DfA5A516a37073c3E1e0a;\n RedstoneAdapterPriceOracle oracle = RedstoneAdapterPriceOracle(redstoneOracleAddress);\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(mpo.admin());\n mpo.add(asArray(MODE_STONE), oracles);\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_STONE,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic StakeStone Ether\",\n \"ionSTONE\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 stoneMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(stoneMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(stoneMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(stoneWhale);\n ERC20(MODE_STONE).approve(address(stoneMarket), 1e36);\n vm.expectRevert(\"not authorized\");\n errCode = stoneMarket.mint(1e18);\n //require(errCode != 0, \"should be unable to supply\");\n }\n\n function testRegisterSFS() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_address(\"pool admin\", pool.admin());\n\n vm.startPrank(multisig);\n pool.registerInSFS();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n markets[i].registerInSFS();\n }\n }\n\n function upgradePool() internal {\n ComptrollerFirstExtension newComptrollerExtension = new ComptrollerFirstExtension();\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n\n // upgrade to the new comptroller extension\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(newComptrollerExtension, DiamondExtension(asUnitroller._listExtensions()[1]));\n\n //asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function testModeBorrowRate() public fork(MODE_MAINNET) {\n //ICErc20[] memory markets = pool.getAllMarkets();\n\n IonicComptroller pool = ezEthMarket.comptroller();\n vm.prank(pool.admin());\n ezEthMarket._setInterestRateModel(JumpRateModel(0x413aD59b80b1632988d478115a466bdF9B26743a));\n\n JumpRateModel discRateModel = JumpRateModel(ezEthMarket.interestRateModel());\n\n uint256 borrows = 200e18;\n uint256 cash = 5000e18 - borrows;\n uint256 reserves = 1e18;\n uint256 rate = discRateModel.getBorrowRate(cash, borrows, reserves);\n\n emit log_named_uint(\"rate per year %e\", rate * discRateModel.blocksPerYear());\n }\n\n function testModeFetchBorrowers() public fork(MODE_MAINNET) {\n // address[] memory borrowers = pool.getAllBorrowers();\n // emit log_named_uint(\"borrowers.len\", borrowers.length);\n\n //upgradePool();\n\n (uint256 totalPages, address[] memory borrowersPage) = pool.getPaginatedBorrowers(1, 0);\n\n emit log_named_uint(\"total pages with 300 size (default)\", totalPages);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(totalPages - 1, 50);\n emit log_named_array(\"last page of 300 borrowers\", borrowersPage);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(1, 50);\n emit log_named_uint(\"total pages with 50 size\", totalPages);\n emit log_named_array(\"page of 50 borrowers\", borrowersPage);\n\n // for (uint256 i = 0; i < borrowers.length; i++) {\n // (\n // uint256 error,\n // uint256 collateralValue,\n // uint256 liquidity,\n // uint256 shortfall\n // ) = pool.getAccountLiquidity(borrowers[i]);\n //\n // emit log(\"\");\n // emit log_named_address(\"user\", borrowers[i]);\n // emit log_named_uint(\"collateralValue\", collateralValue);\n // if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n // if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n // }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testModeDeployMarket() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n address weEthWhale = 0x6e55a90772B92f17f87Be04F9562f3faafd0cc38;\n\n vm.startPrank(pool.admin());\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_WEETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Wrapped eETH\",\n \"ionweETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 weEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(weEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(weEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(weEthWhale);\n ERC20(MODE_WEETH).approve(address(weEthMarket), 1e36);\n errCode = weEthMarket.mint(0.01e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testModeWrsETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6635923) {\n address wrsEth = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n RedstoneAdapterPriceOracleWrsETH oracle = new RedstoneAdapterPriceOracleWrsETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(wrsEth), oracles);\n\n uint256 price = mpo.price(wrsEth);\n emit log_named_uint(\"price of wrsEth\", price);\n }\n\n function testModeWeETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6861468) {\n address weEth = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n RedstoneAdapterPriceOracleWeETH oracle = new RedstoneAdapterPriceOracleWeETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(weEth), oracles);\n\n uint256 price = mpo.price(weEth);\n emit log_named_uint(\"price of weEth\", price);\n assertEq(price, 1036212437077011599);\n }\n\n function testPERLiquidation() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n vm.prank(0x5Cc070844E98F4ceC5f2fBE1592fB1ed73aB7b48);\n _functionCall(\n 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A,\n hex\"20b72325000000000000000000000000f28570694a6c9cd0494955966ae75af61abf5a0700000000000000000000000000000000000000000000000001bc1214ed792fbb0000000000000000000000004341620757bee7eb4553912fafc963e59c949147000000000000000000000000c53edeafb6d502daec5a7015d67936cea0cd0f520000000000000000000000000000000000000000000000000000000000000000\",\n \"error in call\"\n );\n }\n\n function testCtokenUpgrade() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n CErc20PluginRewardsDelegate newImpl = new CErc20PluginRewardsDelegate();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(wethMarket)));\n\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = PoolDirectory(\n 0x39C353Cf9041CcF467A04d0e78B63d961E81458a\n ).getActivePools();\n\n emit log_named_uint(\"First Pool ID\", poolIds[0]);\n emit log_named_uint(\"First Pool ID\", poolIds[1]);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_address(\"First Pool Address\", pools[0].creator);\n emit log_named_address(\"First Pool Address\", pools[1].creator);\n emit log_named_address(\"First Pool Address\", pools[0].comptroller);\n emit log_named_address(\"First Pool Address\", pools[1].comptroller);\n //bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n //address admin = address(uint160(uint256(bytesAtSlot)));\n //vm.prank(admin);\n //proxy.upgradeTo(address(newImpl));\n\n //vm.prank(dpa.owner());\n //proxy.upgradeTo(address(newImpl));\n }\n\n function testAerodromeV2Liquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeV2Liquidator liquidator = new AerodromeV2Liquidator();\n IERC20Upgradeable hyUSD = IERC20Upgradeable(0xCc7FF230365bD730eE4B352cC2492CEdAC49383e);\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n IERC20Upgradeable usdc = IERC20Upgradeable(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);\n address hyusdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0xaac391f166f33CdaEfaa4AfA6616A3BEA66B694d;\n address eusdWhale = 0xEE8Bd6594E046d72D592ac0e278E3CA179b8f189;\n address aerodromeV2Router = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;\n\n vm.startPrank(eusdWhale);\n eUSD.transfer(address(liquidator), 1000 ether);\n IRouter_Aerodrome.Route[] memory path = new IRouter_Aerodrome.Route[](1);\n path[0] = IRouter_Aerodrome.Route({\n from: address(eUSD),\n to: address(usdc),\n stable: true,\n factory: 0x420DD381b31aEf6683db6B902084cB0FFECe40Da\n });\n liquidator.redeem(eUSD, 1000 ether, abi.encode(aerodromeV2Router, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address superOETHWhale = 0xF1010eE787Ee588766b441d7cC397b40DdFB17a3;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n vm.startPrank(superOETHWhale);\n superOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(superOETH, 1 ether, abi.encode(address(superOETH), address(weth), int24(1), aerodromeCLRouter));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorWrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 20203998) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wethWhale = 0x751b77C43643a63362Ab024d466fcC1d75354295;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = AerodromeCLLiquidator(0xb50De36105F6053006306553AB54e77224818B9B);\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n weth,\n 1 ether,\n abi.encode(address(weth), address(wsuperOETH), aerodromeCLRouter, address(0), address(superOETH), 1)\n );\n emit log_named_uint(\"wsuperOETH received\", wsuperOETH.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorUnwrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wsuperOethWhale = 0x0EEaCD4c475040463389d15EAd034d1291b008b1;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n\n vm.startPrank(wsuperOethWhale);\n wsuperOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n wsuperOETH,\n 1 ether,\n abi.encode(address(wsuperOETH), address(weth), aerodromeCLRouter, address(superOETH), address(0), 1)\n );\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testCurveSwapLiquidatorUSDCtowUSDM() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address usdcWhale = 0x134575ff75F9882ca905EE1D78C9340C091d6056;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n vm.prank(usdcWhale);\n IERC20Upgradeable(usdc).transfer(address(liquidator), 100e6);\n liquidator.redeem(IERC20Upgradeable(usdc), 100e6, abi.encode(oracle, wUSDM, address(0), usdm));\n emit log_named_uint(\"wUSDM received\", IERC20Upgradeable(wUSDM).balanceOf(address(liquidator)));\n }\n\n function testCurveSwapLiquidatorwUSDMtoUSDC() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address wusdmWhale = 0x9b8b04B6f82cD5e1dae58cA3614d445F93DeFc5c;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n\n vm.startPrank(wusdmWhale);\n IERC20Upgradeable(wUSDM).transfer(address(liquidator), 30 ether);\n liquidator.redeem(IERC20Upgradeable(wUSDM), 30 ether, abi.encode(oracle, usdc, usdm, address(0)));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testKimLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 13579406) {\n address weth = 0x4200000000000000000000000000000000000006;\n address usdc = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address kimRouter = 0xAc48FcF1049668B285f3dC72483DF5Ae2162f7e8;\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n AlgebraSwapLiquidator liquidator = AlgebraSwapLiquidator(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vm.startPrank(wethWhale);\n IERC20Upgradeable(weth).transfer(address(liquidator), 2018770577362160);\n liquidator.redeem(IERC20Upgradeable(weth), 2018770577362160, abi.encode(usdc, kimRouter));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testVelodromeV2Liquidator_mode_usdcToWeth() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address usdcWhale = 0xFd1D36995d76c0F75bbe4637C84C06E4A68bBB3a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(usdcWhale);\n usdc.transfer(address(liquidator), 1000 * 10e6);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(usdc), to: address(weth), stable: false });\n liquidator.redeem(usdc, 1000 * 10e6, abi.encode(veloRouter, path));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testVelodromeV2Liquidator_mode_wethToUSDC() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(weth), to: address(usdc), stable: false });\n\n liquidator.redeem(weth, 1 ether, abi.encode(veloRouter, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function test_liquidateWithAggregator() public debuggingOnly forkAtBlock(MODE_MAINNET, 15435970) {\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(0x50F13EC4B68c9522260d3ccd4F19826679B3Ce5C));\n emit log_named_address(\"liquidator\", address(liquidator));\n address cErc20 = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18; // weEth\n address cTokenCollateral = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038; // usdc\n uint256 repayAmount = 843900759317990;\n address borrower = 0x1Bec4f239F1Ec11FD8DC7B31A8fea7A5bA5a9Aa4;\n address aggregatorTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE; // lifi\n // 0xd988097fb8612cc24eeC14542bC03424c656005f usdc\n // 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A weeth\n bytes memory aggregatorData = vm.parseBytes(\n \"0x4666fc800d27477c9a16fe2929353656c1222839791dbe26e815e7533f731ea9a6b919bb00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000050f13ec4b68c9522260d3ccd4f19826679b3ce5c0000000000000000000000000000000000000000000000000002ff85fb26dbe8000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c7848740000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c784874000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a000000000000000000000000000000000000000000000000000000000027891800000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000f283bd37f90001d988097fb8612cc24eec14542bc03424c656005f000104c0599ae5a44757c0af6f9ec3b93da8976c150a0327891807030361590977620147ae00019b57dca972db5d8866c630554acdbdfe58b2659c000000011231deb6f5749ef6ce6943a275a1d3e7486f4eae59725ade04010205000601020203000205000100010400ff0000000000000000000000000053e85d00f2c6578a1205b842255ab9df9d05374425ba258e510faca5ab7ff941a1584bdd2174c94dd988097fb8612cc24eec14542bc03424c656005f4200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000\"\n );\n\n emit log_named_uint(\n \"before collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"before borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidator.safeLiquidateWithAggregator(\n borrower,\n repayAmount,\n ICErc20(cErc20),\n ICErc20(cTokenCollateral),\n aggregatorTarget,\n aggregatorData\n );\n vm.stopPrank();\n\n emit log_named_uint(\n \"profit collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"profit borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n }\n\n function upgradeFactory(ILeveredPositionFactory factory) internal {\n LeveredPositionFactoryFirstExtension newExt1 = new LeveredPositionFactoryFirstExtension();\n LeveredPositionFactorySecondExtension newExt2 = new LeveredPositionFactorySecondExtension();\n\n vm.startPrank(factory.owner());\n DiamondBase asBase = DiamondBase(address(factory));\n address[] memory oldExts = asBase._listExtensions();\n\n if (oldExts.length == 1) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(address(0)));\n } else if (oldExts.length == 2) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(oldExts[1]));\n }\n vm.stopPrank();\n }\n\n function test_leveredPosition_aggregator() public debuggingOnly forkAtBlock(BASE_MAINNET, 23251823) {\n address USER = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n ILeveredPositionFactory factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n upgradeFactory(factory);\n\n ICErc20 collateralAsset = ICErc20(0x84341B650598002d427570298564d6701733c805); // weEth\n ICErc20 stableAsset = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3); // weth\n vm.startPrank(USER);\n IERC20Upgradeable fundingAsset = IERC20Upgradeable(collateralAsset.underlying());\n LeveredPosition position = factory.createPosition(collateralAsset, stableAsset);\n emit log_named_address(\"position\", address(position));\n fundingAsset.approve(address(position), type(uint256).max);\n position.fundPosition(\n fundingAsset,\n 0.03 ether,\n address(0),\n abi.encode(address(0))\n );\n (uint256 supplyDelta, uint256 borrowDelta) = position.getAdjustmentAmountDeltas(2 ether, 1);\n emit log_named_uint(\"supplyDelta\", supplyDelta);\n emit log_named_uint(\"borrowDelta\", borrowDelta);\n\n address aggregatorTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n bytes memory aggregatorData = hex\"4666fc80ddffa5afc347e458f2a79169fdd926c8080f864ee743d9da68bec9471aeef95a00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000d2a6330d610d9d0a13c0c0ac437906000838eb8500000000000000000000000000000000000000000000000000554a9fe78263a3000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783030303030303030303030303030303030303030303030303030303030303030303030303030303000000000000000000000000000000000000000000000000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c55000000000000000000000000f2614a233c7c3e7f08b1f887ba133a13f1eb2c55000000000000000000000000420000000000000000000000000000000000000600000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a0000000000000000000000000000000000000000000000000067C2EC2D07866100000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001442646478b00000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000067C2EC2D07866100000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a00000000000000000000000000000000000000000000000000554a9fe78263a20000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004202420000000000000000000000000000000000000601ffff01302976a386fbb375033be3ac1e4112f76cf42ef7001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n position.adjustLeverageRatio(2 ether, aggregatorTarget, aggregatorData, 100);\n\n vm.stopPrank();\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testRawCall() public debuggingOnly forkAtBlock(BASE_MAINNET, 20569373) {\n address caller = 0xC13110d04f22ed464Cb72A620fF8163585358Ff9;\n address target = 0x180272dDf5767C771b3a8d37A2DC6cA507aaa1d9;\n\n ILeveredPositionFactory factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(WETH);\n IERC20Upgradeable outputToken = wsuperOETH;\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(aerodomeClLiquidator, inputToken, outputToken);\n registry._setRedemptionStrategy(aerodomeClLiquidator, outputToken, inputToken);\n vm.stopPrank();\n\n bytes memory data = hex\"c393d0e3\";\n vm.prank(caller);\n _functionCall(target, data, \"raw call failed\");\n\n uint256 superOETHBalance = superOETH.balanceOf(target);\n emit log_named_uint(\"balance of levered position\", superOETHBalance);\n }\n}\n" + }, + "contracts/test/ExtensionsTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MockComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFirstMarketSymbol() public view returns (string memory) {\n return allMarkets[0].symbol();\n }\n\n function _setTransferPaused(bool) public returns (bool) {\n return false;\n }\n\n function _setSeizePaused(bool) public returns (bool) {\n return false;\n }\n\n // a dummy fn to test if the replacement of extension fns works\n function getSecondMarketSymbol() public view returns (string memory) {\n return allMarkets[1].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this.getFirstMarketSymbol.selector;\n functionSelectors[--fnsCount] = this.getSecondMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockSecondComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getThirdMarketSymbol() public view returns (string memory) {\n return allMarkets[2].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getThirdMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockThirdComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFourthMarketSymbol() public view returns (string memory) {\n return allMarkets[3].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getFourthMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract ExtensionsTest is MarketsTest {\n MockComptrollerExtension internal mockExtension;\n MockSecondComptrollerExtension internal second;\n MockThirdComptrollerExtension internal third;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n mockExtension = new MockComptrollerExtension();\n second = new MockSecondComptrollerExtension();\n third = new MockThirdComptrollerExtension();\n }\n\n function testExtensionReplace() public debuggingOnly fork(BSC_MAINNET) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n _upgradeExistingPool(jFiatPoolAddress);\n\n // replace the first extension with the mock\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, mockExtension, comptrollerExtension);\n\n // assert that the replacement worked\n MockComptrollerExtension asMockExtension = MockComptrollerExtension(jFiatPoolAddress);\n emit log(asMockExtension.getSecondMarketSymbol());\n assertEq(asMockExtension.getSecondMarketSymbol(), \"fETH-1\", \"market symbol does not match\");\n\n // add a second mock extension\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, second, DiamondExtension(address(0)));\n\n // add again the third, removing the second\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, third, second);\n\n // assert that it worked\n DiamondBase asBase = DiamondBase(jFiatPoolAddress);\n address[] memory currentExtensions = asBase._listExtensions();\n assertEq(currentExtensions.length, 2, \"extensions count does not match\");\n assertEq(currentExtensions[0], address(mockExtension), \"!first\");\n assertEq(currentExtensions[1], address(third), \"!second\");\n }\n\n function testNewPoolExtensions() public fork(BSC_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n _prepareComptrollerUpgrade(address(0));\n\n // deploy a pool that will have an extension registered automatically\n {\n (, address poolAddress) = fpd.deployPool(\n \"just-a-test2\",\n latestComptrollerImplementation,\n abi.encode(payable(address(ffd))),\n false,\n 0.1e18,\n 1.1e18,\n ap.getAddress(\"MasterPriceOracle\")\n );\n\n address[] memory initExtensionsAfter = DiamondBase(payable(poolAddress))._listExtensions();\n assertEq(initExtensionsAfter.length, 1, \"remove this if the ffd config is set up\");\n assertEq(initExtensionsAfter[0], address(comptrollerExtension), \"first extension is not the CFE\");\n }\n }\n\n function testMulticallMarket() public fork(BSC_MAINNET) {\n uint8 random = uint8(block.timestamp % 256);\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(pools[random % pools.length].comptroller);\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n ICErc20 someMarket = markets[random % markets.length];\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n vm.roll(block.number + 1);\n\n bytes memory blockNumberBeforeCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes memory accrueInterestCall = abi.encodeWithSelector(someMarket.accrueInterest.selector);\n bytes memory blockNumberAfterCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes[] memory results = someMarket.multicall(\n asArray(blockNumberBeforeCall, accrueInterestCall, blockNumberAfterCall)\n );\n uint256 blockNumberBefore = abi.decode(results[0], (uint256));\n uint256 blockNumberAfter = abi.decode(results[2], (uint256));\n\n assertGt(blockNumberAfter, blockNumberBefore, \"did not accrue?\");\n }\n\n function testBscExistingCTokenExtensionUpgrade() public fork(BSC_MAINNET) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function testArbitrumExistingCTokenExtensionUpgrade() public fork(ARBITRUM_ONE) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function _testAllPoolsAllMarketsCTokenExtensionUpgrade() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n _testPoolAllMarketsExtensionUpgrade(pools[i].comptroller);\n }\n }\n\n function _testPoolAllMarketsExtensionUpgrade(address poolAddress) internal {\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(poolAddress);\n\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 someMarket = markets[j];\n CErc20Delegator asDelegator = CErc20Delegator(address(someMarket));\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n try this._testExistingCTokenExtensionUpgrade(asDelegator) {} catch Error(string memory reason) {\n address plugin = address(CErc20PluginDelegate(address(asDelegator)).plugin());\n emit log(\"plugin\");\n emit log_address(plugin);\n\n address latestPlugin = ffd.latestPluginImplementation(plugin);\n emit log(\"latest plugin impl\");\n emit log_address(latestPlugin);\n\n revert(reason);\n }\n }\n }\n\n function _testExistingCTokenExtensionUpgrade(CErc20Delegator asDelegator) public {\n uint256 totalSupplyBefore = asDelegator.totalSupply();\n if (totalSupplyBefore == 0) return; // total supply should be non-zero\n\n // TODO\n _upgradeMarket(ICErc20(address(asDelegator)));\n\n // check if the extension was added\n address[] memory extensions = asDelegator._listExtensions();\n assertEq(extensions.length, 1, \"the first extension should be added\");\n assertEq(extensions[0], address(newCTokenExtension), \"the first extension should be the only extension\");\n\n // check if the storage is read from the same place\n uint256 totalSupplyAfter = asDelegator.totalSupply();\n assertGt(totalSupplyAfter, 0, \"total supply should be non-zero\");\n assertEq(totalSupplyAfter, totalSupplyBefore, \"total supply should be the same\");\n }\n\n function testBscComptrollerExtensions() public debuggingOnly fork(BSC_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testPolygonComptrollerExtensions() public debuggingOnly fork(POLYGON_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testChapelComptrollerExtensions() public debuggingOnly fork(BSC_CHAPEL) {\n _testComptrollersExtensions();\n }\n\n function testArbitrumComptrollerExtensions() public debuggingOnly fork(ARBITRUM_ONE) {\n _testComptrollersExtensions();\n }\n\n function _testComptrollersExtensions() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n address payable asPayable = payable(pools[i].comptroller);\n DiamondBase asBase = DiamondBase(asPayable);\n address[] memory extensions = asBase._listExtensions();\n assertEq(extensions.length, 1, \"each pool should have the first extension\");\n }\n }\n\n function testBulkAutoUpgrade() public debuggingOnly fork(POLYGON_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n vm.prank(ffd.owner());\n ffd.autoUpgradePool(IonicComptroller(pools[i].comptroller));\n }\n }\n\n function testPolygonTotalUnderlyingSupplied() public debuggingOnly fork(POLYGON_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function testBscTotalUnderlyingSupplied() public debuggingOnly fork(BSC_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function _testTotalUnderlyingSupplied() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n // if (pools[i].comptroller == 0x5373C052Df65b317e48D6CAD8Bb8AC50995e9459) continue;\n // if (pools[i].comptroller == 0xD265ff7e5487E9DD556a4BB900ccA6D087Eb3AD2) continue;\n ComptrollerFirstExtension poolExt = ComptrollerFirstExtension(pools[i].comptroller);\n\n ICErc20[] memory markets = poolExt.getAllMarkets();\n for (uint8 k = 0; k < markets.length; k++) {\n CErc20Delegate market = CErc20Delegate(address(markets[k]));\n // emit log(market.contractType());\n // emit log_named_address(\"impl\", market.implementation());\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(address(markets[k]));\n marketAsExt.getTotalUnderlyingSupplied();\n }\n }\n }\n\n function testDelegateType() public debuggingOnly fork(POLYGON_MAINNET) {\n emit log(CErc20Delegate(0x587906620D627fe75C4d1288C6A584089780959c).contractType());\n }\n}\n" + }, + "contracts/test/FLRTest.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity >=0.8.0;\n\n// import \"forge-std/Vm.sol\";\n\n// import \"./config/BaseTest.t.sol\";\n\n// import { ERC20 } from \"solmate/tokens/ERC20.sol\";\n// import { Authority } from \"solmate/auth/Auth.sol\";\n// import { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\n// import { IERC20MetadataUpgradeable, IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n// import { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\n// import { FlywheelStaticRewards } from \"../ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol\";\n// import { FuseFlywheelCore } from \"fuse-flywheel/FuseFlywheelCore.sol\";\n\n// import { CErc20 } from \"../compound/CToken.sol\";\n// import { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle_IFLR } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\n// import { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\n// import { PoolDirectory } from \"../PoolDirectory.sol\";\n// import { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\n// contract FLRTest is BaseTest {\n// address rewardToken;\n\n// IonicFlywheel flywheel;\n// FlywheelStaticRewards rewards;\n// IonicFlywheelLensRouter lensRouter;\n\n// PoolDirectory internal fpd;\n\n// function afterForkSetUp() internal override {\n// fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n// lensRouter = new IonicFlywheelLensRouter(fpd);\n// }\n\n// function setUpFlywheel(\n// address _rewardToken,\n// address mkt,\n// IonicComptroller comptroller,\n// address admin\n// ) public {\n// flywheel = new IonicFlywheel();\n// flywheel.initialize(\n// ERC20(_rewardToken),\n// FlywheelStaticRewards(address(0)),\n// IFlywheelBooster(address(0)),\n// address(this)\n// );\n\n// rewards = new FlywheelStaticRewards(IonicFlywheelCore(address(flywheel)), address(this), Authority(address(0)));\n// flywheel.setFlywheelRewards(rewards);\n\n// flywheel.addStrategyForRewards(ERC20(mkt));\n\n// // add flywheel as rewardsDistributor to call flywheelPreBorrowAction / flywheelPreSupplyAction\n// vm.prank(admin);\n// require(comptroller._addRewardsDistributor(address(flywheel)) == 0);\n\n// // seed rewards to flywheel\n// deal(_rewardToken, address(rewards), 1_000_000 * (10**ERC20(_rewardToken).decimals()));\n\n// // Start reward distribution at 1 token per second\n// rewards.setRewardsInfo(\n// ERC20(mkt),\n// FlywheelStaticRewards.RewardsInfo({\n// rewardsPerSecond: uint224(789 * 10**ERC20(_rewardToken).decimals()),\n// rewardsEndTimestamp: 0\n// })\n// );\n// }\n\n// function testFuseFlywheelLensRouterBsc() public debuggingOnly fork(BSC_MAINNET) {\n// rewardToken = address(0x71be881e9C5d4465B3FfF61e89c6f3651E69B5bb); // BRZ\n// emit log_named_address(\"rewardToken\", address(rewardToken));\n// address mkt = 0x159A529c00CD4f91b65C54E77703EDb67B4942e4;\n// setUpFlywheel(rewardToken, mkt, IonicComptroller(0x5EB884651F50abc72648447dCeabF2db091e4117), ap.owner());\n// emit log_named_uint(\"mkt dec\", ERC20(mkt).decimals());\n\n// (uint224 index, uint32 lastUpdatedTimestamp) = flywheel.strategyState(ERC20(mkt));\n\n// emit log_named_uint(\"index\", index);\n// emit log_named_uint(\"lastUpdatedTimestamp\", lastUpdatedTimestamp);\n// emit log_named_uint(\"block.timestamp\", block.timestamp);\n// emit log_named_uint(\n// \"underlying price\",\n// IPriceOracle_IFLR(address(IonicComptroller(0x5EB884651F50abc72648447dCeabF2db091e4117).oracle())).price(\n// address(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c)\n// )\n// );\n\n// vm.warp(block.timestamp + 10);\n\n// (uint224 rewardsPerSecond, uint32 rewardsEndTimestamp) = rewards.rewardsInfo(ERC20(mkt));\n\n// vm.prank(address(flywheel));\n// uint256 accrued = rewards.getAccruedRewards(ERC20(mkt), lastUpdatedTimestamp);\n\n// emit log_named_uint(\"accrued\", accrued);\n// emit log_named_uint(\"rewardsPerSecond\", rewardsPerSecond);\n// emit log_named_uint(\"rewardsEndTimestamp\", rewardsEndTimestamp);\n// emit log_named_uint(\"mkt ts\", ERC20(mkt).totalSupply());\n\n// IonicFlywheelLensRouter.MarketRewardsInfo[] memory marketRewardsInfos = lensRouter.getPoolMarketRewardsInfo(\n// IonicComptroller(0x5EB884651F50abc72648447dCeabF2db091e4117)\n// );\n// for (uint256 i = 0; i < marketRewardsInfos.length; i++) {\n// if (address(marketRewardsInfos[i].market) != mkt) {\n// emit log(\"NO REWARDS INFO\");\n// continue;\n// }\n\n// emit log(\"\");\n// emit log_named_address(\"RUNNING FOR MARKET\", address(marketRewardsInfos[i].market));\n// for (uint256 j = 0; j < marketRewardsInfos[i].rewardsInfo.length; j++) {\n// emit log_named_uint(\n// \"rewardSpeedPerSecondPerToken\",\n// marketRewardsInfos[i].rewardsInfo[j].rewardSpeedPerSecondPerToken\n// );\n// emit log_named_uint(\"rewardTokenPrice\", marketRewardsInfos[i].rewardsInfo[j].rewardTokenPrice);\n// emit log_named_uint(\"formattedAPR\", marketRewardsInfos[i].rewardsInfo[j].formattedAPR);\n// emit log_named_address(\"rewardToken\", address(marketRewardsInfos[i].rewardsInfo[j].rewardToken));\n// }\n// }\n// }\n\n// function testBscLensRouter() public fork(BSC_MAINNET) {\n// IonicComptroller pool = IonicComptroller(0x1851e32F34565cb95754310b031C5a2Fc0a8a905);\n// address user = 0x927d81b91c41D1961e3A7d24847b95484e60C626;\n// IonicFlywheelLensRouter router = IonicFlywheelLensRouter(ap.getAddress(\"IonicFlywheelLensRouter\"));\n\n// router.claimRewardsForPool(user, pool);\n// }\n\n// function testChapelRouter() public fork(BSC_CHAPEL) {\n// IonicFlywheelLensRouter router = IonicFlywheelLensRouter(0x3391ed1C5203168337Fa827cB5Ac8BB8B60D93B7);\n// router.getPoolMarketRewardsInfo(IonicComptroller(0x044c436b2f3EF29D30f89c121f9240cf0a08Ca4b));\n// }\n\n// function testNetAprPolygon() public fork(POLYGON_MAINNET) {\n// address user = 0x8982aa50bb919E42e9204f12e5b59D053Eb2A602;\n// int256 blocks = 26 * 24 * 365 * 60;\n// int256 apr = lensRouter.getUserNetApr(user, blocks);\n// emit log_named_int(\"apr\", apr);\n// }\n\n// function testNetAprMode() public fork(MODE_MAINNET) {\n// address user = 0x8982aa50bb919E42e9204f12e5b59D053Eb2A602;\n// int256 blocks = 30 * 24 * 365 * 60;\n// int256 apr = lensRouter.getUserNetApr(user, blocks);\n// emit log_named_int(\"apr\", apr);\n// }\n\n// function testNetAprChapel() public fork(BSC_CHAPEL) {\n// address user = 0x8982aa50bb919E42e9204f12e5b59D053Eb2A602;\n// int256 blocks = 26 * 24 * 365 * 60;\n// int256 apr = lensRouter.getUserNetApr(user, blocks);\n// emit log_named_int(\"apr\", apr);\n// }\n// }\n" + }, + "contracts/test/FlywheelUpgradesTest.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity >=0.8.0;\n\n// import { BaseTest } from \"./config/BaseTest.t.sol\";\n\n// import { PoolDirectory } from \"../PoolDirectory.sol\";\n// import { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n// import { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n// import { IonicReplacingFlywheel } from \"../ionic/strategies/flywheel/IonicReplacingFlywheel.sol\";\n// import { ReplacingFlywheelDynamicRewards } from \"../ionic/strategies/flywheel/rewards/ReplacingFlywheelDynamicRewards.sol\";\n// import { IonicFlywheelLensRouter } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\n// import { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\n// import { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\n// import { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n// import { Comptroller } from \"../compound/Comptroller.sol\";\n// import { FlywheelCore } from \"../ionic/strategies/flywheel/FlywheelCore.sol\";\n// import { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\n// import { FlywheelDynamicRewards } from \"../ionic/strategies/flywheel/rewards/FlywheelDynamicRewards.sol\";\n\n// import { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n// import { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\n// contract FlywheelUpgradesTest is BaseTest {\n// PoolDirectory internal fpd;\n\n// function afterForkSetUp() internal override {\n// fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n// }\n\n// function testFlywheelUpgradeBsc() public fork(BSC_MAINNET) {\n// _testFlywheelUpgrade();\n// }\n\n// function testFlywheelUpgradePolygon() public fork(POLYGON_MAINNET) {\n// _testFlywheelUpgrade();\n// }\n\n// function _testFlywheelUpgrade() internal {\n// IonicFlywheelCore newImpl = new IonicFlywheelCore();\n\n// (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n// for (uint8 i = 0; i < pools.length; i++) {\n// IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n\n// ICErc20[] memory markets = pool.getAllMarkets();\n\n// address[] memory flywheels = pool.getRewardsDistributors();\n// if (flywheels.length > 0) {\n// emit log(\"\");\n// emit log_named_address(\"pool\", address(pool));\n// }\n// for (uint8 j = 0; j < flywheels.length; j++) {\n// IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n\n// // upgrade\n// TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(flywheels[j]));\n// bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n// address admin = address(uint160(uint256(bytesAtSlot)));\n\n// if (admin != address(0)) {\n// //vm.prank(admin);\n// //proxy.upgradeTo(address(newImpl));\n// //emit log_named_address(\"upgradable flywheel\", address(flywheel));\n\n// bool anyStrategyHasPositiveIndex = false;\n\n// for (uint8 k = 0; k < markets.length; k++) {\n// ERC20 strategy = ERC20(address(markets[k]));\n// (uint224 index, uint32 ts) = flywheel.strategyState(strategy);\n// if (index > 0) {\n// anyStrategyHasPositiveIndex = true;\n// break;\n// }\n// }\n\n// if (!anyStrategyHasPositiveIndex) {\n// emit log_named_address(\"all zero index strategies flywheel\", address(flywheel));\n// //assertTrue(anyStrategyHasPositiveIndex, \"!flywheel has no strategies added or is broken\");\n// }\n// } else {\n// emit log_named_address(\"not upgradable flywheel\", address(flywheel));\n// assertTrue(false, \"flywheel proxy admin 0\");\n// }\n// }\n// }\n// }\n\n// function testPolygonFlywheelAllowance() public fork(POLYGON_MAINNET) {\n// _testAllPoolsMarketsAllowance();\n// }\n\n// function testBscFlywheelAllowance() public fork(BSC_MAINNET) {\n// _testAllPoolsMarketsAllowance();\n// }\n\n// function _testAllPoolsMarketsAllowance() internal {\n// (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n// for (uint8 i = 0; i < pools.length; i++) {\n// _testMarketsAllowance(pools[i].comptroller);\n// }\n// }\n\n// function _testMarketsAllowance(address poolAddress) internal {\n// ComptrollerFirstExtension poolExt = ComptrollerFirstExtension(poolAddress);\n// address[] memory fws = poolExt.getRewardsDistributors();\n\n// ICErc20[] memory markets = poolExt.getAllMarkets();\n\n// for (uint8 j = 0; j < markets.length; j++) {\n// string memory contractType = CErc20PluginRewardsDelegate(address(markets[j])).contractType();\n// // check it only for dynamic rewards flywheels\n// if (compareStrings(contractType, \"CErc20PluginRewardsDelegate\")) {\n// for (uint8 i = 0; i < fws.length; i++) {\n// ERC20 asStrategy = ERC20(address(markets[j]));\n// IonicFlywheelCore flywheel = IonicFlywheelCore(fws[i]);\n// (uint224 index, ) = flywheel.strategyState(asStrategy);\n// ERC20 rewToken = flywheel.rewardToken();\n// address rewardsContractAddress = address(flywheel.flywheelRewards());\n// if (index > 0) {\n// uint256 allowance = rewToken.allowance(address(asStrategy), rewardsContractAddress);\n// if (allowance == 0) {\n// assertGt(allowance, 0, \"!approved\");\n// emit log_named_address(\"flywheel rewards\", rewardsContractAddress);\n// emit log_named_address(\"strategy\", address(asStrategy));\n// emit log_named_address(\"rwtoken\", address(rewToken));\n// break;\n// }\n// }\n// }\n// }\n// }\n// }\n// }\n" + }, + "contracts/test/GlobalPauser.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport \"./config/BaseTest.t.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { IComptroller } from \"../external/compound/IComptroller.sol\";\nimport { GlobalPauser } from \"../GlobalPauser.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport \"forge-std/console.sol\";\n\ncontract GlobalPauserTest is BaseTest {\n address public poolDirectory = 0x39C353Cf9041CcF467A04d0e78B63d961E81458a;\n address public pauseGuardian = 0xD9677b0eeafdCe6BF322d9774Bb65B1f42cF0404;\n address public multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;\n GlobalPauser public pauser; // = GlobalPauser(0xe646D8Be18e545244C5E79F121202f75FA3880c8);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n pauser = new GlobalPauser(poolDirectory);\n pauser.setPauseGuardian(pauseGuardian, true);\n (, PoolDirectory.Pool[] memory pools) = PoolDirectory(poolDirectory).getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n vm.prank(IonicComptroller(pools[i].comptroller).admin());\n IonicComptroller(pools[i].comptroller)._setPauseGuardian(address(pauser));\n }\n }\n\n function testPauseNotGuardian(address sender) public debuggingOnly forkAtBlock(MODE_MAINNET, 9269895) {\n vm.assume(sender != pauseGuardian);\n vm.expectRevert(bytes(\"!guardian\"));\n pauser.pauseAll();\n }\n\n function testPauseAll() public debuggingOnly forkAtBlock(MODE_MAINNET, 9269895) {\n (, PoolDirectory.Pool[] memory pools) = PoolDirectory(poolDirectory).getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));\n assertEq(isPaused, false);\n isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));\n assertEq(isPaused, false);\n }\n }\n vm.prank(pauseGuardian);\n pauser.pauseAll();\n for (uint256 i = 0; i < pools.length; i++) {\n ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));\n assertEq(isPaused, true);\n isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));\n assertEq(isPaused, true);\n }\n }\n }\n}\n" + }, + "contracts/test/helpers/BalancerReentrancyAttacker.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IBalancerStablePool } from \"../../external/balancer/IBalancerStablePool.sol\";\nimport \"../../external/balancer/IBalancerVault.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\ncontract BalancerReentrancyAttacker {\n IBalancerVault private immutable _vault;\n MasterPriceOracle private _mpo;\n address private _lpToken;\n\n constructor(\n IBalancerVault vault,\n MasterPriceOracle mpo,\n address lpToken\n ) {\n _vault = vault;\n _mpo = mpo;\n _lpToken = lpToken;\n }\n\n function startAttack() external payable {\n UserBalanceOp[] memory ops = new UserBalanceOp[](1);\n ops[0].kind = UserBalanceOpKind.DEPOSIT_INTERNAL;\n // Asking to deposit 1 ETH\n ops[0].amount = 1e18;\n ops[0].sender = address(this);\n ops[0].recipient = payable(address(this));\n\n // but pass 2 eth, so there's an amount of exceding ETH and receive() callback is called\n _vault.manageUserBalance{ value: 2e18 }(ops);\n }\n\n receive() external payable {\n _reenterAttack();\n }\n\n function _reenterAttack() internal view {\n _mpo.price(_lpToken);\n }\n}\n" + }, + "contracts/test/helpers/WithPool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.4.23;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\n\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract WithPool is BaseTest {\n ERC20Upgradeable public underlyingToken;\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n IonicComptroller comptroller;\n Comptroller newComptroller;\n JumpRateModel interestModel;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n MasterPriceOracle priceOracle;\n PoolLens poolLens;\n\n address[] markets;\n bool[] t;\n bool[] f;\n address[] newImplementation;\n address[] hardcodedAddresses;\n string[] hardcodedNames;\n\n function setUpWithPool(MasterPriceOracle _masterPriceOracle, ERC20Upgradeable _underlyingToken) public {\n priceOracle = _masterPriceOracle;\n underlyingToken = _underlyingToken;\n\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n if (address(ionicAdmin) != address(0)) {\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ionicAdmin)));\n bytes32 bytesAtSlot = vm.load(\n address(proxy),\n 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n );\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n } else {\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n }\n\n {\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setPendingOwner(address(this));\n ionicAdmin._acceptOwner();\n }\n setUpBaseContracts();\n setUpExtensions();\n }\n\n function setUpExtensions() internal {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n }\n\n function setUpBaseContracts() internal {\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n poolLens = new PoolLens();\n poolLens.initialize(\n poolDirectory,\n \"Pool\",\n \"lens\",\n hardcodedAddresses,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames\n );\n }\n\n function setUpPool(\n string memory name,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive\n ) public {\n Comptroller newComptrollerImplementation = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(newComptrollerImplementation));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = newComptrollerImplementation;\n ionicAdmin._setComptrollerExtensions(address(newComptrollerImplementation), extensions);\n\n (, address comptrollerAddress) = poolDirectory.deployPool(\n name,\n address(newComptrollerImplementation),\n abi.encode(payable(address(ionicAdmin))),\n enforceWhitelist,\n closeFactor,\n liquidationIncentive,\n address(priceOracle)\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n }\n\n function upgradePool(address pool) internal {\n Comptroller newComptrollerImplementation = new Comptroller();\n\n Unitroller asUnitroller = Unitroller(payable(pool));\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n newComptrollerImplementation,\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function deployCErc20Delegate(\n address _underlyingToken,\n bytes memory name,\n bytes memory symbol,\n uint256 _collateralFactorMantissa\n ) public {\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n _underlyingToken,\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n name,\n symbol,\n uint256(1),\n uint256(0)\n ),\n \"\",\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginDelegate(address _erc4626, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_erc4626),\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginRewardsDelegate(address _mockERC4626Dynamic, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_mockERC4626Dynamic),\n _collateralFactorMantissa\n );\n }\n}\n" + }, + "contracts/test/irm/AdjustableJumpRateModelTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { AdjustableJumpRateModel, InterestRateModelParams } from \"../../ionic/irms/AdjustableJumpRateModel.sol\";\n\ncontract InterestRateModelTest is BaseTest {\n AdjustableJumpRateModel adjustableJumpRateModel;\n InterestRateModelParams params;\n InterestRateModelParams newParams;\n\n function setUp() public {\n params = InterestRateModelParams({\n blocksPerYear: 10512000,\n baseRatePerYear: 0.5e16,\n multiplierPerYear: 0.18e18,\n jumpMultiplierPerYear: 4e18,\n kink: 0.8e18\n });\n adjustableJumpRateModel = new AdjustableJumpRateModel(params);\n }\n\n function testUpdateJrmParams() public {\n assertEq(adjustableJumpRateModel.blocksPerYear(), params.blocksPerYear);\n assertEq(adjustableJumpRateModel.baseRatePerBlock(), params.baseRatePerYear / params.blocksPerYear);\n\n newParams = InterestRateModelParams({\n blocksPerYear: 512000,\n baseRatePerYear: 0.7e16,\n multiplierPerYear: 0.18e18,\n jumpMultiplierPerYear: 4e18,\n kink: 0.8e18\n });\n\n adjustableJumpRateModel._setIrmParameters(newParams);\n vm.roll(1);\n\n assertEq(adjustableJumpRateModel.blocksPerYear(), newParams.blocksPerYear);\n assertEq(adjustableJumpRateModel.baseRatePerBlock(), newParams.baseRatePerYear / newParams.blocksPerYear);\n }\n}\n" + }, + "contracts/test/irm/InterestRateModelTest.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity >=0.8.0;\n\n// import { BaseTest } from \"../config/BaseTest.t.sol\";\n\n// import { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\n\n// contract InterestRateModelTest is BaseTest {\n// AnkrFTMInterestRateModel ankrCertificateInterestRateModelFTM;\n// AnkrBNBInterestRateModel ankrCertificateInterestRateModelBNB;\n\n// JumpRateModel jumpRateModel;\n// JumpRateModel mimoRateModel;\n\n// address ANKR_BNB_RATE_PROVIDER = 0xCb0006B31e6b403fEeEC257A8ABeE0817bEd7eBa;\n// address ANKR_BNB_BOND = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n// address ANKR_FTM_RATE_PROVIDER = 0xB42bF10ab9Df82f9a47B86dd76EEE4bA848d0Fa2;\n\n// uint8 day = 3;\n\n// function afterForkSetUp() internal override {\n// if (block.chainid == BSC_MAINNET) {\n// ankrCertificateInterestRateModelBNB = new AnkrBNBInterestRateModel(\n// 10512000,\n// 0.5e16,\n// 3e18,\n// 0.85e18,\n// day,\n// ANKR_BNB_RATE_PROVIDER,\n// ANKR_BNB_BOND\n// );\n// jumpRateModel = new JumpRateModel(10512000, 0.2e17, 0.18e18, 4e18, 0.8e18);\n// } else if (block.chainid == POLYGON_MAINNET) {\n// mimoRateModel = new JumpRateModel(13665600, 2e18, 0.4e17, 4e18, 0.8e18);\n// jumpRateModel = new JumpRateModel(13665600, 0.2e17, 0.18e18, 2e18, 0.8e18);\n// }\n// }\n\n// function testBscIrm() public fork(BSC_MAINNET) {\n// testJumpRateBorrowRate();\n// testJumpRateSupplyRate();\n// testAnkrBNBBorrowModelRate();\n// testAnkrBNBSupplyModelRate();\n// }\n\n// function testPolygonIrm() public fork(POLYGON_MAINNET) {\n// testJumpRateBorrowRatePolygon();\n// }\n\n// function _convertToPerYearBsc(uint256 value) internal pure returns (uint256) {\n// return value * 10512000;\n// }\n\n// function _convertToPerYearPolygon(uint256 value) internal pure returns (uint256) {\n// return value * 13665600;\n// }\n\n// function _convertToPerYearFtm(uint256 value) internal pure returns (uint256) {\n// return value * 21024000;\n// }\n\n// function testJumpRateBorrowRatePolygon() internal {\n// uint256 borrowRate = mimoRateModel.getBorrowRate(0, 0, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(1e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(2e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(3e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(4e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(5e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// borrowRate = mimoRateModel.getBorrowRate(6e18, 10e18, 5e18);\n// assertGe(_convertToPerYearPolygon(borrowRate), 0);\n// assertLe(_convertToPerYearPolygon(borrowRate), 100e18);\n// }\n\n// function testJumpRateBorrowRate() internal {\n// uint256 borrowRate = jumpRateModel.getBorrowRate(0, 0, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(1e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(2e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(3e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(4e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(5e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// borrowRate = jumpRateModel.getBorrowRate(6e18, 10e18, 5e18);\n// assertGe(_convertToPerYearBsc(borrowRate), 0);\n// assertLe(_convertToPerYearBsc(borrowRate), 100e18);\n// }\n\n// function testJumpRateSupplyRate() internal {\n// uint256 supplyRate = jumpRateModel.getSupplyRate(0, 10e18, 5e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(10e18, 10e18, 5e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(20e18, 10e18, 20e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(30e18, 10e18, 30e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(40e18, 10e18, 10e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(50e18, 10e18, 40e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// jumpRateModel.getSupplyRate(60e18, 10e18, 60e18, 0.2e18);\n// assertGe(_convertToPerYearBsc(supplyRate), 0);\n// assertLe(_convertToPerYearBsc(supplyRate), 100e18);\n// }\n\n// function testAnkrFTMBorrowModelRate() internal {\n// vm.mockCall(\n// address(ANKR_FTM_RATE_PROVIDER),\n// abi.encodeWithSelector(IAnkrFTMRateProvider.averagePercentageRate.selector),\n// abi.encode(5e18)\n// );\n// // utilization 1 -> borrow rate: 0.084%\n// uint256 borrowRate = ankrCertificateInterestRateModelFTM.getBorrowRate(800e18, 8e18, 8e18);\n// uint256 util = ankrCertificateInterestRateModelFTM.utilizationRate(800e18, 8e18, 8e18);\n// assertEq(util, 0.1e17);\n// assertApproxEqRel(_convertToPerYearFtm(borrowRate) * 100, 0.084e18, 1e16, \"!borrow rate for utilization 1\");\n\n// // utilization 10 -> borrow rate: 0.61%\n// borrowRate = ankrCertificateInterestRateModelFTM.getBorrowRate(80e18, 8e18, 8e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(80e18, 8e18, 8e18);\n// assertEq(util, 0.1e18);\n// assertApproxEqRel(_convertToPerYearFtm(borrowRate) * 100, 0.61e18, 1e16, \"!borrow rate for utilization 10\");\n\n// // utilization 20 -> borrow rate: 1.2%\n// borrowRate = ankrCertificateInterestRateModelFTM.getBorrowRate(40e18, 8e18, 8e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(40e18, 8e18, 8e18);\n// assertEq(util, 0.2e18);\n// assertApproxEqRel(_convertToPerYearFtm(borrowRate) * 100, 1.2e18, 1e16, \"!borrow rate for utilization 20\");\n\n// // utilization 80 -> borrow rate: 4.7%\n// borrowRate = ankrCertificateInterestRateModelFTM.getBorrowRate(3e18, 8e18, 1e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(3e18, 8e18, 1e18);\n// assertEq(util, 0.8e18);\n// assertApproxEqRel(_convertToPerYearFtm(borrowRate) * 100, 4.7e18, 1e16, \"!borrow rate for utilization 80\");\n\n// // utilization 90 -> borrow rate: 20.3%\n// borrowRate = ankrCertificateInterestRateModelFTM.getBorrowRate(8e18, 7.2e18, 7.2e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(8e18, 7.2e18, 7.2e18);\n// assertEq(util, 0.9e18);\n// assertApproxEqRel(_convertToPerYearFtm(borrowRate) * 100, 20.3e18, 1e16, \"!borrow rate for utilization 90\");\n// }\n\n// function testAnkrBNBBorrowModelRate() internal {\n// vm.mockCall(\n// address(ANKR_BNB_RATE_PROVIDER),\n// abi.encodeWithSelector(IAnkrBNBRateProvider.averagePercentageRate.selector),\n// abi.encode(2.5e18)\n// );\n\n// // utilization 1 -> borrow rate: 0.04%\n// uint256 borrowRate = ankrCertificateInterestRateModelBNB.getBorrowRate(800e18, 8e18, 8e18);\n// uint256 util = ankrCertificateInterestRateModelBNB.utilizationRate(800e18, 8e18, 8e18);\n// assertEq(util, 0.1e17);\n// assertApproxEqRel(_convertToPerYearBsc(borrowRate) * 100, 0.04e18, 1e17, \"!borrow rate for utilization 1\");\n\n// // utilization 10 -> borrow rate: 0.3%\n// borrowRate = ankrCertificateInterestRateModelBNB.getBorrowRate(80e18, 8e18, 8e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(80e18, 8e18, 8e18);\n// assertEq(util, 0.1e18);\n// assertApproxEqRel(_convertToPerYearBsc(borrowRate) * 100, 0.3e18, 1e17, \"!borrow rate for utilization 10\");\n\n// // utilization 20 -> borrow rate: 0.6%\n// borrowRate = ankrCertificateInterestRateModelBNB.getBorrowRate(40e18, 8e18, 8e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(40e18, 8e18, 8e18);\n// assertEq(util, 0.2e18);\n// assertApproxEqRel(_convertToPerYearBsc(borrowRate) * 100, 0.6e18, 1e17, \"!borrow rate for utilization 20\");\n\n// // utilization 80 -> borrow rate: 2.36%\n// borrowRate = ankrCertificateInterestRateModelBNB.getBorrowRate(3e18, 8e18, 1e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(3e18, 8e18, 1e18);\n// assertEq(util, 0.8e18);\n// assertApproxEqRel(_convertToPerYearBsc(borrowRate) * 100, 2.36e18, 1e17, \"!borrow rate for utilization 80\");\n\n// // utilization 90 -> borrow rate: 17%\n// borrowRate = ankrCertificateInterestRateModelBNB.getBorrowRate(8e18, 7.2e18, 7.2e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(8e18, 7.2e18, 7.2e18);\n// assertEq(util, 0.9e18);\n// assertApproxEqRel(_convertToPerYearBsc(borrowRate) * 100, 17e18, 1e17, \"!borrow rate for utilization 90\");\n// }\n\n// function testAnkrFTMSupplyModelRate() internal {\n// vm.mockCall(\n// address(ANKR_FTM_RATE_PROVIDER),\n// abi.encodeWithSelector(IAnkrFTMRateProvider.averagePercentageRate.selector),\n// abi.encode(5e18)\n// );\n\n// // utilization 1 -> supply rate: 0.00075%\n// uint256 supplyRate = ankrCertificateInterestRateModelFTM.getSupplyRate(800e18, 8e18, 8e18, 0.1e18);\n// uint256 util = ankrCertificateInterestRateModelFTM.utilizationRate(800e18, 8e18, 8e18);\n// assertEq(util, 0.1e17);\n// assertApproxEqRel(_convertToPerYearFtm(supplyRate) * 100, 0.00075e18, 1e16, \"!supply rate for utilization 1\");\n\n// // utilization 10 -> supply rate: 0.0055%\n// supplyRate = ankrCertificateInterestRateModelFTM.getSupplyRate(80e18, 8e18, 8e18, 0.1e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(80e18, 8e18, 8e18);\n// assertEq(util, 0.1e18);\n// assertApproxEqRel(_convertToPerYearFtm(supplyRate) * 100, 0.055e18, 1e16, \"!supply rate for utilization 10\");\n\n// // utilization 20 -> supply rate: 0.022%\n// supplyRate = ankrCertificateInterestRateModelFTM.getSupplyRate(40e18, 8e18, 8e18, 0.1e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(40e18, 8e18, 8e18);\n// assertEq(util, 0.2e18);\n// assertApproxEqRel(_convertToPerYearFtm(supplyRate) * 100, 0.216e18, 1e16, \"!supply rate for utilization 20\");\n\n// // utilization 80 -> supply rate: 3.4%\n// supplyRate = ankrCertificateInterestRateModelFTM.getSupplyRate(3e18, 8e18, 1e18, 0.1e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(3e18, 8e18, 1e18);\n// assertEq(util, 0.8e18);\n// assertApproxEqRel(_convertToPerYearFtm(supplyRate) * 100, 3.4e18, 1e16, \"!supply rate for utilization 80\");\n\n// // utilization 90 -> supply rate: 16.5%\n// supplyRate = ankrCertificateInterestRateModelFTM.getSupplyRate(8e18, 7.2e18, 7.2e18, 0.1e18);\n// util = ankrCertificateInterestRateModelFTM.utilizationRate(8e18, 7.2e18, 7.2e18);\n// assertEq(util, 0.9e18);\n// assertApproxEqRel(_convertToPerYearFtm(supplyRate) * 100, 16.5e18, 1e16, \"!supply rate for utilization 90\");\n// }\n\n// function testAnkrBNBSupplyModelRate() internal {\n// vm.mockCall(\n// address(ANKR_BNB_RATE_PROVIDER),\n// abi.encodeWithSelector(IAnkrBNBRateProvider.averagePercentageRate.selector),\n// abi.encode(2.5e18)\n// );\n\n// // utilization 1 -> supply rate: 0.00037%\n// uint256 supplyRate = ankrCertificateInterestRateModelBNB.getSupplyRate(800e18, 8e18, 8e18, 0.1e18);\n// uint256 util = ankrCertificateInterestRateModelBNB.utilizationRate(800e18, 8e18, 8e18);\n// assertEq(util, 0.1e17);\n// assertApproxEqRel(_convertToPerYearBsc(supplyRate) * 100, 0.00037e18, 1e17, \"!supply rate for utilization 1\");\n\n// // utilization 10 -> supply rate: 0.027%\n// supplyRate = ankrCertificateInterestRateModelBNB.getSupplyRate(80e18, 8e18, 8e18, 0.1e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(80e18, 8e18, 8e18);\n// assertEq(util, 0.1e18);\n// assertApproxEqRel(_convertToPerYearBsc(supplyRate) * 100, 0.027e18, 1e17, \"!supply rate for utilization 10\");\n\n// // utilization 20 -> supply rate: 0.1%\n// supplyRate = ankrCertificateInterestRateModelBNB.getSupplyRate(40e18, 8e18, 8e18, 0.1e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(40e18, 8e18, 8e18);\n// assertEq(util, 0.2e18);\n// assertApproxEqRel(_convertToPerYearBsc(supplyRate) * 100, 0.1e18, 1e17, \"!supply rate for utilization 20\");\n\n// // utilization 80 -> supply rate: 1.7%\n// supplyRate = ankrCertificateInterestRateModelBNB.getSupplyRate(3e18, 8e18, 1e18, 0.1e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(3e18, 8e18, 1e18);\n// assertEq(util, 0.8e18);\n// assertApproxEqRel(_convertToPerYearBsc(supplyRate) * 100, 1.7e18, 1e17, \"!supply rate for utilization 80\");\n\n// // utilization 90 -> supply rate: 14.3%\n// supplyRate = ankrCertificateInterestRateModelBNB.getSupplyRate(8e18, 7.2e18, 7.2e18, 0.1e18);\n// util = ankrCertificateInterestRateModelBNB.utilizationRate(8e18, 7.2e18, 7.2e18);\n// assertEq(util, 0.9e18);\n// assertApproxEqRel(_convertToPerYearBsc(supplyRate) * 100, 14.3e18, 1e17, \"!supply rate for utilization 90\");\n// }\n// }\n" + }, + "contracts/test/irm/PrudentiaIrmTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\nimport { IRateComputer } from \"adrastia-periphery/rates/IRateComputer.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { PrudentiaInterestRateModel } from \"../../ionic/irms/PrudentiaInterestRateModel.sol\";\n\ncontract MockRateComputer is IRateComputer {\n mapping(address => uint64) public rates;\n\n function computeRate(address token) external view override returns (uint64) {\n return rates[token];\n }\n\n function setRate(address token, uint64 rate) public {\n rates[token] = rate;\n }\n}\n\ncontract PrudentiaIrmTest is BaseTest {\n using Math for uint64;\n\n MockRateComputer rateComputer;\n address token;\n PrudentiaInterestRateModel irm;\n uint256 blocksPerYear;\n\n function setUp() public {\n rateComputer = new MockRateComputer();\n token = address(0x1);\n blocksPerYear = 10512000;\n irm = new PrudentiaInterestRateModel(blocksPerYear, token, rateComputer);\n }\n\n function test_utilizationRate_zeroTotal() public {\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.utilizationRate(cash, borrows, reserves), 0);\n }\n\n function test_utilizationRate_zero() public {\n uint256 cash = 100;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.utilizationRate(cash, borrows, reserves), 0);\n }\n\n function test_utilizationRate_50() public {\n uint256 cash = 100;\n uint256 borrows = 100;\n uint256 reserves = 0;\n\n assertEq(irm.utilizationRate(cash, borrows, reserves), 5e17);\n }\n\n function test_utilizationRate_100() public {\n uint256 cash = 0;\n uint256 borrows = 100;\n uint256 reserves = 0;\n\n assertEq(irm.utilizationRate(cash, borrows, reserves), 1e18);\n }\n\n function test_getBorrowRate_100_a() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 0;\n uint256 borrows = 100;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getBorrowRate_100_b() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 100;\n uint256 borrows = 100;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getBorrowRate_50() public {\n uint64 rate = 5e17;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getBorrowRate_1() public {\n uint64 rate = 1e16;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getBorrowRate_0() public {\n uint64 rate = 0;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getBorrowRate_1mantissa() public {\n uint64 rate = 1;\n rateComputer.setRate(token, rate);\n\n // These should have no effect\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n\n assertEq(irm.getBorrowRate(cash, borrows, reserves), 1); // Rounds up to 1. We don't want to return 0.\n }\n\n function test_getSupplyRate_100_100util() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 0;\n uint256 borrows = 100;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), rate.ceilDiv(blocksPerYear));\n }\n\n function test_getSupplyRate_100_50util() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 100;\n uint256 borrows = 100;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), rate.ceilDiv(blocksPerYear) / 2);\n }\n\n function test_getSupplyRate_100_1util() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 99;\n uint256 borrows = 1;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), rate.ceilDiv(blocksPerYear) / 100);\n }\n\n function test_getSupplyRate_100_0util() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 100;\n uint256 borrows = 0;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), 0);\n }\n\n function test_getSupplyRate_0_0util() public {\n uint64 rate = 0;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 0;\n uint256 borrows = 0;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), 0);\n }\n\n function test_getSupplyRate_0_100util() public {\n uint64 rate = 0;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 0;\n uint256 borrows = 100;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), 0);\n }\n\n function test_getSupplyRate_0_50util() public {\n uint64 rate = 0;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 50;\n uint256 borrows = 50;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), 0);\n }\n\n function test_getSupplyRate_0_1util() public {\n uint64 rate = 0;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 99;\n uint256 borrows = 1;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 0;\n\n assertEq(irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa), 0);\n }\n\n function test_getSupplyRate_100_50util_10rf() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 100;\n uint256 borrows = 100;\n uint256 reserves = 0;\n uint256 reserveFactorMantissa = 1e17;\n\n assertEq(\n irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa),\n (uint256(rate.ceilDiv(blocksPerYear) / 2) * (1e18 - reserveFactorMantissa)) / 1e18\n );\n }\n\n function test_getSupplyRate_100_50util_10rf_10reserves() public {\n uint64 rate = 1e18;\n rateComputer.setRate(token, rate);\n\n uint256 cash = 100;\n uint256 borrows = 100;\n uint256 reserves = 10;\n cash += reserves;\n uint256 reserveFactorMantissa = 1e17;\n\n assertEq(\n irm.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa),\n (uint256(rate.ceilDiv(blocksPerYear) / 2) * (1e18 - reserveFactorMantissa)) / 1e18\n );\n }\n}\n" + }, + "contracts/test/LatestImplementationWhitelisted.t.sol": { + "content": "pragma solidity ^0.8.0;\n\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LatestImplementationWhitelisted is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n address[] poolsImplementationsSet;\n address[] marketsImplementationsSet;\n address[] pluginsSet;\n\n function testBscImplementations() public fork(BSC_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function testPolygonImplementations() public fork(POLYGON_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function afterForkSetUp() internal override {\n poolDirectory = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testPoolImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n address implementation = comptroller.comptrollerImplementation();\n\n bool added = false;\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n if (poolsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) poolsImplementationsSet.push(implementation);\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n emit log_address(poolsImplementationsSet[k]);\n\n address latestImpl = ionicAdmin.latestComptrollerImplementation(poolsImplementationsSet[k]);\n assertTrue(poolsImplementationsSet[k] == latestImpl, \"some pool is not upgraded the latest impl\");\n }\n }\n\n function testMarketImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n address implementation = market.implementation();\n\n bool added = false;\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n if (marketsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) marketsImplementationsSet.push(implementation);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n emit log_address(marketsImplementationsSet[k]);\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = ionicAdmin.latestCErc20Delegate(\n CErc20Delegate(marketsImplementationsSet[k]).delegateType()\n );\n\n assertTrue(marketsImplementationsSet[k] == latestCErc20Delegate, \"some markets need to be upgraded\");\n }\n }\n\n function testPluginImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n CErc20PluginDelegate delegate = CErc20PluginDelegate(address(markets[j]));\n\n address plugin;\n try delegate.plugin() returns (IERC4626 _plugin) {\n plugin = address(_plugin);\n } catch {\n continue;\n }\n\n bool added = false;\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n if (pluginsSet[k] == plugin) {\n added = true;\n }\n }\n\n if (!added) pluginsSet.push(plugin);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n address latestPluginImpl = ionicAdmin.latestPluginImplementation(pluginsSet[k]);\n\n emit log_address(pluginsSet[k]);\n\n assertTrue(pluginsSet[k] == latestPluginImpl, \"some plugin is not upgraded to the latest impl\");\n }\n }\n}\n" + }, + "contracts/test/LeveredPositionTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest, BaseTest } from \"./config/MarketsTest.t.sol\";\nimport { DiamondBase, DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { LeveredPositionFactory, IFeeDistributor } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { JarvisLiquidatorFunder } from \"../liquidators/JarvisLiquidatorFunder.sol\";\nimport { BalancerSwapLiquidator } from \"../liquidators/BalancerSwapLiquidator.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { SolidlyLpTokenLiquidator, SolidlyLpTokenWrapper } from \"../liquidators/SolidlyLpTokenLiquidator.sol\";\nimport { SolidlySwapLiquidator } from \"../liquidators/SolidlySwapLiquidator.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\n\nimport { CurveLpTokenLiquidatorNoRegistry } from \"../liquidators/CurveLpTokenLiquidatorNoRegistry.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { LiquidatorsRegistry } from \"../liquidators/registry/LiquidatorsRegistry.sol\";\nimport { LiquidatorsRegistryExtension } from \"../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { SafeOwnable } from \"../ionic/SafeOwnable.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract LeveredPositionLensTest is BaseTest {\n LeveredPositionsLens lens;\n ILeveredPositionFactory factory;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n emit log_named_address(\"factory\", address(factory));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n // lens = new LeveredPositionsLens();\n // lens.initialize(factory);\n }\n\n function testLPLens() public debuggingOnly fork(BSC_CHAPEL) {\n _testLPLens();\n }\n\n function _testLPLens() internal {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(0xb6c11605e971ab46B9BE4fDC48C9650A257075db);\n\n // address[] memory accounts = factory.getAccountsWithOpenPositions();\n // for (uint256 i = 0; i < accounts.length; i++) {\n // (positions, closed) = factory.getPositionsByAccount(accounts[i]);\n // if (positions.length > 0) break;\n // }\n\n uint256[] memory apys = new uint256[](positions.length);\n LeveredPosition[] memory pos = new LeveredPosition[](positions.length);\n for (uint256 j = 0; j < positions.length; j++) {\n apys[j] = 1e17;\n\n if (address(0) == positions[j]) revert(\"zero pos address\");\n pos[j] = LeveredPosition(positions[j]);\n }\n\n LeveredPositionsLens.PositionInfo[] memory infos = lens.getPositionsInfo(pos, apys);\n\n for (uint256 k = 0; k < infos.length; k++) {\n emit log_named_address(\"address\", address(pos[k]));\n emit log_named_uint(\"positionSupplyAmount\", infos[k].positionSupplyAmount);\n emit log_named_uint(\"positionValue\", infos[k].positionValue);\n emit log_named_uint(\"debtAmount\", infos[k].debtAmount);\n emit log_named_uint(\"debtValue\", infos[k].debtValue);\n emit log_named_uint(\"equityValue\", infos[k].equityValue);\n emit log_named_uint(\"equityAmount\", infos[k].equityAmount);\n emit log_named_int(\"currentApy\", infos[k].currentApy);\n emit log_named_uint(\"debtRatio\", infos[k].debtRatio);\n emit log_named_uint(\"liquidationThreshold\", infos[k].liquidationThreshold);\n emit log_named_uint(\"safetyBuffer\", infos[k].safetyBuffer);\n\n emit log(\"\");\n }\n }\n\n function testPrintLeveredPositions() public debuggingOnly fork(POLYGON_MAINNET) {\n address[] memory accounts = factory.getAccountsWithOpenPositions();\n\n emit log_named_array(\"accounts\", accounts);\n\n for (uint256 j = 0; j < accounts.length; j++) {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(accounts[j]);\n emit log_named_array(\"positions\", positions);\n //emit log_named_array(\"closed\", closed);\n }\n }\n\n function testScenarioLeverageFailed() public debuggingOnly forkAtBlock(MODE_MAINNET, 10672173) {\n address USER = 0x95Ce459B20586cf44ee6d295C4f28e1a134CF529;\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006).approve(\n // address(factory),\n // 100000 ether\n // );\n vm.prank(ap.owner());\n ap.setAddress(\"IUniswapV2Router02\", 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45);\n vm.startPrank(USER);\n LeveredPosition position = factory.createAndFundPositionAtRatio(\n ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n IERC20Upgradeable(0x4200000000000000000000000000000000000006),\n 16754252276537996590,\n 3000000000000000000,\n address(0),\n \"\",\n address(0),\n \"\",\n 0\n );\n emit log_named_address(\"position\", address(position));\n\n // vm.stopPrank();\n // ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n // vm.startPrank(registry.owner());\n // registry._setRedemptionStrategy(\n // new UniswapV3LiquidatorFunder(),\n // IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f),\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006)\n // );\n // vm.stopPrank();\n // vm.startPrank(USER);\n\n vm.roll(10673509);\n position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(10852409);\n // position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(11268772);\n // position.adjustLeverageRatio(3000000000000000000);\n vm.stopPrank();\n }\n}\n\ncontract LeveredPositionFactoryTest is BaseTest {\n ILeveredPositionFactory factory;\n LeveredPositionsLens lens;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testChapelNetApy() public debuggingOnly fork(BSC_CHAPEL) {\n ICErc20 _stableMarket = ICErc20(address(1)); // DAI\n\n uint256 borrowRate = 5.2e16; // 5.2%\n vm.mockCall(\n address(_stableMarket),\n abi.encodeWithSelector(_stableMarket.borrowRatePerBlock.selector),\n abi.encode(borrowRate / factory.blocksPerYear())\n );\n\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n emit log_named_uint(\"_borrowRate\", _borrowRate);\n\n int256 netApy = lens.getNetAPY(\n 2.7e16, // 2.7%\n 1e18, // supply amount\n ICErc20(address(0)), // BOMB\n _stableMarket,\n 2e18 // ratio\n );\n\n emit log_named_int(\"net apy\", netApy);\n\n // boosted APY = 2x 2.7% = 5.4 % of the equity\n // borrow APR = 5.2%\n // diff = 5.4 - 5.2 = 0.2%\n assertApproxEqRel(netApy, 0.2e16, 1e12, \"!net apy\");\n }\n}\n\nabstract contract LeveredPositionTest is MarketsTest {\n ICErc20 collateralMarket;\n ICErc20 stableMarket;\n ILeveredPositionFactory factory;\n ILiquidatorsRegistry registry;\n LeveredPosition position;\n LeveredPositionsLens lens;\n\n uint256 minLevRatio;\n uint256 maxLevRatio;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n upgradeFactory();\n registry = factory.liquidatorsRegistry();\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function upgradeFactory() internal {\n // upgrade the factory\n LeveredPositionFactoryFirstExtension newExt1 = new LeveredPositionFactoryFirstExtension();\n LeveredPositionFactorySecondExtension newExt2 = new LeveredPositionFactorySecondExtension();\n\n vm.startPrank(factory.owner());\n DiamondBase asBase = DiamondBase(address(factory));\n address[] memory oldExts = asBase._listExtensions();\n\n if (oldExts.length == 1) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(address(0)));\n } else if (oldExts.length == 2) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(oldExts[1]));\n }\n vm.stopPrank();\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function upgradePoolAndMarkets() internal {\n _upgradeExistingPool(address(collateralMarket.comptroller()));\n _upgradeMarket(collateralMarket);\n _upgradeMarket(stableMarket);\n }\n\n function _unpauseMarkets(address collat, address stable) internal {\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(address(ICErc20(stable).comptroller()));\n vm.startPrank(asExtension.admin());\n asExtension._setMintPaused(ICErc20(collat), false);\n asExtension._setMintPaused(ICErc20(stable), false);\n asExtension._setBorrowPaused(ICErc20(stable), false);\n vm.stopPrank();\n }\n\n function _configurePairAndLiquidator(address _collat, address _stable, IRedemptionStrategy _liquidator) internal {\n _configurePair(_collat, _stable);\n _configureTwoWayLiquidator(_collat, _stable, _liquidator);\n }\n\n function _configurePair(address _collat, address _stable) internal {\n collateralMarket = ICErc20(_collat);\n stableMarket = ICErc20(_stable);\n\n //upgradePoolAndMarkets();\n //_unpauseMarkets(_collat, _stable);\n vm.prank(factory.owner());\n factory._setPairWhitelisted(collateralMarket, stableMarket, true);\n }\n\n function _whitelistTestUser(address user) internal {\n address pool = address(collateralMarket.comptroller());\n PoolRolesAuthority pra = ffd.authoritiesRegistry().poolsAuthorities(pool);\n\n vm.startPrank(pra.owner());\n pra.setUserRole(user, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n }\n\n function _configureTwoWayLiquidator(\n address inputMarket,\n address outputMarket,\n IRedemptionStrategy strategy\n ) internal {\n IERC20Upgradeable inputToken = underlying(inputMarket);\n IERC20Upgradeable outputToken = underlying(outputMarket);\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(strategy, inputToken, outputToken);\n registry._setRedemptionStrategy(strategy, outputToken, inputToken);\n vm.stopPrank();\n }\n\n function underlying(address market) internal view returns (IERC20Upgradeable) {\n return IERC20Upgradeable(ICErc20(market).underlying());\n }\n\n struct Liquidator {\n IERC20Upgradeable inputToken;\n IERC20Upgradeable outputToken;\n IRedemptionStrategy strategy;\n }\n\n function _configureMultipleLiquidators(Liquidator[] memory liquidators) internal {\n IRedemptionStrategy[] memory strategies = new IRedemptionStrategy[](liquidators.length);\n IERC20Upgradeable[] memory inputTokens = new IERC20Upgradeable[](liquidators.length);\n IERC20Upgradeable[] memory outputTokens = new IERC20Upgradeable[](liquidators.length);\n for (uint256 i = 0; i < liquidators.length; i++) {\n strategies[i] = liquidators[i].strategy;\n inputTokens[i] = liquidators[i].inputToken;\n outputTokens[i] = liquidators[i].outputToken;\n }\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategies(strategies, inputTokens, outputTokens);\n vm.stopPrank();\n }\n\n function _fundMarketAndSelf(ICErc20 market, address whale) internal {\n IERC20Upgradeable token = IERC20Upgradeable(market.underlying());\n\n if (whale == address(0)) {\n whale = address(911);\n //vm.deal(address(token), whale, 100e18);\n }\n\n uint256 allTokens = token.balanceOf(whale);\n vm.prank(whale);\n token.transfer(address(this), allTokens / 20);\n\n if (market.getCash() < allTokens / 2) {\n _whitelistTestUser(whale);\n vm.startPrank(whale);\n token.approve(address(market), allTokens / 2);\n market.mint(allTokens / 2);\n vm.stopPrank();\n }\n }\n\n function _openLeveredPosition(\n address _positionOwner,\n uint256 _depositAmount\n ) internal returns (LeveredPosition _position, uint256 _maxRatio, uint256 _minRatio) {\n return _openLeveredPosition(_positionOwner, _depositAmount, address(0), \"\");\n }\n\n function _openLeveredPosition(\n address _positionOwner,\n uint256 _depositAmount,\n address _aggregatorTarget,\n bytes memory _aggregatorData\n ) internal returns (LeveredPosition _position, uint256 _maxRatio, uint256 _minRatio) {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(_positionOwner, _depositAmount);\n\n vm.startPrank(_positionOwner);\n collateralToken.approve(address(factory), _depositAmount);\n _position = factory.createAndFundPosition(\n collateralMarket,\n stableMarket,\n collateralToken,\n _depositAmount,\n _aggregatorTarget,\n _aggregatorData\n );\n vm.stopPrank();\n\n _maxRatio = _position.getMaxLeverageRatio();\n emit log_named_uint(\"max ratio\", _maxRatio);\n _minRatio = _position.getMinLeverageRatio();\n emit log_named_uint(\"min ratio\", _minRatio);\n\n assertGt(_maxRatio, _minRatio, \"max ratio <= min ratio\");\n }\n\n function testOpenLeveredPosition() public virtual whenForking {\n assertApproxEqRel(position.getCurrentLeverageRatio(), 1e18, 4e16, \"initial leverage ratio should be 1.0 (1e18)\");\n }\n\n function testAnyLeverageRatio(uint64 ratioDiff) public debuggingOnly whenForking {\n // ratioDiff is between 0 and 2^64 ~= 18.446e18\n uint256 targetLeverageRatio = 1e18 + uint256(ratioDiff);\n emit log_named_uint(\"fuzz max ratio\", maxLevRatio);\n emit log_named_uint(\"fuzz min ratio\", minLevRatio);\n emit log_named_uint(\"target ratio\", targetLeverageRatio);\n vm.assume(targetLeverageRatio < maxLevRatio);\n vm.assume(minLevRatio < targetLeverageRatio);\n\n uint256 borrowedAssetPrice = stableMarket.comptroller().oracle().getUnderlyingPrice(stableMarket);\n (uint256 sd, uint256 bd) = position.getAdjustmentAmountDeltas(targetLeverageRatio);\n emit log_named_uint(\"borrows delta val\", (bd * borrowedAssetPrice) / 1e18);\n emit log_named_uint(\"min borrow value\", ffd.getMinBorrowEth(stableMarket));\n\n uint256 equityAmount = position.getEquityAmount();\n emit log_named_uint(\"equity amount\", equityAmount);\n\n uint256 currentLeverageRatio = position.getCurrentLeverageRatio();\n emit log_named_uint(\"current ratio\", currentLeverageRatio);\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(targetLeverageRatio);\n emit log_named_uint(\"equity amount\", position.getEquityAmount());\n assertApproxEqRel(leverageRatioRealized, targetLeverageRatio, 4e16, \"target ratio not matching\");\n }\n\n function testMinMaxLeverageRatio() public virtual whenForking {\n assertGt(maxLevRatio, minLevRatio, \"max ratio <= min ratio\");\n\n // attempting to adjust to minLevRatio - 0.01 should fail\n vm.expectRevert(abi.encodeWithSelector(LeveredPosition.BorrowStableFailed.selector, 0x3fa));\n position.adjustLeverageRatio((minLevRatio + 1e18) / 2);\n // just testing\n position.adjustLeverageRatio(maxLevRatio);\n // but adjusting to the minLevRatio + 0.01 should succeed\n position.adjustLeverageRatio(minLevRatio + 0.01e18);\n }\n\n function testMaxLeverageRatio() public whenForking {\n uint256 _equityAmount = position.getEquityAmount();\n uint256 rate = lens.getBorrowRateAtRatio(collateralMarket, stableMarket, _equityAmount, maxLevRatio);\n emit log_named_uint(\"borrow rate at max ratio\", rate);\n\n position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(position.getCurrentLeverageRatio(), maxLevRatio, 4e16, \"target max ratio not matching\");\n }\n\n function testRewardsAccruedClaimed() public whenForking {\n address[] memory flywheels = position.pool().getRewardsDistributors();\n if (flywheels.length > 0) {\n vm.warp(block.timestamp + 60 * 60 * 24);\n vm.roll(block.number + 10000);\n\n (ERC20[] memory rewardTokens, uint256[] memory amounts) = position.getAccruedRewards();\n\n ERC20 rewardToken;\n bool atLeastOneAccrued = false;\n for (uint256 i = 0; i < amounts.length; i++) {\n atLeastOneAccrued = amounts[i] > 0;\n if (atLeastOneAccrued) {\n rewardToken = rewardTokens[i];\n emit log_named_address(\"accrued from reward token\", address(rewardTokens[i]));\n break;\n }\n }\n\n assertEq(atLeastOneAccrued, true, \"!should have accrued at least one reward token\");\n\n if (atLeastOneAccrued) {\n uint256 rewardsBalanceBefore = rewardToken.balanceOf(address(this));\n position.claimRewards();\n uint256 rewardsBalanceAfter = rewardToken.balanceOf(address(this));\n assertGt(rewardsBalanceAfter - rewardsBalanceBefore, 0, \"should have claimed some rewards\");\n }\n } else {\n emit log(\"no flywheels/rewards for the pair pool\");\n }\n }\n\n function testLeverMaxDown() public virtual whenForking {\n IERC20Upgradeable stableAsset = IERC20Upgradeable(stableMarket.underlying());\n IERC20Upgradeable collateralAsset = IERC20Upgradeable(collateralMarket.underlying());\n uint256 startingEquity = position.getEquityAmount();\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(leverageRatioRealized, maxLevRatio, 4e16, \"target ratio not matching\");\n\n // decrease the ratio in 10 equal steps\n uint256 ratioDiffStep = (maxLevRatio - 1e18) / 9;\n while (leverageRatioRealized > 1e18) {\n uint256 targetLeverDownRatio = leverageRatioRealized - ratioDiffStep;\n if (targetLeverDownRatio < minLevRatio) targetLeverDownRatio = 1e18;\n leverageRatioRealized = position.adjustLeverageRatio(targetLeverDownRatio);\n assertApproxEqRel(leverageRatioRealized, targetLeverDownRatio, 3e16, \"target lever down ratio not matching\");\n }\n\n uint256 withdrawAmount = position.closePosition();\n emit log_named_uint(\"withdraw amount\", withdrawAmount);\n assertApproxEqRel(startingEquity, withdrawAmount, 5e16, \"!withdraw amount\");\n\n assertEq(position.getEquityAmount(), 0, \"!nonzero equity amount\");\n assertEq(position.getCurrentLeverageRatio(), 0, \"!nonzero leverage ratio\");\n }\n}\n\ncontract WmaticMaticXLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 500e18;\n\n address wmaticMarket = 0xCb8D7c2690536d3444Da3d207f62A939483c8A93;\n address maticxMarket = 0x6ebdbEe1a509247B4A3ac3b73a43bd434C52C7c2;\n address wmaticWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;\n address maticxWhale = 0x72f0275444F2aF8dBf13F78D54A8D3aD7b6E68db;\n\n _configurePair(wmaticMarket, maticxMarket);\n _fundMarketAndSelf(ICErc20(wmaticMarket), wmaticWhale);\n _fundMarketAndSelf(ICErc20(maticxMarket), maticxWhale);\n\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n\n vm.startPrank(wmaticWhale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 100e18, stableToken);\n vm.stopPrank();\n vm.startPrank(maticxWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 100e18, collateralToken);\n vm.stopPrank();\n\n emit log_named_uint(\"slippage coll->stable\", registry.getSlippage(collateralToken, stableToken));\n emit log_named_uint(\"slippage stable->coll\", registry.getSlippage(stableToken, collateralToken));\n }\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public forkAtBlock(MODE_MAINNET, 16828444) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e17;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wethWhale = 0x9c29a8eC901DBec4fFf165cD57D4f9E03D4838f7;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wethMarket, USDCMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDCMarket), USDCWhale);\n\n vm.prank(factory.owner());\n factory._setWhitelistedSwapRouters(asArray(0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE));\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(\n address(this),\n depositAmount\n );\n }\n\n function testMinMaxLeverageRatio() public override whenForking {\n assertGt(maxLevRatio, minLevRatio, \"max ratio <= min ratio\");\n\n // attempting to adjust to minLevRatio - 0.01 should fail\n vm.expectRevert(abi.encodeWithSelector(LeveredPosition.BorrowStableFailed.selector, 0x3fa));\n position.adjustLeverageRatio(\n (minLevRatio + 1e18) / 2,\n 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE,\n hex\"4666fc8056e8074a96852217764bfb8bef8a9808d5bae23b61f080c55b5a3ef1648a8ab300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f3ff620e014ad62103d4dc6776033773c51109a900000000000000000000000000000000000000000000000001200f39320a6748000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e64000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000001242dde000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000122490411a32000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000000000000000000000000001242dde000000000000000000000000000000000000000000000000001200f39320a6748000000000000000000000000000000000000000000000000012181cad9873d5a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000003adf15f77f2911f84b0fe9dbdff43ef60d40012c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a84b924000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00006442000000000000000000000000000000000000060000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000381930c000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000f2e9c024f1c0b7a2a4ea11243c2d86a7b38dd72f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000959883000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f0001f442000000000000000000000000000000000000060000230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000009c92aa1d12de024e219884e133b58895c27d661000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000002ebfa8a000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000001f0f161fda2712db8b566946122a5af183995e2ed0000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000bafea3000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000000f0f161fda2712db8b566946122a5af183995e2ed00002500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000d8abc2be7ad5d17940112969973357a3a356299800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ef0f161fda2712db8b566946122a5af183995e2ed00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000004200000000000000000000000000000000000006000000000000000000000000922164bbbd36acf9e854acbbf32facc949fcaeef000000000000000000000000000000000000000000000000012181cad9873d5a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f9900000000000000000000000042000000000000000000000000000000000000060000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n 500 // 5% expected slippage\n );\n // just testing\n position.adjustLeverageRatio(\n maxLevRatio,\n 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE,\n hex\"4666fc8056e8074a96852217764bfb8bef8a9808d5bae23b61f080c55b5a3ef1648a8ab300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f3ff620e014ad62103d4dc6776033773c51109a900000000000000000000000000000000000000000000000001224952C44F2756000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e64000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000012F4FB2E00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000122490411a32000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000012F4FB2E00000000000000000000000000000000000000000000000001224952C44F275600000000000000000000000000000000000000000000000001224952C44F27560000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000003adf15f77f2911f84b0fe9dbdff43ef60d40012c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a84b924000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00006442000000000000000000000000000000000000060000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000381930c000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000f2e9c024f1c0b7a2a4ea11243c2d86a7b38dd72f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000959883000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f0001f442000000000000000000000000000000000000060000230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000009c92aa1d12de024e219884e133b58895c27d661000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000002ebfa8a000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000001f0f161fda2712db8b566946122a5af183995e2ed0000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000bafea3000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000000f0f161fda2712db8b566946122a5af183995e2ed00002500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000d8abc2be7ad5d17940112969973357a3a356299800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ef0f161fda2712db8b566946122a5af183995e2ed00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000004200000000000000000000000000000000000006000000000000000000000000922164bbbd36acf9e854acbbf32facc949fcaeef00000000000000000000000000000000000000000000000001224952C44F275600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f9900000000000000000000000042000000000000000000000000000000000000060000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n 500 // 5% expected slippage\n );\n // but adjusting to the minLevRatio + 0.01 should succeed\n position.adjustLeverageRatio(\n minLevRatio + 0.01e18,\n 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE,\n hex\"4666fc80badfecd760c6c3342ec44b52a0bf70879786ecf766397ce5f6ec4d503cdf1b1500000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f3ff620e014ad62103d4dc6776033773c51109a90000000000000000000000000000000000000000000000000000000011a2ae24000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c7848740000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c7848740000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000000000000000000000000000000118db1d3fed8ed300000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000d483bd37f9000142000000000000000000000000000000000000060001d988097fb8612cc24eec14542bc03424c656005f080118db1d3fed8ed30411b95df80147ae00019b57dca972db5d8866c630554acdbdfe58b2659c000000011231deb6f5749ef6ce6943a275a1d3e7486f4eae59725ade0301020401166de74b06010101020100060101030201ff0000000000000000000025ba258e510faca5ab7ff941a1584bdd2174c94d42000000000000000000000000000000000000063adf15f77f2911f84b0fe9dbdff43ef60d40012c00000000000000000000000000000000\",\n 500 // 1% expected slippage\n );\n }\n\n\n function testClosePositionWithAggregator() public whenForking {\n IERC20Upgradeable stableAsset = IERC20Upgradeable(stableMarket.underlying());\n IERC20Upgradeable collateralAsset = IERC20Upgradeable(collateralMarket.underlying());\n uint256 startingEquity = position.getEquityAmount();\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(\n maxLevRatio,\n 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE,\n hex\"4666fc8056e8074a96852217764bfb8bef8a9808d5bae23b61f080c55b5a3ef1648a8ab300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f3ff620e014ad62103d4dc6776033773c51109a900000000000000000000000000000000000000000000000001224952C44F2756000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e64000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000012690D7000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000122490411a32000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000012690D7000000000000000000000000000000000000000000000000001224952C44F275600000000000000000000000000000000000000000000000001224952C44F27560000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000003adf15f77f2911f84b0fe9dbdff43ef60d40012c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a84b924000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00006442000000000000000000000000000000000000060000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000381930c000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000f2e9c024f1c0b7a2a4ea11243c2d86a7b38dd72f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000959883000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f0001f442000000000000000000000000000000000000060000230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000009c92aa1d12de024e219884e133b58895c27d661000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000002ebfa8a000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000001f0f161fda2712db8b566946122a5af183995e2ed0000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000bafea3000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ed988097fb8612cc24eec14542bc03424c656005f000000f0f161fda2712db8b566946122a5af183995e2ed00002500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000d8abc2be7ad5d17940112969973357a3a356299800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ef0f161fda2712db8b566946122a5af183995e2ed00000042000000000000000000000000000000000000060000250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000004200000000000000000000000000000000000006000000000000000000000000922164bbbd36acf9e854acbbf32facc949fcaeef00000000000000000000000000000000000000000000000001224952C44F275600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f9900000000000000000000000042000000000000000000000000000000000000060000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n 900 // 9% expected slippage\n );\n assertApproxEqRel(leverageRatioRealized, maxLevRatio, 4e16, \"target ratio not matching\");\n\n uint256 withdrawAmount = position.closePosition(\n 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE,\n hex\"4666fc80be99f0486e2820a4df57daa8dd15555a292cd28c9a980b52f1a8b7b8dea3397b00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f3ff620e014ad62103d4dc6776033773c51109a9000000000000000000000000000000000000000000000000000000001254c0d4000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000000000000000000000000000000125a1a2e4bcc84e00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000122490411a32000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000125a1a2e4bcc84e000000000000000000000000000000000000000000000000000000001254c0d400000000000000000000000000000000000000000000000000000000126c55bd0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002c00000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000003adf15f77f2911f84b0fe9dbdff43ef60d40012c000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000eae7b583ca39d8000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e4200000000000000000000000000000000000006000064d988097fb8612cc24eec14542bc03424c656005f0000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000962e5982c1507af4ea5af2d6a25774f6e93b50d400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000002595b6a47246b000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e42000000000000000000000000000000000000060001f4f0f161fda2712db8b566946122a5af183995e2ed0000230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000d8abc2be7ad5d17940112969973357a3a35629980000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002a486d79008f88000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e4200000000000000000000000000000000000006000000f0f161fda2712db8b566946122a5af183995e2ed00002500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f990000000000000000000000004200000000000000000000000000000000000006000000000000000000000000f4c85269240c1d447309fa602a90ac23f1cb0dc000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000643afe5f00010000000000000000000000f4c85269240c1d447309fa602a90ac23f1cb0dc00000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000f0f161fda2712db8b566946122a5af183995e2ed00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000009c92aa1d12de024e219884e133b58895c27d661000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ba6c1933235feca781fe896562895adb59dedb8c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002ef0f161fda2712db8b566946122a5af183995e2ed000001d988097fb8612cc24eec14542bc03424c656005f0000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f000000000000000000000000922164bbbd36acf9e854acbbf32facc949fcaeef00000000000000000000000000000000000000000000000000000000126c55bd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n 100 // 1% expected slippage\n );\n emit log_named_uint(\"withdraw amount\", withdrawAmount);\n assertApproxEqRel(startingEquity, withdrawAmount, 5e16, \"!withdraw amount\");\n\n assertEq(position.getEquityAmount(), 0, \"!nonzero equity amount\");\n assertEq(position.getCurrentLeverageRatio(), 0, \"!nonzero leverage ratio\");\n }\n}\n\ncontract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wethWhale = 0x9c29a8eC901DBec4fFf165cD57D4f9E03D4838f7;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n\n _configurePair(wethMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wbtcWhale = 0x3f3429D28438Cc14133966820b8A9Ea61Cf1D4F0;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n IERC20Upgradeable token = IERC20Upgradeable(ICErc20(wbtcMarket).underlying());\n\n _configurePair(wbtcMarket, USDCMarket);\n\n uint256 allTokens = token.balanceOf(wbtcWhale);\n\n vm.prank(wbtcWhale);\n token.transfer(address(this), allTokens);\n vm.stopPrank();\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wbtcWhale = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wbtcMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wbtcMarket), wbtcWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address usdcMarket = 0xa900A17a49Bc4D442bA7F72c39FA2108865671f0;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n\n {\n IERC20Upgradeable x = IERC20Upgradeable(ICErc20(hyUsdMarket).underlying());\n IERC20Upgradeable y = IERC20Upgradeable(ICErc20(usdcMarket).underlying());\n IERC20Upgradeable[] memory xToYPath = new IERC20Upgradeable[](2);\n IERC20Upgradeable[] memory yToXPath = new IERC20Upgradeable[](2);\n\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n xToYPath[0] = eUSD;\n yToXPath[0] = eUSD;\n xToYPath[1] = y;\n yToXPath[1] = x;\n\n vm.startPrank(registry.owner());\n registry._setOptimalSwapPath(IERC20Upgradeable(x), IERC20Upgradeable(y), xToYPath);\n registry._setOptimalSwapPath(IERC20Upgradeable(y), IERC20Upgradeable(x), yToXPath);\n vm.stopPrank();\n }\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePair(hyUsdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDeUSDLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address eUsdMarket = 0x9c2A4f9c5471fd36bE3BBd8437A33935107215A1;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address eUsdWhale = 0xa9E0588E82E9Ee1440f7e5375970a429D09646c1;\n AerodromeV2Liquidator aerodomeV2Liquidator = AerodromeV2Liquidator(0xD46b85409C43571145206B11D370A62AaeB22475);\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(hyUsdMarket, eUsdMarket, IRedemptionStrategy(address(aerodomeV2Liquidator)));\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(eUsdMarket), eUsdWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract WSuperOETHWETHLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n address wsuperOeth = 0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6;\n address weth = 0x4200000000000000000000000000000000000006;\n\n uint256 depositAmount = 1e18;\n\n address wsuperOethMarket = 0xC462eb5587062e2f2391990b8609D2428d8Cf598;\n address wethMarket = 0x49420311B518f3d0c94e897592014de53831cfA3;\n address wsuperOethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address wethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(wethMarket);\n\n uint256[] memory newSupplyCaps = new uint256[](1);\n newSupplyCaps[0] = 1e36;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(cTokens, newSupplyCaps);\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n vm.prank(registry.owner());\n registry._setWrappedToUnwrapped4626(address(wsuperOeth), address(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3));\n // vm.prank(aerodomeClLiquidator.owner());\n // emit log_named_address(\"wsuperOeth\", address(wsuperOeth));\n // aerodomeClLiquidator.setWrappedToUnwrapped(\n // address(wsuperOeth),\n // 0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3\n // );\n _configurePairAndLiquidator(wsuperOethMarket, wethMarket, IRedemptionStrategy(address(aerodomeClLiquidator)));\n _fundMarketAndSelf(ICErc20(wsuperOethMarket), wsuperOethWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\n/*\ncontract XYLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(X_CHAIN_ID) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address xMarket = 0x...1;\n address yMarket = 0x...2;\n address xWhale = 0x...3;\n address yWhale = 0x...4;\n\n IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(xMarket, yMarket, liquidator);\n _fundMarketAndSelf(ICErc20(xMarket), xWhale);\n _fundMarketAndSelf(ICErc20(yMarket), yWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n*/\n" + }, + "contracts/test/liquidators/AaveTokenLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport \"../../liquidators/AaveTokenLiquidator.sol\";\n\ncontract AaveTokenLiquidatorTest is BaseTest {\n AaveTokenLiquidator public liquidator;\n address stable;\n address amUsdc = 0x1a13F4Ca1d028320A707D99520AbFefca3998b7F;\n uint256 inputAmount;\n\n function afterForkSetUp() internal override {\n liquidator = new AaveTokenLiquidator();\n stable = ap.getAddress(\"stableToken\");\n }\n\n function testAmUsdcPolygon() public fork(POLYGON_MAINNET) {\n address amUsdcWhale = 0xe8599F3cc5D38a9aD6F3684cd5CEa72f10Dbc383; // curve pool\n inputAmount = 1000e6;\n\n IERC20Upgradeable amUsdcToken = IERC20Upgradeable(amUsdc);\n vm.prank(amUsdcWhale);\n amUsdcToken.transfer(address(liquidator), inputAmount);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n amUsdcToken,\n inputAmount,\n abi.encode(stable)\n );\n\n assertEq(address(outputToken), stable, \"!usdc output\");\n assertApproxEqRel(outputAmount, inputAmount, 8e16, \"!output does not match input\");\n }\n}\n" + }, + "contracts/test/liquidators/AlgebraSwapLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport \"../../liquidators/AlgebraSwapLiquidator.sol\";\n\ncontract AlgebraSwapLiquidatorTest is BaseTest {\n AlgebraSwapLiquidator public liquidator;\n address algebraSwapRouter = 0x327Dd3208f0bCF590A66110aCB6e5e6941A4EfA0;\n address ankrBnbAddress = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n address wbnbAddress = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;\n uint256 inputAmount = 1e18;\n\n function afterForkSetUp() internal override {\n liquidator = new AlgebraSwapLiquidator();\n }\n\n function testAlgebraAnkrBnbWbnb() public fork(BSC_MAINNET) {\n address ankrBnbWhale = 0x366B523317Cc95B1a4D30b33f8637882825C5E23;\n\n IERC20Upgradeable ankr = IERC20Upgradeable(ankrBnbAddress);\n vm.prank(ankrBnbWhale);\n ankr.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n ankr,\n inputAmount,\n abi.encode(wbnbAddress, algebraSwapRouter)\n );\n\n assertEq(address(outputToken), wbnbAddress, \"!wbnb output\");\n assertApproxEqRel(outputAmount, inputAmount, 8e16, \"!wbnb amount\");\n }\n\n function testAlgebraWbnbAnkrBnb() public fork(BSC_MAINNET) {\n address wbnbWhale = 0x36696169C63e42cd08ce11f5deeBbCeBae652050;\n\n IERC20Upgradeable wbnb = IERC20Upgradeable(wbnbAddress);\n vm.prank(wbnbWhale);\n wbnb.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n wbnb,\n inputAmount,\n abi.encode(ankrBnbAddress, algebraSwapRouter)\n );\n\n assertEq(address(outputToken), ankrBnbAddress, \"!ankrbnb output\");\n assertApproxEqRel(outputAmount, inputAmount, 8e16, \"!ankrbnb amount\");\n }\n\n function testModeKimV4RedemptionStrategy() public fork(MODE_MAINNET) {\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ezEthWhale = 0x2344F131B07E6AFd943b0901C55898573F0d1561;\n address kimV4Router = 0xAc48FcF1049668B285f3dC72483DF5Ae2162f7e8;\n address modeWETH = ap.getAddress(\"wtoken\");\n\n IERC20Upgradeable ezETH = IERC20Upgradeable(MODE_EZETH);\n vm.prank(ezEthWhale);\n ezETH.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n ezETH,\n inputAmount,\n abi.encode(modeWETH, kimV4Router)\n );\n\n assertEq(address(outputToken), modeWETH, \"!WETH output token\");\n assertApproxEqRel(outputAmount, inputAmount, 8e16, \"!weth amount\");\n }\n}\n" + }, + "contracts/test/liquidators/BalancerLpTokenLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { BalancerLpTokenLiquidator } from \"../../liquidators/BalancerLpTokenLiquidator.sol\";\nimport { BalancerSwapLiquidator } from \"../../liquidators/BalancerSwapLiquidator.sol\";\n\nimport { ICErc20Compound as ICErc20 } from \"../../external/compound/ICErc20.sol\";\nimport \"../../external/balancer/IBalancerPool.sol\";\nimport \"../../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract BalancerLpTokenLiquidatorTest is BaseTest {\n BalancerLpTokenLiquidator private lpTokenLiquidator;\n BalancerSwapLiquidator private swapLiquidator;\n address stable;\n address wtoken;\n\n function afterForkSetUp() internal override {\n lpTokenLiquidator = new BalancerLpTokenLiquidator();\n swapLiquidator = new BalancerSwapLiquidator();\n stable = ap.getAddress(\"stableToken\");\n wtoken = ap.getAddress(\"wtoken\");\n }\n\n function testRedeemLpToken(\n address whaleAddress,\n address inputTokenAddress,\n address outputTokenAddress\n ) internal {\n return testBalancerLpTokenLiquidator(lpTokenLiquidator, 1e18, whaleAddress, inputTokenAddress, outputTokenAddress);\n }\n\n function testBalancerLpTokenLiquidator(\n IRedemptionStrategy liquidator,\n uint256 amount,\n address whaleAddress,\n address inputTokenAddress,\n address outputTokenAddress\n ) internal {\n IERC20Upgradeable inputToken = IERC20Upgradeable(inputTokenAddress);\n IERC20Upgradeable outputToken = IERC20Upgradeable(outputTokenAddress);\n\n vm.prank(whaleAddress);\n inputToken.transfer(address(liquidator), amount);\n\n uint256 balanceBefore = outputToken.balanceOf(address(liquidator));\n\n bytes memory data = abi.encode(address(outputToken));\n liquidator.redeem(inputToken, amount, data);\n\n uint256 balanceAfter = outputToken.balanceOf(address(liquidator));\n\n assertGt(balanceAfter - balanceBefore, 0, \"!redeem input token\");\n }\n\n function testBalancerSwapLiquidator(\n uint256 amount,\n address whaleAddress,\n address inputTokenAddress,\n address outputTokenAddress,\n address pool\n ) internal {\n IERC20Upgradeable inputToken = IERC20Upgradeable(inputTokenAddress);\n IERC20Upgradeable outputToken = IERC20Upgradeable(outputTokenAddress);\n\n vm.prank(whaleAddress);\n inputToken.transfer(address(swapLiquidator), amount);\n\n uint256 balanceBefore = outputToken.balanceOf(address(swapLiquidator));\n\n bytes memory data = abi.encode(outputTokenAddress, pool);\n swapLiquidator.redeem(inputToken, amount, data);\n\n uint256 balanceAfter = outputToken.balanceOf(address(swapLiquidator));\n\n assertGt(balanceAfter - balanceBefore, 0, \"!swap input token\");\n }\n\n function testMimoParBalancerLpLiquidatorRedeem() public fork(POLYGON_MAINNET) {\n address lpToken = 0x82d7f08026e21c7713CfAd1071df7C8271B17Eae; //MIMO-PAR 8020\n address lpTokenWhale = 0xbB60ADbe38B4e6ab7fb0f9546C2C1b665B86af11;\n address outputTokenAddress = 0xE2Aa7db6dA1dAE97C5f5C6914d285fBfCC32A128; // PAR\n\n testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);\n }\n\n function testWmaticStmaticLPLiquidatorRedeem() public fork(POLYGON_MAINNET) {\n address lpToken = 0x8159462d255C1D24915CB51ec361F700174cD994; // stMATIC-WMATIC stable\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2\n address outputTokenAddress = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // WMATIC\n\n testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);\n }\n\n function testWmaticMaticXLPLiquidatorRedeem() public fork(POLYGON_MAINNET) {\n address lpToken = 0xC17636e36398602dd37Bb5d1B3a9008c7629005f; // WMATIC-MaticX stable\n address lpTokenWhale = 0x48534d027f8962692122dB440714fFE88Ab1fA85;\n address outputTokenAddress = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // WMATIC\n\n testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);\n }\n\n function testJbrlBrzLiquidatorRedeem() public fork(POLYGON_MAINNET) {\n address lpToken = 0xE22483774bd8611bE2Ad2F4194078DaC9159F4bA; // jBRL-BRZ stable\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2\n address outputTokenAddress = 0xf2f77FE7b8e66571E0fca7104c4d670BF1C8d722; // jBRL\n\n testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);\n }\n\n function testBoostedAaveRedeem() public fork(POLYGON_MAINNET) {\n address inputToken = 0x48e6B98ef6329f8f0A30eBB8c7C960330d648085; // bb-am-USD\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2\n address outputTokenAddress = 0xF93579002DBE8046c43FEfE86ec78b1112247BB8; // linear aaver usdc\n testRedeemLpToken(lpTokenWhale, inputToken, outputTokenAddress);\n }\n\n function testWmaticStmaticLiquidatorRedeem() public fork(POLYGON_MAINNET) {\n address inputToken = 0x8159462d255C1D24915CB51ec361F700174cD994; // Balancer stMATIC Stable Pool\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Gauge\n address outputTokenAddress = wtoken;\n testRedeemLpToken(lpTokenWhale, inputToken, outputTokenAddress);\n }\n\n function testBoostedAaaveWmaticMaticXRedeem() public fork(POLYGON_MAINNET) {\n address inputToken = 0xE78b25c06dB117fdF8F98583CDaaa6c92B79E917; // Balancer MaticX Boosted Aave WMATIC StablePool\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Gauge\n address outputTokenAddress = 0xE4885Ed2818Cc9E840A25f94F9b2A28169D1AEA7; // aave-linear-wmatic\n testRedeemLpToken(lpTokenWhale, inputToken, outputTokenAddress);\n }\n\n function testLinearAaaveWmaticRedeem() public fork(POLYGON_MAINNET) {\n uint256 amount = 1e18;\n address inputToken = 0xE4885Ed2818Cc9E840A25f94F9b2A28169D1AEA7; // aave-linear-wmatic\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Gauge\n address outputTokenAddress = wtoken;\n address pool = inputToken; // use own for swap\n testBalancerSwapLiquidator(amount, lpTokenWhale, inputToken, outputTokenAddress, pool);\n }\n\n function testLinearAaveUsdcRedeem() public fork(POLYGON_MAINNET) {\n uint256 amount = 1e18;\n address inputToken = 0xF93579002DBE8046c43FEfE86ec78b1112247BB8; // bb-am-USD\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer Gauge\n address outputTokenAddress = stable; // usdc\n address pool = inputToken; // use own for swap\n testBalancerSwapLiquidator(amount, lpTokenWhale, inputToken, outputTokenAddress, pool);\n }\n\n function testSwapWmaticStMatic() public fork(POLYGON_MAINNET) {\n uint256 amount = 1000e18;\n address pool = 0x8159462d255C1D24915CB51ec361F700174cD994; // wmatic-stmatic\n address inputToken = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // wmatic\n address inputTokenWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97; // aave wmatic\n address outputToken = 0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4; // stmatic\n\n testBalancerSwapLiquidator(amount, inputTokenWhale, inputToken, outputToken, pool);\n }\n}\n" + }, + "contracts/test/liquidators/CurveLpTokenLiquidatorNoRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { CurveLpTokenLiquidatorNoRegistry, CurveLpTokenWrapper } from \"../../liquidators/CurveLpTokenLiquidatorNoRegistry.sol\";\nimport { CurveLpTokenPriceOracleNoRegistry } from \"../../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract CurveLpTokenLiquidatorNoRegistryTest is BaseTest {\n CurveLpTokenLiquidatorNoRegistry private liquidator;\n\n IERC20Upgradeable twobrl = IERC20Upgradeable(0x1B6E11c5DB9B15DE87714eA9934a6c52371CfEA9);\n IERC20Upgradeable lpToken3Eps = IERC20Upgradeable(0xaF4dE8E872131AE328Ce21D909C74705d3Aaf452);\n\n address pool3Eps = 0x160CAed03795365F3A589f10C379FfA7d75d4E76;\n address pool2Brl = 0xad51e40D8f255dba1Ad08501D6B1a6ACb7C188f3;\n\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle;\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle;\n\n IERC20Upgradeable bUSD;\n address wtoken;\n\n function afterForkSetUp() internal override {\n wtoken = ap.getAddress(\"wtoken\");\n liquidator = new CurveLpTokenLiquidatorNoRegistry();\n bUSD = IERC20Upgradeable(ap.getAddress(\"bUSD\"));\n curveV1Oracle = CurveLpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveLpTokenPriceOracleNoRegistry\"));\n curveV2Oracle = CurveV2LpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveV2LpTokenPriceOracleNoRegistry\"));\n }\n\n function testRedeemToken() public fork(BSC_MAINNET) {\n address lpTokenWhale = 0x8D7408C2b3154F9f97fc6dd24cd36143908d1E52;\n vm.prank(lpTokenWhale);\n lpToken3Eps.transfer(address(liquidator), 1234);\n\n bytes memory data = abi.encode(bUSD, wtoken, curveV1Oracle);\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(lpToken3Eps, 1234, data);\n\n assertEq(address(outputToken), address(bUSD), \"!outputToken\");\n assertGt(outputAmount, 0, \"!outputAmount>0\");\n assertEq(outputToken.balanceOf(address(liquidator)), outputAmount, \"!outputAmount\");\n }\n\n function testRedeem2Brl() public fork(BSC_MAINNET) {\n address jbrl = 0x316622977073BBC3dF32E7d2A9B3c77596a0a603;\n address whale2brl = 0x6219b46d6a5B5BfB4Ec433a9F96DB3BF4076AEE1;\n vm.prank(whale2brl);\n twobrl.transfer(address(liquidator), 123456);\n\n address poolOf2Brl = curveV1Oracle.poolOf(address(twobrl)); // 0xad51e40D8f255dba1Ad08501D6B1a6ACb7C188f3\n\n require(poolOf2Brl != address(0), \"could not find the pool for 2brl\");\n\n bytes memory data = abi.encode(jbrl, wtoken, curveV1Oracle);\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(twobrl, 123456, data);\n assertEq(address(outputToken), jbrl);\n assertGt(outputAmount, 0);\n assertEq(outputToken.balanceOf(address(liquidator)), outputAmount);\n }\n\n address maiAddress = 0xa3Fa99A148fA48D14Ed51d610c367C61876997F1;\n address whaleMai = 0xC63c477465a792537D291ADb32Ed15c0095E106B;\n address whaleMai3Crv = 0x96c62EC93c552b60d2a7F0801313A29E4B8feecE;\n address mai3Crv = 0x447646e84498552e62eCF097Cc305eaBFFF09308;\n IERC20Upgradeable mai3CrvToken = IERC20Upgradeable(mai3Crv);\n\n // Not set up / deployed\n // function testRedeemMai3Crv() public fork(POLYGON_MAINNET) {\n // vm.prank(whaleMai3Crv);\n // mai3Crv.transfer(address(liquidator), 1.23456e18);\n\n // bytes memory data = abi.encode(maiAddress, wtoken, curveV1Oracle);\n // (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(mai3Crv, 1.23456e18, data);\n // assertEq(address(outputToken), maiAddress);\n // assertGt(outputAmount, 0);\n // assertEq(outputToken.balanceOf(address(liquidator)), outputAmount);\n // }\n\n function testCurveLpTokenWrapper() public fork(POLYGON_MAINNET) {\n IERC20Upgradeable mai = IERC20Upgradeable(maiAddress);\n CurveLpTokenWrapper wrapper = new CurveLpTokenWrapper();\n vm.prank(whaleMai);\n mai.transfer(address(wrapper), 1e18);\n\n wrapper.redeem(mai, 1e18, abi.encode(mai3Crv, mai3Crv));\n\n assertGt(mai3CrvToken.balanceOf(address(wrapper)), 0, \"!wrapped\");\n assertEq(mai.balanceOf(address(wrapper)), 0, \"!unused mai\");\n }\n\n function test3CrvWrapMai3Crv() public fork(POLYGON_MAINNET) {\n address threeCrvWhale = 0x7117de93b352AE048925323F3fCb1Cd4b4d52eC4;\n address threeCrvAddress = 0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171;\n\n IERC20Upgradeable threeCrv = IERC20Upgradeable(threeCrvAddress);\n\n CurveLpTokenWrapper wrapper = new CurveLpTokenWrapper();\n vm.prank(threeCrvWhale);\n threeCrv.transfer(address(wrapper), 1e18);\n\n wrapper.redeem(threeCrv, 1e18, abi.encode(mai3Crv, mai3Crv)); // pool = token\n\n assertGt(mai3CrvToken.balanceOf(address(wrapper)), 0, \"!wrapped\");\n assertEq(threeCrv.balanceOf(address(wrapper)), 0, \"!unused 3Crv\");\n }\n}\n" + }, + "contracts/test/liquidators/CurveSwapLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ICurvePool } from \"../../external/curve/ICurvePool.sol\";\nimport { CurveSwapLiquidatorFunder } from \"../../liquidators/CurveSwapLiquidatorFunder.sol\";\n\nimport { CurveLpTokenPriceOracleNoRegistry } from \"../../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract CurveSwapLiquidatorTest is BaseTest {\n CurveSwapLiquidatorFunder private csl;\n address private maiAddress = 0x3F56e0c36d275367b8C502090EDF38289b3dEa0d;\n address private val3EPSAddress = 0x5b5bD8913D766D005859CE002533D4838B0Ebbb5;\n\n address private lpTokenMai3EPS = 0x80D00D2c8d920a9253c3D65BA901250a55011b37;\n address private poolAddress = 0x68354c6E8Bbd020F9dE81EAf57ea5424ba9ef322;\n\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle;\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle;\n\n function afterForkSetUp() internal override {\n csl = new CurveSwapLiquidatorFunder();\n curveV1Oracle = CurveLpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveLpTokenPriceOracleNoRegistry\"));\n curveV2Oracle = CurveV2LpTokenPriceOracleNoRegistry(ap.getAddress(\"CurveV2LpTokenPriceOracleNoRegistry\"));\n\n if (address(curveV1Oracle) == address(0)) {\n address[][] memory _poolUnderlyings = new address[][](1);\n _poolUnderlyings[0] = asArray(maiAddress, val3EPSAddress);\n curveV1Oracle = new CurveLpTokenPriceOracleNoRegistry();\n curveV1Oracle.initialize(asArray(lpTokenMai3EPS), asArray(poolAddress), _poolUnderlyings);\n }\n }\n\n // Curve pools need to be configured in the CurveV1 or CurveV2 oracles\n // We have not deployed CurveV2 oracle yet\n function testSwapCurveV1UsdtUsdc() public debuggingOnly fork(ARBITRUM_ONE) {\n address usdtAddress = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9;\n address usdcAddress = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8;\n address usdtWhale = 0xB38e8c17e38363aF6EbdCb3dAE12e0243582891D; // binance\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(usdtAddress);\n uint256 inputAmount = 150e6;\n\n bytes memory data = abi.encode(curveV1Oracle, curveV2Oracle, usdtAddress, usdcAddress, ap.getAddress(\"wtoken\"));\n\n vm.prank(usdtWhale);\n inputToken.transfer(address(csl), inputAmount);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = csl.redeem(inputToken, inputAmount, data);\n\n assertEq(address(outputToken), usdcAddress, \"output token does not match\");\n assertApproxEqAbs(outputAmount, inputAmount, 1e5, \"output amount does not match\");\n }\n\n function testSwapCurveV2EspBnbxBnb() public fork(BSC_MAINNET) {\n address bnbxAddress = 0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275;\n address wbnb = ap.getAddress(\"wtoken\");\n address bnbxWhale = 0x4eE98B27eeF58844E460922eC9Da7C05D32F284A;\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(bnbxAddress);\n uint256 inputAmount = 3e18;\n\n bytes memory data = abi.encode(curveV1Oracle, curveV2Oracle, bnbxAddress, wbnb, wbnb);\n\n vm.prank(bnbxWhale);\n inputToken.transfer(address(csl), inputAmount);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = csl.redeem(inputToken, inputAmount, data);\n\n assertEq(address(outputToken), wbnb, \"output token does not match\");\n assertApproxEqRel(outputAmount, inputAmount, 8e16, \"output amount does not match\");\n }\n\n function testRedeemMAI() public fork(BSC_MAINNET) {\n ICurvePool curvePool = ICurvePool(poolAddress);\n\n assertEq(maiAddress, curvePool.coins(0), \"coin 0 must be MAI\");\n assertEq(val3EPSAddress, curvePool.coins(1), \"coin 1 must be val3EPS\");\n\n uint256 inputAmount = 1e10;\n\n uint256 maiForVal3EPS = curvePool.get_dy(0, 1, inputAmount);\n emit log_uint(maiForVal3EPS);\n\n dealMai(address(csl), inputAmount);\n\n bytes memory data = abi.encode(curveV1Oracle, address(0), maiAddress, val3EPSAddress, ap.getAddress(\"wtoken\"));\n (IERC20Upgradeable shouldBeVal3EPS, uint256 outputAmount) = csl.redeem(\n IERC20Upgradeable(maiAddress),\n inputAmount,\n data\n );\n assertEq(address(shouldBeVal3EPS), val3EPSAddress, \"output token does not match\");\n\n assertEq(maiForVal3EPS, outputAmount, \"output amount does not match\");\n }\n\n function testEstimateInputAmount() public fork(BSC_MAINNET) {\n ICurvePool curvePool = ICurvePool(poolAddress);\n\n assertEq(maiAddress, curvePool.coins(0), \"coin 0 must be MAI\");\n assertEq(val3EPSAddress, curvePool.coins(1), \"coin 1 must be val3EPS\");\n\n bytes memory data = abi.encode(curveV1Oracle, address(0), maiAddress, val3EPSAddress, ap.getAddress(\"wtoken\"));\n\n (IERC20Upgradeable inputToken, uint256 inputAmount) = csl.estimateInputAmount(2e10, data);\n\n emit log(\"input\");\n emit log_uint(inputAmount);\n emit log_address(address(inputToken));\n uint256 shouldBeAround2e10 = curvePool.get_dy(1, 0, inputAmount);\n emit log(\"should be around 2e10\");\n emit log_uint(shouldBeAround2e10);\n assertTrue(shouldBeAround2e10 >= 20e9 && shouldBeAround2e10 <= 23e9, \"rough estimate didn't work\");\n }\n\n function dealMai(address to, uint256 amount) internal {\n address whale = 0xc412eCccaa35621cFCbAdA4ce203e3Ef78c4114a; // anyswap\n vm.prank(whale);\n IERC20Upgradeable(maiAddress).transfer(to, amount);\n }\n}\n" + }, + "contracts/test/liquidators/GammaLpTokenLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { GammaAlgebraLpTokenLiquidator, GammaAlgebraLpTokenWrapper } from \"../../liquidators/gamma/GammaAlgebraLpTokenLiquidator.sol\";\nimport { GammaUniswapV3LpTokenLiquidator, GammaUniswapV3LpTokenWrapper } from \"../../liquidators/gamma/GammaUniswapV3LpTokenLiquidator.sol\";\nimport { IHypervisor } from \"../../external/gamma/IHypervisor.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract GammaLpTokenLiquidatorTest is BaseTest {\n GammaAlgebraLpTokenLiquidator public aLiquidator;\n GammaUniswapV3LpTokenLiquidator public uLiquidator;\n GammaAlgebraLpTokenWrapper aWrapper;\n GammaUniswapV3LpTokenWrapper uWrapper;\n\n address uniV3SwapRouter;\n address algebraSwapRouter;\n address uniProxyAlgebra;\n address uniProxyUni;\n address wtoken;\n\n function afterForkSetUp() internal override {\n aLiquidator = new GammaAlgebraLpTokenLiquidator();\n uLiquidator = new GammaUniswapV3LpTokenLiquidator();\n aWrapper = new GammaAlgebraLpTokenWrapper();\n uWrapper = new GammaUniswapV3LpTokenWrapper();\n wtoken = ap.getAddress(\"wtoken\");\n if (block.chainid == POLYGON_MAINNET) {\n uniProxyAlgebra = 0xA42d55074869491D60Ac05490376B74cF19B00e6;\n uniProxyUni = 0xDC8eE75f52FABF057ae43Bb4B85C55315b57186c;\n uniV3SwapRouter = 0x1891783cb3497Fdad1F25C933225243c2c7c4102; // Retro\n algebraSwapRouter = 0xf5b509bB0909a69B1c207E495f687a596C168E12; // QS\n }\n }\n\n function testGammaUniswapV3LpTokenLiquidator() public fork(POLYGON_MAINNET) {\n uint256 withdrawAmount = 1e18;\n\n address WMATIC_WETH_RETRO_GAMMA_VAULT = 0xe7806B5ba13d4B2Ab3EaB3061cB31d4a4F3390Aa;\n address WMATIC_WETH_RETRO_WHALE = 0xcb7c356b9287DeC7d36923238F53e6C955bfE778;\n\n IHypervisor vault = IHypervisor(WMATIC_WETH_RETRO_GAMMA_VAULT);\n vm.prank(WMATIC_WETH_RETRO_WHALE);\n vault.transfer(address(uLiquidator), withdrawAmount);\n\n address outputTokenAddress = ap.getAddress(\"wtoken\"); // WMATIC\n bytes memory strategyData = abi.encode(outputTokenAddress, uniV3SwapRouter);\n (, uint256 outputAmount) = uLiquidator.redeem(vault, withdrawAmount, strategyData);\n\n emit log_named_uint(\"wmatic redeemed\", outputAmount);\n assertGt(outputAmount, 0, \"!failed to withdraw and swap\");\n }\n\n function testGammaAlgebraLpTokenLiquidator() public fork(POLYGON_MAINNET) {\n uint256 withdrawAmount = 1e18;\n address DAI_GNS_QS_GAMMA_VAULT = 0x7aE7FB44c92B4d41abB6E28494f46a2EB3c2a690;\n address DAI_GNS_QS_WHALE = 0x20ec0d06F447d550fC6edee42121bc8C1817b97D;\n\n IHypervisor vault = IHypervisor(DAI_GNS_QS_GAMMA_VAULT);\n vm.prank(DAI_GNS_QS_WHALE);\n vault.transfer(address(aLiquidator), withdrawAmount);\n\n address outputTokenAddress = ap.getAddress(\"wtoken\"); // WMATIC\n bytes memory strategyData = abi.encode(outputTokenAddress, algebraSwapRouter);\n (, uint256 outputAmount) = aLiquidator.redeem(vault, withdrawAmount, strategyData);\n\n emit log_named_uint(\"wbnb redeemed\", outputAmount);\n assertGt(outputAmount, 0, \"!failed to withdraw and swap\");\n }\n\n function testGammaLpTokenWrapperWmatic() public fork(POLYGON_MAINNET) {\n address WMATIC_WETH_QS_GAMMA_VAULT = 0x02203f2351E7aC6aB5051205172D3f772db7D814;\n IHypervisor vault = IHypervisor(WMATIC_WETH_QS_GAMMA_VAULT);\n address wtokenWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;\n address wethAddress = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619;\n\n vm.prank(wtokenWhale);\n IERC20Upgradeable(wtoken).transfer(address(aWrapper), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = aWrapper.redeem(\n IERC20Upgradeable(wtoken),\n 1e18,\n abi.encode(algebraSwapRouter, uniProxyAlgebra, vault)\n );\n\n emit log_named_uint(\"lp tokens minted\", outputAmount);\n\n assertGt(outputToken.balanceOf(address(aWrapper)), 0, \"!wrapped\");\n assertEq(IERC20Upgradeable(wtoken).balanceOf(address(aWrapper)), 0, \"!unused wtoken\");\n assertEq(IERC20Upgradeable(wethAddress).balanceOf(address(aWrapper)), 0, \"!unused usdt\");\n }\n\n function testGammaLpTokenWrapperUsdt() public fork(POLYGON_MAINNET) {\n address ETH_USDT_QS_GAMMA_VAULT = 0x5928f9f61902b139e1c40cBa59077516734ff09f; // Wide\n IHypervisor vault = IHypervisor(ETH_USDT_QS_GAMMA_VAULT);\n address usdtAddress = 0xc2132D05D31c914a87C6611C10748AEb04B58e8F;\n address usdtWhale = 0x0639556F03714A74a5fEEaF5736a4A64fF70D206;\n IERC20Upgradeable usdt = IERC20Upgradeable(usdtAddress);\n\n vm.prank(usdtWhale);\n usdt.transfer(address(aWrapper), 1e6);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = aWrapper.redeem(\n usdt,\n 1e6,\n abi.encode(algebraSwapRouter, uniProxyAlgebra, vault)\n );\n\n emit log_named_uint(\"lp tokens minted\", outputAmount);\n\n assertGt(outputToken.balanceOf(address(aWrapper)), 0, \"!wrapped\");\n assertEq(IERC20Upgradeable(wtoken).balanceOf(address(aWrapper)), 0, \"!unused wtoken\");\n assertEq(usdt.balanceOf(address(aWrapper)), 0, \"!unused usdt\");\n }\n\n function testGammaUniV3LpTokenWrapper() public fork(POLYGON_MAINNET) {\n address USDC_CASH_GAMMA_VAULT = 0x64e14623CA543b540d0bA80477977f7c2c00a7Ea;\n IHypervisor vault = IHypervisor(USDC_CASH_GAMMA_VAULT);\n address usdcAddress = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;\n address usdcWhale = 0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245;\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcAddress);\n\n vm.prank(usdcWhale);\n usdc.transfer(address(uWrapper), 1e6);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = uWrapper.redeem(\n usdc,\n 1e6,\n abi.encode(uniV3SwapRouter, uniProxyUni, vault)\n );\n\n emit log_named_uint(\"lp tokens minted\", outputAmount);\n\n assertGt(outputToken.balanceOf(address(uWrapper)), 0, \"!wrapped\");\n assertEq(IERC20Upgradeable(wtoken).balanceOf(address(uWrapper)), 0, \"!unused wtoken\");\n assertEq(usdc.balanceOf(address(uWrapper)), 0, \"!unused usdc\");\n }\n\n function testUsdcWethGammaUniV3LpTokenWrapper() public debuggingOnly fork(POLYGON_MAINNET) {\n address USDC_WETH_RETRO_GAMMA_VAULT = 0xe058e1FfFF9B13d3FCd4803FDb55d1Cc2fe07DDC;\n address usdcAddress = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;\n address usdcWhale = 0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245;\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcAddress);\n\n vm.prank(usdcWhale);\n usdc.transfer(address(uWrapper), 9601.830212e6);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = uWrapper.redeem(\n usdc,\n 9601.830212e6,\n abi.encode(uniV3SwapRouter, uniProxyUni, USDC_WETH_RETRO_GAMMA_VAULT)\n );\n\n emit log_named_uint(\"lp tokens minted\", outputAmount);\n\n assertGt(outputToken.balanceOf(address(uWrapper)), 0, \"!wrapped\");\n assertEq(IERC20Upgradeable(wtoken).balanceOf(address(uWrapper)), 0, \"!unused wtoken\");\n assertEq(usdc.balanceOf(address(uWrapper)), 0, \"!unused usdc\");\n }\n}\n" + }, + "contracts/test/liquidators/IonicLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\nimport { IonicLiquidator, ILiquidator } from \"../../IonicLiquidator.sol\";\nimport { IonicUniV3Liquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport { ICurvePool } from \"../../external/curve/ICurvePool.sol\";\nimport { CurveSwapLiquidatorFunder } from \"../../liquidators/CurveSwapLiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport \"../../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { UpgradesBaseTest } from \"../UpgradesBaseTest.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { ProxyAdmin } from \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\n\ncontract MockRedemptionStrategy is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable,\n uint256,\n bytes memory\n ) external returns (IERC20Upgradeable, uint256) {\n return (IERC20Upgradeable(address(0)), 1);\n }\n\n function name() public pure returns (string memory) {\n return \"MockRedemptionStrategy\";\n }\n}\n\ncontract IonicLiquidatorTest is UpgradesBaseTest {\n ILiquidator liquidator;\n address uniswapRouter;\n address swapRouter;\n IUniswapV3Quoter quoter;\n address usdcWhale;\n address wethWhale;\n address poolAddress;\n address uniV3PooForFlash;\n uint256 usdcMarketIndex;\n uint256 wethMarketIndex;\n\n AuthoritiesRegistry authRegistry;\n ILiquidatorsRegistry liquidatorsRegistry;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == BSC_MAINNET) {\n uniswapRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E;\n } else if (block.chainid == POLYGON_MAINNET) {\n uniswapRouter = 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff;\n swapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n quoter = IUniswapV3Quoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);\n usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD; // aave reserve\n wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n poolAddress = 0x22A705DEC988410A959B8b17C8c23E33c121580b; // Retro stables pool\n uniV3PooForFlash = 0xA374094527e1673A86dE625aa59517c5dE346d32; // usdc-wmatic\n usdcMarketIndex = 3;\n wethMarketIndex = 5;\n } else if (block.chainid == MODE_MAINNET) {\n uniswapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n // uniswapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n // swapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n swapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n //quoter = IUniswapV3Quoter(0x7Fd569b2021850fbA53887dd07736010aCBFc787); // other sup quoter?\n quoter = IUniswapV3Quoter(0x5E6AEbab1AD525f5336Bd12E6847b851531F72ba); // sup quoter\n usdcWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79; // vault\n wethWhale = 0xF4C85269240C1D447309fA602A90ac23F1CB0Dc0;\n poolAddress = 0xFB3323E24743Caf4ADD0fDCCFB268565c0685556;\n //uniV3PooForFlash = 0x293f2B2c17f8cEa4db346D87Ef5712C9dd0491EF; // kim weth-usdc pool\n uniV3PooForFlash = 0x047CF4b081ee80d2928cb2ce3F3C4964e26eB0B9; // kim usdt-usdc pool\n // uniV3PooForFlash = 0xf2e9C024F1C0B7a2a4ea11243C2D86A7b38DD72f; // sup univ2 0x34a1E3Db82f669f8cF88135422AfD80e4f70701A\n usdcMarketIndex = 1;\n wethMarketIndex = 0;\n // weth 0x4200000000000000000000000000000000000006\n // usdc 0xd988097fb8612cc24eeC14542bC03424c656005f\n }\n\n // vm.prank(ap.owner());\n // ap.setAddress(\"IUniswapV2Router02\", uniswapRouter);\n vm.prank(ap.owner());\n ap.setAddress(\"UNISWAP_V3_ROUTER\", uniswapRouter);\n\n authRegistry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n liquidatorsRegistry = ILiquidatorsRegistry(ap.getAddress(\"LiquidatorsRegistry\"));\n liquidator = IonicLiquidator(payable(ap.getAddress(\"IonicLiquidator\")));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(liquidatorsRegistry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function testBsc() public fork(BSC_MAINNET) {\n testUpgrade();\n }\n\n function testPolygon() public fork(POLYGON_MAINNET) {\n testUpgrade();\n }\n\n function testUpgrade() internal {\n // in case these slots start to get used, please redeploy the FSL\n // with a larger storage gap to protect the owner variable of OwnableUpgradeable\n // from being overwritten by the IonicLiquidator storage\n for (uint256 i = 40; i < 51; i++) {\n address atSloti = address(uint160(uint256(vm.load(address(liquidator), bytes32(i)))));\n assertEq(\n atSloti,\n address(0),\n \"replace the FSL proxy/storage contract with a new one before the owner variable is overwritten\"\n );\n }\n }\n\n function testSpecificLiquidation() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0x5834a3AAFA83A53822B313994Bb554d8E8c215dF;\n address debtMarketAddr = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address collateralMarketAddr = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n liquidator = ILiquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars;\n vars.borrower = borrower;\n vars.cErc20 = ICErc20(debtMarketAddr);\n vars.cTokenCollateral = ICErc20(collateralMarketAddr);\n vars.repayAmount = 0x408c7a4d7c4092;\n vars.flashSwapContract = 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc;\n vars.minProfitAmount = 0;\n vars.redemptionStrategies = new IRedemptionStrategy[](1);\n vars.strategyData = new bytes[](1);\n vars.debtFundingStrategies = new IFundsConversionStrategy[](0);\n vars.debtFundingStrategiesData = new bytes[](0);\n\n vars.redemptionStrategies[0] = IFundsConversionStrategy(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vars.strategyData[\n 0\n ] = hex\"0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8\";\n\n liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n }\n\n function testWithdrawalLiquidator() public debuggingOnly fork(MODE_MAINNET) {\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.prank(0x4200000000000000000000000000000000000016);\n (bool success, ) = address(liquidatorV3).call{ value: 1 ether }(\"\");\n require(success, \"transfer of funds failed\");\n\n uint256 beforeBalance = liquidatorV3.owner().balance;\n\n vm.prank(liquidatorV3.owner());\n liquidatorV3.withdrawAll();\n\n emit log_named_uint(\"balance of liquidator\", liquidatorV3.owner().balance);\n\n assertEq(liquidatorV3.owner().balance, beforeBalance + 1 ether);\n assertEq(address(liquidatorV3).balance, 0);\n }\n\n function testLiquidateAfterUpgradeLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(1e18);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: 0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n function testLiquidateAfterUpgradeLiquidatorExpressRelay() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n address expressRelay = makeAddr(\"expressRelay\");\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(95e16);\n liquidatorV3.setExpressRelay(expressRelay);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n address borrower = address(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: borrower,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(false) \n );\n vm.expectRevert(\"invalid liquidation\");\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(true) \n );\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n // TODO test with marginal shortfall for liquidation penalty errors\n function _testLiquidatorLiquidate(address contractForFlashSwap) internal {\n IonicComptroller pool = IonicComptroller(poolAddress);\n // _upgradePoolWithExtension(Unitroller(payable(poolAddress)));\n //upgradeRegistry();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.prank(pool.admin());\n pool._setBorrowCapForCollateral(address(usdcMarket), address(wethMarket), 1e36);\n }\n\n {\n vm.prank(pool.admin());\n pool._borrowCapWhitelist(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038, address(this), true);\n }\n\n {\n vm.prank(wethWhale);\n weth.transfer(address(this), 0.1e18);\n\n weth.approve(address(wethMarket), 1e36);\n require(wethMarket.mint(0.1e18) == 0, \"mint weth failed\");\n pool.enterMarkets(asArray(address(usdcMarket), address(wethMarket)));\n }\n\n {\n vm.startPrank(usdcWhale);\n usdc.approve(address(usdcMarket), 2e36);\n require(usdcMarket.mint(70e6) == 0, \"mint usdc failed\");\n vm.stopPrank();\n }\n\n {\n require(usdcMarket.borrow(50e6) == 0, \"borrow usdc failed\");\n\n // the collateral prices change\n BasePriceOracle mpo = pool.oracle();\n uint256 priceCollateral = mpo.getUnderlyingPrice(wethMarket);\n vm.mockCall(\n address(mpo),\n abi.encodeWithSelector(mpo.getUnderlyingPrice.selector, wethMarket),\n abi.encode(priceCollateral / 10)\n );\n }\n\n (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) = liquidatorsRegistry\n .getRedemptionStrategies(weth, usdc);\n\n uint256 seizedAmount = liquidator.safeLiquidateToTokensWithFlashLoan(\n ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: address(this),\n repayAmount: 10e6,\n cErc20: usdcMarket,\n cTokenCollateral: wethMarket,\n flashSwapContract: contractForFlashSwap,\n minProfitAmount: 6,\n redemptionStrategies: strategies,\n strategyData: strategiesData,\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n })\n );\n\n emit log_named_uint(\"seized amount\", seizedAmount);\n require(seizedAmount > 0, \"didn't seize any assets\");\n }\n}\n" + }, + "contracts/test/liquidators/JarvisLiquidatorFunderTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { JarvisLiquidatorFunder } from \"../../liquidators/JarvisLiquidatorFunder.sol\";\nimport { IonicLiquidator, ILiquidator } from \"../../IonicLiquidator.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { IUniswapV2Factory } from \"../../external/uniswap/IUniswapV2Factory.sol\";\nimport { IComptroller } from \"../../external/compound/IComptroller.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ISynthereumLiquidityPool } from \"../../external/jarvis/ISynthereumLiquidityPool.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ninterface IMockERC20 is IERC20Upgradeable {\n function mint(address _address, uint256 amount) external;\n}\n\ncontract JarvisLiquidatorFunderTest is BaseTest {\n JarvisLiquidatorFunder private jarvisLiquidator;\n\n ISynthereumLiquidityPool synthereumLiquidityPool =\n ISynthereumLiquidityPool(0x0fD8170Dc284CD558325029f6AEc1538c7d99f49);\n\n address minter = 0x0fD8170Dc284CD558325029f6AEc1538c7d99f49;\n IMockERC20 jBRLToken = IMockERC20(0x316622977073BBC3dF32E7d2A9B3c77596a0a603);\n\n IERC20Upgradeable bUSD;\n\n function afterForkSetUp() internal override {\n uint64 expirationPeriod = 60 * 40; // 40 mins\n bUSD = IERC20Upgradeable(ap.getAddress(\"bUSD\")); // TODO check if bUSD == stableToken at AP\n\n ISynthereumLiquidityPool[] memory pools = new ISynthereumLiquidityPool[](1);\n pools[0] = synthereumLiquidityPool;\n uint256[] memory times = new uint256[](1);\n times[0] = expirationPeriod;\n\n jarvisLiquidator = new JarvisLiquidatorFunder();\n }\n\n function testRedeemToken() public fork(BSC_MAINNET) {\n vm.prank(minter);\n jBRLToken.mint(address(jarvisLiquidator), 10e18);\n\n bytes memory data = abi.encode(address(jBRLToken), address(synthereumLiquidityPool), 60 * 40);\n (uint256 redeemableAmount, ) = synthereumLiquidityPool.getRedeemTradeInfo(10e18);\n (IERC20Upgradeable outputToken, uint256 outputAmount) = jarvisLiquidator.redeem(jBRLToken, 10e18, data);\n\n // should be BUSD\n assertEq(address(outputToken), address(bUSD));\n assertEq(outputAmount, redeemableAmount);\n }\n\n function testEmergencyRedeemToken() public fork(BSC_MAINNET) {\n ISynthereumLiquidityPool pool = synthereumLiquidityPool;\n address manager = pool.synthereumFinder().getImplementationAddress(\"Manager\");\n vm.prank(manager);\n pool.emergencyShutdown();\n\n vm.prank(minter);\n jBRLToken.mint(address(jarvisLiquidator), 10e18);\n\n bytes memory data = abi.encode(address(jBRLToken), address(synthereumLiquidityPool), 60 * 40);\n (uint256 redeemableAmount, uint256 fee) = synthereumLiquidityPool.getRedeemTradeInfo(10e18);\n (IERC20Upgradeable outputToken, uint256 outputAmount) = jarvisLiquidator.redeem(jBRLToken, 10e18, data);\n\n // should be BUSD\n assertEq(address(outputToken), address(bUSD));\n assertEq(outputAmount, redeemableAmount + fee);\n }\n\n struct LiquidationData {\n address[] cTokens;\n IRedemptionStrategy[] strategies;\n bytes[] abis;\n IonicLiquidator liquidator;\n IFundsConversionStrategy[] fundingStrategies;\n bytes[] data;\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testJbrlLiquidation() public debuggingOnly forkAtBlock(BSC_MAINNET, 21700285) {\n LiquidationData memory vars;\n IUniswapV2Router02 uniswapRouter = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);\n\n // setting up a new liquidator\n // vars.liquidator = IonicLiquidator(payable(0xc9C3D317E89f4390A564D56180bBB1842CF3c99C));\n vars.liquidator = new IonicLiquidator();\n vars.liquidator.initialize(ap.getAddress(\"wtoken\"), address(uniswapRouter), 25);\n\n IComptroller comptroller = IComptroller(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n\n ICErc20 cTokenJBRL = ICErc20(0x82A3103bc306293227B756f7554AfAeE82F8ab7a);\n ICErc20 cTokenBUSD = ICErc20(0xa7213deB44f570646Ea955771Cc7f39B58841363);\n\n uint256 borrowAmount = 1e21;\n address accountOne = address(10001);\n address accountTwo = address(20002);\n\n // Account One supply JBRL\n dealJBRL(accountOne, 10e12);\n // Account One supply BUSD\n dealBUSD(accountOne, 10e21);\n\n // Account One deposit BUSD\n vm.startPrank(accountOne);\n {\n vars.cTokens = new address[](2);\n vars.cTokens[0] = address(cTokenJBRL);\n vars.cTokens[1] = address(cTokenBUSD);\n comptroller.enterMarkets(vars.cTokens);\n }\n bUSD.approve(address(cTokenBUSD), 1e36);\n require(cTokenBUSD.mint(5e21) == 0, \"mint failed\");\n vm.stopPrank();\n\n // Account One borrow jBRL\n vm.prank(accountOne);\n require(cTokenJBRL.borrow(borrowAmount) == 0, \"borrow failed\");\n\n // some time passes, interest accrues and prices change\n {\n vm.roll(block.number + 100);\n cTokenBUSD.accrueInterest();\n cTokenJBRL.accrueInterest();\n\n MasterPriceOracle mpo = MasterPriceOracle(address(comptroller.oracle()));\n uint256 priceBUSD = mpo.getUnderlyingPrice(cTokenBUSD);\n vm.mockCall(\n address(mpo),\n abi.encodeWithSelector(mpo.getUnderlyingPrice.selector, cTokenBUSD),\n abi.encode(priceBUSD / 100)\n );\n }\n\n // prepare the liquidation\n vars.strategies = new IRedemptionStrategy[](0);\n vars.abis = new bytes[](0);\n\n vars.fundingStrategies = new IFundsConversionStrategy[](1);\n vars.data = new bytes[](1);\n vars.data[0] = abi.encode(ap.getAddress(\"bUSD\"), address(synthereumLiquidityPool), 60 * 40);\n vars.fundingStrategies[0] = jarvisLiquidator;\n\n // all strategies need to be whitelisted\n vm.prank(vars.liquidator.owner());\n vars.liquidator._whitelistRedemptionStrategy(vars.fundingStrategies[0], true);\n\n address pairAddress = IUniswapV2Factory(uniswapRouter.factory()).getPair(address(bUSD), ap.getAddress(\"wtoken\"));\n IUniswapV2Pair flashSwapPair = IUniswapV2Pair(pairAddress);\n\n uint256 repayAmount = borrowAmount / 10;\n // liquidate\n vm.prank(accountTwo);\n vars.liquidator.safeLiquidateToTokensWithFlashLoan(\n ILiquidator.LiquidateToTokensWithFlashSwapVars(\n accountOne,\n repayAmount,\n ICErc20(address(cTokenJBRL)),\n ICErc20(address(cTokenBUSD)),\n address(flashSwapPair),\n 0,\n vars.strategies,\n vars.abis,\n vars.fundingStrategies,\n vars.data\n )\n );\n }\n\n function dealBUSD(address to, uint256 amount) internal {\n vm.prank(0x0000000000000000000000000000000000001004); // whale\n bUSD.transfer(to, amount);\n }\n\n function dealJBRL(address to, uint256 amount) internal {\n vm.prank(0xad51e40D8f255dba1Ad08501D6B1a6ACb7C188f3); // whale\n jBRLToken.transfer(to, amount);\n }\n}\n" + }, + "contracts/test/liquidators/SaddleLpTokenLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { SaddleLpTokenLiquidator } from \"../../liquidators/SaddleLpTokenLiquidator.sol\";\nimport { SaddleLpPriceOracle } from \"../../oracles/default/SaddleLpPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { ISwap } from \"../../external/saddle/ISwap.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract SaddleLpTokenLiquidatorTest is BaseTest {\n MasterPriceOracle mpo;\n address stable;\n SaddleLpTokenLiquidator private liquidator;\n SaddleLpPriceOracle oracle;\n address fraxUsdc_lp = 0x896935B02D3cBEb152192774e4F1991bb1D2ED3f;\n address frax = 0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F;\n\n function afterForkSetUp() internal override {\n liquidator = new SaddleLpTokenLiquidator();\n oracle = new SaddleLpPriceOracle();\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n stable = ap.getAddress(\"stableToken\");\n\n address[] memory uls = new address[](2);\n uls[0] = stable;\n uls[1] = frax;\n\n address[][] memory underlyings = new address[][](1);\n underlyings[0] = uls;\n\n vm.prank(mpo.admin());\n oracle.initialize(asArray(fraxUsdc_lp), asArray(0x401AFbc31ad2A3Bc0eD8960d63eFcDEA749b4849), underlyings);\n }\n\n function testSaddleLpTokenLiquidator() public fork(ARBITRUM_ONE) {\n IERC20Upgradeable lpToken = IERC20Upgradeable(fraxUsdc_lp);\n address lpTokenWhale = 0xa5bD85ed9fA27ba23BfB702989e7218E44fd4706; // metaswap\n uint8 outputTokenIndex = 0;\n address poolAddr = oracle.poolOf(address(lpToken));\n ISwap pool = ISwap(poolAddr);\n address outputTokenAddr = pool.getToken(0);\n bytes memory data = abi.encode(outputTokenAddr, address(oracle), ap.getAddress(\"wtoken\"));\n uint256 amount = 1e18;\n\n IERC20Upgradeable outputToken = IERC20Upgradeable(outputTokenAddr);\n\n vm.prank(lpTokenWhale);\n lpToken.transfer(address(liquidator), 1e18);\n\n vm.prank(address(liquidator));\n lpToken.approve(poolAddr, 1e18);\n vm.expectRevert(bytes(\"Pausable: paused\"));\n liquidator.redeem(lpToken, amount, data);\n // assertGt(outputToken.balanceOf(address(liquidator)), 0, \"!redeem output\");\n }\n}\n" + }, + "contracts/test/liquidators/SolidlyLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport \"../../liquidators/SolidlySwapLiquidator.sol\";\n\ncontract SolidlyLiquidatorTest is BaseTest {\n SolidlySwapLiquidator public liquidator;\n MasterPriceOracle public mpo;\n address stableToken;\n address solidlySwapRouter;\n address hayAddress = 0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5;\n address ankrAddress = 0xf307910A4c7bbc79691fD374889b36d8531B08e3;\n address ankrBnbAddress = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n uint256 inputAmount = 1e18;\n\n function afterForkSetUp() internal override {\n liquidator = new SolidlySwapLiquidator();\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n stableToken = ap.getAddress(\"stableToken\");\n\n if (block.chainid == BSC_MAINNET) {\n solidlySwapRouter = 0xd4ae6eCA985340Dd434D38F470aCCce4DC78D109;\n } else if (block.chainid == POLYGON_MAINNET) {\n solidlySwapRouter = 0x06374F57991CDc836E5A318569A910FE6456D230;\n }\n }\n\n function testSolidlyHayBusd() public fork(BSC_MAINNET) {\n address hayWhale = 0x1fa71DF4b344ffa5755726Ea7a9a56fbbEe0D38b;\n\n IERC20Upgradeable hay = IERC20Upgradeable(hayAddress);\n vm.prank(hayWhale);\n hay.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n hay,\n inputAmount,\n abi.encode(solidlySwapRouter, stableToken, true)\n );\n\n assertEq(address(outputToken), stableToken, \"!busd output\");\n assertApproxEqRel(inputAmount, outputAmount, 8e16, \"!busd amount\");\n }\n\n function testSolidlyAnkrHay() public fork(BSC_MAINNET) {\n address ankrWhale = 0x146eE71e057e6B10eFB93AEdf631Fde6CbAED5E2;\n\n IERC20Upgradeable ankr = IERC20Upgradeable(ankrAddress);\n vm.prank(ankrWhale);\n ankr.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n ankr,\n inputAmount,\n abi.encode(solidlySwapRouter, hayAddress, false)\n );\n\n uint256 outputValue = mpo.price(hayAddress) * outputAmount;\n uint256 inputValue = mpo.price(ankrAddress) * inputAmount;\n\n assertEq(address(outputToken), hayAddress, \"!hay output\");\n assertApproxEqRel(outputValue, inputValue, 9e16, \"!hay amount\");\n }\n\n function testSolidlyAnkrAnkrBNB() public fork(BSC_MAINNET) {\n address ankrWhale = 0x146eE71e057e6B10eFB93AEdf631Fde6CbAED5E2;\n\n IERC20Upgradeable ankr = IERC20Upgradeable(ankrAddress);\n vm.prank(ankrWhale);\n ankr.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n ankr,\n inputAmount,\n abi.encode(solidlySwapRouter, ankrBnbAddress, false)\n );\n\n uint256 outputValue = mpo.price(ankrBnbAddress) * outputAmount;\n uint256 inputValue = mpo.price(ankrAddress) * inputAmount;\n\n assertEq(address(outputToken), ankrBnbAddress, \"!ankrBNB output\");\n assertApproxEqRel(outputValue, inputValue, 8e16, \"!ankrBNB amount\");\n }\n\n function testSolidlyHayAnkrBNB() public fork(BSC_MAINNET) {\n address hayWhale = 0x1fa71DF4b344ffa5755726Ea7a9a56fbbEe0D38b;\n\n IERC20Upgradeable hay = IERC20Upgradeable(hayAddress);\n vm.prank(hayWhale);\n hay.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n hay,\n inputAmount,\n abi.encode(solidlySwapRouter, ankrBnbAddress, false)\n );\n\n uint256 outputValue = mpo.price(ankrBnbAddress) * outputAmount;\n uint256 inputValue = mpo.price(hayAddress) * inputAmount;\n\n assertEq(address(outputToken), ankrBnbAddress, \"!ankrBNB output\");\n assertApproxEqRel(outputValue, inputValue, 8e16, \"!ankrBNB amount\");\n }\n\n function testSolidlyDaiUsdrLp() public fork(POLYGON_MAINNET) {\n address daiUsdrLpAddress = 0x6ab291A9BB3C20F0017f2E93A6d1196842D09bF4;\n address daiUsdrLpWhale = 0x5E21386E8E0e6C77Abd1E08e21e9D41e760D3747;\n address usdrAddress = 0xb5DFABd7fF7F83BAB83995E72A52B97ABb7bcf63;\n\n IERC20Upgradeable daiUsdrLp = IERC20Upgradeable(daiUsdrLpAddress);\n vm.prank(daiUsdrLpWhale);\n daiUsdrLp.transfer(address(liquidator), 1e18);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n daiUsdrLp,\n inputAmount,\n abi.encode(solidlySwapRouter, usdrAddress, false)\n );\n\n uint256 outputValue = mpo.price(usdrAddress) * outputAmount;\n uint256 inputValue = mpo.price(daiUsdrLpAddress) * inputAmount;\n\n assertEq(address(outputToken), usdrAddress, \"!usdr output\");\n assertApproxEqRel(outputValue, inputValue, 8e16, \"!in value != out value\");\n }\n}\n" + }, + "contracts/test/liquidators/UniswapLikeLpTokenLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { UniswapLpTokenPriceOracle } from \"../../oracles/default/UniswapLpTokenPriceOracle.sol\";\nimport { SolidlyLpTokenPriceOracle } from \"../../oracles/default/SolidlyLpTokenPriceOracle.sol\";\nimport { UniswapLikeLpTokenPriceOracle } from \"../../oracles/default/UniswapLikeLpTokenPriceOracle.sol\";\nimport { UniswapLpTokenLiquidator } from \"../../liquidators/UniswapLpTokenLiquidator.sol\";\nimport { SolidlyLpTokenLiquidator, SolidlyLpTokenWrapper } from \"../../liquidators/SolidlyLpTokenLiquidator.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { IRouter } from \"../../external/solidly/IRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract UniswapLikeLpTokenLiquidatorTest is BaseTest {\n UniswapLpTokenLiquidator private uniLiquidator;\n SolidlyLpTokenLiquidator private solidlyLpTokenLiquidator;\n SolidlyLpTokenWrapper solidlyLpTokenWrapper;\n SolidlyLpTokenPriceOracle private oracleSolidly;\n UniswapLpTokenPriceOracle private oracleUniswap;\n MasterPriceOracle mpo;\n address wtoken;\n address stableToken;\n address uniswapV2Router;\n address solidlyRouter;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n uniswapV2Router = ap.getAddress(\"IUniswapV2Router02\");\n wtoken = ap.getAddress(\"wtoken\");\n stableToken = ap.getAddress(\"stableToken\");\n solidlyRouter = ap.getAddress(\"SOLIDLY_SWAP_ROUTER\");\n emit log_named_address(\"solidlyRouter\", solidlyRouter);\n uniLiquidator = new UniswapLpTokenLiquidator();\n solidlyLpTokenLiquidator = new SolidlyLpTokenLiquidator();\n solidlyLpTokenWrapper = new SolidlyLpTokenWrapper();\n oracleSolidly = new SolidlyLpTokenPriceOracle(wtoken);\n oracleUniswap = new UniswapLpTokenPriceOracle(wtoken);\n }\n\n function setUpOracles(address lpToken, UniswapLikeLpTokenPriceOracle oracle) internal {\n if (address(mpo.oracles(lpToken)) == address(0)) {\n address[] memory underlyings = new address[](1);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n\n underlyings[0] = lpToken;\n oracles[0] = BasePriceOracle(oracle);\n\n vm.prank(mpo.admin());\n mpo.add(underlyings, oracles);\n emit log(\"added the oracle\");\n } else {\n emit log(\"found the oracle\");\n }\n }\n\n function testUniswapLpTokenRedeem(\n address whale,\n address lpToken,\n UniswapLikeLpTokenPriceOracle oracle\n ) internal {\n setUpOracles(lpToken, oracle);\n IERC20Upgradeable lpTokenContract = IERC20Upgradeable(lpToken);\n IUniswapV2Pair pool = IUniswapV2Pair(lpToken);\n\n address token0 = pool.token0();\n address token1 = pool.token1();\n\n address[] memory swapToken0Path;\n address[] memory swapToken1Path;\n\n IERC20Upgradeable outputToken = IERC20Upgradeable(wtoken);\n\n if (token0 != wtoken) {\n swapToken0Path = asArray(token0, wtoken);\n swapToken1Path = new address[](0);\n } else {\n swapToken0Path = new address[](0);\n swapToken1Path = asArray(token1, wtoken);\n }\n\n uint256 outputBalanceBefore = outputToken.balanceOf(address(uniLiquidator));\n\n uint256 redeemAmount = 1e18;\n // redeem\n {\n bytes memory data = abi.encode(uniswapV2Router, swapToken0Path, swapToken1Path);\n\n vm.prank(whale);\n lpTokenContract.transfer(address(uniLiquidator), redeemAmount);\n\n vm.prank(address(uniLiquidator));\n lpTokenContract.approve(lpToken, redeemAmount);\n uniLiquidator.redeem(lpTokenContract, redeemAmount, data);\n }\n\n uint256 outputBalanceAfter = outputToken.balanceOf(address(uniLiquidator));\n uint256 outputBalanceDiff = outputBalanceAfter - outputBalanceBefore;\n assertGt(outputBalanceDiff, 0, \"!redeem output\");\n\n // compare the value of the input LP tokens and the value of the output tokens\n checkInputOutputValue(redeemAmount, lpToken, outputBalanceDiff, address(outputToken));\n }\n\n function testSolidlyLpTokenRedeem(\n address whale,\n address lpToken,\n address outputTokenAddress,\n UniswapLikeLpTokenPriceOracle oracle\n ) internal {\n setUpOracles(lpToken, oracle);\n IERC20Upgradeable lpTokenContract = IERC20Upgradeable(lpToken);\n\n IERC20Upgradeable outputToken = IERC20Upgradeable(outputTokenAddress);\n\n uint256 outputBalanceBefore = outputToken.balanceOf(address(solidlyLpTokenLiquidator));\n\n uint256 redeemAmount = 1e18;\n // redeem\n {\n bytes memory data = abi.encode(solidlyRouter, outputTokenAddress);\n\n vm.prank(whale);\n lpTokenContract.transfer(address(solidlyLpTokenLiquidator), redeemAmount);\n\n solidlyLpTokenLiquidator.redeem(lpTokenContract, redeemAmount, data);\n }\n\n uint256 outputBalanceAfter = outputToken.balanceOf(address(solidlyLpTokenLiquidator));\n uint256 outputBalanceDiff = outputBalanceAfter - outputBalanceBefore;\n assertGt(outputBalanceDiff, 0, \"!redeem output\");\n\n // compare the value of the input LP tokens and the value of the output tokens\n checkInputOutputValue(redeemAmount, lpToken, outputBalanceDiff, address(outputToken));\n }\n\n function checkInputOutputValue(\n uint256 inputAmount,\n address inputToken,\n uint256 outputAmount,\n address outputToken\n ) internal {\n uint256 outputTokenPrice = mpo.price(address(outputToken));\n uint256 outputValue = (outputTokenPrice * outputAmount) / 1e18;\n uint256 inputTokenPrice = mpo.price(inputToken);\n uint256 inputValue = (inputAmount * inputTokenPrice) / 1e18;\n\n assertApproxEqAbs(inputValue, outputValue, 1e15, \"value of output does not match the value of the output\");\n }\n\n function testUniswapLpRedeem() public fork(BSC_MAINNET) {\n address lpTokenWhale = 0xa5f8C5Dbd5F286960b9d90548680aE5ebFf07652; // pcs main staking contract\n address WBNB_BUSD_Uniswap = 0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16;\n testUniswapLpTokenRedeem(lpTokenWhale, WBNB_BUSD_Uniswap, oracleUniswap);\n }\n\n function testSolidlyLpRedeem() public fork(BSC_MAINNET) {\n address ankrBNB = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n\n address WBNB_BUSD = 0x483653bcF3a10d9a1c334CE16a19471a614F4385;\n address HAY_BUSD = 0x93B32a8dfE10e9196403dd111974E325219aec24;\n address ANKR_ankrBNB = 0x7ef540f672Cd643B79D2488344944499F7518b1f;\n\n address WBNB_BUSD_whale = 0x7144851e51523a88EA6BeC9710cC07f3a9B3baa7;\n address HAY_BUSD_whale = 0x5f8a3d4ad41352A8145DDe8dC0aA3159C7B7649D;\n address ANKR_ankrBNB_whale = 0x5FFEAe4E352Bf3789C9152Ef7eAfD9c1B3bfcE26;\n\n testSolidlyLpTokenRedeem(WBNB_BUSD_whale, WBNB_BUSD, wtoken, oracleSolidly);\n testSolidlyLpTokenRedeem(HAY_BUSD_whale, HAY_BUSD, stableToken, oracleSolidly);\n testSolidlyLpTokenRedeem(ANKR_ankrBNB_whale, ANKR_ankrBNB, ankrBNB, oracleSolidly);\n }\n\n function _testSolidlyLpTokenWrapper(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n address whale,\n IPair lpToken\n ) internal {\n // TODO get the data from the liquidators registry\n IRouter.Route[] memory swapPath0 = new IRouter.Route[](1);\n IRouter.Route[] memory swapPath1 = new IRouter.Route[](1);\n IERC20Upgradeable otherUnderlying;\n {\n address token0 = lpToken.token0();\n address token1 = lpToken.token1();\n bool isInputToken0 = token0 == address(inputToken);\n bool isInputToken1 = token1 == address(inputToken);\n require(isInputToken0 || isInputToken1, \"!input token not underlying\");\n\n if (isInputToken0) otherUnderlying = IERC20Upgradeable(token1);\n else otherUnderlying = IERC20Upgradeable(token0);\n\n swapPath0[0].stable = lpToken.stable();\n swapPath0[0].from = token0;\n swapPath0[0].to = token1;\n\n swapPath1[0].stable = lpToken.stable();\n swapPath1[0].from = token1;\n swapPath1[0].to = token0;\n }\n\n bytes memory data = abi.encode(solidlyRouter, lpToken, swapPath0, swapPath1);\n\n vm.prank(whale);\n inputToken.transfer(address(solidlyLpTokenWrapper), inputAmount);\n\n (IERC20Upgradeable outputToken, uint256 outputAmount) = solidlyLpTokenWrapper.redeem(inputToken, inputAmount, data);\n\n BasePriceOracle[] memory solOracles = new BasePriceOracle[](1);\n solOracles[0] = oracleSolidly;\n if (mpo.oracles(address(outputToken)) == BasePriceOracle(address(0))) {\n vm.prank(mpo.admin());\n mpo.add(asArray(address(outputToken)), solOracles);\n }\n\n uint256 lpTokensBalance = lpToken.balanceOf(address(solidlyLpTokenWrapper));\n assertGt(lpTokensBalance, 0, \"!no lp tokens wrapped\");\n uint256 inputTokensAfter = inputToken.balanceOf(address(solidlyLpTokenWrapper));\n assertEq(inputTokensAfter, 0, \"!input tokens left after\");\n // uint256 otherTokensAfter = otherUnderlying.balanceOf(address(solidlyLpTokenWrapper));\n // assertEq(otherTokensAfter, 0, \"!other underlying tokens left after\");\n // emit log_named_uint(\"bps other leftover\", (valueOf(otherUnderlying, otherTokensAfter) * 10000) / valueOf(inputToken, inputAmount));\n assertApproxEqRel(valueOf(inputToken, inputAmount), valueOf(outputToken, outputAmount), 5e16, \"!slippage too high\");\n }\n\n function valueOf(IERC20Upgradeable token, uint256 amount) internal view returns (uint256) {\n uint256 price = mpo.price(address(token));\n uint256 decimalsScale = 10**ERC20Upgradeable(address(token)).decimals();\n return (amount * price) / decimalsScale;\n }\n\n function testWrapSolidlyLpTokensWbnbBusd() public fork(BSC_MAINNET) {\n IERC20Upgradeable wbnb = IERC20Upgradeable(ap.getAddress(\"wtoken\"));\n address WBNB_BUSD = 0x483653bcF3a10d9a1c334CE16a19471a614F4385;\n address wbnbWhale = 0xF977814e90dA44bFA03b6295A0616a897441aceC;\n\n _testSolidlyLpTokenWrapper(wbnb, 1e18, wbnbWhale, IPair(WBNB_BUSD));\n }\n\n function testWrapSolidlyLpTokensHayBusd() public fork(BSC_MAINNET) {\n IERC20Upgradeable busd = IERC20Upgradeable(ap.getAddress(\"stableToken\"));\n address HAY_BUSD = 0x93B32a8dfE10e9196403dd111974E325219aec24;\n address busdWhale = 0xF977814e90dA44bFA03b6295A0616a897441aceC;\n\n _testSolidlyLpTokenWrapper(busd, 1000e18, busdWhale, IPair(HAY_BUSD));\n }\n\n function testWrapSolidlyLpTokensjBrlBrz() public fork(BSC_MAINNET) {\n IERC20Upgradeable jBRL = IERC20Upgradeable(0x316622977073BBC3dF32E7d2A9B3c77596a0a603);\n address jBRL_BRZ = 0xA0695f78AF837F570bcc50f53e58Cda300798B65;\n address jBRLWhale = 0xad51e40D8f255dba1Ad08501D6B1a6ACb7C188f3;\n\n _testSolidlyLpTokenWrapper(jBRL, 1000e18, jBRLWhale, IPair(jBRL_BRZ));\n }\n\n function testWrapSolidlyLpTokensBrzJBrl() public fork(BSC_MAINNET) {\n IERC20Upgradeable brz = IERC20Upgradeable(0x71be881e9C5d4465B3FfF61e89c6f3651E69B5bb);\n address jBRL_BRZ = 0xA0695f78AF837F570bcc50f53e58Cda300798B65;\n address brzWhale = 0xad51e40D8f255dba1Ad08501D6B1a6ACb7C188f3;\n\n _testSolidlyLpTokenWrapper(brz, 1000e4, brzWhale, IPair(jBRL_BRZ));\n }\n\n function testWrapSolidlyLpTokensUsdrUsdc() public fork(POLYGON_MAINNET) {\n IERC20Upgradeable usdc = IERC20Upgradeable(ap.getAddress(\"stableToken\"));\n address USDC_USDR = 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b;\n address USDCWhale = 0xe7804c37c13166fF0b37F5aE0BB07A3aEbb6e245; // binance hot wallet\n\n _testSolidlyLpTokenWrapper(usdc, 1000e6, USDCWhale, IPair(USDC_USDR));\n }\n\n function testWrapSolidlyLpTokensUsdrUsdr() public fork(POLYGON_MAINNET) {\n IERC20Upgradeable usdr = IERC20Upgradeable(0x40379a439D4F6795B6fc9aa5687dB461677A2dBa);\n address WUSDR_USDR = 0x8711a1a52c34EDe8E61eF40496ab2618a8F6EA4B;\n address USDRWhale = 0xBD02973b441Aa83c8EecEA158b98B5984bb1036E; // curve lp token\n\n _testSolidlyLpTokenWrapper(usdr, 1000e9, USDRWhale, IPair(WUSDR_USDR));\n }\n\n function testWrapSolidlyLpTokensMaticUsdr() public fork(POLYGON_MAINNET) {\n IERC20Upgradeable usdr = IERC20Upgradeable(0x40379a439D4F6795B6fc9aa5687dB461677A2dBa);\n address MATIC_USDR = 0xB4d852b92148eAA16467295975167e640E1FE57A;\n address USDRWhale = 0xBD02973b441Aa83c8EecEA158b98B5984bb1036E; // curve lp token\n\n _testSolidlyLpTokenWrapper(usdr, 1000e9, USDRWhale, IPair(MATIC_USDR));\n }\n}\n" + }, + "contracts/test/liquidators/UniswapV2LiquidatorFunderTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { UniswapV2LiquidatorFunder } from \"../../liquidators/UniswapV2LiquidatorFunder.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract UniswapV2LiquidatorFunderTest is BaseTest {\n address maiAddress;\n address usdcAddress;\n UniswapV2LiquidatorFunder uv2lf;\n address uniswapV2Router;\n\n function afterForkSetUp() internal override {\n uv2lf = new UniswapV2LiquidatorFunder();\n uniswapV2Router = ap.getAddress(\"IUniswapV2Router02\");\n usdcAddress = 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d;\n maiAddress = 0x3F56e0c36d275367b8C502090EDF38289b3dEa0d;\n }\n\n function testConvertUsdcMai() public fork(BSC_MAINNET) {\n address[] memory swapPath = new address[](2);\n swapPath[0] = maiAddress;\n swapPath[1] = usdcAddress;\n bytes memory strategyData = abi.encode(uniswapV2Router, swapPath);\n\n uint256 outputUsdcExpected = 1e10;\n (IERC20Upgradeable inputToken, uint256 inputMaiRequired) = uv2lf.estimateInputAmount(\n outputUsdcExpected,\n strategyData\n );\n\n assertApproxEqAbs(inputMaiRequired, outputUsdcExpected, 1e9);\n assertEq(address(inputToken), maiAddress, \"!mai address\");\n }\n}\n" + }, + "contracts/test/liquidators/UniswapV3LiquidatorFunderTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { IonicLiquidator } from \"../../IonicLiquidator.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { IUniswapV2Factory } from \"../../external/uniswap/IUniswapV2Factory.sol\";\nimport { IUniswapV3Factory } from \"../../external/uniswap/IUniswapV3Factory.sol\";\nimport { Quoter } from \"../../external/uniswap/quoter/Quoter.sol\";\nimport { IUniswapV3Pool } from \"../../external/uniswap/IUniswapV3Pool.sol\";\nimport { ISwapRouter } from \"../../external/uniswap/ISwapRouter.sol\";\nimport { IComptroller } from \"../../external/compound/IComptroller.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract UniswapV3LiquidatorFunderTest is BaseTest {\n UniswapV3LiquidatorFunder private uniswapv3Liquidator;\n\n IERC20Upgradeable parToken;\n IERC20Upgradeable usdcToken;\n address univ3SwapRouter;\n uint256 poolFee;\n Quoter quoter;\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n if (block.chainid == POLYGON_MAINNET) {\n quoter = new Quoter(0x1F98431c8aD98523631AE4a59f267346ea31F984);\n univ3SwapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n parToken = IERC20Upgradeable(0xE2Aa7db6dA1dAE97C5f5C6914d285fBfCC32A128); // PAR, 18 decimals\n usdcToken = IERC20Upgradeable(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174); // USDC, 6 decimals\n poolFee = 500;\n }\n uniswapv3Liquidator = new UniswapV3LiquidatorFunder();\n }\n\n function testUniV3ParUsdcRedeem() public fork(POLYGON_MAINNET) {\n uint256 parInputAmount = 10000e18;\n address parTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2\n\n vm.prank(parTokenWhale);\n parToken.transfer(address(uniswapv3Liquidator), parInputAmount);\n\n bytes memory data = abi.encode(parToken, usdcToken, poolFee, ISwapRouter(univ3SwapRouter), quoter);\n (IERC20Upgradeable outputToken, uint256 outputAmount) = uniswapv3Liquidator.redeem(parToken, parInputAmount, data);\n\n uint256 inputValue = (parInputAmount * mpo.price(address(parToken))) / 1e18;\n uint256 outputValue = (outputAmount * mpo.price(address(usdcToken))) / 1e6;\n\n assertEq(address(outputToken), address(usdcToken), \"!out tok\");\n assertApproxEqRel(inputValue, outputValue, 1e16, \"!out amount\");\n }\n}\n" + }, + "contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IonicUniV3Liquidator, IUniswapV3Pool, ILiquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\nimport { IUniswapV3Factory } from \"../../external/uniswap/IUniswapV3Factory.sol\";\nimport { UniswapV2LiquidatorFunder } from \"../../liquidators/UniswapV2LiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { KimUniV2Liquidator } from \"../../liquidators/KimUniV2Liquidator.sol\";\n\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport \"./IonicLiquidatorTest.sol\";\n\ncontract UniswapV3LiquidatorTest is IonicLiquidatorTest {\n function testPolygonUniV3LiquidatorLiquidate() public fork(POLYGON_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeUniV3LiquidatorLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = new UniswapV3LiquidatorFunder();\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n vm.prank(OwnableUpgradeable(address(liquidator)).owner());\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeKimUniV2Liquidator() public fork(MODE_MAINNET) {\n IonicLiquidator _liquidator = new IonicLiquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), ap.getAddress(\"IUniswapV2Router02\"), 30);\n liquidator = _liquidator;\n liquidator.setPoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n liquidator.setHealthFactorThreshold(1e18);\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = KimUniV2Liquidator(0x6aC17D406a820fa464fFdc0940FCa7E60b3b36B7);\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testUniV3PoolForFee() public debuggingOnly fork(MODE_MAINNET) {\n address wethAddr = 0x4200000000000000000000000000000000000006;\n address usdcAddr = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcAddr);\n IERC20Upgradeable weth = IERC20Upgradeable(wethAddr);\n\n IUniswapV2Router02 kimRouter = IUniswapV2Router02(0x5D61c537393cf21893BE619E36fC94cd73C77DD3);\n address factoryAddress;\n //factory = kimRouter.factory();\n factoryAddress = 0xC33Ce0058004d44E7e1F366E5797A578fDF38584;\n IUniswapV3Factory factory = IUniswapV3Factory(factoryAddress);\n address pool;\n\n uint256 feeConfig = liquidatorsRegistry.uniswapV3Fees(usdc, weth);\n emit log_named_uint(\"feeConfig\", feeConfig);\n\n if (feeConfig == 0) {\n pool = factory.getPool(wethAddr, usdcAddr, uint24(feeConfig));\n emit log_named_address(\"Pool at fee 0\", pool);\n }\n\n pool = factory.getPool(wethAddr, usdcAddr, 500);\n emit log_named_address(\"Pool at fee 500\", pool);\n }\n}\n" + }, + "contracts/test/liquidators/WombatLpTokenLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { WombatLpTokenLiquidator } from \"../../liquidators/WombatLpTokenLiquidator.sol\";\nimport { IWombatLpAsset } from \"../../oracles/default/WombatLpTokenPriceOracle.sol\";\nimport { WombatLpTokenPriceOracle } from \"../../oracles/default/WombatLpTokenPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\ncontract WombatLpTokenLiquidatorTest is BaseTest {\n WombatLpTokenLiquidator private wtl;\n WombatLpTokenPriceOracle private oracle;\n MasterPriceOracle private mp;\n\n function afterForkSetUp() internal override {\n wtl = new WombatLpTokenLiquidator();\n oracle = new WombatLpTokenPriceOracle();\n mp = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n function testRedeemWBNB() public fork(BSC_MAINNET) {\n address wombatBUSD = 0xF319947eCe3823b790dd87b0A509396fE325745a;\n uint256 assetAmount = 100e18;\n\n deal(wombatBUSD, address(wtl), assetAmount);\n\n vm.prank(address(mp));\n uint256 assetPrice = oracle.price(wombatBUSD); // wombatBUSD price\n uint256 underlyingPrice = mp.price(IWombatLpAsset(wombatBUSD).underlyingToken()); // wbnb price\n\n // amount convertion = assetAmount * underlyingPrice / assetPrice\n uint256 expectedAmount = (assetAmount * underlyingPrice) / assetPrice;\n\n bytes memory strategyData = abi.encode(\n IWombatLpAsset(wombatBUSD).pool(),\n IWombatLpAsset(wombatBUSD).underlyingToken()\n );\n (, uint256 redeemAmount) = wtl.redeem(IERC20Upgradeable(wombatBUSD), assetAmount, strategyData);\n\n assertApproxEqAbs(\n expectedAmount,\n redeemAmount,\n uint256(5e17),\n string(abi.encodePacked(\"!redeemAmount == expectedAmount \"))\n );\n }\n}\n" + }, + "contracts/test/liquidators/XBombLiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../../external/bomb/IXBomb.sol\";\nimport \"../../liquidators/XBombLiquidatorFunder.sol\";\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract XBombLiquidatorTest is BaseTest {\n // the Pancake BOMB/xBOMB pair\n address holder = 0x6aE0Fb5D98911cF5AF6A8CE0AeCE426227d41103;\n IXBomb xbombToken = IXBomb(0xAf16cB45B8149DA403AF41C63AbFEBFbcd16264b);\n address bombTokenAddress = 0x522348779DCb2911539e76A1042aA922F9C47Ee3; // BOMB\n XBombLiquidatorFunder liquidator;\n\n function afterForkSetUp() internal override {\n liquidator = new XBombLiquidatorFunder();\n }\n\n function testRedeem() public debuggingOnly fork(BSC_MAINNET) {\n // make sure we're testing with at least some tokens\n uint256 balance = xbombToken.balanceOf(holder);\n assertTrue(balance > 0);\n\n // impersonate the holder\n vm.prank(holder);\n\n // fund the liquidator so it can redeem the tokens\n xbombToken.transfer(address(liquidator), balance);\n\n bytes memory data = abi.encode(address(xbombToken), address(xbombToken), bombTokenAddress);\n // redeem the underlying reward token\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n IERC20Upgradeable(address(xbombToken)),\n balance,\n data\n );\n\n assertEq(address(outputToken), bombTokenAddress);\n assertEq(outputAmount, xbombToken.toREWARD(balance));\n }\n}\n" + }, + "contracts/test/LiquidatorsRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { LiquidatorsRegistry } from \"../liquidators/registry/LiquidatorsRegistry.sol\";\nimport { LiquidatorsRegistryExtension } from \"../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport \"../ionic/DiamondExtension.sol\";\nimport { SafeOwnable } from \"../ionic/SafeOwnable.sol\";\n\ncontract LiquidatorsRegistryTest is BaseTest {\n ILiquidatorsRegistry registry;\n\n // all-chains\n IERC20Upgradeable stable;\n IERC20Upgradeable wtoken;\n MasterPriceOracle mpo;\n\n // chapel\n IERC20Upgradeable chapelBomb = IERC20Upgradeable(0xe45589fBad3A1FB90F5b2A8A3E8958a8BAB5f768);\n IERC20Upgradeable chapelTUsd = IERC20Upgradeable(0x4f1885D25eF219D3D4Fa064809D6D4985FAb9A0b);\n IERC20Upgradeable chapelTDai = IERC20Upgradeable(0x8870f7102F1DcB1c35b01af10f1baF1B00aD6805);\n\n // bsc\n IERC20Upgradeable wbnbBusdLpToken = IERC20Upgradeable(0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16);\n IERC20Upgradeable usdcBusdCakeLpToken = IERC20Upgradeable(0x2354ef4DF11afacb85a5C7f98B624072ECcddbB1);\n IERC20Upgradeable ankrAnkrBnbGammaLpToken = IERC20Upgradeable(0x3f8f3caefF393B1994a9968E835Fd38eCba6C1be);\n\n // polygon\n IERC20Upgradeable usdr3CrvCurveLpToken = IERC20Upgradeable(0xa138341185a9D0429B0021A11FB717B225e13e1F);\n IERC20Upgradeable maticxBbaBalancerStableLpToken = IERC20Upgradeable(0xb20fC01D21A50d2C734C4a1262B4404d41fA7BF0);\n IERC20Upgradeable stMaticBbaBalancerStableLpToken = IERC20Upgradeable(0x216690738Aac4aa0C4770253CA26a28f0115c595);\n IERC20Upgradeable mimoParBalancerWeightedLpToken = IERC20Upgradeable(0x82d7f08026e21c7713CfAd1071df7C8271B17Eae);\n\n function afterForkSetUp() internal override {\n registry = ILiquidatorsRegistry(ap.getAddress(\"LiquidatorsRegistry\"));\n stable = IERC20Upgradeable(ap.getAddress(\"stableToken\"));\n wtoken = IERC20Upgradeable(ap.getAddress(\"wtoken\"));\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testResetStrategies() public debuggingOnly fork(BSC_CHAPEL) {\n upgradeRegistry();\n\n IRedemptionStrategy[] memory strategiesConfig = new IRedemptionStrategy[](3);\n IERC20Upgradeable[] memory inputTokensConfig = new IERC20Upgradeable[](3);\n IERC20Upgradeable[] memory outputTokensConfig = new IERC20Upgradeable[](3);\n {\n strategiesConfig[0] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n strategiesConfig[1] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n strategiesConfig[2] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n inputTokensConfig[0] = IERC20Upgradeable(chapelBomb);\n inputTokensConfig[1] = IERC20Upgradeable(chapelTUsd);\n inputTokensConfig[2] = IERC20Upgradeable(chapelTDai);\n outputTokensConfig[0] = IERC20Upgradeable(chapelTUsd);\n outputTokensConfig[1] = IERC20Upgradeable(chapelBomb);\n outputTokensConfig[2] = IERC20Upgradeable(chapelBomb);\n }\n\n bool matchingBefore = registry.pairsStrategiesMatch(strategiesConfig, inputTokensConfig, outputTokensConfig);\n assertEq(matchingBefore, false, \"should not match prior\");\n\n vm.prank(ap.getAddress(\"deployer\"));\n registry._resetRedemptionStrategies(strategiesConfig, inputTokensConfig, outputTokensConfig);\n\n bool matchingAfter = registry.pairsStrategiesMatch(strategiesConfig, inputTokensConfig, outputTokensConfig);\n assertEq(matchingAfter, true, \"should match after\");\n }\n\n function testResetDuplicatingStrategies() public debuggingOnly fork(BSC_CHAPEL) {\n upgradeRegistry();\n\n IRedemptionStrategy[] memory strategiesConfig = new IRedemptionStrategy[](4);\n IERC20Upgradeable[] memory inputTokensConfig = new IERC20Upgradeable[](4);\n IERC20Upgradeable[] memory outputTokensConfig = new IERC20Upgradeable[](4);\n {\n strategiesConfig[0] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n strategiesConfig[1] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n strategiesConfig[2] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n strategiesConfig[3] = IRedemptionStrategy(0xC875a8D8E8a593953115131697a788faEAa37109);\n inputTokensConfig[0] = IERC20Upgradeable(chapelBomb);\n inputTokensConfig[1] = IERC20Upgradeable(chapelTUsd);\n inputTokensConfig[2] = IERC20Upgradeable(chapelTDai);\n inputTokensConfig[3] = IERC20Upgradeable(chapelTDai);\n outputTokensConfig[0] = IERC20Upgradeable(chapelTUsd);\n outputTokensConfig[1] = IERC20Upgradeable(chapelBomb);\n outputTokensConfig[2] = IERC20Upgradeable(chapelBomb);\n outputTokensConfig[3] = IERC20Upgradeable(chapelBomb);\n }\n\n bool matchingBefore = registry.pairsStrategiesMatch(strategiesConfig, inputTokensConfig, outputTokensConfig);\n assertEq(matchingBefore, false, \"should not match prior\");\n\n vm.prank(ap.getAddress(\"deployer\"));\n registry._resetRedemptionStrategies(strategiesConfig, inputTokensConfig, outputTokensConfig);\n\n bool matchingAfter = registry.pairsStrategiesMatch(strategiesConfig, inputTokensConfig, outputTokensConfig);\n assertEq(matchingAfter, true, \"should match after\");\n }\n\n function testRedemptionPathChapel() public debuggingOnly fork(BSC_CHAPEL) {\n emit log(\"bomb tusd\");\n emit log(registry.redemptionStrategiesByTokens(chapelBomb, chapelTDai).name());\n emit log(\"tusd bomb\");\n emit log(registry.redemptionStrategiesByTokens(chapelTDai, chapelBomb).name());\n\n (IRedemptionStrategy strategy, bytes memory strategyData) = registry.getRedemptionStrategy(chapelBomb, chapelTDai);\n }\n\n function testInputTokensChapel() public debuggingOnly fork(BSC_CHAPEL) {\n address[] memory inputTokens = registry.getInputTokensByOutputToken(chapelBomb);\n\n emit log_named_array(\"inputs\", inputTokens);\n }\n\n function testInputTokensBsc() public debuggingOnly fork(BSC_MAINNET) {\n address[] memory inputTokens = registry.getInputTokensByOutputToken(stable);\n\n emit log_named_array(\"inputs\", inputTokens);\n }\n\n function _swap(\n address whale,\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken,\n uint256 tolerance\n ) internal {\n vm.startPrank(whale);\n inputToken.approve(address(registry), inputAmount);\n (uint256 swappedAmountOut, uint256 slippage) = registry.amountOutAndSlippageOfSwap(\n inputToken,\n inputAmount,\n outputToken\n );\n vm.stopPrank();\n\n emit log_named_uint(\"received\", swappedAmountOut);\n assertLt(slippage, tolerance, \"slippage too high\");\n }\n\n function testSwappingUniLpBsc() public fork(BSC_MAINNET) {\n address lpTokenWhale = 0x14B2e8329b8e06BCD524eb114E23fAbD21910109;\n\n IERC20Upgradeable inputToken = usdcBusdCakeLpToken;\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = stable;\n\n _swap(lpTokenWhale, inputToken, inputAmount, outputToken, 1e16);\n }\n\n function testSwappingGammaLpBsc() public fork(BSC_MAINNET) {\n address lpTokenWhale = 0xd44ad81474d075c3Bf0307830977A5804BfC0bc7; // thena gauge\n\n IERC20Upgradeable inputToken = ankrAnkrBnbGammaLpToken;\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = wtoken;\n\n _swap(lpTokenWhale, inputToken, inputAmount, outputToken, 1e16);\n }\n\n function testSwappingBalancerStableLpPolygon() public fork(POLYGON_MAINNET) {\n // TODO: run deployment to fix the liquidation path and set the balancer liquidator data\n address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // balancer gauge\n\n // maticx-wmatic aave boosted\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = wtoken;\n\n _swap(lpTokenWhale, maticxBbaBalancerStableLpToken, inputAmount, outputToken, 1e16);\n\n // stmatic-wmatic aave boosted\n _swap(lpTokenWhale, stMaticBbaBalancerStableLpToken, inputAmount, outputToken, 1e16);\n }\n\n function testSwappingBalancerWeightedLpPolygon() public fork(POLYGON_MAINNET) {\n address lpTokenWhale = 0xbB60ADbe38B4e6ab7fb0f9546C2C1b665B86af11; // mimo staker\n\n IERC20Upgradeable inputToken = mimoParBalancerWeightedLpToken;\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = IERC20Upgradeable(0xE2Aa7db6dA1dAE97C5f5C6914d285fBfCC32A128); // PAR\n\n _swap(lpTokenWhale, inputToken, inputAmount, outputToken, 5e16);\n }\n\n address tusdWhale = 0x161FbE0943Af4A39a50262026A81a243B635982d; // old XBombSwap\n address tdaiWhale = 0xd816eb4660615BBF080ddf425F28ea4AF30d04D5; // old XBombSwap\n address bombWhale = 0xd816eb4660615BBF080ddf425F28ea4AF30d04D5; // old XBombSwap\n\n function testSwappingBombTDaiChapel() public debuggingOnly fork(BSC_CHAPEL) {\n IERC20Upgradeable inputToken = chapelBomb;\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = chapelTDai;\n\n _swap(bombWhale, inputToken, inputAmount, outputToken, 5e16);\n }\n\n function testSwappingTUsdBombChapel() public debuggingOnly fork(BSC_CHAPEL) {\n IERC20Upgradeable inputToken = chapelTUsd;\n uint256 inputAmount = 1e18;\n IERC20Upgradeable outputToken = chapelBomb;\n\n _swap(tusdWhale, inputToken, inputAmount, outputToken, 5e16);\n }\n}\n" + }, + "contracts/test/LiquidityMining.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { FlywheelStaticRewards } from \"../ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { IonicFlywheelLensRouter } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LiquidityMiningTest is BaseTest {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n CErc20Delegate cErc20Delegate;\n ICErc20 cErc20;\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheel flywheel;\n FlywheelStaticRewards rewards;\n IonicFlywheelLensRouter flywheelClaimer;\n\n address user = address(1337);\n\n uint8 baseDecimal;\n uint8 rewardDecimal;\n\n address[] markets;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts(uint8 _baseDecimal, uint8 _rewardDecimal) public {\n baseDecimal = _baseDecimal;\n rewardDecimal = _rewardDecimal;\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", baseDecimal);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", rewardDecimal);\n interestModel = new JumpRateModel(2343665, 1 * 10**baseDecimal, 1 * 10**baseDecimal, 4 * 10**baseDecimal, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1 * 10**(baseDecimal - 2));\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n cErc20Delegate = new CErc20Delegate();\n // set the new delegate as the latest\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), abi.encode(address(0)));\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n }\n\n function setUpPoolAndMarket() public {\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, user, poolAuth.BORROWER_ROLE(), true);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"CUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n cErc20 = allMarkets[allMarkets.length - 1];\n }\n\n function setUpFlywheel() public {\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, FlywheelStaticRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n rewards = new FlywheelStaticRewards(IonicFlywheelCore(address(flywheel)), address(this), Authority(address(0)));\n flywheel.setFlywheelRewards(rewards);\n\n flywheelClaimer = new IonicFlywheelLensRouter(poolDirectory);\n\n flywheel.addStrategyForRewards(ERC20(address(cErc20)));\n\n // add flywheel as rewardsDistributor to call flywheelPreBorrowAction / flywheelPreSupplyAction\n require(comptroller._addRewardsDistributor(address(flywheel)) == 0);\n\n // seed rewards to flywheel\n rewardToken.mint(address(rewards), 100 * 10**rewardDecimal);\n\n // Start reward distribution at 1 token per second\n rewards.setRewardsInfo(\n ERC20(address(cErc20)),\n FlywheelStaticRewards.RewardsInfo({ rewardsPerSecond: uint224(1 * 10**rewardDecimal), rewardsEndTimestamp: 0 })\n );\n\n // preparation for a later call\n flywheelsToClaim.push(IonicFlywheelCore(address(flywheel)));\n }\n\n function _initialize(uint8 _baseDecimal, uint8 _rewardDecimal) internal {\n setUpBaseContracts(_baseDecimal, _rewardDecimal);\n setUpPoolAndMarket();\n setUpFlywheel();\n deposit(1 * 10**_baseDecimal);\n vm.warp(block.timestamp + 1);\n }\n\n function deposit(uint256 _amount) public {\n underlyingToken.mint(user, _amount);\n vm.startPrank(user);\n underlyingToken.approve(address(cErc20), _amount);\n comptroller.enterMarkets(markets);\n cErc20.mint(_amount);\n vm.stopPrank();\n }\n\n function _testIntegration() internal {\n uint256 percentFee = flywheel.performanceFee();\n uint224 percent100 = 100e16; //flywheel.ONE();\n\n // store expected rewards per token (1 token per second over total supply)\n uint256 rewardsPerTokenPlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerTokenForFee = (rewardsPerTokenPlusFee * percentFee) / percent100;\n uint256 rewardsPerToken = rewardsPerTokenPlusFee - rewardsPerTokenForFee;\n\n // store expected user rewards (user balance times reward per second over 1 token)\n uint256 userRewards = (rewardsPerToken * cErc20.balanceOf(user)) / (1 * 10**baseDecimal);\n\n ERC20 asErc20 = ERC20(address(cErc20));\n // accrue rewards and check against expected\n assertEq(flywheel.accrue(asErc20, user), userRewards, \"!accrue amount\");\n\n // check market index\n (uint224 index, ) = flywheel.strategyState(asErc20);\n assertEq(index, 10**rewardDecimal + rewardsPerToken, \"!index\");\n\n // claim and check user balance\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n assertEq(rewardToken.balanceOf(user), userRewards, \"!user rewards\");\n\n // mint more tokens by user and rerun test\n deposit(1 * 10**baseDecimal);\n\n // for next test, advance 10 seconds instead of 1 (multiply expectations by 10)\n vm.warp(block.timestamp + 10);\n\n uint256 rewardsPerToken2PlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerToken2ForFee = (rewardsPerToken2PlusFee * percentFee) / percent100;\n uint256 rewardsPerToken2 = rewardsPerToken2PlusFee - rewardsPerToken2ForFee;\n\n uint256 userRewards2 = (10 * (rewardsPerToken2 * cErc20.balanceOf(user))) / (1 * 10**baseDecimal);\n\n // accrue all unclaimed rewards and claim them\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n\n emit log_named_uint(\"userRewards\", userRewards);\n emit log_named_uint(\"userRewards2\", userRewards2);\n // user balance should accumulate from both rewards\n assertEq(rewardToken.balanceOf(user), userRewards + userRewards2, \"balance mismatch\");\n }\n\n function testIntegrationRewardStandard(uint8 i, uint8 j) public {\n vm.assume(i > 1);\n vm.assume(j > 1);\n vm.assume(i < 19);\n vm.assume(j < 19);\n\n _initialize(i, j);\n _testIntegration();\n }\n}\n" + }, + "contracts/test/LoopTest.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity >=0.8.0;\n\n// import \"forge-std/Test.sol\";\n\n// import { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\n// import { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\n// import { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n// import { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\n// import { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\n// import { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\n// contract ezEthWethLeveredPositionTest is Test {\n// address me = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n\n// function setUp() public {}\n\n// function test_ezEthWeth() public {\n// vm.createSelectFork(vm.rpcUrl(\"base_archive\"));\n// vm.rollFork(19713666);\n\n// ILeveredPositionFactory factory = ILeveredPositionFactory(0x0Bd42a5226db7FCEb9D3e50539778A15C3665da8);\n// ICErc20 collateralMarket = ICErc20(0x014e08F05ac11BB532BE62774A4C548368f59779);\n// ICErc20 stableMarket = ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0);\n// uint256 depositAmount = 48672877617700471281;\n\n// IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n// emit log_named_uint(\"collateral balance\", collateralToken.balanceOf(me));\n\n// vm.startPrank(me);\n// collateralToken.approve(address(factory), depositAmount);\n// LeveredPosition position = factory.createAndFundPositionAtRatio(\n// collateralMarket,\n// stableMarket,\n// collateralToken,\n// depositAmount,\n// 3 ether\n// );\n// vm.stopPrank();\n\n// uint256 _maxRatio;\n// uint256 _minRatio;\n\n// _maxRatio = position.getMaxLeverageRatio();\n// emit log_named_uint(\"max ratio\", _maxRatio);\n// _minRatio = position.getMinLeverageRatio();\n// emit log_named_uint(\"min ratio\", _minRatio);\n// assertGt(_maxRatio, _minRatio, \"max ratio <= min ratio\");\n\n// uint256 currentRatio = position.getCurrentLeverageRatio();\n// emit log_named_uint(\"current ratio\", currentRatio);\n// }\n// }\n" + }, + "contracts/test/MaxBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./helpers/WithPool.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract MockAsset is MockERC20 {\n constructor() MockERC20(\"test\", \"test\", 8) {}\n\n function deposit() external payable {}\n}\n\ncontract MaxBorrowTest is WithPool {\n address usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD;\n address daiWhale = 0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B;\n\n struct LiquidationData {\n address[] cTokens;\n ICErc20[] allMarkets;\n MockAsset usdc;\n MockAsset dai;\n }\n\n function afterForkSetUp() internal override {\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n if (block.chainid == POLYGON_MAINNET) {\n vm.prank(0x369582d2010B6eD950B571F4101e3bB9b554876F); // SAND/WMATIC\n MockERC20(address(underlyingToken)).transfer(address(this), 100e18);\n setUpPool(\"polygon-test\", false, 0.1e18, 1.1e18);\n } else if (block.chainid == BSC_MAINNET) {\n deal(address(underlyingToken), address(this), 100e18);\n setUpPool(\"bsc-test\", false, 0.1e18, 1.1e18);\n }\n }\n\n // TODO redeploy to polygon to fix\n function testMaxBorrow() public fork(POLYGON_MAINNET) {\n PoolLensSecondary poolLensSecondary = new PoolLensSecondary();\n poolLensSecondary.initialize(poolDirectory);\n\n LiquidationData memory vars;\n vm.roll(1);\n vars.usdc = MockAsset(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n vars.dai = MockAsset(0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063);\n\n deployCErc20Delegate(address(vars.usdc), \"USDC\", \"usdc\", 0.9e18);\n deployCErc20Delegate(address(vars.dai), \"DAI\", \"dai\", 0.9e18);\n\n vars.allMarkets = comptroller.getAllMarkets();\n\n CErc20Delegate cToken = CErc20Delegate(address(vars.allMarkets[0]));\n\n CErc20Delegate cDaiToken = CErc20Delegate(address(vars.allMarkets[1]));\n\n vars.cTokens = new address[](1);\n\n address accountOne = address(1);\n PoolRolesAuthority pra = ionicAdmin.authoritiesRegistry().poolsAuthorities(address(comptroller));\n\n vm.startPrank(pra.owner());\n pra.setUserRole(accountOne, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n\n vm.prank(usdcWhale);\n MockERC20(address(vars.usdc)).transfer(accountOne, 10000e6);\n\n vm.prank(daiWhale);\n MockERC20(address(vars.dai)).transfer(accountOne, 10000e18);\n\n // Account One Supply\n {\n emit log(\"Account One Supply\");\n vm.startPrank(accountOne);\n vars.usdc.approve(address(cToken), 1e36);\n cToken.mint(1e6);\n vars.cTokens[0] = address(cToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vars.dai.approve(address(cDaiToken), 1e36);\n cDaiToken.mint(1e18);\n vars.cTokens[0] = address(cDaiToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vm.stopPrank();\n assertEq(cToken.totalSupply(), 1e6 * 5);\n assertEq(cDaiToken.totalSupply(), 1e18 * 5);\n\n uint256 maxBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n uint256 maxDaiBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cDaiToken)));\n assertApproxEqAbs((maxBorrow * 1e18) / 10**cToken.decimals(), maxDaiBorrow, uint256(1e16), \"!max borrow\");\n }\n\n // borrow cap for collateral test\n {\n vm.prank(comptroller.admin());\n comptroller._setBorrowCapForCollateral(address(cToken), address(cDaiToken), 0.5e6);\n }\n\n uint256 maxBorrowAfterBorrowCap = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertApproxEqAbs(maxBorrowAfterBorrowCap, 0.5e6, uint256(1e5), \"!max borrow\");\n\n // blacklist\n {\n vm.prank(comptroller.admin());\n comptroller._blacklistBorrowingAgainstCollateral(address(cToken), address(cDaiToken), true);\n }\n\n uint256 maxBorrowAfterBlacklist = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertEq(maxBorrowAfterBlacklist, 0, \"!blacklist\");\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapPerCollateral() public debuggingOnly forkAtBlock(BSC_MAINNET, 23761190) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n\n address poolAddress = jFiatPoolAddress;\n Comptroller pool = Comptroller(poolAddress);\n\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(poolAddress);\n address[] memory borrowers = asExtension.getAllBorrowers();\n address someBorrower = borrowers[1];\n\n ICErc20[] memory markets = asExtension.getAllMarkets();\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = markets[i];\n uint256 borrowed = market.borrowBalanceCurrent(someBorrower);\n if (borrowed > 0) {\n emit log(\"borrower has borrowed\");\n emit log_uint(borrowed);\n emit log(\"from market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n\n uint256 collateral = market.balanceOf(someBorrower);\n if (collateral > 0) {\n emit log(\"has collateral\");\n emit log_uint(collateral);\n emit log(\"in market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n }\n\n ICErc20 marketToBorrow = markets[0];\n ICErc20 cappedCollateralMarket = markets[6];\n uint256 borrowAmount = marketToBorrow.borrowBalanceCurrent(someBorrower);\n\n {\n (uint256 errBefore, , uint256 liquidityBefore, uint256 shortfallBefore) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errBefore\");\n emit log_uint(errBefore);\n emit log(\"liquidityBefore\");\n emit log_uint(liquidityBefore);\n emit log(\"shortfallBefore\");\n emit log_uint(shortfallBefore);\n\n assertGt(liquidityBefore, 0, \"expected positive liquidity\");\n }\n\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(marketToBorrow), address(cappedCollateralMarket), 1);\n emit log(\"\");\n\n (uint256 errAfter, , uint256 liquidityAfter, uint256 shortfallAfter) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errAfter\");\n emit log_uint(errAfter);\n emit log(\"liquidityAfter\");\n emit log_uint(liquidityAfter);\n emit log(\"shortfallAfter\");\n emit log_uint(shortfallAfter);\n\n assertGt(shortfallAfter, 0, \"expected some shortfall\");\n }\n}\n" + }, + "contracts/test/MaxWithdrawTest.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity >=0.8.0;\n\n// import \"./helpers/WithPool.sol\";\n// import { BaseTest } from \"./config/BaseTest.t.sol\";\n// import \"forge-std/Test.sol\";\n\n// import { ERC20 } from \"solmate/tokens/ERC20.sol\";\n// import { FuseFlywheelDynamicRewards } from \"fuse-flywheel/rewards/FuseFlywheelDynamicRewards.sol\";\n// import { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\n// import { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n// import { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\n// import { IFundsConversionStrategy } from \"../liquidators/IFundsConversionStrategy.sol\";\n// import { IUniswapV2Router02 } from \"../external/uniswap/IUniswapV2Router02.sol\";\n// import { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\n// import { UniswapLpTokenLiquidator } from \"../liquidators/UniswapLpTokenLiquidator.sol\";\n// import { IUniswapV2Pair } from \"../external/uniswap/IUniswapV2Pair.sol\";\n// import { IUniswapV2Factory } from \"../external/uniswap/IUniswapV2Factory.sol\";\n// import { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\n// contract MockAsset is MockERC20 {\n// constructor() MockERC20(\"test\", \"test\", 8) {}\n\n// function deposit() external payable {}\n// }\n\n// contract MaxWithdrawTest is WithPool {\n// struct LiquidationData {\n// address[] cTokens;\n// ICErc20[] allMarkets;\n// MockAsset bnb;\n// MockAsset mimo;\n// MockAsset usdc;\n// }\n\n// function afterForkSetUp() internal override {\n// super.setUpWithPool(\n// MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n// ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n// );\n\n// deal(address(underlyingToken), address(this), 100e18);\n// setUpPool(\"bsc-test\", false, 0.1e18, 1.1e18);\n// }\n\n// function testMaxWithdrawBsc() public fork(BSC_MAINNET) {\n// PoolLensSecondary poolLensSecondary = new PoolLensSecondary();\n// poolLensSecondary.initialize(poolDirectory);\n\n// LiquidationData memory vars;\n// vm.roll(1);\n// vars.bnb = MockAsset(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);\n// vars.usdc = MockAsset(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);\n\n// deployCErc20Delegate(address(vars.bnb), \"BNB\", \"bnb\", 0.9e18);\n// deployCErc20Delegate(address(vars.usdc), \"USDC\", \"usdc\", 0.9e18);\n\n// // TODO no need to upgrade after the next deploy\n// upgradePool(address(comptroller));\n\n// vars.allMarkets = comptroller.getAllMarkets();\n// CErc20Delegate cBnbToken = CErc20Delegate(address(vars.allMarkets[0]));\n\n// CErc20Delegate cUSDC = CErc20Delegate(address(vars.allMarkets[1]));\n\n// vars.cTokens = new address[](1);\n// vars.cTokens[0] = address(cBnbToken);\n\n// address accountOne = address(1);\n// address accountTwo = address(2);\n// address accountThree = address(3);\n\n// {\n// address comptrollerAddress = address(comptroller);\n// AuthoritiesRegistry ar = ionicAdmin.authoritiesRegistry();\n// PoolRolesAuthority poolAuth = ar.poolsAuthorities(comptrollerAddress);\n// ar.setUserRole(comptrollerAddress, accountOne, poolAuth.BORROWER_ROLE(), true);\n// ar.setUserRole(comptrollerAddress, accountTwo, poolAuth.BORROWER_ROLE(), true);\n// ar.setUserRole(comptrollerAddress, accountThree, poolAuth.BORROWER_ROLE(), true);\n// }\n\n// // Account One Supply\n// deal(address(vars.bnb), accountOne, 5000000000e18);\n// deal(address(vars.bnb), accountThree, 5000000000e18);\n// deal(address(vars.usdc), accountTwo, 10000e18);\n\n// // Account One Supply\n// {\n// emit log(\"Account One Supply\");\n// vm.startPrank(accountOne);\n// vars.bnb.approve(address(cBnbToken), 1e36);\n// assertEq(cBnbToken.mint(1e18), 0, \"!cbnb mint acc 1\");\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// }\n\n// // Account Three Supply\n// {\n// emit log(\"Account Three Supply\");\n// vm.startPrank(accountThree);\n// vars.bnb.approve(address(cBnbToken), 1e36);\n// assertEq(cBnbToken.mint(1e18), 0, \"!cbnb mint acc 3\");\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// }\n\n// // Account Two Supply\n// {\n// emit log(\"Account Two Supply\");\n// vm.startPrank(accountTwo);\n// vars.usdc.approve(address(cUSDC), 1e36);\n// assertEq(cUSDC.mint(1000e18), 0, \"!cusdc mint acc 2\");\n// vars.cTokens[0] = address(cUSDC);\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// assertEq(cUSDC.totalSupply(), 1000e18 * 5, \"!cUSDC total supply\");\n// assertEq(cBnbToken.totalSupply(), 1e18 * 5 * 2, \"!cBNB total supply\");\n// }\n\n// // Account Two Borrow\n// {\n// emit log(\"Account Two Borrow\");\n// vm.startPrank(accountTwo);\n// assertEq(cBnbToken.borrow(0.5e18), 0, \"!cbnb borrow acc 2\");\n// vm.stopPrank();\n// }\n\n// // Account One Borrow\n// {\n// emit log(\"Account One Borrow\");\n// vm.startPrank(accountOne);\n// assertEq(cUSDC.borrow(110e18), 0, \"!cusdc borrow acc 1\");\n// assertEq(cUSDC.totalBorrows(), 110e18, \"!total borrows\");\n\n// uint256 maxWithdraw = poolLensSecondary.getMaxRedeem(accountOne, ICErc20(address(cBnbToken)));\n\n// uint256 beforeBnbBalance = vars.bnb.balanceOf(accountOne);\n// cBnbToken.redeemUnderlying(type(uint256).max);\n// uint256 afterBnbBalance = vars.bnb.balanceOf(accountOne);\n\n// assertEq(afterBnbBalance - beforeBnbBalance, maxWithdraw, \"!bnb diff\");\n// vm.stopPrank();\n// }\n// }\n\n// function testMIIMOMaxWithdraw() public fork(POLYGON_MAINNET) {\n// PoolLensSecondary poolLensSecondary = new PoolLensSecondary();\n// poolLensSecondary.initialize(poolDirectory);\n\n// LiquidationData memory vars;\n// vm.roll(1);\n// vars.mimo = MockAsset(0xADAC33f543267c4D59a8c299cF804c303BC3e4aC);\n// vars.usdc = MockAsset(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n\n// deployCErc20Delegate(address(vars.mimo), \"MIMO\", \"mimo\", 0.9e18);\n// deployCErc20Delegate(address(vars.usdc), \"USDC\", \"usdc\", 0.9e18);\n\n// vars.allMarkets = comptroller.getAllMarkets();\n// CErc20Delegate cMimoToken = CErc20Delegate(address(vars.allMarkets[0]));\n\n// CErc20Delegate cUSDC = CErc20Delegate(address(vars.allMarkets[1]));\n\n// vars.cTokens = new address[](1);\n\n// address accountOne = address(1);\n// address accountTwo = address(2);\n// address accountThree = address(3);\n\n// {\n// address comptrollerAddress = address(comptroller);\n// AuthoritiesRegistry ar = ionicAdmin.authoritiesRegistry();\n// PoolRolesAuthority poolAuth = ar.poolsAuthorities(comptrollerAddress);\n// ar.setUserRole(comptrollerAddress, accountOne, poolAuth.BORROWER_ROLE(), true);\n// ar.setUserRole(comptrollerAddress, accountTwo, poolAuth.BORROWER_ROLE(), true);\n// ar.setUserRole(comptrollerAddress, accountThree, poolAuth.BORROWER_ROLE(), true);\n// }\n\n// deal(address(vars.mimo), accountOne, 5e27);\n// deal(address(vars.mimo), accountThree, 5e27);\n// deal(address(vars.usdc), accountTwo, 10000e6);\n\n// // Account One Supply\n// {\n// emit log(\"Account One Supply\");\n// vm.startPrank(accountOne);\n// vars.mimo.approve(address(cMimoToken), 1e36);\n// assertEq(cMimoToken.mint(10e24), 0, \"!cmimo mint acc 1\");\n// vars.cTokens[0] = address(cMimoToken);\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// }\n\n// // Account Three Supply\n// {\n// emit log(\"Account Three Supply\");\n// vm.startPrank(accountThree);\n// vars.mimo.approve(address(cMimoToken), 1e36);\n// assertEq(cMimoToken.mint(10e24), 0, \"!cmimo mint acc 3\");\n// vars.cTokens[0] = address(cMimoToken);\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// }\n\n// // Account Two Supply\n// {\n// emit log(\"Account Two Supply\");\n// vm.startPrank(accountTwo);\n// vars.usdc.approve(address(cUSDC), 1e36);\n// assertEq(cUSDC.mint(1000e6), 0, \"!cusdc mint acc 2\");\n// vars.cTokens[0] = address(cUSDC);\n// comptroller.enterMarkets(vars.cTokens);\n// vm.stopPrank();\n// assertEq(cUSDC.totalSupply(), 1000e6 * 5, \"!cUSDC total supply\");\n// assertEq(cMimoToken.totalSupply(), 10000000e18 * 5 * 2, \"!cMimo total supply\");\n// }\n\n// // Account Two Borrow\n// {\n// emit log(\"Account Two Borrow\");\n// vm.startPrank(accountTwo);\n// uint256 maxBorrow = poolLensSecondary.getMaxBorrow(accountTwo, ICErc20(address(cMimoToken)));\n// emit log_uint(maxBorrow);\n// assertEq(cMimoToken.borrow(maxBorrow), 0, \"!cmimo borrow acc 2\");\n// assertEq(cMimoToken.totalBorrows(), maxBorrow, \"!cMimo total borrows\");\n\n// vm.stopPrank();\n// }\n\n// // Account One Borrow\n// {\n// emit log(\"Account One Borrow\");\n// vm.startPrank(accountOne);\n// vars.usdc.approve(address(cUSDC), 1e36);\n// assertEq(cUSDC.borrow(150e6), 0, \"!cusdc borrow acc 1\");\n// assertEq(cUSDC.totalBorrows(), 150e6, \"!cUSDC total borrows\");\n\n// uint256 maxWithdraw = poolLensSecondary.getMaxRedeem(accountOne, ICErc20(address(cMimoToken)));\n\n// uint256 beforeMimoBalance = vars.mimo.balanceOf(accountOne);\n// cMimoToken.redeemUnderlying(type(uint256).max);\n// uint256 afterMimoBalance = vars.mimo.balanceOf(accountOne);\n\n// assertEq(afterMimoBalance - beforeMimoBalance, maxWithdraw, \"!mimo diff\");\n// vm.stopPrank();\n// }\n// }\n// }\n" + }, + "contracts/test/MinBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract MinBorrowTest is BaseTest {\n FeeDistributor ffd;\n\n function afterForkSetUp() internal override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testMinBorrow() public fork(BSC_MAINNET) {\n IERC20Upgradeable usdc = IERC20Upgradeable(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);\n IERC20Upgradeable busd = IERC20Upgradeable(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);\n\n ICErc20 usdcMarket = ICErc20(0x16B8da195CdC7F380B333bf6cF2f0f33c1061755);\n ICErc20 busdMarket = ICErc20(0x3BCb7dbBe729B24bE6c660B3e8ADD1Cb352e371D);\n IonicComptroller comptroller = usdcMarket.comptroller();\n deal(address(usdc), address(this), 10000e18);\n deal(address(busd), address(1), 10000e18);\n\n usdc.approve(address(usdcMarket), 1e36);\n usdcMarket.mint(1000e18);\n\n vm.startPrank(address(1));\n busd.approve(address(busdMarket), 1e36);\n busdMarket.mint(1000e18);\n vm.stopPrank();\n\n // the 0 liquidity base min borrow amount\n uint256 baseMinBorrowEth = ffd.minBorrowEth();\n\n address[] memory cTokens = new address[](2);\n cTokens[0] = address(usdcMarket);\n cTokens[1] = address(busdMarket);\n comptroller.enterMarkets(cTokens);\n\n uint256 minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, baseMinBorrowEth, \"!minBorrowEth for default min borrow eth\");\n\n busdMarket.borrow(300e18);\n\n minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, 0, \"!minBorrowEth after borrowing less amount than min amount\");\n }\n}\n" + }, + "contracts/test/OracleProtectedTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\ncontract MockOraclePasses is IHypernativeOracle {\n function isBlacklistedContext(address _account, address _origin) external pure returns (bool) {\n return false;\n }\n function isTimeExceeded(address _account) external pure returns (bool) {\n return true;\n }\n function isBlacklistedAccount(address _account) external pure returns (bool) {\n return false;\n }\n function register(address _account) external {}\n function registerStrict(address _account) external {}\n}\n\ncontract MockOracleFails is IHypernativeOracle {\n function isBlacklistedContext(address _account, address _origin) external pure returns (bool) {\n return true;\n }\n\n function isTimeExceeded(address _account) external pure returns (bool) {\n return true;\n }\n\n function isBlacklistedAccount(address _account) external pure returns (bool) {\n return false;\n }\n function register(address _account) external {}\n function registerStrict(address _account) external {}\n}\n\ncontract OracleProtectedTest is UpgradesBaseTest {\n error InteractionNotAllowed();\n ICErc20 market = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3);\n address admin = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n IHypernativeOracle oraclePasses;\n IHypernativeOracle oracleFails;\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n _upgradeMarketWithExtension(market);\n oraclePasses = new MockOraclePasses();\n oracleFails = new MockOracleFails();\n }\n\n function test_mint_failsForBlacklisted() public debuggingOnly forkAtBlock(BASE_MAINNET, 20538729) {\n CTokenFirstExtension asExt = CTokenFirstExtension(address(market)); \n // Set up the oracle\n vm.startPrank(admin);\n ap.setAddress(\"HYPERNATIVE_ORACLE\", address(oracleFails));\n vm.stopPrank();\n \n // Try to mint\n address user = address(0x1234);\n uint256 mintAmount = 1e18;\n deal(asExt.underlying(), user, mintAmount);\n \n vm.startPrank(user);\n ICErc20(asExt.underlying()).approve(address(asExt), mintAmount);\n \n vm.expectRevert(InteractionNotAllowed.selector);\n market.mint(mintAmount);\n vm.stopPrank();\n\n // Set up the oracle to pass\n vm.prank(admin);\n ap.setAddress(\"HYPERNATIVE_ORACLE\", address(oraclePasses));\n\n vm.startPrank(user);\n market.mint(mintAmount);\n vm.stopPrank();\n\n // check balances\n assertGt(market.balanceOf(user), 0);\n }\n}\n" + }, + "contracts/test/oracles/default/AlgebraPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { AlgebraPriceOracle } from \"../../../oracles/default/AlgebraPriceOracle.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"../../../oracles/default/ConcentratedLiquidityBasePriceOracle.sol\";\nimport { IAlgebraPool } from \"../../../external/algebra/IAlgebraPool.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract AlgebraPriceOracleTest is BaseTest {\n AlgebraPriceOracle oracle;\n MasterPriceOracle mpo;\n address wtoken;\n address wbtc;\n address stable;\n\n function afterForkSetUp() internal override {\n stable = ap.getAddress(\"stableToken\");\n wtoken = ap.getAddress(\"wtoken\"); // WETH\n wbtc = ap.getAddress(\"wBTCToken\"); // WBTC\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new AlgebraPriceOracle();\n\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n }\n\n function testBscAssets() public forkAtBlock(BSC_MAINNET, 27513712) {\n address thena = 0xF4C8E32EaDEC4BFe97E0F595AdD0f4450a863a11; // THE (18 decimals)\n address usdt = 0x55d398326f99059fF775485246999027B3197955; // USDT (18 decimals)\n\n address[] memory underlyings = new address[](2);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](2);\n\n underlyings[0] = thena;\n underlyings[1] = usdt;\n\n // THE-WBNB\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x51Bd5e6d3da9064D59BcaA5A76776560aB42cEb8,\n 10 minutes,\n wtoken\n );\n // USDT-USDC\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x1b9a1120a17617D8eC4dC80B921A9A1C50Caef7d,\n 10 minutes,\n stable\n );\n\n uint256[] memory expPrices = new uint256[](2);\n expPrices[0] = 1279780177402873; // == 0,001279 BNB -> $0,418 / $326 = 0,0012822 (20/04/2023)\n expPrices[1] = mpo.price(usdt);\n\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n\n assertEq(prices[0], expPrices[0], \"!Price Error\");\n assertApproxEqRel(prices[1], expPrices[1], 1e17, \"!Price Error\");\n }\n\n function testPolygonAssets() public forkAtBlock(POLYGON_MAINNET, 46013460) {\n address maticX = 0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6;\n address dai = 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063;\n address[] memory underlyings = new address[](3);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](3);\n\n // 18 / 18\n underlyings[0] = maticX; // MaticX (18 decimals)\n // 8 / 6\n underlyings[1] = wbtc; // WBTC (8 decimals)\n // 18 / 6\n underlyings[2] = dai; // DAI (18 decimals)\n\n // MaticX-Wmatic\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x05BFE97Bf794a4DB69d3059091F064eA0a5E538E,\n 10 minutes,\n wtoken\n );\n // WBTC-USDC\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xA5CD8351Cbf30B531C7b11B0D9d3Ff38eA2E280f,\n 10 minutes,\n stable\n );\n // DAI-USDC\n configs[2] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xe7E0eB9F6bCcCfe847fDf62a3628319a092F11a2,\n 10 minutes,\n stable\n );\n\n uint256[] memory expPrices = new uint256[](3);\n expPrices[0] = 1072289959017680334; // 0,72$ / 0,67$ = 1,07 MATIC (07/07/2023)\n expPrices[1] = mpo.price(wbtc);\n expPrices[2] = mpo.price(dai);\n\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n\n assertEq(prices[0], expPrices[0], \"!Price Error\");\n assertApproxEqRel(prices[1], expPrices[1], 1e17, \"!Price Error\");\n assertApproxEqRel(prices[2], expPrices[2], 1e17, \"!Price Error\");\n }\n\n function testZkEvmAssets() public forkAtBlock(ZKEVM_MAINNET, 4167547) {\n address usdt = 0x1E4a5963aBFD975d8c9021ce480b42188849D41d; // 6 decimals\n address wmatic = 0xa2036f0538221a77A3937F1379699f44945018d0;\n\n address[] memory underlyings = new address[](3);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](3);\n\n underlyings[0] = wmatic; // WMATIC (18 decimals)\n underlyings[1] = wbtc; // WBTC (8 decimals)\n underlyings[2] = usdt; // WBTC (6 decimals)\n\n // WMATIC-WETH\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xB73AbFb5a2C89f4038baA476Ff3A7942A021c196,\n 10 minutes,\n wtoken\n );\n // WBTC-WETH\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xFC4A3A7dc6b62bd2EA595b106392f5E006083b83,\n 10 minutes,\n wtoken\n );\n // USDT-USDC\n configs[2] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x9591b8A30c3a52256ea93E98dA49EE43Afa136A8,\n 10 minutes,\n stable\n );\n\n uint256[] memory expPrices = new uint256[](3);\n expPrices[0] = 366000000000000; // $0.670691 / 1833$ = 0,000366 (07/07x/2023)\n expPrices[1] = 15849057118531331165; // $29,016.86 / 1833$ = 15,85 (07/07/2023)\n expPrices[2] = 545553737043099; // $1 / 1833$ = 0,000545$ (07/07/2023)\n\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n\n assertApproxEqRel(prices[0], expPrices[0], 1e17, \"!Price Error\");\n assertApproxEqRel(prices[1], expPrices[1], 1e17, \"!Price Error\");\n assertApproxEqRel(prices[2], expPrices[2], 1e17, \"!Price Error\");\n }\n\n function getPriceFeed(address[] memory underlyings, ConcentratedLiquidityBasePriceOracle.AssetConfig[] memory configs)\n internal\n returns (uint256[] memory price)\n {\n vm.prank(oracle.owner());\n oracle.setPoolFeeds(underlyings, configs);\n vm.roll(1);\n\n price = new uint256[](underlyings.length);\n for (uint256 i = 0; i < underlyings.length; i++) {\n vm.prank(address(mpo));\n price[i] = oracle.price(underlyings[i]);\n }\n return price;\n }\n\n function testSetUnsupportedBaseToken() public fork(POLYGON_MAINNET) {\n address usdt = 0xc2132D05D31c914a87C6611C10748AEb04B58e8F;\n address ixt = 0xE06Bd4F5aAc8D0aA337D13eC88dB6defC6eAEefE;\n\n address[] memory underlyings = new address[](1);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](1);\n\n underlyings[0] = ixt;\n\n // USDT/IXT\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xD6e486c197606559946384AE2624367d750A160f,\n 10 minutes,\n usdt\n );\n // revert if underlying is not supported\n vm.startPrank(oracle.owner());\n vm.expectRevert(bytes(\"Base token must be supported\"));\n oracle.setPoolFeeds(underlyings, configs);\n\n // add it successfully when suported\n oracle._setSupportedBaseTokens(asArray(usdt, stable));\n oracle.setPoolFeeds(underlyings, configs);\n vm.stopPrank();\n\n // check prices\n vm.prank(address(mpo));\n uint256 price = oracle.price(ixt);\n assertTrue(price > 0, \"!Price Error\");\n }\n}\n" + }, + "contracts/test/oracles/default/AnkrCertificateTokenPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { AnkrCertificateTokenPriceOracle } from \"../../../oracles/default/AnkrCertificateTokenPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\n\ncontract AnkrCertificateTokenPriceOracleTest is BaseTest {\n AnkrCertificateTokenPriceOracle private oracle;\n MasterPriceOracle mpo;\n address wtoken;\n address aFTMc = 0xCfC785741Dc0e98ad4c9F6394Bb9d43Cd1eF5179;\n address ankrBNB = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n address aMATICc = 0x0E9b89007eEE9c958c0EDA24eF70723C2C93dD58;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n wtoken = ap.getAddress(\"wtoken\");\n oracle = new AnkrCertificateTokenPriceOracle();\n if (block.chainid == BSC_MAINNET) {\n oracle.initialize(ankrBNB);\n } else if (block.chainid == POLYGON_MAINNET) {\n oracle.initialize(aMATICc);\n }\n }\n\n function testAnkrBSCOracle() public forkAtBlock(BSC_MAINNET, 24150586) {\n uint256 priceAnkrBNB = oracle.price(ankrBNB);\n assertGt(priceAnkrBNB, 1e18);\n assertEq(priceAnkrBNB, 1040035572321529337);\n }\n\n function testAnkrPolygonOracle() public fork(POLYGON_MAINNET) {\n uint256 priceAnkrMATICc = oracle.price(aMATICc);\n uint256 pricWmatic = mpo.price(wtoken);\n assertGt(priceAnkrMATICc, 1e18);\n assertGt(priceAnkrMATICc, pricWmatic);\n }\n}\n" + }, + "contracts/test/oracles/default/API3PriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { API3PriceOracle } from \"../../../oracles/default/API3PriceOracle.sol\";\nimport { IProxy } from \"../../../external/api3/IProxy.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\ncontract API3PriceOracleTest is BaseTest {\n API3PriceOracle private oracle;\n MasterPriceOracle mpo;\n address stableToken;\n address otherToken;\n address anotherToken;\n address wbtc;\n address wtoken;\n address NATIVE_TOKEN_USD_PRICE_FEED;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n stableToken = ap.getAddress(\"stableToken\");\n wbtc = ap.getAddress(\"wBTCToken\");\n wtoken = ap.getAddress(\"wtoken\");\n oracle = new API3PriceOracle();\n if (block.chainid == ZKEVM_MAINNET) {\n // ETH-USD\n NATIVE_TOKEN_USD_PRICE_FEED = 0x26690F9f17FdC26D419371315bc17950a0FC90eD;\n } else {\n revert(\"Unsupported chain\");\n }\n }\n\n function setUpZkEvm() public {\n vm.prank(mpo.admin());\n oracle.initialize(stableToken, NATIVE_TOKEN_USD_PRICE_FEED);\n\n address[] memory underlyings = new address[](4);\n address[] memory proxies = new address[](4);\n\n // USDT\n otherToken = 0x1E4a5963aBFD975d8c9021ce480b42188849D41d;\n // WMATIC\n anotherToken = 0xa2036f0538221a77A3937F1379699f44945018d0;\n\n underlyings[0] = stableToken;\n underlyings[1] = otherToken;\n underlyings[2] = anotherToken;\n underlyings[3] = wbtc;\n\n proxies[0] = 0x8DF7d919Fe9e866259BB4D135922c5Bd96AF6A27;\n proxies[1] = 0xF63Fa6EA00678F435Ae3e845541EBb2Db0a1e8fF;\n proxies[2] = 0xF63Fa6EA00678F435Ae3e845541EBb2Db0a1e8fF;\n proxies[3] = 0xe5Cf15fED24942E656dBF75165aF1851C89F21B5;\n\n vm.prank(oracle.owner());\n oracle.setPriceFeeds(underlyings, proxies);\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](4);\n oracles[0] = oracle;\n oracles[1] = oracle;\n oracles[2] = oracle;\n oracles[3] = oracle;\n\n vm.prank(mpo.admin());\n mpo.add(underlyings, oracles);\n }\n\n function testAPI3PriceOracleZkEvm() public fork(ZKEVM_MAINNET) {\n setUpZkEvm();\n vm.startPrank(address(mpo));\n uint256 api3UsdcPrice = oracle.price(stableToken);\n uint256 api3UsdtPrice = oracle.price(otherToken);\n uint256 api3WmaticPrice = oracle.price(anotherToken);\n uint256 api3WbtcPrice = oracle.price(wbtc);\n uint256 mpoWethPrice = mpo.price(wtoken);\n vm.stopPrank();\n\n assertApproxEqRel(api3UsdcPrice, api3UsdtPrice, 1e16);\n\n assertGt(api3UsdcPrice, api3WmaticPrice);\n assertGt(api3WbtcPrice, mpoWethPrice);\n assertGt(mpoWethPrice, api3UsdcPrice);\n }\n}\n" + }, + "contracts/test/oracles/default/BalancerLpPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { BalancerLpTokenPriceOracle } from \"../../../oracles/default/BalancerLpTokenPriceOracle.sol\";\nimport { BalancerLpTokenPriceOracleNTokens } from \"../../../oracles/default/BalancerLpTokenPriceOracleNTokens.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\nimport \"../../../external/balancer/IBalancerPool.sol\";\nimport \"../../../external/balancer/IBalancerVault.sol\";\nimport \"../../../external/balancer/BNum.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract BalancerLpTokenPriceOracleTest is BaseTest, BNum {\n BalancerLpTokenPriceOracle oracle;\n BalancerLpTokenPriceOracleNTokens oracleNTokens;\n\n MasterPriceOracle mpo;\n\n address wbtc = 0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6;\n address weth = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619;\n\n address balWeth2080 = 0x3d468AB2329F296e1b9d8476Bb54Dd77D8c2320f;\n address wbtcWeth5050 = 0xCF354603A9AEbD2Ff9f33E1B04246d8Ea204ae95;\n address wmaticUsdcWethBal25252525 = 0x0297e37f1873D2DAb4487Aa67cD56B58E2F27875;\n address threeBrl333333 = 0x5A5E4Fa45Be4c9cb214cD4EC2f2eB7053F9b4F6D;\n\n address mimoPar8020 = 0x82d7f08026e21c7713CfAd1071df7C8271B17Eae;\n address mimoPar8020_c = 0xcb67Bd2aE0597eDb2426802CdF34bb4085d9483A;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new BalancerLpTokenPriceOracle();\n oracleNTokens = new BalancerLpTokenPriceOracleNTokens();\n oracle.initialize(mpo);\n oracleNTokens.initialize(mpo);\n }\n\n // TODO: add test for mimo / par pair, when we deploy the MIMO DIA price oracle\n // See: https://github.com/Midas-Protocol/monorepo/issues/476\n function testPriceBalancer() public forkAtBlock(POLYGON_MAINNET, 46024675) {\n // 2-token pools\n uint256 priceWbtcEth = oracle.price(wbtcWeth5050);\n uint256 priceNTokensWbtEth = oracleNTokens.price(wbtcWeth5050);\n\n uint256 priceMimoPar = oracle.price(mimoPar8020);\n uint256 priceNTokensMimoPar = oracleNTokens.price(mimoPar8020);\n uint256 underlyingPriceMimoPar = mpo.getUnderlyingPrice(ICErc20(mimoPar8020_c));\n\n // Based on this tx: https://polygonscan.com/tx/0x206f359e35b49265c7b3cb28691e1ca547ae79475af8e479331dc936fcbf0dd0\n // 1220 USD$ worth of liquidity was removed for 0,197227836914 wbtcWeth5050 tokens\n\n // (1220 / 0,19722783691) = 6.185,7 USD / wbtcWeth5050\n // 6.185,7 / 1.00 = 6.185,7 wbtcWeth5050 / MATIC [1 MATIC ~= 1 USD$]\n // 6.185,7 * 1e18 ~ 6.185e21\n // Updated: 07/07/2023\n assertEq(priceWbtcEth, 11262839540893715595453);\n // Max deviation of 1e17, or 0.1%\n assertApproxEqRel(priceWbtcEth, priceNTokensWbtEth, 1e17);\n\n // Based on this tx: https://polygonscan.com/tx/0x38eda84addb9392a1bd15b1fe518de6d9e4a6dc3df7a611aba5d4ddf5cc83b47\n // 0,03 USD$ worth of liquidity was removed for 0,92153 mimoPar8020 tokens\n\n // (0,03 / 0,92153) = 0,03255 USD / mimoPar8020\n // 0,03255 / 1.00 = 0,03255 mimoPar8020 / MATIC [1 MATIC ~= 1 USD$]\n // 0,03255 * 1e18 ~ 3,255e16\n\n assertEq(priceMimoPar, 55237961865401672);\n assertEq(priceMimoPar, underlyingPriceMimoPar);\n // Max deviation of 1e17, or 0.1%\n assertApproxEqRel(priceMimoPar, priceNTokensMimoPar, 1e17);\n\n // 4-token pools\n uint256 priceNTokenswmaticUsdcWethBal = oracleNTokens.price(wmaticUsdcWethBal25252525);\n\n // Based on this tx: https://polygonscan.com/tx/0x206f359e35b49265c7b3cb28691e1ca547ae79475af8e479331dc936fcbf0dd0\n // 5390 USD$ worth of liquidity was removed for 440,3219429 wmaticUsdcWethBal25252525 tokens\n\n // (5390 / 440,321) = 12,2410 USD / wmaticUsdcWethBal25252525\n // 12,2410 / 1.00 = 12,2410 wmaticUsdcWethBal25252525 / MATIC [1 MATIC ~= 1 USD$]\n // 12,2410 * 1e18 ~ 1,2241e19\n // Updated: 07/07/2023\n assertEq(priceNTokenswmaticUsdcWethBal, 15468228316697206187);\n }\n}\n" + }, + "contracts/test/oracles/default/BalancerLpStablePoolPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BalancerLpStablePoolPriceOracle } from \"../../../oracles/default/BalancerLpStablePoolPriceOracle.sol\";\nimport { BalancerLpLinearPoolPriceOracle } from \"../../../oracles/default/BalancerLpLinearPoolPriceOracle.sol\";\nimport { BalancerRateProviderOracle } from \"../../../oracles/default/BalancerRateProviderOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { IBalancerLinearPool } from \"../../../external/balancer/IBalancerLinearPool.sol\";\nimport { IBalancerStablePool } from \"../../../external/balancer/IBalancerStablePool.sol\";\nimport { IBalancerVault, UserBalanceOp } from \"../../../external/balancer/IBalancerVault.sol\";\nimport { BalancerReentrancyAttacker } from \"../../helpers/BalancerReentrancyAttacker.sol\";\n\ncontract BalancerLpStablePoolPriceOracleTest is BaseTest {\n BalancerLpStablePoolPriceOracle stableLpOracle;\n BalancerLpLinearPoolPriceOracle linearLpOracle;\n BalancerRateProviderOracle rateProviderOracle;\n MasterPriceOracle mpo;\n\n address MATICx_AaveMATIC_pool = 0xE78b25c06dB117fdF8F98583CDaaa6c92B79E917;\n address stMATIC_AaveMATIC_pool = 0x216690738Aac4aa0C4770253CA26a28f0115c595;\n address stMATIC_WMATIC_pool = 0x8159462d255C1D24915CB51ec361F700174cD994;\n address jBRL_BRZ_pool = 0xE22483774bd8611bE2Ad2F4194078DaC9159F4bA;\n address jEUR_agEUR_pool = 0xa48D164F6eB0EDC68bd03B56fa59E12F24499aD1;\n address MATICx_WMATIC_pool = 0xb20fC01D21A50d2C734C4a1262B4404d41fA7BF0;\n address csMATIC_WMATIC_pool = 0x02d2e2D7a89D6c5CB3681cfCb6F7dAC02A55eDA4;\n\n address boostedAavePool = 0x48e6B98ef6329f8f0A30eBB8c7C960330d648085;\n address linearAaveUsdtPool = 0xFf4ce5AAAb5a627bf82f4A571AB1cE94Aa365eA6;\n address linearAaveUsdcPool = 0xF93579002DBE8046c43FEfE86ec78b1112247BB8;\n address linearAaveDaiPool = 0x178E029173417b1F9C8bC16DCeC6f697bC323746;\n address linearAaveWmaticPool = 0xE4885Ed2818Cc9E840A25f94F9b2A28169D1AEA7;\n\n address boostedTetuPool = 0xb3d658d5b95BF04E2932370DD1FF976fe18dd66A;\n address linearTetuUsdtPool = 0x7c82A23B4C48D796dee36A9cA215b641C6a8709d;\n address linearTetuUsdcPool = 0xae646817e458C0bE890b81e8d880206710E3c44e;\n address linearTetuDaiPool = 0xDa1CD1711743e57Dd57102E9e61b75f3587703da;\n\n address wtoken;\n address stMATIC = 0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4;\n address MATICx = 0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6;\n address csMATIC = 0xFcBB00dF1d663eeE58123946A30AB2138bF9eb2A;\n address agEUR = 0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4;\n address jEUR = 0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c;\n address jBRL = 0xf2f77FE7b8e66571E0fca7104c4d670BF1C8d722;\n address BRZ = 0x491a4eB4f1FC3BfF8E1d2FC856a6A46663aD556f;\n address usdt = 0xc2132D05D31c914a87C6611C10748AEb04B58e8F;\n address usdc = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;\n address dai = 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063;\n address mai = 0xa3Fa99A148fA48D14Ed51d610c367C61876997F1;\n\n address csMATICRateProvider = 0x87393BE8ac323F2E63520A6184e5A8A9CC9fC051;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n wtoken = ap.getAddress(\"wtoken\");\n\n address[] memory linearAaveLps = asArray(linearAaveUsdtPool, linearAaveUsdcPool, linearAaveDaiPool);\n address[] memory linearTetuLps = asArray(linearTetuUsdtPool, linearTetuUsdcPool, linearTetuDaiPool);\n\n stableLpOracle = new BalancerLpStablePoolPriceOracle();\n stableLpOracle.initialize();\n\n linearLpOracle = new BalancerLpLinearPoolPriceOracle();\n linearLpOracle.initialize(linearAaveLps);\n linearLpOracle.registerToken(linearAaveWmaticPool);\n\n vm.startPrank(linearLpOracle.owner());\n for (uint256 i = 0; i < linearTetuLps.length; i++) {\n linearLpOracle.registerToken(linearTetuLps[i]);\n }\n vm.stopPrank();\n\n rateProviderOracle = new BalancerRateProviderOracle();\n rateProviderOracle.initialize(asArray(csMATICRateProvider), asArray(wtoken), asArray(csMATIC));\n\n // Add the oracles to the MPO\n BasePriceOracle[] memory aaveLinerlpOracles = new BasePriceOracle[](linearAaveLps.length);\n for (uint256 i = 0; i < linearAaveLps.length; i++) {\n aaveLinerlpOracles[i] = linearLpOracle;\n }\n BasePriceOracle[] memory tetuLinearlpOracles = new BasePriceOracle[](linearTetuLps.length);\n for (uint256 i = 0; i < linearTetuLps.length; i++) {\n tetuLinearlpOracles[i] = linearLpOracle;\n }\n\n BasePriceOracle[] memory linearAaveWmaticOracle = new BasePriceOracle[](1);\n linearAaveWmaticOracle[0] = linearLpOracle;\n\n BasePriceOracle[] memory csMATICOracle = new BasePriceOracle[](1);\n csMATICOracle[0] = rateProviderOracle;\n\n vm.startPrank(mpo.admin());\n mpo.add(linearAaveLps, aaveLinerlpOracles);\n mpo.add(linearTetuLps, tetuLinearlpOracles);\n mpo.add(asArray(csMATIC), csMATICOracle);\n mpo.add(asArray(linearAaveWmaticPool), linearAaveWmaticOracle);\n vm.stopPrank();\n }\n\n function testReentrancyWmaticStmaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n address vault = address(IBalancerStablePool(stMATIC_WMATIC_pool).getVault());\n BalancerReentrancyAttacker reentrancyAttacker = new BalancerReentrancyAttacker(\n IBalancerVault(vault),\n mpo,\n stMATIC_WMATIC_pool\n );\n\n // add the oracle to the mpo for that LP token\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = BasePriceOracle(stableLpOracle);\n vm.prank(mpo.admin());\n mpo.add(asArray(stMATIC_WMATIC_pool), oracles);\n\n // gives ETH to attacker\n vm.deal(address(reentrancyAttacker), 5 ether);\n\n // makes sure the address calling the attack is from attacker\n vm.prank(address(reentrancyAttacker));\n\n // should revert with the specific message\n vm.expectRevert(bytes(\"BAL#420\"));\n reentrancyAttacker.startAttack();\n }\n\n function testReentrancyErrorMessageWmaticStmaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n // add the oracle to the mpo for that LP token\n {\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = BasePriceOracle(stableLpOracle);\n vm.prank(mpo.admin());\n mpo.add(asArray(stMATIC_WMATIC_pool), oracles);\n }\n\n address vault = address(IBalancerStablePool(stMATIC_WMATIC_pool).getVault());\n // raise the reentrancy flag for that vault\n vm.store(vault, bytes32(uint256(0)), bytes32(uint256(2)));\n // should revert with the specific message\n vm.expectRevert(bytes(\"Balancer vault view reentrancy\"));\n mpo.price(stMATIC_WMATIC_pool);\n }\n\n // Tests for ComposableStablePools\n function testJeurAgEurLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(jEUR_agEUR_pool, stableLpOracle);\n\n uint256[] memory baseTokenPrices = new uint256[](2);\n baseTokenPrices[0] = mpo.price(jEUR);\n baseTokenPrices[1] = mpo.price(agEUR);\n uint256 minTokenPrice = _getMinValue(baseTokenPrices);\n uint256 poolRate = IBalancerStablePool(jEUR_agEUR_pool).getRate();\n uint256 expectedRate = (minTokenPrice * poolRate) / 1e18;\n\n assertTrue(price > 0);\n assertEq(price, expectedRate);\n }\n\n function testJbrlBrzLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(jBRL_BRZ_pool, stableLpOracle);\n\n uint256[] memory baseTokenPrices = new uint256[](2);\n baseTokenPrices[0] = mpo.price(jBRL);\n baseTokenPrices[1] = mpo.price(BRZ);\n uint256 minTokenPrice = _getMinValue(baseTokenPrices);\n uint256 poolRate = IBalancerStablePool(jBRL_BRZ_pool).getRate();\n uint256 expectedRate = (minTokenPrice * poolRate) / 1e18;\n\n assertTrue(price > 0);\n assertEq(price, expectedRate);\n }\n\n function testWmaticStmaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(stMATIC_WMATIC_pool, stableLpOracle);\n\n uint256[] memory baseTokenPrices = new uint256[](2);\n baseTokenPrices[0] = mpo.price(stMATIC);\n baseTokenPrices[1] = mpo.price(wtoken);\n uint256 minTokenPrice = _getMinValue(baseTokenPrices);\n uint256 poolRate = IBalancerStablePool(stMATIC_WMATIC_pool).getRate();\n uint256 expectedRate = (minTokenPrice * poolRate) / 1e18;\n\n assertTrue(price > 0);\n assertApproxEqRel(price, expectedRate, 1e15);\n }\n\n function testCsMaticWmaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(csMATIC_WMATIC_pool, stableLpOracle);\n\n uint256[] memory baseTokenPrices = new uint256[](2);\n baseTokenPrices[0] = mpo.price(csMATIC);\n baseTokenPrices[1] = mpo.price(wtoken);\n\n uint256 minTokenPrice = _getMinValue(baseTokenPrices);\n uint256 poolRate = IBalancerStablePool(csMATIC_WMATIC_pool).getRate();\n uint256 expectedRate = (minTokenPrice * poolRate) / 1e18;\n\n assertTrue(price > 0);\n assertEq(price, expectedRate);\n }\n\n function testBoostedAaveLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n IBalancerStablePool stablePool = IBalancerStablePool(boostedAavePool);\n\n // Updates cache of getTokenRate\n stablePool.updateTokenRateCache(linearAaveUsdtPool);\n stablePool.updateTokenRateCache(linearAaveUsdcPool);\n stablePool.updateTokenRateCache(linearAaveDaiPool);\n\n uint256 price = _getLpTokenPrice(boostedAavePool, stableLpOracle);\n\n // Find min price among the three underlying linear pools\n uint256[] memory linearPoolTokenPrices = new uint256[](3);\n linearPoolTokenPrices[0] =\n (mpo.price(linearAaveUsdtPool) * 1e18) /\n IBalancerLinearPool(linearAaveUsdtPool).getRate();\n linearPoolTokenPrices[1] =\n (mpo.price(linearAaveUsdcPool) * 1e18) /\n IBalancerLinearPool(linearAaveUsdcPool).getRate();\n linearPoolTokenPrices[2] = (mpo.price(linearAaveDaiPool) * 1e18) / IBalancerLinearPool(linearAaveDaiPool).getRate();\n uint256 mainTokenPrice = _getMinValue(linearPoolTokenPrices);\n\n uint256 stablePoolRate = IBalancerStablePool(boostedAavePool).getRate();\n uint256 expectedRate = (mainTokenPrice * stablePoolRate) / 1e18;\n\n assertTrue(price > 0);\n assertEq(price, expectedRate);\n }\n\n function testMaticXAaveMaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n IBalancerStablePool stablePool = IBalancerStablePool(MATICx_AaveMATIC_pool);\n\n // Updates cache of getTokenRate\n stablePool.updateTokenRateCache(linearAaveWmaticPool);\n\n uint256 price = _getLpTokenPrice(MATICx_AaveMATIC_pool, stableLpOracle);\n\n // Find min price among the three underlying linear pools\n uint256[] memory poolTokenPrices = new uint256[](2);\n poolTokenPrices[0] = (mpo.price(linearAaveWmaticPool) * 1e18) / IBalancerLinearPool(linearAaveWmaticPool).getRate();\n poolTokenPrices[1] = mpo.price(MATICx);\n\n uint256 mainTokenPrice = _getMinValue(poolTokenPrices);\n uint256 stablePoolRate = IBalancerStablePool(MATICx_AaveMATIC_pool).getRate();\n uint256 expectedRate = (mainTokenPrice * stablePoolRate) / 1e18;\n\n assertTrue(price > 0);\n assertApproxEqRel(price, expectedRate, 1e16, \"!price\");\n }\n\n function testStMaticAaveMaticLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n IBalancerStablePool stablePool = IBalancerStablePool(stMATIC_AaveMATIC_pool);\n\n // Updates cache of getTokenRate\n stablePool.updateTokenRateCache(linearAaveWmaticPool);\n\n uint256 price = _getLpTokenPrice(stMATIC_AaveMATIC_pool, stableLpOracle);\n\n // Find min price among the three underlying linear pools\n uint256[] memory poolTokenPrices = new uint256[](2);\n poolTokenPrices[0] = (mpo.price(linearAaveWmaticPool) * 1e18) / IBalancerLinearPool(linearAaveWmaticPool).getRate();\n poolTokenPrices[1] = mpo.price(MATICx);\n\n uint256 mainTokenPrice = _getMinValue(poolTokenPrices);\n uint256 stablePoolRate = IBalancerStablePool(stMATIC_AaveMATIC_pool).getRate();\n uint256 expectedRate = (mainTokenPrice * stablePoolRate) / 1e18;\n\n assertTrue(price > 0);\n assertApproxEqRel(price, expectedRate, 1e16, \"!price\");\n }\n\n // Tests for LinearPools\n function testLinearAaveUsdtLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(linearAaveUsdtPool, linearLpOracle);\n\n assertTrue(price > 0);\n uint256 poolRate = IBalancerLinearPool(linearAaveUsdtPool).getRate();\n uint256 expectedRate = (mpo.price(usdt) * poolRate) / 1e18;\n assertEq(price, expectedRate);\n }\n\n function testLinearTetuUsdtLpTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 price = _getLpTokenPrice(linearTetuUsdtPool, linearLpOracle);\n\n assertTrue(price > 0);\n uint256 poolRate = IBalancerLinearPool(linearTetuUsdtPool).getRate();\n uint256 expectedRate = (mpo.price(usdt) * poolRate) / 1e18;\n assertEq(price, expectedRate);\n }\n\n function _getLpTokenPrice(address lpToken, BasePriceOracle oracle) internal returns (uint256) {\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n\n vm.prank(mpo.admin());\n mpo.add(asArray(lpToken), oracles);\n emit log(\"added the oracle\");\n return mpo.price(lpToken);\n }\n\n function _getMinValue(uint256[] memory prices) internal pure returns (uint256 minPrice) {\n minPrice = type(uint256).max;\n for (uint256 i = 0; i < prices.length; i++) {\n if (prices[i] < minPrice) {\n minPrice = prices[i];\n }\n }\n }\n}\n" + }, + "contracts/test/oracles/default/BalancerRateProviderOracle.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { BalancerRateProviderOracle } from \"../../../oracles/default/BalancerRateProviderOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { IBalancerStablePool } from \"../../../external/balancer/IBalancerStablePool.sol\";\nimport { IBalancerVault, UserBalanceOp } from \"../../../external/balancer/IBalancerVault.sol\";\n\ncontract BalancerRateProviderOracleTest is BaseTest {\n BalancerRateProviderOracle oracle;\n MasterPriceOracle mpo;\n uint256 wtokenPrice;\n\n // base tokens\n address wtoken;\n address weth = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619;\n\n // Underlyings\n address stMATIC = 0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4;\n address MATICx = 0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6;\n address csMATIC = 0xFcBB00dF1d663eeE58123946A30AB2138bF9eb2A;\n address wstETH = 0x03b54A6e9a984069379fae1a4fC4dBAE93B3bCCD;\n\n // Rate Providers\n address csMATICRateProvider = 0x87393BE8ac323F2E63520A6184e5A8A9CC9fC051;\n address stMATICRateProvider = 0xdEd6C522d803E35f65318a9a4d7333a22d582199;\n address MATICxRateProvider = 0xeE652bbF72689AA59F0B8F981c9c90e2A8Af8d8f;\n address wstETHRateProvider = 0x8c1944E305c590FaDAf0aDe4f737f5f95a4971B6;\n\n // zkEVM\n address wstETHzkevmRateProvider = 0x00346D2Fd4B2Dc3468fA38B857409BC99f832ef8;\n address rETHzkevmRateProvider = 0x60b39BEC6AF8206d1E6E8DFC63ceA214A506D6c3;\n\n address rETHzkevm = 0xb23C20EFcE6e24Acca0Cef9B7B7aA196b84EC942;\n address wstETHzkevm = 0x5D8cfF95D7A57c0BF50B30b43c7CC0D52825D4a9;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n wtoken = ap.getAddress(\"wtoken\");\n\n address[] memory baseTokens;\n address[] memory underlyings;\n address[] memory rateProviders;\n\n if (block.chainid == POLYGON_MAINNET) {\n wtokenPrice = mpo.price(wtoken);\n underlyings = asArray(stMATIC, MATICx, csMATIC);\n baseTokens = asArray(wtoken, wtoken, wtoken);\n rateProviders = asArray(stMATICRateProvider, MATICxRateProvider, csMATICRateProvider);\n } else if (block.chainid == ZKEVM_MAINNET) {\n underlyings = asArray(rETHzkevm, wstETHzkevm);\n baseTokens = asArray(wtoken, wtoken);\n rateProviders = asArray(rETHzkevmRateProvider, wstETHzkevmRateProvider);\n } else {\n revert(\"not supported\");\n }\n oracle = new BalancerRateProviderOracle();\n oracle.initialize(rateProviders, baseTokens, underlyings);\n }\n\n function getTokenPrice(address token) internal returns (uint256) {\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = BasePriceOracle(oracle);\n\n vm.prank(mpo.admin());\n mpo.add(asArray(token), oracles);\n emit log(\"added the oracle\");\n return mpo.price(token);\n }\n\n function testStmaticTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 priceFromMpo = mpo.price(stMATIC);\n uint256 priceFromRateProviderOracle = getTokenPrice(stMATIC);\n assertApproxEqRel(priceFromMpo, priceFromRateProviderOracle, 1e16, \"!diff > 1%\");\n\n // Must be close but higher than to the price for WTOKEN\n assertTrue(priceFromRateProviderOracle > wtokenPrice);\n assertApproxEqRel(mpo.price(wtoken), priceFromRateProviderOracle, 2e17, \"!diff > 20%\");\n }\n\n function testMaticXTokenOraclePrice() public fork(POLYGON_MAINNET) {\n uint256 priceFromMpo = mpo.price(MATICx);\n uint256 priceFromRateProviderOracle = getTokenPrice(MATICx);\n assertApproxEqRel(priceFromMpo, priceFromRateProviderOracle, 1e16, \"!diff > 1%\");\n // Must be close but higher than to the price for WTOKEN\n assertTrue(priceFromRateProviderOracle > wtokenPrice);\n assertApproxEqRel(mpo.price(wtoken), priceFromRateProviderOracle, 2e17, \"!diff > 20%\");\n }\n\n function testCsMaticTokenOraclePrice() public fork(POLYGON_MAINNET) {\n // We don't have yet a price feed for csMATIC currently live\n // uint256 priceFromMpo = mpo.price(csMATIC);\n uint256 priceFromRateProviderOracle = getTokenPrice(csMATIC);\n // assertApproxEqRel(priceFromMpo, priceFromRateProviderOracle, 1e16, \"!diff > 1%\");\n // Must be close but higher than to the price for WTOKEN\n assertTrue(priceFromRateProviderOracle > wtokenPrice);\n assertApproxEqRel(mpo.price(wtoken), priceFromRateProviderOracle, 2e17, \"!diff > 20%\");\n }\n\n // function tesZkEvmPriceOracle() public fork(ZKEVM_MAINNET) {\n function testGetZkEvmRP() public fork(ZKEVM_MAINNET) {\n // We don't have yet a price feed for csMATIC currently live\n // uint256 priceFromMpo = mpo.price(csMATIC);\n uint256 rEthPriceFromRateProviderOracle = getTokenPrice(rETHzkevm);\n uint256 wstEthPriceFromRateProviderOracle = getTokenPrice(wstETHzkevm);\n // assertApproxEqRel(priceFromMpo, priceFromRateProviderOracle, 1e16, \"!diff > 1%\");\n // Must be close but higher than to the price for WTOKEN\n assertTrue(rEthPriceFromRateProviderOracle > wtokenPrice);\n assertTrue(wstEthPriceFromRateProviderOracle > wtokenPrice);\n assertApproxEqRel(mpo.price(wtoken), rEthPriceFromRateProviderOracle, 2e17, \"!diff > 20%\");\n assertApproxEqRel(mpo.price(wtoken), wstEthPriceFromRateProviderOracle, 2e17, \"!diff > 20%\");\n }\n\n function testRegisterNewToken() public fork(POLYGON_MAINNET) {\n vm.prank(oracle.owner());\n\n uint256 lenghtBefore = oracle.getAllUnderlyings().length;\n oracle.registerToken(wstETHRateProvider, weth, wstETH);\n assertTrue(oracle.getAllUnderlyings().length == lenghtBefore + 1);\n\n uint256 price = getTokenPrice(wstETH);\n // Must be close but higher than to the price for WETH\n assertTrue(price > mpo.price(weth));\n assertApproxEqRel(mpo.price(weth), price, 2e17, \"!diff > 20%\");\n }\n}\n" + }, + "contracts/test/oracles/default/BNBxPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { BNBxPriceOracle } from \"../../../oracles/default/BNBxPriceOracle.sol\";\n\ncontract BNBxPriceOracleTest is BaseTest {\n BNBxPriceOracle private oracle;\n address BNBx = 0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275;\n\n function afterForkSetUp() internal override {\n oracle = new BNBxPriceOracle();\n oracle.initialize();\n }\n\n function testBnbXOraclePrice() public forkAtBlock(BSC_MAINNET, 22332594) {\n uint256 priceBnbX = oracle.price(BNBx);\n assertGt(priceBnbX, 1e18);\n assertEq(priceBnbX, 1041708576933034575);\n }\n}\n" + }, + "contracts/test/oracles/default/ChainlinkOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ChainlinkPriceOracleV2 } from \"../../../oracles/default/ChainlinkPriceOracleV2.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract ChainlinkOraclesTest is BaseTest {\n ChainlinkPriceOracleV2 oracle;\n\n address usdcPolygon = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;\n address usdtPolygon = 0xc2132D05D31c914a87C6611C10748AEb04B58e8F;\n address usdcFeedPolygon = 0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7;\n address usdtFeedPolygon = 0x0A6513e40db6EB1b165753AD52E80663aeA50545;\n\n address jBRLBsc = 0x316622977073BBC3dF32E7d2A9B3c77596a0a603;\n address jBRLFeedBsc = 0x5cb1Cb3eA5FB46de1CE1D0F3BaDB3212e8d8eF48;\n address usdcBsc = 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d;\n address usdtBsc = 0x55d398326f99059fF775485246999027B3197955;\n address usdtFeedBsc = 0xB97Ad0E74fa7d920791E90258A6E2085088b4320;\n address usdcFeedBsc = 0x51597f405303C4377E36123cBc172b13269EA163;\n ICErc20 usdcMarketBsc = ICErc20(0x8D5bE2768c335e88b71E4e913189AEE7104f01B4);\n ICErc20 usdtMarketBsc = ICErc20(0x1F73754c135d5B9fDE674806f43AeDfA2c7eaDb5);\n\n function afterForkSetUp() internal override {\n oracle = ChainlinkPriceOracleV2(ap.getAddress(\"ChainlinkPriceOracleV2\"));\n }\n\n function setUpOracleFeed(address testedTokenAddress, address aggregatorAddress) internal {\n address[] memory underlyings = new address[](1);\n underlyings[0] = testedTokenAddress;\n address[] memory aggregators = new address[](1);\n aggregators[0] = aggregatorAddress;\n\n vm.prank(oracle.owner());\n oracle.setPriceFeeds(underlyings, aggregators, ChainlinkPriceOracleV2.FeedBaseCurrency.USD);\n }\n\n function testJBRLPrice() public fork(BSC_MAINNET) {\n setUpOracleFeed(jBRLBsc, jBRLFeedBsc);\n assert(oracle.price(jBRLBsc) > 0);\n }\n\n function testBSCChainlinkUSDCPrice() public fork(BSC_MAINNET) {\n setUpOracleFeed(usdcBsc, usdcFeedBsc);\n uint256 price = oracle.price(usdcBsc);\n uint256 underlyingPrice = oracle.getUnderlyingPrice(usdcMarketBsc);\n assertEq(price, underlyingPrice);\n }\n\n function testBSCChainlinkUSDTPrice() public fork(BSC_MAINNET) {\n setUpOracleFeed(usdtBsc, usdtFeedBsc);\n uint256 price = oracle.price(usdtBsc);\n uint256 underlyingPrice = oracle.getUnderlyingPrice(usdtMarketBsc);\n assertEq(price, underlyingPrice);\n }\n\n function testUsdcUsdtDeviationBsc() public fork(BSC_MAINNET) {\n setUpOracleFeed(usdtBsc, usdtFeedBsc);\n setUpOracleFeed(usdcBsc, usdcFeedBsc);\n\n uint256 usdtPrice = oracle.getUnderlyingPrice(usdtMarketBsc);\n uint256 usdcPrice = oracle.getUnderlyingPrice(usdcMarketBsc);\n\n assertApproxEqAbs(usdtPrice, usdcPrice, 1e16, \"usd prices differ too much\");\n }\n\n function testUsdcUsdtDeviationPolygon() public fork(POLYGON_MAINNET) {\n setUpOracleFeed(usdtPolygon, usdtFeedPolygon);\n setUpOracleFeed(usdcPolygon, usdcFeedPolygon);\n\n uint256 usdtPrice = oracle.price(usdtPolygon);\n uint256 usdcPrice = oracle.price(usdcPolygon);\n\n assertApproxEqAbs(usdtPrice, usdcPrice, 1e16, \"usd prices differ too much\");\n }\n}\n" + }, + "contracts/test/oracles/default/CurveV2LpTokenPriceOracleNoRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurveV2Pool } from \"../../../external/curve/ICurveV2Pool.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../../../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract CurveLpTokenPriceOracleNoRegistryTest is BaseTest {\n CurveV2LpTokenPriceOracleNoRegistry oracle;\n address busd;\n address epsJCHFBUSD_lp = 0x5887cEa5e2bb7dD36F0C06Da47A8Df918c289A29;\n address epsJCHFBUSD_pool = 0xBcA6E25937B0F7E0FD8130076b6B218F595E32e2;\n ICErc20 epsJCHFBUSD_c = ICErc20(0x1F0452D6a8bb9EAbC53Fa6809Fa0a060Dd531267);\n\n address epsBnbxBnb_lp = 0xFD4afeAc39DA03a05f61844095A75c4fB7D766DA;\n address epsBnbxBnb_pool = 0xFD4afeAc39DA03a05f61844095A75c4fB7D766DA;\n ICErc20 epsBnbxBnb_c = ICErc20(0xD96643Ba2Bf96e73509C4bb73c0cb259dAf34de1);\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n busd = ap.getAddress(\"bUSD\");\n\n address[] memory lpTokens = new address[](2);\n lpTokens[0] = epsJCHFBUSD_lp;\n lpTokens[1] = epsBnbxBnb_lp;\n\n address[] memory pools = new address[](2);\n pools[0] = epsJCHFBUSD_pool;\n pools[1] = epsBnbxBnb_pool;\n\n address[] memory baseTokens = new address[](2);\n baseTokens[0] = busd;\n baseTokens[1] = address(0);\n\n oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n oracle.initialize(lpTokens, pools);\n }\n\n function testCurveV2LpTokenPriceOracleCHFBUSD() public forkAtBlock(BSC_MAINNET, 21675481) {\n ICurveV2Pool pool = ICurveV2Pool(epsJCHFBUSD_pool);\n vm.prank(address(mpo));\n uint256 lp_price = (pool.lp_price() * mpo.price(busd)) / 10**18;\n vm.startPrank(address(mpo));\n uint256 price = oracle.price(epsJCHFBUSD_lp);\n uint256 ulPrice = oracle.getUnderlyingPrice(epsJCHFBUSD_c);\n assertEq(price, ulPrice);\n assertEq(price, lp_price);\n assertEq(price, 7319017681980243);\n vm.stopPrank();\n }\n\n function testCurveV2LpTokenPriceOracleBNBXBNB() public forkAtBlock(BSC_MAINNET, 24036448) {\n ICurveV2Pool pool = ICurveV2Pool(epsBnbxBnb_pool);\n vm.startPrank(address(mpo));\n // coins(0) is BNBx\n uint256 lp_price = (pool.lp_price() * mpo.price(0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275)) / 10**18;\n uint256 price = oracle.price(epsBnbxBnb_lp);\n\n // TODO: add these when the oracle is added\n // uint256 ulPrice = oracle.getUnderlyingPrice(epsBnbxBnb_c);\n // assertEq(price, ulPrice);\n assertEq(price, lp_price);\n assertEq(price, 2058628564849750905);\n vm.stopPrank();\n }\n}\n" + }, + "contracts/test/oracles/default/CurveV2PriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurveV2Pool } from \"../../../external/curve/ICurveV2Pool.sol\";\nimport { CurveV2PriceOracle } from \"../../../oracles/default/CurveV2PriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract CurveV2PriceOracleTest is BaseTest {\n CurveV2PriceOracle oracle;\n address busd;\n address wbtc;\n\n address Bnbx = 0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275;\n address epsBnbxBnb_pool = 0xFD4afeAc39DA03a05f61844095A75c4fB7D766DA;\n address epsBusdBtc_pool = 0xeF8A7e653F18CFD4b92a0f5b644393A4C635f19f;\n\n address eusd = 0x97de57eC338AB5d51557DA3434828C5DbFaDA371; // 18 decimals\n address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; // 6 decimals\n uint256 usdcPriceEth = 0.00057716e18;\n address usdcEusdPool = 0x880F2fB3704f1875361DE6ee59629c6c6497a5E3;\n\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n address[] memory tokens;\n address[] memory pools;\n\n if (block.chainid == ETHEREUM_MAINNET) {\n tokens = new address[](1);\n tokens[0] = eusd;\n\n pools = new address[](1);\n pools[0] = usdcEusdPool;\n } else {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n busd = ap.getAddress(\"bUSD\");\n wbtc = ap.getAddress(\"wBTCToken\");\n\n tokens = new address[](3);\n tokens[0] = Bnbx;\n tokens[1] = wbtc;\n tokens[2] = busd;\n\n pools = new address[](3);\n pools[0] = epsBnbxBnb_pool;\n pools[1] = epsBusdBtc_pool;\n pools[2] = epsBusdBtc_pool;\n }\n\n oracle = new CurveV2PriceOracle();\n oracle.initialize(tokens, pools);\n }\n\n function testCurveV2PriceOracleBNBxBNB() public fork(BSC_MAINNET) {\n vm.prank(address(mpo));\n uint256 bnbx_mpo_price = mpo.price(Bnbx);\n vm.startPrank(address(mpo));\n uint256 priceBnbx = oracle.price(Bnbx);\n assertApproxEqRel(bnbx_mpo_price, priceBnbx, 1e16); // 1%\n vm.stopPrank();\n }\n\n function testCurveV2PriceOracleWbtcBNB() public fork(BSC_MAINNET) {\n vm.prank(address(mpo));\n uint256 wbtc_mpo_price = mpo.price(wbtc);\n uint256 busd_mpo_price = mpo.price(busd);\n vm.startPrank(address(mpo));\n uint256 priceWbtc = oracle.price(wbtc);\n uint256 priceBusd = oracle.price(busd);\n assertApproxEqRel(wbtc_mpo_price, priceWbtc, 1e16); // 1%\n assertApproxEqRel(busd_mpo_price, priceBusd, 1e16); // 1%\n vm.stopPrank();\n }\n\n function testCurveV2PriceOracleEUsdUsdc() public fork(ETHEREUM_MAINNET) {\n // TODO use the MPO when deployed\n // testing the decimals scaling, eusd has 18, usdc has 6 decimals\n uint256 priceEusd = oracle.price(eusd);\n assertApproxEqRel(usdcPriceEth, priceEusd, 1e17); // 10%\n }\n\n function price(address asset) public view returns (uint256) {\n if (asset == usdc) return usdcPriceEth;\n else return 0;\n }\n}\n" + }, + "contracts/test/oracles/default/DiaPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { DiaPriceOracle, DIAOracleV2 } from \"../../../oracles/default/DiaPriceOracle.sol\";\nimport { SimplePriceOracle } from \"../../../oracles/default/SimplePriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\ncontract MockDiaPriceFeed is DIAOracleV2 {\n struct DiaOracle {\n DIAOracleV2 feed;\n string key;\n }\n\n uint128 public staticPrice;\n\n constructor(uint128 _staticPrice) {\n staticPrice = _staticPrice;\n }\n\n function getValue(string memory key) external view returns (uint128, uint128) {\n return (staticPrice, uint128(block.timestamp));\n }\n}\n\ncontract DiaPriceOracleTest is BaseTest {\n DiaPriceOracle private oracle;\n MasterPriceOracle masterPriceOracle;\n\n function testDiaPriceOracleWithMasterPriceOracleBsc() public forkAtBlock(BSC_MAINNET, 20238373) {\n oracle = DiaPriceOracle(0x944e833dC2Af9fc58D5cfA99B9D8666c843Ad58C);\n\n // miMATIC (MAI)\n uint256 price = oracle.price(0x3F56e0c36d275367b8C502090EDF38289b3dEa0d);\n assertApproxEqAbs(price, 3086017057904017, 1e14);\n masterPriceOracle = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n // compare to BUSD, ensure price does not deviate too much\n uint256 priceBusd = masterPriceOracle.price(ap.getAddress(\"bUSD\"));\n assertApproxEqAbs(price, priceBusd, 1e14);\n }\n\n function setUpWithMasterPriceOracle() internal {\n SimplePriceOracle spo = new SimplePriceOracle();\n spo.initialize();\n spo.setDirectPrice(address(2), 200000000000000000); // 1e36 / 200000000000000000 = 5e18\n MasterPriceOracle mpo = new MasterPriceOracle();\n address[] memory underlyings = new address[](1);\n underlyings[0] = address(2);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = spo;\n mpo.initialize(underlyings, oracles, spo, address(this), true, address(0));\n oracle = new DiaPriceOracle(address(this), true, address(0), MockDiaPriceFeed(address(0)), \"\", mpo, address(2));\n }\n}\n" + }, + "contracts/test/oracles/default/ERC4626OracleAndLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { ERC4626Oracle } from \"../../../oracles/default/ERC4626Oracle.sol\";\nimport { SimplePriceOracle } from \"../../../oracles/default/SimplePriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { IERC4626 } from \"../../../compound/IERC4626.sol\";\nimport { ChainlinkPriceOracleV2 } from \"../../../oracles/default/ChainlinkPriceOracleV2.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\nimport { IUniswapV3Factory } from \"../../../external/uniswap/IUniswapV3Factory.sol\";\nimport { Quoter } from \"../../../external/uniswap/quoter/Quoter.sol\";\nimport { IUniswapV3Pool } from \"../../../external/uniswap/IUniswapV3Pool.sol\";\nimport { ISwapRouter } from \"../../../external/uniswap/ISwapRouter.sol\";\nimport { ERC4626Liquidator } from \"../../../liquidators/ERC4626Liquidator.sol\";\n\ncontract ERC4626OracleAndLiquidatorTest is BaseTest {\n // TODO: refactor this into oracle and liquidator tests once oracles are deployed\n // TODO: refactor oracle set up using the address provider\n\n MasterPriceOracle mpo;\n ChainlinkPriceOracleV2 chainlinkOracle;\n ERC4626Oracle erc4626Oracle;\n\n IERC20Upgradeable wethToken;\n IERC20Upgradeable wbtcToken;\n IERC20Upgradeable daiToken;\n IERC20Upgradeable usdcToken;\n IERC20Upgradeable usdtToken;\n\n address nativeUsdPriceFeed;\n address usdcEthPriceFeed;\n address wbtcEthPriceFeed;\n\n IERC4626 erc4626Vault;\n address[] underlyingTokens;\n ERC4626Liquidator liquidator;\n\n address usdcMarketAddress;\n address univ3SwapRouter;\n\n uint256 poolFee;\n\n Quoter quoter;\n\n address holder;\n\n function setUpErc4626Oracle() public {\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n erc4626Oracle = new ERC4626Oracle();\n vm.prank(erc4626Oracle.owner());\n erc4626Oracle.initialize();\n oracles[0] = erc4626Oracle;\n vm.prank(mpo.admin());\n mpo.add(asArray(address(erc4626Vault)), oracles);\n }\n\n function setUpBaseOracles() public {\n setUpMpoAndAddresses();\n BasePriceOracle[] memory oracles = new BasePriceOracle[](2);\n chainlinkOracle = new ChainlinkPriceOracleV2();\n chainlinkOracle.initialize(address(usdcToken), nativeUsdPriceFeed);\n vm.prank(chainlinkOracle.owner());\n chainlinkOracle.setPriceFeeds(\n asArray(address(usdcToken), address(wbtcToken)),\n asArray(usdcEthPriceFeed, wbtcEthPriceFeed),\n ChainlinkPriceOracleV2.FeedBaseCurrency.ETH\n );\n oracles[0] = BasePriceOracle(address(chainlinkOracle));\n oracles[1] = BasePriceOracle(address(chainlinkOracle));\n\n vm.prank(mpo.admin());\n mpo.add(asArray(address(usdcToken), address(wbtcToken)), oracles);\n }\n\n function setUpMpoAndAddresses() public {\n if (block.chainid == ETHEREUM_MAINNET) {\n usdcToken = IERC20Upgradeable(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);\n daiToken = IERC20Upgradeable(0x6B175474E89094C44Da98b954EedeAC495271d0F);\n usdtToken = IERC20Upgradeable(0xdAC17F958D2ee523a2206206994597C13D831ec7);\n wbtcToken = IERC20Upgradeable(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);\n wethToken = IERC20Upgradeable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n nativeUsdPriceFeed = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;\n usdcEthPriceFeed = 0x986b5E1e1755e3C2440e960477f25201B0a8bbD4;\n wbtcEthPriceFeed = 0xdeb288F737066589598e9214E782fa5A8eD689e8;\n\n address[] memory assets = new address[](0);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](0);\n mpo = new MasterPriceOracle();\n mpo.initialize(assets, oracles, BasePriceOracle(address(0)), address(this), true, address(wethToken));\n }\n }\n\n function setupRealYieldStrategyUsdAddresses() public {\n if (block.chainid == ETHEREUM_MAINNET) {\n underlyingTokens = asArray(address(usdcToken), address(daiToken), address(usdtToken)); // USDC, 6 decimals\n poolFee = 10;\n erc4626Vault = IERC4626(0x97e6E0a40a3D02F12d1cEC30ebfbAE04e37C119E); // USDC-DAI-USDT Real Yield\n quoter = new Quoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);\n univ3SwapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n holder = 0x3541Fda19b09769A938EB2A5f5154b01aE5b0869;\n }\n liquidator = new ERC4626Liquidator();\n }\n\n function setupEthBtcStrategyAddresses() public {\n if (block.chainid == ETHEREUM_MAINNET) {\n underlyingTokens = asArray(address(usdcToken), address(wbtcToken), address(wethToken));\n poolFee = 500;\n erc4626Vault = IERC4626(0x6b7f87279982d919Bbf85182DDeAB179B366D8f2); // ETH-BTC trend\n quoter = new Quoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);\n univ3SwapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n holder = 0xF955C57f9EA9Dc8781965FEaE0b6A2acE2BAD6f3;\n }\n liquidator = new ERC4626Liquidator();\n }\n\n function testRealYieldErc4626PriceOracle() public fork(ETHEREUM_MAINNET) {\n setUpBaseOracles();\n setupRealYieldStrategyUsdAddresses();\n setUpErc4626Oracle();\n\n uint256 priceRealYieldUsdc = mpo.price(address(erc4626Vault));\n uint256 priceUsdc = mpo.price(address(usdcToken));\n\n // Approximate only -- these should not match.\n assertApproxEqRel(priceRealYieldUsdc, priceUsdc, 3e16, \"!diff > 3%\");\n }\n\n function testRealYieldUsdErc4626RedemptionStrategy() public fork(ETHEREUM_MAINNET) {\n setUpBaseOracles();\n setupRealYieldStrategyUsdAddresses();\n setUpErc4626Oracle();\n executeTestRedemptionStrategy(usdcToken);\n }\n\n function testEthBtcMomementumErc4626RedemptionStrategy() public fork(ETHEREUM_MAINNET) {\n setUpBaseOracles();\n setupEthBtcStrategyAddresses();\n setUpErc4626Oracle();\n executeTestRedemptionStrategy(wethToken);\n }\n\n function executeTestRedemptionStrategy(IERC20Upgradeable _outputToken) internal {\n uint256 balance = erc4626Vault.balanceOf(holder);\n assertTrue(balance > 0);\n\n // impersonate the holder\n vm.prank(holder);\n\n // fund the liquidator so it can redeem the tokens\n erc4626Vault.transfer(address(liquidator), balance);\n\n bytes memory data = abi.encode(address(_outputToken), poolFee, univ3SwapRouter, underlyingTokens, quoter);\n\n // redeem the underlying reward token\n (IERC20Upgradeable outputToken, uint256 outputAmount) = liquidator.redeem(\n IERC20Upgradeable(address(erc4626Vault)),\n balance,\n data\n );\n\n // ensure the output token is the expected token\n assertEq(address(outputToken), address(_outputToken));\n\n uint256 liquidatorBalance = _outputToken.balanceOf(address(liquidator));\n // get the redeemed value of the erc4626 token\n uint256 redeemValue = (mpo.price(address(erc4626Vault)) * balance) / 1e18;\n // get the redeemed value of the output token\n uint256 redeemOutputTokenValue = (mpo.price(address(_outputToken)) * liquidatorBalance) /\n 10**ERC20Upgradeable(address(_outputToken)).decimals();\n // ensure they are approximately equal\n assertApproxEqRel(redeemValue, redeemOutputTokenValue, 3e16, \"!diff > 3%\");\n\n uint256 maxVal = redeemValue > redeemOutputTokenValue ? redeemValue : redeemOutputTokenValue;\n uint256 minVal = redeemValue < redeemOutputTokenValue ? redeemValue : redeemOutputTokenValue;\n\n uint256 absoluteDifference = maxVal - minVal;\n uint256 percentageDifference = (absoluteDifference * 10000) / maxVal; // Multiplied by 10000 for 2 decimal places of precision\n\n // log the differences\n emit log_named_uint(\"redeemOutputTokenValue\", redeemOutputTokenValue);\n emit log_named_uint(\"redeemValue\", redeemValue);\n emit log_named_uint(\"base 1000 diff\", percentageDifference);\n }\n}\n" + }, + "contracts/test/oracles/default/GammaPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { GammaPoolAlgebraPriceOracle } from \"../../../oracles/default/GammaPoolPriceOracle.sol\";\nimport { GammaPoolUniswapV3PriceOracle } from \"../../../oracles/default/GammaPoolPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { LiquidityAmounts } from \"../../../external/uniswap/LiquidityAmounts.sol\";\nimport { IUniswapV3Pool } from \"../../../external/uniswap/IUniswapV3Pool.sol\";\n\nimport { IHypervisor } from \"../../../external/gamma/IHypervisor.sol\";\n\ncontract GammaPoolPriceOracleTest is BaseTest {\n GammaPoolAlgebraPriceOracle private aOracle;\n GammaPoolUniswapV3PriceOracle private uOracle;\n MasterPriceOracle mpo;\n address wtoken;\n address stable;\n\n function afterForkSetUp() internal override {\n stable = ap.getAddress(\"stableToken\");\n wtoken = ap.getAddress(\"wtoken\");\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n aOracle = new GammaPoolAlgebraPriceOracle();\n uOracle = new GammaPoolUniswapV3PriceOracle();\n vm.prank(mpo.admin());\n aOracle.initialize(wtoken);\n uOracle.initialize(wtoken);\n }\n\n function testPriceGammaAlgebraNow() public fork(POLYGON_MAINNET) {\n {\n uint256 withdrawAmount = 1e18;\n address DAI_GNS_QS_GAMMA_VAULT = 0x7aE7FB44c92B4d41abB6E28494f46a2EB3c2a690; // QS aDAI-GNS (Narrow)\n address DAI_GNS_QS_GAMMA_WHALE = 0x20ec0d06F447d550fC6edee42121bc8C1817b97D; // QS Masterchef\n\n vm.prank(address(mpo));\n uint256 price_DAI_GNS = aOracle.price(DAI_GNS_QS_GAMMA_VAULT);\n\n uint256 expectedPrice = priceAtWithdraw(DAI_GNS_QS_GAMMA_WHALE, DAI_GNS_QS_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_DAI_GNS, expectedPrice, 1e16, \"!aDAI-GNS price\");\n }\n\n {\n uint256 withdrawAmount = 1e6;\n address DAI_USDT_QS_GAMMA_VAULT = 0x45A3A657b834699f5cC902e796c547F826703b79;\n address DAI_USDT_QS_WHALE = 0x20ec0d06F447d550fC6edee42121bc8C1817b97D; // QS Masterchef\n\n vm.prank(address(mpo));\n uint256 price_DAI_USDT = aOracle.price(DAI_USDT_QS_GAMMA_VAULT) / (1e18 / withdrawAmount);\n\n uint256 expectedPrice = priceAtWithdraw(DAI_USDT_QS_WHALE, DAI_USDT_QS_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_DAI_USDT, expectedPrice, 1e16, \"!aDAI-USDT price\");\n }\n\n {\n uint256 withdrawAmount = 1e6;\n address WETH_USDT_QS_GAMMA_VAULT = 0x5928f9f61902b139e1c40cBa59077516734ff09f; // QS aWETH-USDT (Narrow)\n address WETH_USDT_QS_WHALE = 0x20ec0d06F447d550fC6edee42121bc8C1817b97D; // QS Masterchef\n\n vm.prank(address(mpo));\n uint256 price_WETH_USDT = aOracle.price(WETH_USDT_QS_GAMMA_VAULT) / (1e18 / withdrawAmount);\n\n uint256 expectedPrice = priceAtWithdraw(WETH_USDT_QS_WHALE, WETH_USDT_QS_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_WETH_USDT, expectedPrice, 10e16, \"!aWETH-USDT price\");\n }\n }\n\n function testPriceGammaUniV3Now() public fork(POLYGON_MAINNET) {\n uint256 withdrawAmount = 1e18;\n {\n address USDC_CASH_RETRO_GAMMA_VAULT = 0x64e14623CA543b540d0bA80477977f7c2c00a7Ea;\n address USDC_CASH_RETRO_WHALE = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n\n vm.prank(address(mpo));\n uint256 price_USDC_CASH = uOracle.price(USDC_CASH_RETRO_GAMMA_VAULT);\n\n uint256 expectedPrice = priceAtWithdraw(USDC_CASH_RETRO_WHALE, USDC_CASH_RETRO_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_USDC_CASH, expectedPrice, 1e16, \"!aUSDC-CASH price\");\n }\n\n {\n address USDC_WETH_RETRO_GAMMA_VAULT = 0xe058e1FfFF9B13d3FCd4803FDb55d1Cc2fe07DDC;\n address USDC_WETH_RETRO_WHALE = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n\n vm.prank(address(mpo));\n uint256 price_USDC_WETH = uOracle.price(USDC_WETH_RETRO_GAMMA_VAULT);\n\n uint256 expectedPrice = priceAtWithdraw(USDC_WETH_RETRO_WHALE, USDC_WETH_RETRO_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_USDC_WETH, expectedPrice, 5e16, \"!aUSDC_WETH price\");\n }\n\n {\n address WMATIC_MATICX_RETRO_GAMMA_VAULT = 0x2589469b7A72802CE02484f053CB6df869eB2689;\n address WMATIC_MATICX_RETRO_WHALE = 0xcFB07d195DB81da622E94BDB3171392756775914;\n\n vm.prank(address(mpo));\n uint256 price_WMATIC_MATICX = uOracle.price(WMATIC_MATICX_RETRO_GAMMA_VAULT);\n\n uint256 expectedPrice = priceAtWithdraw(\n WMATIC_MATICX_RETRO_WHALE,\n WMATIC_MATICX_RETRO_GAMMA_VAULT,\n withdrawAmount\n );\n\n assertApproxEqRel(price_WMATIC_MATICX, expectedPrice, 1e16, \"!aWMATIC_MATICX price\");\n }\n\n {\n address WBTC_WETH_RETRO_GAMMA_VAULT = 0x336536F5bB478D8624dDcE0942fdeF5C92bC4662;\n address WBTC_WETH_RETRO_GAMMA_WHALE = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n\n vm.prank(address(mpo));\n uint256 price_WBTC_WETH = uOracle.price(WBTC_WETH_RETRO_GAMMA_VAULT);\n\n uint256 expectedPrice = priceAtWithdraw(WBTC_WETH_RETRO_GAMMA_WHALE, WBTC_WETH_RETRO_GAMMA_VAULT, withdrawAmount);\n assertApproxEqRel(price_WBTC_WETH, expectedPrice, 5e16, \"!aWBTC_WETH price\");\n }\n }\n\n function priceAtWithdraw(\n address whale,\n address vaultAddress,\n uint256 withdrawAmount\n ) internal returns (uint256) {\n address emptyAddress = address(900202020);\n IHypervisor vault = IHypervisor(vaultAddress);\n ERC20Upgradeable token0 = ERC20Upgradeable(vault.token0());\n ERC20Upgradeable token1 = ERC20Upgradeable(vault.token1());\n\n uint256 balance0Before = token0.balanceOf(emptyAddress);\n uint256 balance1Before = token1.balanceOf(emptyAddress);\n\n uint256[4] memory minAmounts;\n vm.prank(whale);\n vault.withdraw(withdrawAmount, emptyAddress, whale, minAmounts);\n\n uint256 balance0After = token0.balanceOf(emptyAddress);\n uint256 balance1After = token1.balanceOf(emptyAddress);\n\n uint256 price0 = mpo.price(address(token0));\n uint256 price1 = mpo.price(address(token1));\n\n uint256 balance0Diff = (balance0After - balance0Before) * 10**(18 - uint256(token0.decimals()));\n uint256 balance1Diff = (balance1After - balance1Before) * 10**(18 - uint256(token1.decimals()));\n\n return (balance0Diff * price0 + balance1Diff * price1) / 1e18;\n }\n}\n" + }, + "contracts/test/oracles/default/GelatoGUniPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { GelatoGUniPriceOracle } from \"../../../oracles/default/GelatoGUniPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\n\ncontract GelatoGUniPriceOracleTest is BaseTest {\n GelatoGUniPriceOracle private oracle;\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new GelatoGUniPriceOracle(ap.getAddress(\"wtoken\"));\n }\n\n function testPriceGelatoGUni() public fork(POLYGON_MAINNET) {\n address PAR_USDC_ARRAKIS_VAULT = 0xC1DF4E2fd282e39346422e40C403139CD633Aacd;\n address WBTC_WETH_ARRAKIS_VAULT = 0x590217ef04BcB96FF6Da991AB070958b8F9E77f0;\n\n vm.prank(address(mpo));\n uint256 price_PAR_USDC = oracle.price(PAR_USDC_ARRAKIS_VAULT);\n\n vm.prank(address(mpo));\n uint256 price_WBTC_WETH = oracle.price(WBTC_WETH_ARRAKIS_VAULT);\n\n assertTrue(price_PAR_USDC > 0, \"!Price Error\");\n assertTrue(price_WBTC_WETH > 0, \"!Price Error\");\n assertGt(price_WBTC_WETH, price_PAR_USDC);\n }\n}\n" + }, + "contracts/test/oracles/default/KyberSwapPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { KyberSwapPriceOracle } from \"../../../oracles/default/KyberSwapPriceOracle.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"../../../oracles/default/ConcentratedLiquidityBasePriceOracle.sol\";\nimport { IPool } from \"../../../external/kyber/IPool.sol\";\nimport { IPoolOracle } from \"../../../external/kyber/IPoolOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"../../../oracles/default/ConcentratedLiquidityBasePriceOracle.sol\";\n\nimport \"../../../external/uniswap/TickMath.sol\";\nimport \"../../../external/uniswap/FullMath.sol\";\n\ncontract KyberSwapPriceOracleTest is BaseTest {\n KyberSwapPriceOracle oracle;\n MasterPriceOracle mpo;\n address wtoken;\n address wbtc;\n address stable;\n\n function afterForkSetUp() internal override {\n stable = 0x176211869cA2b568f2A7D4EE941E073a821EE1ff; // ap.getAddress(\"stableToken\");\n\n wtoken = ap.getAddress(\"wtoken\"); // WETH\n wbtc = ap.getAddress(\"wBTCToken\"); // WBTC\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new KyberSwapPriceOracle();\n\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n }\n\n function getPriceX96FromSqrtPriceX96(\n address token0,\n address priceToken,\n uint160 sqrtPriceX96\n ) public pure returns (uint256 price_) {\n price_ = FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, uint256(2**(96 * 2)) / 1e18);\n if (token0 != priceToken) price_ = 1e36 / price_;\n }\n\n function testLineaAssets() public debuggingOnly forkAtBlock(LINEA_MAINNET, 173370) {\n address axlUsdc = 0xEB466342C4d449BC9f53A865D5Cb90586f405215;\n address dai = 0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5;\n\n address[] memory underlyings = new address[](3);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](3);\n\n underlyings[0] = stable; // (6 decimals)\n underlyings[1] = axlUsdc; // (6 decimals)\n underlyings[2] = dai; // (6 decimals)\n\n // 6 / 18\n IPool usdcWethPool = IPool(0x4b21d64Cf83e56860F1739452817E4c0fa1D399D);\n // 6 / 6\n IPool axlUsdcUsdcPool = IPool(0xFbEdC4eBEB2951fF96A636c934FCE35117847c9d);\n // 18 / 6\n IPool daiUsdcPool = IPool(0xB6E91bA27bB6C3b2ADC31884459D3653F9293e33);\n\n // WETH-USDC\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(address(usdcWethPool), 1200, wtoken);\n // USDC-axlUSDC\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(address(axlUsdcUsdcPool), 1200, stable);\n // DAI-USDC\n configs[2] = ConcentratedLiquidityBasePriceOracle.AssetConfig(address(daiUsdcPool), 1200, stable);\n\n uint256 priceUsdc = mpo.price(stable);\n uint256[] memory expPrices = new uint256[](3);\n\n expPrices[0] = priceUsdc;\n expPrices[1] = priceUsdc;\n expPrices[2] = priceUsdc;\n\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n\n assertApproxEqRel(prices[0], expPrices[0], 1e17, \"!Price Error\");\n assertApproxEqRel(prices[1], expPrices[1], 1e17, \"!Price Error\");\n assertApproxEqRel(prices[2], expPrices[2], 1e17, \"!Price Error\");\n }\n\n function getPriceFeed(address[] memory underlyings, ConcentratedLiquidityBasePriceOracle.AssetConfig[] memory configs)\n internal\n returns (uint256[] memory price)\n {\n vm.prank(oracle.owner());\n oracle.setPoolFeeds(underlyings, configs);\n vm.roll(1);\n\n price = new uint256[](underlyings.length);\n for (uint256 i = 0; i < underlyings.length; i++) {\n vm.prank(address(mpo));\n price[i] = oracle.price(underlyings[i]);\n }\n return price;\n }\n}\n" + }, + "contracts/test/oracles/default/MasterPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport { SimplePriceOracle } from \"../../../oracles/default/SimplePriceOracle.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { MockRevertPriceOracle } from \"../../../oracles/1337/MockRevertPriceOracle.sol\";\n\ncontract MasterPriceOracleTest is BaseTest {\n MasterPriceOracle mpo;\n SimplePriceOracle mainOracle;\n SimplePriceOracle fallbackOracle;\n MockRevertPriceOracle revertingOracle;\n ICErc20 mockCToken;\n address someAdminAccount = address(94949);\n address ezETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ionezETH = 0x59e710215d45F584f44c0FEe83DA6d43D762D857;\n\n function afterForkSetUp() internal override {\n MasterPriceOracle newMpo = new MasterPriceOracle();\n SimplePriceOracle defaultOracle = new SimplePriceOracle();\n\n address[] memory underlyings = new address[](0);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](0);\n\n vm.prank(someAdminAccount);\n newMpo.initialize(underlyings, oracles, defaultOracle, someAdminAccount, true, address(0));\n\n mpo = newMpo;\n\n SimplePriceOracle impl = new SimplePriceOracle();\n vm.prank(address(someAdminAccount));\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(impl),\n address(dpa),\n abi.encodePacked(impl.initialize.selector)\n );\n mainOracle = SimplePriceOracle(address(proxy));\n\n SimplePriceOracle fallbackImpl = new SimplePriceOracle();\n vm.prank(address(someAdminAccount));\n TransparentUpgradeableProxy fallbackProxy = new TransparentUpgradeableProxy(\n address(fallbackImpl),\n address(dpa),\n abi.encodePacked(impl.initialize.selector)\n );\n fallbackOracle = SimplePriceOracle(address(fallbackProxy));\n\n vm.startPrank(someAdminAccount);\n mainOracle.setDirectPrice(ezETH, 2000);\n fallbackOracle.setDirectPrice(ezETH, 2000);\n vm.stopPrank();\n\n address[] memory tokens = new address[](1);\n tokens[0] = ezETH;\n\n BasePriceOracle[] memory oraclesToAdd = new BasePriceOracle[](1);\n oraclesToAdd[0] = BasePriceOracle(mainOracle);\n BasePriceOracle[] memory fallbackOraclesToAdd = new BasePriceOracle[](1);\n fallbackOraclesToAdd[0] = BasePriceOracle(fallbackOracle);\n\n vm.startPrank(someAdminAccount);\n mpo.add(tokens, oraclesToAdd);\n mpo.addFallbacks(tokens, fallbackOraclesToAdd);\n vm.stopPrank();\n\n revertingOracle = new MockRevertPriceOracle();\n }\n\n function testGetUnderlyingPrice() public fork(MODE_MAINNET) {\n vm.prank(someAdminAccount);\n uint256 price = mpo.getUnderlyingPrice(ICErc20(ionezETH));\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testGetUnderlyingPriceWhenZero() public fork(MODE_MAINNET) {\n vm.prank(someAdminAccount);\n mainOracle.setDirectPrice(ezETH, 0);\n uint256 price = mpo.getUnderlyingPrice(ICErc20(ionezETH));\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testGetUnderlyingPriceWhenZeroAddressOracle() public fork(MODE_MAINNET) {\n address[] memory tokens = new address[](1);\n tokens[0] = ezETH;\n\n BasePriceOracle[] memory oraclesToAdd = new BasePriceOracle[](1);\n oraclesToAdd[0] = BasePriceOracle(0x0000000000000000000000000000000000000000);\n\n vm.prank(someAdminAccount);\n mpo.add(tokens, oraclesToAdd);\n\n uint256 price = mpo.getUnderlyingPrice(ICErc20(ionezETH));\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testGetUnderlyingPriceWhenOracleReverts() public fork(MODE_MAINNET) {\n address[] memory tokens = new address[](1);\n tokens[0] = ezETH;\n\n BasePriceOracle[] memory oraclesToAdd = new BasePriceOracle[](1);\n oraclesToAdd[0] = BasePriceOracle(revertingOracle);\n\n vm.prank(someAdminAccount);\n mpo.add(tokens, oraclesToAdd);\n\n uint256 price = mpo.getUnderlyingPrice(ICErc20(ionezETH));\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testPrice() public fork(MODE_MAINNET) {\n vm.prank(someAdminAccount);\n uint256 price = mpo.price(ezETH);\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testPriceWhenZero() public fork(MODE_MAINNET) {\n vm.prank(someAdminAccount);\n mainOracle.setDirectPrice(ezETH, 0);\n uint256 price = mpo.price(ezETH);\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testPriceWhenZeroAddressOracle() public fork(MODE_MAINNET) {\n address[] memory tokens = new address[](1);\n tokens[0] = ezETH;\n\n BasePriceOracle[] memory oraclesToAdd = new BasePriceOracle[](1);\n oraclesToAdd[0] = BasePriceOracle(0x0000000000000000000000000000000000000000);\n\n vm.prank(someAdminAccount);\n mpo.add(tokens, oraclesToAdd);\n\n uint256 price = mpo.price(ezETH);\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n\n function testPriceWhenOracleReverts() public fork(MODE_MAINNET) {\n address[] memory tokens = new address[](1);\n tokens[0] = ezETH;\n\n BasePriceOracle[] memory oraclesToAdd = new BasePriceOracle[](1);\n oraclesToAdd[0] = BasePriceOracle(revertingOracle);\n\n vm.prank(someAdminAccount);\n mpo.add(tokens, oraclesToAdd);\n\n uint256 price = mpo.price(ezETH);\n assertEq(price, 2000, \"Price should match the mock price\");\n }\n}\n" + }, + "contracts/test/oracles/default/PythPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PythPriceOracle } from \"../../../oracles/default/PythPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { IPyth } from \"@pythnetwork/pyth-sdk-solidity/MockPyth.sol\";\nimport { PythStructs } from \"@pythnetwork/pyth-sdk-solidity/PythStructs.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\ncontract PythPriceOracleTest is BaseTest {\n PythPriceOracle oracle;\n IPyth pythOracle;\n MasterPriceOracle mpo;\n\n address stable;\n address wtoken;\n address wbtc;\n\n address neonPyth = 0x7f2dB085eFC3560AFF33865dD727225d91B4f9A5;\n address lineaPyth = 0xA2aa501b19aff244D90cc15a4Cf739D2725B5729;\n address polygonPyth = 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C;\n address zkevmPyth = 0xC5E56d6b40F3e3B5fbfa266bCd35C37426537c65;\n\n bytes32 ethUsdTokenPriceFeed = 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace;\n bytes32 btcUsdTokenPriceFeed = 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43;\n bytes32 neonUsdTokenPriceFeed = 0xd82183dd487bef3208a227bb25d748930db58862c5121198e723ed0976eb92b7;\n bytes32 maticUsdTokenPriceFeed = 0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52;\n bytes32 usdcUsdTokenPriceFeed = 0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a;\n\n function afterForkSetUp() internal override {\n stable = ap.getAddress(\"stableToken\");\n wtoken = ap.getAddress(\"wtoken\");\n wbtc = ap.getAddress(\"wBTCToken\");\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new PythPriceOracle();\n\n // create an array of bytes to pass to the oracle\n bytes32[] memory feedIds = new bytes32[](2);\n feedIds[0] = usdcUsdTokenPriceFeed;\n feedIds[1] = btcUsdTokenPriceFeed;\n vm.startPrank(mpo.admin());\n\n if (block.chainid == NEON_MAINNET) {\n oracle.initialize(neonPyth, neonUsdTokenPriceFeed, stable);\n } else if (block.chainid == LINEA_MAINNET) {\n oracle.initialize(lineaPyth, ethUsdTokenPriceFeed, stable);\n } else if (block.chainid == POLYGON_MAINNET) {\n oracle.initialize(polygonPyth, maticUsdTokenPriceFeed, stable);\n } else if (block.chainid == ZKEVM_MAINNET) {\n oracle.initialize(zkevmPyth, ethUsdTokenPriceFeed, stable);\n } else {\n revert(\"Unsupported chain\");\n }\n oracle.setPriceFeeds(asArray(stable, wbtc), feedIds);\n vm.stopPrank();\n }\n\n function testPolygonTokenPrice() public debuggingOnly fork(POLYGON_MAINNET) {\n PythStructs.Price memory pythPrice = IPyth(polygonPyth).getPriceUnsafe(maticUsdTokenPriceFeed);\n emit log_named_uint(\"price\", uint256(uint64(pythPrice.price)));\n emit log_named_uint(\"updated\", pythPrice.publishTime);\n emit log_named_uint(\"ts\", block.timestamp);\n\n uint256 price = oracle.price(wbtc);\n uint256 priceMpo = mpo.price(wbtc);\n assertApproxEqRel(price, priceMpo, 1e16);\n }\n\n function testLineaTokenPrice() public debuggingOnly fork(LINEA_MAINNET) {\n PythStructs.Price memory pythPrice = IPyth(lineaPyth).getPriceUnsafe(btcUsdTokenPriceFeed);\n emit log_named_uint(\"price\", uint256(uint64(pythPrice.price)));\n emit log_named_uint(\"updated\", pythPrice.publishTime);\n emit log_named_uint(\"ts\", block.timestamp);\n\n uint256 price = oracle.price(wbtc);\n uint256 priceMpo = mpo.price(wbtc);\n assertApproxEqRel(price, priceMpo, 1e17);\n }\n\n function testNeonTokenPrice() public debuggingOnly fork(NEON_MAINNET) {\n PythStructs.Price memory pythPriceNeon = IPyth(neonPyth).getPriceUnsafe(neonUsdTokenPriceFeed);\n emit log_named_uint(\"price\", uint256(uint64(pythPriceNeon.price)));\n emit log_named_uint(\"updated\", pythPriceNeon.publishTime);\n emit log_named_uint(\"ts\", block.timestamp);\n PythStructs.Price memory pythPrice = IPyth(neonPyth).getPriceUnsafe(btcUsdTokenPriceFeed);\n emit log_named_uint(\"price\", uint256(uint64(pythPrice.price)));\n emit log_named_uint(\"updated\", pythPrice.publishTime);\n emit log_named_uint(\"ts\", block.timestamp);\n\n uint256 price = oracle.price(wbtc);\n uint256 priceMpo = mpo.price(wbtc);\n assertApproxEqRel(price, priceMpo, 1e16);\n }\n\n function testZkEvmTokenPrice() public fork(ZKEVM_MAINNET) {\n PythStructs.Price memory pythPrice = IPyth(zkevmPyth).getPriceUnsafe(btcUsdTokenPriceFeed);\n emit log_named_uint(\"price\", uint256(uint64(pythPrice.price)));\n emit log_named_uint(\"updated\", pythPrice.publishTime);\n emit log_named_uint(\"ts\", block.timestamp);\n\n uint256 price = oracle.price(wbtc);\n uint256 priceMpo = mpo.price(wbtc);\n assertApproxEqRel(price, priceMpo, 1e16);\n }\n}\n" + }, + "contracts/test/oracles/default/SaddleLpPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ISwap } from \"../../../external/saddle/ISwap.sol\";\nimport { SaddleLpPriceOracle } from \"../../../oracles/default/SaddleLpPriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract SaddleLpPriceOracleTest is BaseTest {\n SaddleLpPriceOracle oracle;\n address usdc = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8;\n address frax = 0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F;\n address fraxUsdc_lp = 0x896935B02D3cBEb152192774e4F1991bb1D2ED3f;\n address fraxUsdc_pool = 0x401AFbc31ad2A3Bc0eD8960d63eFcDEA749b4849;\n // TODO: add test once this is deployed\n // ICErc20 fraxUsdc_c = ICErc20(0x);\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n address[] memory lpTokens = new address[](1);\n lpTokens[0] = fraxUsdc_lp;\n address[] memory pools = new address[](1);\n pools[0] = fraxUsdc_pool;\n address[][] memory underlyings = new address[][](1);\n underlyings[0] = new address[](2);\n underlyings[0][0] = usdc;\n underlyings[0][1] = frax;\n\n vm.startPrank(mpo.admin());\n oracle = new SaddleLpPriceOracle();\n oracle.initialize(lpTokens, pools, underlyings);\n vm.stopPrank();\n }\n\n function testSaddleLpTokenPriceOracle() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 44898730) {\n vm.prank(address(mpo));\n uint256 price = oracle.price(fraxUsdc_lp);\n assertEq(price, 785240575939374);\n }\n}\n" + }, + "contracts/test/oracles/default/SimplePriceOracleTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { SimplePriceOracle } from \"../../../oracles/default/SimplePriceOracle.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract SimplePriceOracleTest is BaseTest {\n SimplePriceOracle oracle;\n MasterPriceOracle mpo;\n address someAdminAccount = address(94949);\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n SimplePriceOracle impl = new SimplePriceOracle();\n\n vm.prank(someAdminAccount);\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(impl),\n address(dpa),\n abi.encodePacked(impl.initialize.selector)\n );\n oracle = SimplePriceOracle(address(proxy));\n }\n\n function testSimplePO() public fork(BSC_MAINNET) {\n vm.expectRevert(\"Ownable: caller is not the owner\");\n oracle.setDirectPrice(address(1), 1);\n\n vm.prank(someAdminAccount);\n oracle.setDirectPrice(address(1), 1);\n }\n}\n" + }, + "contracts/test/oracles/default/SolidlyPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { SolidlyPriceOracle } from \"../../../oracles/default/SolidlyPriceOracle.sol\";\nimport { SolidlyLpTokenPriceOracle } from \"../../../oracles/default/SolidlyLpTokenPriceOracle.sol\";\nimport { IPair } from \"../../../external/solidly/IPair.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nstruct PriceExpected {\n uint256 price;\n uint256 percentErrorAllowed;\n}\n\ncontract SolidlyPriceOracleTest is BaseTest {\n SolidlyPriceOracle oracle;\n MasterPriceOracle mpo;\n address wtoken;\n address stable;\n\n function afterForkSetUp() internal override {\n // Not using the address provider yet -- config just added\n // TODO: use ap when deployment is done\n\n stable = ap.getAddress(\"stableToken\"); // USDC\n wtoken = ap.getAddress(\"wtoken\"); // WETH\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new SolidlyPriceOracle();\n\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n }\n\n // Ankr Price: $0.034632 (fetched from block explorer)\n // BNB Price at block 26678077: $337.67 (fetched from block explorer)\n function testBscCustomAsset() public forkAtBlock(BSC_MAINNET, 26678077) {\n address ankr = 0xf307910A4c7bbc79691fD374889b36d8531B08e3;\n address ankrBNB = 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827;\n\n address[] memory underlyings = new address[](1);\n SolidlyPriceOracle.AssetConfig[] memory configs = new SolidlyPriceOracle.AssetConfig[](1);\n\n underlyings[0] = ankr;\n // ANKR/ankrBNB\n configs[0] = SolidlyPriceOracle.AssetConfig(0x7ef540f672Cd643B79D2488344944499F7518b1f, ankrBNB);\n\n vm.prank(oracle.owner());\n oracle._setSupportedBaseTokens(asArray(stable, ankrBNB));\n\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n // Assert price in $ is equal\n assertApproxEqRel((prices[0] * 33667) / 100, 0.03463e18, 1e17); // 0.1 % error\n }\n\n function testBscAssets() public fork(BSC_MAINNET) {\n address busd = 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56;\n address usdt = 0x55d398326f99059fF775485246999027B3197955;\n address hay = 0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5;\n address bnbx = 0x1bdd3Cf7F79cfB8EdbB955f20ad99211551BA275;\n address eth = 0x2170Ed0880ac9A755fd29B2688956BD959F933F8;\n\n address[] memory underlyings = new address[](4);\n SolidlyPriceOracle.AssetConfig[] memory configs = new SolidlyPriceOracle.AssetConfig[](4);\n\n underlyings[0] = hay;\n underlyings[1] = bnbx;\n underlyings[2] = eth;\n underlyings[3] = usdt;\n\n // HAY/BUSD\n configs[0] = SolidlyPriceOracle.AssetConfig(0x93B32a8dfE10e9196403dd111974E325219aec24, busd);\n // BNBx/WBNB\n configs[1] = SolidlyPriceOracle.AssetConfig(0x6c83E45fE3Be4A9c12BB28cB5BA4cD210455fb55, wtoken);\n // ETH/WBNB\n configs[2] = SolidlyPriceOracle.AssetConfig(0x1d168C5b5DEa1c6dA0E9FD9bf4B7607e4e9D8EeC, wtoken);\n // USDT/BUSD\n configs[3] = SolidlyPriceOracle.AssetConfig(0x6321B57b6fdc14924be480c54e93294617E672aB, busd);\n\n PriceExpected[] memory expPrices = new PriceExpected[](4);\n\n expPrices[0] = PriceExpected({ price: mpo.price(hay), percentErrorAllowed: 1e18 }); // 1%\n expPrices[1] = PriceExpected({ price: mpo.price(bnbx), percentErrorAllowed: 1e18 }); // 1%\n expPrices[2] = PriceExpected({ price: mpo.price(eth), percentErrorAllowed: 1e17 }); // 0.1%\n expPrices[3] = PriceExpected({ price: mpo.price(usdt), percentErrorAllowed: 1e17 }); // 0.1%\n\n emit log_named_uint(\"USDC PRICE\", mpo.price(stable));\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertApproxEqRel(prices[i], expPrices[i].price, expPrices[i].percentErrorAllowed, \"!Price Error\");\n }\n }\n\n function testArbitrumAssets() public fork(ARBITRUM_ONE) {\n address wbtc = 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f;\n address dai = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1;\n address usdt = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9;\n\n address[] memory underlyings = new address[](3);\n SolidlyPriceOracle.AssetConfig[] memory configs = new SolidlyPriceOracle.AssetConfig[](3);\n\n underlyings[0] = wbtc;\n underlyings[1] = dai;\n underlyings[2] = usdt;\n\n // WBTC/WETH (8/18 decimals)\n configs[0] = SolidlyPriceOracle.AssetConfig(0xd9D611c6943585bc0e18E51034AF8fa28778F7Da, wtoken);\n // DAI/USDC (18/6)\n configs[1] = SolidlyPriceOracle.AssetConfig(0x07d7F291e731A41D3F0EA4F1AE5b6d920ffb3Fe0, stable);\n // USDT/USDC (6/6)\n configs[2] = SolidlyPriceOracle.AssetConfig(0xC9dF93497B1852552F2200701cE58C236cC0378C, stable);\n\n PriceExpected[] memory expPrices = new PriceExpected[](3);\n\n expPrices[0] = PriceExpected({ price: mpo.price(wbtc), percentErrorAllowed: 1e18 }); // 1%\n expPrices[1] = PriceExpected({ price: mpo.price(dai), percentErrorAllowed: 1e18 }); // 1%\n expPrices[2] = PriceExpected({ price: mpo.price(usdt), percentErrorAllowed: 1e17 }); // 0.1%\n\n emit log_named_uint(\"USDC PRICE\", mpo.price(stable));\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertApproxEqRel(prices[i], expPrices[i].price, expPrices[i].percentErrorAllowed, \"!Price Error\");\n }\n }\n\n function testPolygonAssets() public fork(POLYGON_MAINNET) {\n address usdr = 0xb5DFABd7fF7F83BAB83995E72A52B97ABb7bcf63;\n address usdc = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;\n\n address[] memory underlyings = new address[](1);\n SolidlyPriceOracle.AssetConfig[] memory configs = new SolidlyPriceOracle.AssetConfig[](1);\n\n underlyings[0] = usdr;\n\n // USDR/USDC (9/6), usinf Pearl Exchange\n configs[0] = SolidlyPriceOracle.AssetConfig(0xf6A72Bd46F53Cd5103812ea1f4B5CF38099aB797, stable);\n\n PriceExpected[] memory expPrices = new PriceExpected[](4);\n\n expPrices[0] = PriceExpected({ price: mpo.price(usdc), percentErrorAllowed: 1e17 }); // 0.1%\n\n emit log_named_uint(\"USDC PRICE\", mpo.price(stable));\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertApproxEqRel(prices[i], expPrices[i].price, expPrices[i].percentErrorAllowed, \"!Price Error\");\n }\n }\n\n function getPriceFeed(address[] memory underlyings, SolidlyPriceOracle.AssetConfig[] memory configs)\n internal\n returns (uint256[] memory price)\n {\n vm.prank(oracle.owner());\n oracle.setPoolFeeds(underlyings, configs);\n vm.roll(1);\n\n price = new uint256[](underlyings.length);\n for (uint256 i = 0; i < underlyings.length; i++) {\n vm.prank(address(mpo));\n price[i] = oracle.price(underlyings[i]);\n }\n return price;\n }\n\n function testSetUnsupportedBaseToken() public fork(ARBITRUM_ONE) {\n address dai = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1;\n address usdt = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9;\n\n address[] memory underlyings = new address[](1);\n SolidlyPriceOracle.AssetConfig[] memory configs = new SolidlyPriceOracle.AssetConfig[](1);\n\n underlyings[0] = dai;\n\n // DAI/USDT\n configs[0] = SolidlyPriceOracle.AssetConfig(0x15b9D20bcaa4f65d9004D2BEBAc4058445FD5285, usdt);\n\n // revert if underlying is not supported\n vm.startPrank(oracle.owner());\n vm.expectRevert(bytes(\"Underlying token must be supported\"));\n oracle.setPoolFeeds(underlyings, configs);\n\n // add it successfully when suported\n oracle._setSupportedBaseTokens(asArray(usdt, stable));\n oracle.setPoolFeeds(underlyings, configs);\n vm.stopPrank();\n\n // check prices\n vm.prank(address(mpo));\n uint256 price = oracle.price(dai);\n assertApproxEqRel(price, mpo.price(dai), 1e17, \"!Price Error\");\n }\n}\n" + }, + "contracts/test/oracles/default/StkBNBPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { StkBNBPriceOracle } from \"../../../oracles/default/StkBNBPriceOracle.sol\";\n\ncontract StkBNBPriceOracleTest is BaseTest {\n StkBNBPriceOracle private oracle;\n address stkBnb = 0xc2E9d07F66A89c44062459A47a0D2Dc038E4fb16;\n\n function afterForkSetUp() internal override {\n oracle = new StkBNBPriceOracle();\n oracle.initialize();\n }\n\n function testStkBnbOraclePrice() public forkAtBlock(BSC_MAINNET, 21952914) {\n uint256 priceStkBnb = oracle.price(stkBnb);\n\n assertGt(priceStkBnb, 1e18);\n assertEq(priceStkBnb, 1006482474298479702);\n }\n}\n" + }, + "contracts/test/oracles/default/TwapOraclesBaseTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { UniswapTwapPriceOracleV2Factory } from \"../../../oracles/default/UniswapTwapPriceOracleV2Factory.sol\";\nimport { UniswapTwapPriceOracleV2Root } from \"../../../oracles/default/UniswapTwapPriceOracleV2Root.sol\";\nimport { UniswapTwapPriceOracleV2 } from \"../../../oracles/default/UniswapTwapPriceOracleV2.sol\";\nimport { IUniswapV2Factory } from \"../../../external/uniswap/IUniswapV2Factory.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { IUniswapV2Pair } from \"../../../external/uniswap/IUniswapV2Pair.sol\";\nimport { IUniswapV2Factory } from \"../../../external/uniswap/IUniswapV2Factory.sol\";\n\ncontract TwapOraclesBaseTest is BaseTest {\n IUniswapV2Factory uniswapV2Factory;\n UniswapTwapPriceOracleV2Factory twapPriceOracleFactory;\n MasterPriceOracle mpo;\n\n function afterForkSetUp() internal override {\n uniswapV2Factory = IUniswapV2Factory(ap.getAddress(\"IUniswapV2Factory\"));\n twapPriceOracleFactory = UniswapTwapPriceOracleV2Factory(ap.getAddress(\"UniswapTwapPriceOracleV2Factory\"));\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n // BOMB\n function testBombTwapOraclePrice() public fork(BSC_MAINNET) {\n address baseToken = 0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c; // WBTC\n address testedAssetTokenAddress = 0x522348779DCb2911539e76A1042aA922F9C47Ee3; // BOMB\n\n assertTrue(getTokenTwapPrice(testedAssetTokenAddress, baseToken) > 0);\n }\n\n function getTokenTwapPrice(address tokenAddress, address baseTokenAddress) internal returns (uint256) {\n address testedPairAddress = uniswapV2Factory.getPair(tokenAddress, baseTokenAddress);\n\n // trigger a price update\n UniswapTwapPriceOracleV2Root twapOracleRoot = UniswapTwapPriceOracleV2Root(twapPriceOracleFactory.rootOracle());\n address[] memory pairs = new address[](1);\n pairs[0] = testedPairAddress;\n twapOracleRoot.update(pairs);\n\n // check if the base toke oracle is present in the master price oracle\n if (address(mpo.oracles(tokenAddress)) == address(0)) {\n // deploy or get the base token twap oracle\n address oracleAddress = twapPriceOracleFactory.deploy(address(uniswapV2Factory), baseTokenAddress);\n UniswapTwapPriceOracleV2 oracle = UniswapTwapPriceOracleV2(oracleAddress);\n // add the new twap oracle to the master oracle\n address[] memory underlyings = new address[](1);\n underlyings[0] = tokenAddress;\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n // impersonate the admin to add the oracle\n vm.prank(mpo.admin());\n mpo.add(underlyings, oracles);\n emit log(\"added the oracle\");\n } else {\n emit log(\"found the oracle\");\n }\n\n // return the price denominated in W_NATIVE\n return mpo.price(tokenAddress);\n }\n\n // function testChapelEthBusdOraclePrice() public {\n // address baseToken = 0x7ef95a0FEE0Dd31b22626fA2e10Ee6A223F8a684; // USDT\n // address testedAssetTokenAddress = 0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7; // BUSD\n // assertTrue(getTokenTwapPrice(testedAssetTokenAddress, baseToken) > 0);\n // }\n}\n" + }, + "contracts/test/oracles/default/UmbrellaPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { UmbrellaPriceOracle } from \"../../../oracles/default/UmbrellaPriceOracle.sol\";\nimport { IRegistry } from \"../../../external/umbrella/IRegistry.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\n\ncontract UmbrellaPriceOracleTest is BaseTest {\n UmbrellaPriceOracle private oracle;\n IRegistry public registry;\n MasterPriceOracle mpo;\n address stableToken;\n address otherToken;\n address wbtc;\n address wtoken;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n stableToken = ap.getAddress(\"stableToken\");\n wbtc = ap.getAddress(\"wBTCToken\");\n wtoken = ap.getAddress(\"wtoken\");\n oracle = new UmbrellaPriceOracle();\n\n if (block.chainid == LINEA_MAINNET) {\n registry = IRegistry(0x1B17DBB40fbED8735E7fE8C9eB02C20984fAdfD6);\n } else if (block.chainid == POLYGON_MAINNET) {\n registry = IRegistry(0x455acbbC2c15c086978083968a69B2e7E4d38d34);\n } else {\n revert(\"Unsupported chain\");\n }\n }\n\n function setUpLinea() public {\n vm.prank(mpo.admin());\n oracle.initialize(\"ETH-USD\", registry);\n\n address[] memory underlyings = new address[](3);\n string[] memory feeds = new string[](3);\n\n // USDT\n otherToken = 0x1990BC6dfe2ef605Bfc08f5A23564dB75642Ad73;\n\n underlyings[0] = stableToken;\n underlyings[1] = otherToken;\n underlyings[2] = wbtc;\n\n feeds[0] = \"USDC-USD\";\n feeds[1] = \"USDT-USD\";\n feeds[2] = \"WBTC-USD\";\n\n vm.prank(oracle.owner());\n oracle.setPriceFeeds(underlyings, feeds);\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](3);\n oracles[0] = oracle;\n oracles[1] = oracle;\n oracles[2] = oracle;\n\n vm.prank(mpo.admin());\n mpo.add(underlyings, oracles);\n }\n\n function testUmbrellaPriceOracleLinea() public fork(LINEA_MAINNET) {\n setUpLinea();\n vm.startPrank(address(mpo));\n uint256 upoUsdcPrice = oracle.price(stableToken);\n uint256 upoUsdtPrice = oracle.price(otherToken);\n uint256 upoWbtcPrice = oracle.price(wbtc);\n uint256 mpoWethPrice = mpo.price(wtoken);\n vm.stopPrank();\n\n assertApproxEqRel(upoUsdcPrice, upoUsdtPrice, 1e16);\n assertGt(upoWbtcPrice, mpoWethPrice);\n assertGt(mpoWethPrice, upoUsdcPrice);\n }\n}\n" + }, + "contracts/test/oracles/default/UniswapLikeLpTokenPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { IPair, Observation } from \"../../../external/solidly/IPair.sol\";\nimport { IRouter } from \"../../../external/solidly/IRouter.sol\";\nimport { IUniswapV2Pair } from \"../../../external/uniswap/IUniswapV2Pair.sol\";\nimport { UniswapLpTokenPriceOracle } from \"../../../oracles/default/UniswapLpTokenPriceOracle.sol\";\nimport { SolidlyLpTokenPriceOracle } from \"../../../oracles/default/SolidlyLpTokenPriceOracle.sol\";\nimport { UniswapLikeLpTokenPriceOracle } from \"../../../oracles/default/UniswapLikeLpTokenPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract UniswapLikeLpTokenPriceOracleTest is BaseTest {\n UniswapLikeLpTokenPriceOracle uniswapLpTokenPriceOracle;\n MasterPriceOracle mpo;\n address wtoken;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n function getSolidlyLpTokenPriceOracle() internal returns (UniswapLikeLpTokenPriceOracle) {\n return new SolidlyLpTokenPriceOracle(wtoken);\n }\n\n function getUniswapLpTokenPriceOracle() internal returns (UniswapLikeLpTokenPriceOracle) {\n return new UniswapLpTokenPriceOracle(wtoken);\n }\n\n function getLpPrice(address lpToken, UniswapLikeLpTokenPriceOracle oracle) internal returns (uint256) {\n if (address(mpo.oracles(lpToken)) == address(0)) {\n address[] memory underlyings = new address[](1);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n\n underlyings[0] = lpToken;\n oracles[0] = oracle;\n\n vm.prank(mpo.admin());\n mpo.add(underlyings, oracles);\n emit log(\"added the oracle\");\n } else {\n emit log(\"found the oracle\");\n }\n return mpo.price(lpToken);\n }\n\n function verifyLpPrice(\n address lpToken,\n uint256 price,\n uint256 tolerance\n ) internal {\n uint256 priceToken0 = mpo.price(IPair(lpToken).token0());\n uint256 priceToken1 = mpo.price(IPair(lpToken).token1());\n uint256 token0Decimals = uint256(ERC20Upgradeable(IPair(lpToken).token0()).decimals());\n uint256 token1Decimals = uint256(ERC20Upgradeable(IPair(lpToken).token1()).decimals());\n\n assertApproxEqRel(\n 2 * sqrt(priceToken0 * (10**(18 - token0Decimals))) * sqrt(priceToken1 * (10**(18 - token1Decimals))),\n price,\n tolerance\n );\n }\n\n function testBnbXBnbSolidly() public fork(BSC_MAINNET) {\n address lpToken = 0x6c83E45fE3Be4A9c12BB28cB5BA4cD210455fb55; // Lp BNBx/WBNB (volatile AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17); // 1% tolerance\n }\n\n function testUsdtUsdcSolidly() public fork(BSC_MAINNET) {\n address lpToken = 0x618f9Eb0E1a698409621f4F487B563529f003643; // Lp USDT/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17);\n }\n\n function testBusdWbnbSolidly() public fork(BSC_MAINNET) {\n address lpToken = 0x483653bcF3a10d9a1c334CE16a19471a614F4385; // Lp USDT/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17);\n }\n\n function testWbtcWethArbiSolidly() public fork(ARBITRUM_ONE) {\n address lpToken = 0xd9D611c6943585bc0e18E51034AF8fa28778F7Da; // Lp WBTC/WETH (volatile AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17); // 1% tolerance\n }\n\n function testDaitUsdcArbiSolidly() public fork(ARBITRUM_ONE) {\n address lpToken = 0x07d7F291e731A41D3F0EA4F1AE5b6d920ffb3Fe0; // Lp DAI/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17);\n }\n\n function testUsdtUsdcArbiSolidly() public fork(ARBITRUM_ONE) {\n address lpToken = 0xC9dF93497B1852552F2200701cE58C236cC0378C; // Lp USDT/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17);\n }\n\n function testWethGmxArbiSolidly() public fork(ARBITRUM_ONE) {\n address lpToken = 0x06A4c4389d5C6cD1Ec63dDFFb7e9b3214254A720; // Lp WETH/GMX (volatile AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertTrue(price > 0);\n verifyLpPrice(lpToken, price, 1e17);\n }\n\n // Fixed block number tests\n\n // https://bscscan.com/tx/0xad3d5e2ddcd246bf6b76e381b8231ef32e3d82b539baf2e1d6a677b9a61967a4\n // 2,932.668 LP tokens removed from the pool\n // - 48,841.999 BUSD\n // - 176,1972 WBNB\n // =~ $97,945.00 = ~352,32 BNB (BNB price: $278)\n // Therefor, LP price is 352,32/2,932.668 = 0,1201\n // FAILING\n function testForkedBusdWbnbSolidly() public debuggingOnly forkAtBlock(BSC_MAINNET, 26399998) {\n address lpToken = 0x483653bcF3a10d9a1c334CE16a19471a614F4385; // Lp WBNB-BUSD\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 120054770949519465); // 120054770949519465/1e18 = 0,1200\n }\n\n // https://bscscan.com/tx/0xbc26ea6b98235d62b3d6bd48171f999e5016a39f739a35fa36c18de4462baf4b\n // 39,3053 LP tokens removed from the pool\n // - 896,4976 BUSD\n // - 3,233 WBNB\n // =~ $1,797.86 = ~6,467 BNB (BNB price: $278)\n // Therefor, LP price is 6,467/39,3053 = 0,1645\n function testForkedBusdWbnbUniswap() public debuggingOnly forkAtBlock(BSC_MAINNET, 26399706) {\n address lpToken = 0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16; // Lp WBNB-BUSD\n\n uint256 price = getLpPrice(lpToken, getUniswapLpTokenPriceOracle());\n assertEq(price, 164507819383257850); // 164507819383257850/1e18 = 0,1645\n }\n\n // https://arbiscan.io/tx/0xff32f8f997d487a3e6f602552f2da9edc1e31f1e023e0e9dcacc77bd177791b1\n // 0.015037668670 LP tokens removed from the pool\n // - 14,546.17 DAI\n // - 15,543.33 USDC\n // =~ $30,119.52 = ~19.307 ETH (ETH price: $1560)\n // Therefor, LP price is 19.307/0.015037668670 = 1283,9\n function testForkedDaiUsdcArbiSolidly() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 67509709) {\n address lpToken = 0x07d7F291e731A41D3F0EA4F1AE5b6d920ffb3Fe0; // Lp DAI/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 1271806681784147372847); // 1271806681784147372847/1e18 = 1271,80\n }\n\n // https://arbiscan.io/tx/0x8e5366d84d278c7dc5fa285c9cb3cf63697763066a77c228b7ae2a2cea9115e7\n // 0.000000011455333328 LP tokens removed from the pool\n // - 11,264.0276 USDT\n // - 11,646.6401 USDC\n // =~ $22,910 = ~14.68 ETH (ETH price: $1560)\n // Therefor, LP price is 14.68/0.000000011455333328 = 1,2815e9\n function testForkedUsdtUsdcArbiSolidly() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 67509709) {\n address lpToken = 0xC9dF93497B1852552F2200701cE58C236cC0378C; // Lp USDT/USDC (stable AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 1271259093277228095541923239); // 1271259093277228095541923239/1e18 = 1,275e9\n }\n\n // https://arbiscan.io/tx/0xcd98ae753ca7cbe93bfb653c3090fa0973ad10ab6b096fe7005216eae3f96a0f\n // 5.111039 LP tokens added from the pool\n // - 1.11740494 WETH\n // - 24.5277511 GMX\n // =~ $3490,5 = ~2,237 ETH (ETH price: $1560)\n // Therefor, LP price is 2,237/5,111 = 0,4377\n function testForkeWethGmxArbiSolidly() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 67509709) {\n address lpToken = 0x06A4c4389d5C6cD1Ec63dDFFb7e9b3214254A720; // Lp WETH/GMX (volatile AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 439388395594901356); // 439388395594901356/1e18 = 0.43939\n }\n\n // https://arbiscan.io/tx/0xb33c8fd30b124070c08eff4c7dd8fbf98c1a8ac8b61e7e9afb5da3c77176c4ff\n // 0.000000084147497167 LP tokens added from the pool\n // - 0.00222613 WBTC\n // - 0.031808 WETH\n // =~ $99,73 = ~0.06393 ETH (ETH price: $1560)\n // Therefor, LP price is 0.06393/0.000000084147497167 = 759.737,391\n function testForkeWethWbtcArbiSolidly() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 67509709) {\n address lpToken = 0xd9D611c6943585bc0e18E51034AF8fa28778F7Da; // Lp WETH/WBTC (volatile AMM)\n\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 755603082914754302563322); // 755603649957725481578826/1e18 = 755,603.6499\n }\n\n // https://bscscan.com/tx/0x4f08c603fddf6d4fcc4cfd7e8fa325d5a2ed6d61f097c86204a5ef915acf4948\n // 12,593.45 LP tokens added from the pool\n // - 12,282.086 USDT\n // - 12,904.8221 USDC\n // =~ $25,211 = ~86,99 BNB (ETH price: $289,77)\n // Therefor, LP price is 86,99/12,593.45 = 0,0069\n\n function testForkeUsdtUsdcBscSolidly() public forkAtBlock(BSC_MAINNET, 26257339) {\n address lpToken = 0x618f9Eb0E1a698409621f4F487B563529f003643; // Lp USDT/USDC (stable AMM)\n uint256 price = getLpPrice(lpToken, getSolidlyLpTokenPriceOracle());\n assertEq(price, 6999543840666976); // 6999543840666976/1e18 = 0.006999543840666965\n }\n\n function testSolidlyLPTokenPriceManipulationWithMintAndBurn() public debuggingOnly fork(ARBITRUM_ONE) {\n address pairAddress = 0x15b9D20bcaa4f65d9004D2BEBAc4058445FD5285;\n address pairWhale = 0x637DCef6f06A120e0cca5BCa079F6cF6Da9264e8;\n IRouter router = IRouter(0xF26515D5482e2C2FD237149bF6A653dA4794b3D0);\n\n SolidlyLpTokenPriceOracle lpOracle = new SolidlyLpTokenPriceOracle(ap.getAddress(\"wtoken\"));\n\n vm.prank(address(mpo));\n uint256 priceBefore = lpOracle.price(pairAddress);\n\n uint256 initialPairBalance = ERC20Upgradeable(pairAddress).balanceOf(pairWhale);\n emit log_named_uint(\"initialPairBalance\", initialPairBalance);\n\n // manipulate\n {\n uint256 burnAmount = (initialPairBalance * 8) / 10;\n vm.startPrank(pairWhale);\n ERC20Upgradeable(pairAddress).approve(address(router), burnAmount);\n (uint256 amountA, uint256 amountB) = router.removeLiquidity(\n 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1, // dai\n 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9, // usdt\n true,\n burnAmount,\n 0,\n 0,\n pairWhale,\n block.timestamp + 1\n );\n emit log_named_uint(\"amountA\", amountA);\n emit log_named_uint(\"amountB\", amountB);\n vm.stopPrank();\n }\n vm.prank(address(mpo));\n uint256 priceAfter = lpOracle.price(pairAddress);\n emit log_named_uint(\"price before\", priceBefore);\n emit log_named_uint(\"price after\", priceAfter);\n }\n\n function testSolidlyLPTokenPriceManipulationWithSwaps() public debuggingOnly fork(ARBITRUM_ONE) {\n address pairAddress = 0x15b9D20bcaa4f65d9004D2BEBAc4058445FD5285;\n\n address dai = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1;\n address usdt = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9;\n\n address daiWhale = 0x969f7699fbB9C79d8B61315630CDeED95977Cfb8;\n address usdtWhale = 0xf89d7b9c864f589bbF53a82105107622B35EaA40;\n\n SolidlyLpTokenPriceOracle lpOracle = new SolidlyLpTokenPriceOracle(ap.getAddress(\"wtoken\"));\n\n vm.prank(address(mpo));\n uint256 priceBefore = lpOracle.price(pairAddress);\n emit log_named_uint(\"price before\", priceBefore);\n\n IPair pair = IPair(pairAddress);\n ERC20Upgradeable daiToken = ERC20Upgradeable(pair.token0());\n ERC20Upgradeable usdtToken = ERC20Upgradeable(pair.token1());\n\n // manipulate\n {\n address hacker = address(666);\n vm.startPrank(daiWhale);\n daiToken.transfer(hacker, daiToken.balanceOf(daiWhale));\n vm.stopPrank();\n\n vm.startPrank(usdtWhale);\n usdtToken.transfer(hacker, usdtToken.balanceOf(usdtWhale));\n vm.stopPrank();\n\n vm.startPrank(hacker);\n ERC20Upgradeable tokenToSwap = daiToken;\n\n // advance > 30 mins so an observations is recorded\n //vm.warp(block.timestamp + 60 * 22);\n\n uint256 amountOut = pair.getAmountOut(tokenToSwap.balanceOf(hacker) / 10, address(tokenToSwap));\n emit log_named_uint(\"amountOut\", amountOut);\n\n tokenToSwap.transfer(pairAddress, tokenToSwap.balanceOf(hacker) / 10);\n pair.swap(amountOut, 0, hacker, \"\");\n vm.stopPrank();\n vm.prank(address(mpo));\n emit log_named_uint(\"price after at the same block\", lpOracle.price(pairAddress));\n }\n\n for (uint256 i = 0; i < 10; i++) {\n vm.warp(block.timestamp + 15);\n pair.sync();\n\n emit log_named_uint(\"i\", i);\n vm.prank(address(mpo));\n emit log_named_uint(\"price after\", lpOracle.price(pairAddress));\n }\n }\n}\n" + }, + "contracts/test/oracles/default/UniswapTwapPriceOracleV2Resolver.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { UniswapTwapPriceOracleV2Root } from \"../../../oracles/default/UniswapTwapPriceOracleV2Root.sol\";\nimport { IUniswapV2Factory } from \"../../../external/uniswap/IUniswapV2Factory.sol\";\nimport { UniswapTwapPriceOracleV2Resolver } from \"../../../oracles/default/UniswapTwapPriceOracleV2Resolver.sol\";\nimport { IUniswapV2Pair } from \"../../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract UniswapTwapOracleV2ResolverTest is BaseTest {\n UniswapTwapPriceOracleV2Root twapPriceOracleRoot;\n UniswapTwapPriceOracleV2Resolver resolver;\n IUniswapV2Factory uniswapV2Factory;\n MasterPriceOracle mpo;\n\n struct Observation {\n uint32 timestamp;\n uint256 price0Cumulative;\n uint256 price1Cumulative;\n }\n\n function afterForkSetUp() internal override {\n uniswapV2Factory = IUniswapV2Factory(ap.getAddress(\"IUniswapV2Factory\"));\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n function getTokenTwapPrice(address tokenAddress) internal view returns (uint256) {\n // return the price denominated in W_NATIVE\n return mpo.price(tokenAddress);\n }\n}\n" + }, + "contracts/test/oracles/default/UniswapV3PriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { UniswapV3PriceOracle } from \"../../../oracles/default/UniswapV3PriceOracle.sol\";\nimport { ChainlinkPriceOracleV2 } from \"../../../oracles/default/ChainlinkPriceOracleV2.sol\";\nimport { ConcentratedLiquidityBasePriceOracle } from \"../../../oracles/default/ConcentratedLiquidityBasePriceOracle.sol\";\nimport { IUniswapV3Pool } from \"../../../external/uniswap/IUniswapV3Pool.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { MasterPriceOracle } from \"../../../oracles/MasterPriceOracle.sol\";\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\n\ncontract UniswapV3PriceOracleTest is BaseTest {\n UniswapV3PriceOracle oracle;\n MasterPriceOracle mpo;\n address wtoken;\n address stable;\n\n function afterForkSetUp() internal override {\n // TODO: remove this after deployment\n if (block.chainid == ETHEREUM_MAINNET) {\n return;\n }\n stable = ap.getAddress(\"stableToken\"); // USDC or arbitrum\n wtoken = ap.getAddress(\"wtoken\"); // WETH\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n oracle = new UniswapV3PriceOracle();\n\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n }\n\n function testPolygonRetroAlmAssets() public fork(POLYGON_MAINNET) {\n address[] memory underlyings = new address[](1);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](1);\n\n underlyings[0] = 0x5D066D022EDE10eFa2717eD3D79f22F949F8C175; // CASH (18 decimals)\n\n // USDC-CASH\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x619259F699839dD1498FFC22297044462483bD27,\n 10 minutes,\n stable\n );\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertTrue(prices[i] > 0, \"!Price Error\");\n }\n uint256[] memory expPrices = new uint256[](7);\n expPrices[0] = mpo.price(stable);\n\n // CASH should be priced like USDC\n assertApproxEqRel(prices[0], expPrices[0], 1e15);\n\n bool[] memory cardinalityChecks = getCardinality(configs);\n for (uint256 i = 0; i < cardinalityChecks.length; i++) {\n assertEq(cardinalityChecks[i], true, \"!Cardinality Error\");\n }\n }\n\n function testPolygonAssets() public fork(POLYGON_MAINNET) {\n address[] memory underlyings = new address[](1);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](1);\n\n underlyings[0] = 0xE5417Af564e4bFDA1c483642db72007871397896; // GNS (18 decimals)\n\n // GNS-MATIC\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xEFa98Fdf168f372E5e9e9b910FcDfd65856f3986,\n 10 minutes,\n wtoken\n );\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertTrue(prices[i] > 0, \"!Price Error\");\n }\n\n bool[] memory cardinalityChecks = getCardinality(configs);\n for (uint256 i = 0; i < cardinalityChecks.length; i++) {\n assertEq(cardinalityChecks[i], true, \"!Cardinality Error\");\n }\n }\n\n function testArbitrumAssets() public fork(ARBITRUM_ONE) {\n address[] memory underlyings = new address[](1);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](1);\n\n underlyings[0] = 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f; // WBTC (18 decimals)\n // WBTC-USDC\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xA62aD78825E3a55A77823F00Fe0050F567c1e4EE,\n 10 minutes,\n stable\n );\n vm.prank(oracle.owner());\n oracle.setPoolFeeds(underlyings, configs);\n vm.roll(1);\n\n vm.prank(address(mpo));\n uint256 oraclePrice = oracle.price(underlyings[0]);\n uint256 mpoPrice = mpo.price(underlyings[0]);\n assertApproxEqRel(oraclePrice, mpoPrice, 1e16, \"Oracle price != MPO price by > 1%\");\n }\n\n function testForkedArbitrumAssets() public debuggingOnly forkAtBlock(ARBITRUM_ONE, 122287973) {\n address[] memory underlyings = new address[](7);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](7);\n\n underlyings[0] = 0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a; // GMX (18 decimals)\n underlyings[1] = 0x6C2C06790b3E3E3c38e12Ee22F8183b37a13EE55; // DPX (18 decimals)\n underlyings[2] = 0x539bdE0d7Dbd336b79148AA742883198BBF60342; // MAGIC (18 decimals)\n underlyings[3] = 0xD74f5255D557944cf7Dd0E45FF521520002D5748; // USDs (18 decimals)\n underlyings[4] = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9; // USDT (6 decimals)\n underlyings[5] = 0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a; // GMX (18 decimals)\n underlyings[6] = 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f; // WBTC (8 decimals)\n\n // GMX-ETH\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x80A9ae39310abf666A87C743d6ebBD0E8C42158E,\n 10 minutes,\n wtoken\n );\n // DPX-ETH\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xb52781C275431bD48d290a4318e338FE0dF89eb9,\n 10 minutes,\n wtoken\n );\n // MAGIC-ETH\n configs[2] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x7e7FB3CCEcA5F2ac952eDF221fd2a9f62E411980,\n 10 minutes,\n wtoken\n );\n // USDs-USDC\n configs[3] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x50450351517117Cb58189edBa6bbaD6284D45902,\n 10 minutes,\n stable\n );\n // USDT-USDC\n configs[4] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0x13398E27a21Be1218b6900cbEDF677571df42A48,\n 10 minutes,\n stable\n );\n // GMX-USDC\n configs[5] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xBed2589feFAE17d62A8a4FdAC92fa5895cAe90d2,\n 10 minutes,\n stable\n );\n // WBTC-USDC\n configs[6] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xA62aD78825E3a55A77823F00Fe0050F567c1e4EE,\n 10 minutes,\n stable\n );\n\n uint256[] memory expPrices = new uint256[](7);\n expPrices[0] = 22458983666679741; // (22458983666679741 / 1e18) * 1807 = $75.4 (17/08/2023)\n expPrices[1] = 39909577522344847; // (39909577522344847 / 1e18) * 1807 = $72 (17/08/2023)\n expPrices[2] = 373271191958027; // (373271191958027 / 1e18) * 1807 = $0.67 (17/08/2023\n expPrices[3] = 557704868599802; // (557704868599802 / 1e18) * 1807 = $1.005 (17/08/2023\n expPrices[4] = 559771099154822; // (559771099154822 / 1e18) * 1807 = $1.01 (17/08/2023\n expPrices[5] = 22458983666679741; // (22458983666679741 / 1e18) * 1807 = $40,5 (17/08/2023)\n expPrices[6] = 15955521590135476492; // (15955521590135476492 / 1e18) * 1807 = $28.864,6 (17/08/2023)\n\n emit log_named_uint(\"USDC PRICE\", mpo.price(stable));\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n for (uint256 i = 0; i < prices.length; i++) {\n assertEq(prices[i], expPrices[i], \"!Price Error\");\n }\n\n bool[] memory cardinalityChecks = getCardinality(configs);\n for (uint256 i = 0; i < cardinalityChecks.length; i++) {\n assertEq(cardinalityChecks[i], true, \"!Cardinality Error\");\n }\n }\n\n function testEthereumAssets() public fork(ETHEREUM_MAINNET) {\n // TODO: Remove these after mainnet deployment\n // Initialise MPO\n stable = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;\n wtoken = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n setUpBaseOracles();\n\n // Initialise Uniswap Oracle\n oracle = new UniswapV3PriceOracle();\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n\n address[] memory underlyings = new address[](2);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](2);\n\n underlyings[0] = 0x68037790A0229e9Ce6EaA8A99ea92964106C4703; // PAR (18 decimals)\n underlyings[1] = 0x0ab87046fBb341D058F17CBC4c1133F25a20a52f; // gOHM decimals)\n // PAR-USDC\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xD7Dcb0eb6AaB643b85ba74cf9997c840fE32e695,\n 10 minutes,\n stable\n );\n // GOHM-USDC\n configs[1] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xcF7e21b96a7DAe8e1663b5A266FD812CBE973E70,\n 10 minutes,\n stable\n );\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n uint256 mpoPrice = mpo.price(underlyings[0]);\n // Compare univ3 (PAR/USDC) vs Chainlink prices (EUR/USD)\n assertApproxEqRel(prices[0], mpoPrice, 1e16, \"Oracle price != MPO price by > 1%\");\n assertGt(prices[1], mpo.price(wtoken), \"gOHM price is > eth price\");\n\n bool[] memory cardinalityChecks = getCardinality(configs);\n for (uint256 i = 0; i < cardinalityChecks.length; i++) {\n assertEq(cardinalityChecks[i], true, \"!Cardinality Error\");\n }\n }\n\n function testForkedEthereumAssets() public forkAtBlock(ETHEREUM_MAINNET, 17065696) {\n // TODO: Remove these after mainnet deployment\n // Initialise MPO\n stable = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;\n wtoken = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n setUpBaseOracles();\n\n // Initialise Uniswap Oracle\n oracle = new UniswapV3PriceOracle();\n vm.prank(mpo.admin());\n oracle.initialize(wtoken, asArray(stable));\n\n address[] memory underlyings = new address[](1);\n ConcentratedLiquidityBasePriceOracle.AssetConfig[]\n memory configs = new ConcentratedLiquidityBasePriceOracle.AssetConfig[](1);\n\n underlyings[0] = 0x0ab87046fBb341D058F17CBC4c1133F25a20a52f; // gOHM decimals)\n // GOHM-USDC\n configs[0] = ConcentratedLiquidityBasePriceOracle.AssetConfig(\n 0xcF7e21b96a7DAe8e1663b5A266FD812CBE973E70,\n 10 minutes,\n wtoken\n );\n uint256[] memory prices = getPriceFeed(underlyings, configs);\n\n // 17/04/2024\n // - ETH Price = 2096 USD\n // - gOHM Price = 2,745.22 USD\n // - gOHM Price = 1.30 ETH\n assertEq(prices[0], 1296264965685839645, \"!price\");\n }\n\n function setUpBaseOracles() public {\n // TODO: Remove these after mainnet deployment\n if (block.chainid == ETHEREUM_MAINNET) {\n setUpMpoAndAddresses();\n BasePriceOracle[] memory oracles = new BasePriceOracle[](2);\n ChainlinkPriceOracleV2 chainlinkOracle = new ChainlinkPriceOracleV2();\n chainlinkOracle.initialize(stable, 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);\n\n vm.prank(chainlinkOracle.owner());\n chainlinkOracle.setPriceFeeds(\n asArray(stable),\n asArray(0x986b5E1e1755e3C2440e960477f25201B0a8bbD4),\n ChainlinkPriceOracleV2.FeedBaseCurrency.ETH\n );\n chainlinkOracle.setPriceFeeds(\n asArray(0x68037790A0229e9Ce6EaA8A99ea92964106C4703), // PAR\n asArray(0xb49f677943BC038e9857d61E7d053CaA2C1734C1), // EUR/USD price feed\n ChainlinkPriceOracleV2.FeedBaseCurrency.USD\n );\n oracles[0] = chainlinkOracle;\n oracles[1] = chainlinkOracle;\n\n vm.prank(mpo.admin());\n mpo.add(asArray(stable, 0x68037790A0229e9Ce6EaA8A99ea92964106C4703), oracles);\n }\n }\n\n function setUpMpoAndAddresses() public {\n address[] memory assets = new address[](0);\n BasePriceOracle[] memory oracles = new BasePriceOracle[](0);\n mpo = new MasterPriceOracle();\n mpo.initialize(assets, oracles, BasePriceOracle(address(0)), address(this), true, address(wtoken));\n }\n\n function getPriceFeed(address[] memory underlyings, UniswapV3PriceOracle.AssetConfig[] memory configs)\n internal\n returns (uint256[] memory price)\n {\n vm.prank(oracle.owner());\n oracle.setPoolFeeds(underlyings, configs);\n vm.roll(1);\n\n price = new uint256[](underlyings.length);\n for (uint256 i = 0; i < underlyings.length; i++) {\n vm.prank(address(mpo));\n price[i] = oracle.price(underlyings[i]);\n }\n return price;\n }\n\n function getCardinality(UniswapV3PriceOracle.AssetConfig[] memory configs) internal view returns (bool[] memory) {\n bool[] memory checks = new bool[](configs.length);\n for (uint256 i = 0; i < configs.length; i += 1) {\n (, , , , uint16 observationCardinalityNext, , ) = IUniswapV3Pool(configs[i].poolAddress).slot0();\n checks[i] = observationCardinalityNext >= 10;\n }\n\n return checks;\n }\n}\n" + }, + "contracts/test/oracles/default/WombatLpTokenPriceOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { WombatLpTokenPriceOracle } from \"../../../oracles/default/WombatLpTokenPriceOracle.sol\";\n\ncontract WombatLpTokenPriceOracleTest is BaseTest {\n WombatLpTokenPriceOracle private oracle;\n\n function afterForkSetUp() internal override {\n oracle = new WombatLpTokenPriceOracle();\n }\n\n function testPrice() public fork(BSC_MAINNET) {\n // price for Wombat Wrapped BNB asset\n vm.prank(ap.getAddress(\"MasterPriceOracle\"));\n uint256 price = oracle.price(0x74f019A5C4eD2C2950Ce16FaD7Af838549092c5b);\n assertEq(price, 1e18);\n }\n}\n" + }, + "contracts/test/oracles/default/WSTEthPriceOracleTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"../../config/BaseTest.t.sol\";\nimport { WSTEthPriceOracle } from \"../../../oracles/default/WSTEthPriceOracle.sol\";\n\ncontract WSTEthPriceOracleTest is BaseTest {\n WSTEthPriceOracle private oracle;\n address wstETH = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;\n address mpo = 0xdD8d4e09Acb39C2B4DE9A84384389B79850f3271;\n\n function afterForkSetUp() internal override {\n oracle = new WSTEthPriceOracle();\n oracle.initialize();\n }\n\n function testWstEthOraclePrice() public forkAtBlock(ETHEREUM_MAINNET, 17469681) {\n vm.prank(mpo);\n uint256 priceWstEth = oracle.price(wstETH);\n\n assertGt(priceWstEth, 1e18);\n assertEq(priceWstEth, 1006482474298479702);\n }\n}\n" + }, + "contracts/test/oracles/RedstoneAdapterOracleTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { RedstoneAdapterPriceOracle } from \"../../oracles/default/RedstoneAdapterPriceOracle.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract RedstoneAdapterOracleTest is BaseTest {\n MasterPriceOracle public mpo;\n RedstoneAdapterPriceOracle public oracle;\n address public redstoneOracleAddress;\n address MODE_USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address MODE_WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;\n address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n\n function afterForkSetUp() internal override {\n if (block.chainid == MODE_MAINNET) {\n redstoneOracleAddress = 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256;\n }\n\n oracle = new RedstoneAdapterPriceOracle(redstoneOracleAddress);\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n }\n\n function testPrintPricesMode() public fork(MODE_MAINNET) {\n emit log_named_uint(\"ezETH price (18 dec)\", oracle.price(MODE_EZETH));\n emit log_named_uint(\"WBTC price (8 dec)\", oracle.price(MODE_WBTC));\n emit log_named_uint(\"weETH price (18 dec)\", oracle.price(MODE_WEETH));\n }\n\n function testPrintMpoPricesMode() public fork(MODE_MAINNET) {\n emit log_named_uint(\"weETH price (18 dec)\", mpo.price(MODE_WEETH));\n }\n}\n" + }, + "contracts/test/OraclesDecimalsScalingTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract OraclesDecimalsScalingTest is BaseTest {\n MasterPriceOracle mpo;\n PoolDirectory poolDirectory;\n address stable;\n\n function afterForkSetUp() internal override {\n mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n poolDirectory = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n stable = ap.getAddress(\"stableToken\");\n }\n\n function testOracleDecimalsBsc() public fork(BSC_MAINNET) {\n testOraclesDecimals();\n }\n\n function testOracleDecimalsArbitrum() public fork(ARBITRUM_ONE) {\n testOraclesDecimals();\n }\n\n function testOracleDecimalsPolygon() public fork(POLYGON_MAINNET) {\n testOraclesDecimals();\n }\n\n function testOracleDecimalsNeon() public fork(NEON_MAINNET) {\n vm.mockCall(stable, abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector), abi.encode(6));\n // SOL\n vm.mockCall(\n 0x5f38248f339Bf4e84A2caf4e4c0552862dC9F82a,\n abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector),\n abi.encode(9)\n );\n testOraclesDecimals();\n }\n\n function testOraclesDecimals() internal {\n if (address(poolDirectory) != address(0)) {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n address underlying = markets[j].underlying();\n\n if (isSkipped(underlying)) {\n emit log(\"the oracle for this underlying cannot be tested\");\n emit log_address(underlying);\n continue;\n }\n\n uint256 oraclePrice = mpo.price(underlying);\n uint256 scaledPrice = mpo.getUnderlyingPrice(markets[j]);\n\n uint8 decimals = IERC20MetadataUpgradeable(underlying).decimals();\n uint256 expectedScaledPrice = decimals <= 18\n ? uint256(oraclePrice) * (10**(18 - decimals))\n : uint256(oraclePrice) / (10**(decimals - 18));\n\n assertEq(scaledPrice, expectedScaledPrice, \"the comptroller expects prices to be scaled by 1e(36-decimals)\");\n }\n }\n }\n }\n\n function isSkipped(address token) internal pure returns (bool) {\n return token == 0x5f38248f339Bf4e84A2caf4e4c0552862dC9F82a; // SOL on neon, failing for unknwon reasons, works in HH\n }\n}\n" + }, + "contracts/test/performanceFee/ERC4626PerformanceFee.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity ^0.8.0;\n\n// import { BaseTest } from \"../config/BaseTest.t.sol\";\n\n// import { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n// import { IBeefyVault, BeefyERC4626, IonicERC4626 } from \"../../ionic/strategies/BeefyERC4626.sol\";\n// import { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\n// import { PoolDirectory } from \"../../PoolDirectory.sol\";\n// import { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\n// import { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n// import { IERC4626 } from \"../../compound/IERC4626.sol\";\n\n// import { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\n// contract ERC4626PerformanceFeeTest is BaseTest {\n// using FixedPointMathLib for uint256;\n\n// uint256 PERFORMANCE_FEE = 5e16;\n// uint256 DEPOSIT_AMOUNT = 100e18;\n// uint256 BPS_DENOMINATOR = 10_000;\n\n// BeefyERC4626 plugin;\n// ERC20Upgradeable underlyingToken;\n// IBeefyVault beefyVault = IBeefyVault(0x94E85B8E050F3F281CB9597cc0144F1F7AF1fe9B); // BOMB-BTCB LP\n// address beefyStrategy = 0xEeBcd7E1f008C52fe5804B306832B7DD317e163D;\n// address lpChef = 0x1083926054069AaD75d7238E9B809b0eF9d94e5B;\n// address newFeeRecipient = address(5);\n\n// function afterForkSetUp() internal override {\n// if (block.chainid == BSC_MAINNET) {\n// underlyingToken = ERC20Upgradeable(address(beefyVault.want()));\n// plugin = new BeefyERC4626();\n// plugin.initialize(underlyingToken, beefyVault, 10);\n\n// uint256 currentPerformanceFee = plugin.performanceFee();\n// plugin.updateFeeSettings(currentPerformanceFee, newFeeRecipient);\n// }\n// }\n\n// /* --------------------- HELPER FUNCTIONS --------------------- */\n\n// function deposit(address _owner, uint256 amount) public {\n// vm.startPrank(_owner);\n// underlyingToken.approve(address(plugin), amount);\n// plugin.deposit(amount, _owner);\n// vm.stopPrank();\n// }\n\n// function increaseAssetsInVault() public {\n// deal(address(underlyingToken), address(beefyVault), 1000e18);\n// beefyVault.earn();\n// }\n\n// function createPerformanceFee() public {\n// deal(address(underlyingToken), address(this), DEPOSIT_AMOUNT);\n\n// deposit(address(this), DEPOSIT_AMOUNT);\n\n// increaseAssetsInVault();\n// }\n\n// /* --------------------- ERC4626 PERFORMANCE FEE TESTS --------------------- */\n\n// function test__initializedValues() public fork(BSC_MAINNET) {\n// assertEq(plugin.performanceFee(), PERFORMANCE_FEE, \"!perFee\");\n// assertEq(plugin.feeRecipient(), newFeeRecipient, \"!feeRecipient\");\n// }\n\n// function test__UpdateFeeSettings() public fork(BSC_MAINNET) {\n// uint256 newPerfFee = 100;\n// address anotherFeeRecipient = address(10);\n\n// plugin.updateFeeSettings(newPerfFee, anotherFeeRecipient);\n\n// assertEq(plugin.performanceFee(), newPerfFee, \"!perfFee == newPerfFee\");\n\n// assertEq(plugin.feeRecipient(), anotherFeeRecipient, \"!feeRecipient == anotherFeeRecipient\");\n// }\n\n// function testRevert__UpdateFeeSettings() public fork(BSC_MAINNET) {\n// vm.startPrank(address(10));\n// vm.expectRevert(\"Ownable: caller is not the owner\");\n// plugin.updateFeeSettings(100, address(10));\n// }\n\n// function test__TakePerformanceFeeInUnderlyingAsset() public fork(BSC_MAINNET) {\n// createPerformanceFee();\n\n// uint256 oldAssets = plugin.totalAssets();\n// uint256 oldSupply = plugin.totalSupply();\n\n// uint256 accruedPerformanceFee = (oldAssets - DEPOSIT_AMOUNT).mulDivDown(PERFORMANCE_FEE, 1e18);\n// // I had to change this from -1 on the current block to -2 in the pinned block. Not a 100% sure why there is this difference in returned assets from beefy\n// uint256 expectedFeeShares = accruedPerformanceFee.mulDivDown(oldSupply, (oldAssets - accruedPerformanceFee)) - 2;\n\n// plugin.takePerformanceFee();\n\n// assertApproxEqAbs(\n// plugin.totalSupply() - oldSupply,\n// expectedFeeShares,\n// uint256(10),\n// \"totalSupply increase didnt match expectedFeeShares\"\n// );\n// assertApproxEqAbs(plugin.balanceOf(plugin.feeRecipient()), expectedFeeShares, uint256(10), \"!feeRecipient shares\");\n// assertEq(plugin.totalAssets(), oldAssets, \"totalAssets should not change\");\n// }\n\n// function test__WithdrawAccruedFees() public fork(BSC_MAINNET) {\n// plugin.updateFeeSettings(PERFORMANCE_FEE, address(10));\n\n// createPerformanceFee();\n\n// uint256 oldAssets = plugin.totalAssets();\n// uint256 oldSupply = plugin.totalSupply();\n\n// uint256 accruedPerformanceFee = (oldAssets - DEPOSIT_AMOUNT).mulDivDown(PERFORMANCE_FEE, 1e18);\n// // I had to change this from -1 on the current block to -2 in the pinned block. Not a 100% sure why there is this difference in returned assets from beefy\n// uint256 expectedFeeShares = accruedPerformanceFee.mulDivDown(oldSupply, (oldAssets - accruedPerformanceFee)) - 2;\n\n// plugin.takePerformanceFee();\n\n// assertApproxEqAbs(\n// plugin.totalSupply() - oldSupply,\n// expectedFeeShares,\n// uint256(10),\n// \"totalSupply increase didnt match expectedFeeShares\"\n// );\n// assertApproxEqAbs(plugin.balanceOf(plugin.feeRecipient()), expectedFeeShares, uint256(10), \"!feeShares minted\");\n\n// plugin.withdrawAccruedFees();\n\n// assertEq(plugin.balanceOf(plugin.feeRecipient()), 0, \"!feeRecipient plugin bal == 0\");\n// assertEq(plugin.totalSupply(), oldSupply, \"!totalSupply == oldSupply\");\n// }\n\n// function testRevert__WithdrawAccruedFees() public fork(BSC_MAINNET) {\n// vm.startPrank(address(10));\n// vm.expectRevert(\"Ownable: caller is not the owner\");\n// plugin.withdrawAccruedFees();\n// }\n\n// function testPolygonAllPluginsFeeRecipient() public debuggingOnly fork(POLYGON_MAINNET) {\n// _testAllPluginsFeeRecipient();\n// }\n\n// function testBscAllPluginsFeeRecipient() public debuggingOnly fork(BSC_MAINNET) {\n// _testAllPluginsFeeRecipient();\n// }\n\n// function testArbitrumAllPluginsFeeRecipient() public debuggingOnly fork(ARBITRUM_ONE) {\n// _testAllPluginsFeeRecipient();\n// }\n\n// function _testAllPluginsFeeRecipient() internal {\n// PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n// (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n// for (uint8 i = 0; i < pools.length; i++) {\n// IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n// ICErc20[] memory markets = comptroller.getAllMarkets();\n// for (uint8 j = 0; j < markets.length; j++) {\n// CErc20PluginDelegate delegate = CErc20PluginDelegate(address(markets[j]));\n\n// try delegate.plugin() returns (IERC4626 _plugin) {\n// IonicERC4626 plugin = IonicERC4626(address(_plugin));\n\n// address fr = plugin.feeRecipient();\n// if (fr != ap.getAddress(\"deployer\")) emit log_named_address(\"plugin fr\", address(plugin));\n// assertEq(fr, ap.getAddress(\"deployer\"), \"fee recipient not correct\");\n// } catch {\n// continue;\n// }\n// }\n// }\n// }\n// }\n" + }, + "contracts/test/performanceFee/FlywheelPerformanceFee.t.sol": { + "content": "// // SPDX-License-Identifier: UNLICENSED\n// pragma solidity ^0.8.0;\n\n// import { BaseTest } from \"../config/BaseTest.t.sol\";\n\n// import { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n// import { IonicERC4626, DotDotLpERC4626, ILpDepositor } from \"../../ionic/strategies/DotDotLpERC4626.sol\";\n// import { ERC20 } from \"solmate/tokens/ERC20.sol\";\n// import { IonicFlywheelCore } from \"../../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n// import { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\n// import { PoolDirectory } from \"../../PoolDirectory.sol\";\n\n// import { FlywheelCore, IFlywheelRewards } from \"flywheel-v2/FlywheelCore.sol\";\n// import { FuseFlywheelDynamicRewards } from \"fuse-flywheel/rewards/FuseFlywheelDynamicRewards.sol\";\n// import { IFlywheelBooster } from \"flywheel-v2/interfaces/IFlywheelBooster.sol\";\n// import { Authority } from \"solmate/auth/Auth.sol\";\n\n// import { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n// import { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\n// struct RewardsCycle {\n// uint32 start;\n// uint32 end;\n// uint192 reward;\n// }\n\n// contract FlywheelPerformanceFeeTest is BaseTest {\n// using FixedPointMathLib for uint256;\n\n// uint256 PERFORMANCE_FEE = 10e16;\n// uint256 DEPOSIT_AMOUNT = 100e18;\n// uint256 BPS_DENOMINATOR = 10_000;\n\n// address feeRecipient = address(16);\n// IonicERC4626 plugin;\n// ERC20Upgradeable underlyingToken = ERC20Upgradeable(0x1B6E11c5DB9B15DE87714eA9934a6c52371CfEA9);\n\n// address whale = 0x0BC3a8239B0a63E945Ea1bd6722Ba747b9557e56;\n\n// ILpDepositor lpDepositor = ILpDepositor(0x8189F0afdBf8fE6a9e13c69bA35528ac6abeB1af);\n// ERC20 depositShare = ERC20(0xEFF5b0E496dC7C26fFaA014cEa0d2Baa83DB11c4);\n\n// ERC20 dddToken = ERC20(0x84c97300a190676a19D1E13115629A11f8482Bd1);\n// address flywheelOwner = address(1338);\n// IonicFlywheelCore dddFlywheel;\n// FuseFlywheelDynamicRewards dddRewards;\n\n// ERC20 epxToken = ERC20(0xAf41054C1487b0e5E2B9250C0332eCBCe6CE9d71);\n// IonicFlywheelCore epxFlywheel;\n\n// uint256 rewardAmount = 1000e18;\n// ERC20 marketKey;\n// address marketAddress;\n\n// ERC20Upgradeable[] rewardsToken;\n\n// function afterForkSetUp() internal override {\n// vm.startPrank(flywheelOwner);\n// IonicFlywheelCore impl = new IonicFlywheelCore();\n// TransparentUpgradeableProxy proxyDdd = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n// dddFlywheel = IonicFlywheelCore(address(proxyDdd));\n// dddFlywheel.initialize(dddToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), flywheelOwner);\n// dddRewards = new FuseFlywheelDynamicRewards(FlywheelCore(address(dddFlywheel)), 1);\n// dddFlywheel.setFlywheelRewards(dddRewards);\n\n// TransparentUpgradeableProxy proxyEpx = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n// epxFlywheel = IonicFlywheelCore(address(proxyEpx));\n// epxFlywheel.initialize(epxToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n\n// ERC20 dddFlywheelRewardToken = FlywheelCore(address(dddFlywheel)).rewardToken();\n// rewardsToken.push(ERC20Upgradeable(address(dddFlywheelRewardToken)));\n// ERC20 epxFlywheelRewardToken = FlywheelCore(address(epxFlywheel)).rewardToken();\n// rewardsToken.push(ERC20Upgradeable(address(epxFlywheelRewardToken)));\n\n// DotDotLpERC4626 dotDotLpERC4626 = new DotDotLpERC4626();\n// dotDotLpERC4626.initialize(\n// underlyingToken,\n// FlywheelCore(address(dddFlywheel)),\n// FlywheelCore(address(epxFlywheel)),\n// ILpDepositor(address(lpDepositor)),\n// address(flywheelOwner),\n// rewardsToken\n// );\n\n// plugin = dotDotLpERC4626;\n// marketAddress = address(plugin);\n// marketKey = ERC20(address(plugin));\n\n// dddFlywheel.addStrategyForRewards(marketKey);\n// DotDotLpERC4626(address(plugin)).setRewardDestination(marketAddress);\n// vm.stopPrank();\n\n// vm.prank(marketAddress);\n// dddToken.approve(address(dddRewards), type(uint256).max);\n// }\n\n// /* --------------------- HELPER FUNCTIONS --------------------- */\n\n// function deposit(address _owner, uint256 amount) internal {\n// vm.startPrank(_owner);\n// underlyingToken.approve(address(plugin), amount);\n// plugin.deposit(amount, _owner);\n// vm.stopPrank();\n// }\n\n// function createPerformanceFee() internal {\n// deal(address(underlyingToken), address(this), DEPOSIT_AMOUNT);\n\n// deposit(address(this), DEPOSIT_AMOUNT);\n\n// // Create rewards\n// deal(address(dddToken), marketAddress, rewardAmount);\n\n// dddFlywheel.accrue(marketKey, address(this));\n\n// vm.warp(block.timestamp + 150);\n// vm.roll(10);\n\n// dddFlywheel.accrue(marketKey, address(this));\n// }\n\n// /* --------------------- FLYWHEEL PERFORMANCE FEE TESTS --------------------- */\n\n// function test__initializedValues() public fork(BSC_MAINNET) {\n// assertEq(dddFlywheel.performanceFee(), PERFORMANCE_FEE, \"!perFee\");\n// assertEq(dddFlywheel.feeRecipient(), flywheelOwner, \"!feeRecipient\");\n// }\n\n// function test__UpdateFeeSettings() public fork(BSC_MAINNET) {\n// uint256 newPerfFee = 100;\n// address newFeeRecipient = feeRecipient;\n\n// vm.prank(flywheelOwner);\n// dddFlywheel.updateFeeSettings(newPerfFee, newFeeRecipient);\n\n// assertEq(dddFlywheel.performanceFee(), newPerfFee, \"!perfFee == newPerfFee\");\n// assertEq(dddFlywheel.feeRecipient(), newFeeRecipient, \"!feeRecipient == newFeeRecipient\");\n// }\n\n// function testRevert__UpdateFeeSettings() public fork(BSC_MAINNET) {\n// vm.prank(feeRecipient);\n// vm.expectRevert(\"Ownable: caller is not the owner\");\n// dddFlywheel.updateFeeSettings(100, feeRecipient);\n// }\n\n// function test__TakePerformanceFeeInUnderlyingAsset() public fork(BSC_MAINNET) {\n// createPerformanceFee();\n\n// uint256 expectedPerformanceFee = (rewardAmount * dddFlywheel.performanceFee()) / 1e18;\n\n// assertEq(\n// dddFlywheel.rewardsAccrued(dddFlywheel.feeRecipient()),\n// expectedPerformanceFee,\n// \"rewards accrued of the feeRecipient dont match expectedPerformanceFee\"\n// );\n// // Proxy call for checking the global rewards accrued. (address(this) is the only depositor so they should receive all other rewards)\n// assertEq(\n// dddFlywheel.rewardsAccrued(address(this)),\n// rewardAmount - expectedPerformanceFee,\n// \"the rewardsState gets updated correctly\"\n// );\n// }\n\n// function test__WithdrawAccruedFees() public fork(BSC_MAINNET) {\n// vm.prank(flywheelOwner);\n// dddFlywheel.updateFeeSettings(PERFORMANCE_FEE, feeRecipient);\n\n// createPerformanceFee();\n\n// uint256 expectedPerformanceFee = (rewardAmount * dddFlywheel.performanceFee()) / 1e18;\n\n// dddFlywheel.claimRewards(feeRecipient);\n\n// assertEq(dddToken.balanceOf(feeRecipient), expectedPerformanceFee, \"feeRecipient didnt receive their fees\");\n// assertEq(\n// dddToken.balanceOf(address(dddRewards)),\n// rewardAmount - expectedPerformanceFee,\n// \"the rewardsModule didnt properly send the fees\"\n// );\n// assertEq(dddFlywheel.rewardsAccrued(feeRecipient), 0, \"feeRecipient rewardsAccrued should be 0\");\n// }\n\n// function testPolygonAllFlywheelsFeeRecipient() public debuggingOnly fork(POLYGON_MAINNET) {\n// _testAllFlywheelsFeeRecipient();\n// }\n\n// function testBscAllFlywheelsFeeRecipient() public debuggingOnly fork(BSC_MAINNET) {\n// _testAllFlywheelsFeeRecipient();\n// }\n\n// function testArbitrumAllFlywheelsFeeRecipient() public debuggingOnly fork(ARBITRUM_ONE) {\n// _testAllFlywheelsFeeRecipient();\n// }\n\n// function _testAllFlywheelsFeeRecipient() internal {\n// PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n// (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n// for (uint8 i = 0; i < pools.length; i++) {\n// ComptrollerFirstExtension poolExt = ComptrollerFirstExtension(pools[i].comptroller);\n// address[] memory fws = poolExt.getRewardsDistributors();\n// for (uint256 j = 0; j < fws.length; j++) {\n// address fr = IonicFlywheelCore(fws[j]).feeRecipient();\n// if (fr != ap.getAddress(\"deployer\")) emit log_named_address(\"flywheel fr\", fws[j]);\n// assertEq(fr, ap.getAddress(\"deployer\"), \"fee recipient not correct\");\n// }\n// }\n// }\n// }\n" + }, + "contracts/test/PermissionedLiquidationsMarketTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ILiquidator } from \"../ILiquidator.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../liquidators/IFundsConversionStrategy.sol\";\n\ncontract PermissionedLiquidationsMarketTest is MarketsTest {\n ICErc20 wethMarket;\n ICErc20 usdtMarket;\n\n ICErc20 wethNativeMarket;\n ICErc20 usdcNativeMarket;\n ICErc20 usdtNativeMarket;\n ICErc20 modeNativeMarket;\n\n IonicComptroller pool;\n PoolLens lens;\n address borrower;\n address liquidator;\n IonicUniV3Liquidator uniV3liquidator;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n\n wethNativeMarket = ICErc20(0xDb8eE6D1114021A94A045956BBeeCF35d13a30F2);\n usdcNativeMarket = ICErc20(0xc53edEafb6D502DAEC5A7015D67936CEa0cD0F52);\n usdtNativeMarket = ICErc20(0x3120B4907851cc9D780eef9aF88ae4d5360175Fd);\n modeNativeMarket = ICErc20(0x4341620757Bee7EB4553912FaFC963e59C949147);\n\n pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n borrower = 0xcE6cEFa163468F730206688665516952bcf83B74;\n liquidator = 0xE000008459b74a91e306a47C808061DFA372000E;\n uniV3liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n vm.prank(ap.owner());\n ap.setAddress(\"PoolLens\", address(lens));\n }\n\n function testLiquidateNoThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateThresholdActive() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n vm.expectRevert(\"Health factor not low enough for non-permissioned liquidations\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n vm.stopPrank();\n }\n\n function testLiquidateHealthFactorLowerThanThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n // fast forward until position unhealthy enough\n vm.roll(block.number + 10000000);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPythShouldRevert() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPyth() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.mockCall(\n address(uniV3liquidator.expressRelay()),\n abi.encodeWithSelector(\n bytes4(keccak256(\"isPermissioned(address,bytes)\")),\n address(uniV3liquidator),\n abi.encode(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6)\n ),\n abi.encode(false)\n );\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testPostUpgradeLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0xE10B38bbe359656066b3c4648DfEa7018711c35f;\n PoolLens.PoolAsset[] memory assets = lens.getPoolAssetsByUser(pool, borrower);\n\n for (uint i; i < assets.length; i++) {\n emit log_named_string(\"Asset Named\", assets[i].underlyingName);\n emit log_named_uint(\"Supply Balance\", assets[i].supplyBalance);\n emit log_named_uint(\"Borrow Balance\", assets[i].borrowBalance);\n emit log_named_uint(\"Liquidity\", assets[i].liquidity);\n emit log(\"----------------------------------------------------\");\n }\n\n emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n\n // vm.startPrank(0x344d9C4f488bb5519D390304457D64034618145C);\n\n // ERC20(0xd988097fb8612cc24eeC14542bC03424c656005f).approve(address(uniV3liquidator), 4000);\n\n // // ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n // // borrower: borrower,\n // // repayAmount: 4000,\n // // cErc20: ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n // // cTokenCollateral: wethMarket,\n // // flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n // // minProfitAmount: 0,\n // // redemptionStrategies: new IRedemptionStrategy[](0),\n // // strategyData: new bytes[](0),\n // // debtFundingStrategies: new IFundsConversionStrategy[](0),\n // // debtFundingStrategiesData: new bytes[](0)\n // // });\n // // uniV3liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n\n // uniV3liquidator.safeLiquidate(borrower, 4000, ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038), wethMarket, 0);\n\n // vm.stopPrank();\n\n // emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n }\n\n function testUpgradeNativeMarket() public debuggingOnly fork(MODE_MAINNET) {\n _upgradeMarket(wethNativeMarket);\n _upgradeMarket(usdcNativeMarket);\n _upgradeMarket(usdtNativeMarket);\n _upgradeMarket(modeNativeMarket);\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n }\n\n struct CErc20StorageStruct {\n address ionicAdmin;\n string name;\n string symbol;\n uint8 decimals;\n address comptroller;\n address interestRateModel;\n uint256 adminFeeMantissa;\n uint256 ionicFeeMantissa;\n uint256 reserveFactorMantissa;\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalAdminFees;\n uint256 totalIonicFees;\n uint256 totalSupply;\n uint256 protocolSeizeShareMantissa;\n uint256 feeSeizeShareMantissa;\n address underlying;\n address ap;\n uint256 cash;\n uint256 totalBorrowsCurrent;\n uint256 balanceOfUnderlying;\n uint256 borrowBalanceCurrent;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 exchangeRateCurrent;\n uint256 totalUnderlyingSupplied;\n uint256 allowance;\n uint256 balanceOf;\n }\n\n function testStorageLayoutSafe() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n // Capture storage layout before upgrade\n CErc20StorageStruct memory storageDataBefore;\n CErc20StorageStruct memory storageDataAfter;\n\n address owner = 0xbF86588d7e20502f1b250561da775343Dfdb3250; // Use a valid spender address as needed\n\n storageDataBefore.ionicAdmin = wethMarket.ionicAdmin();\n storageDataBefore.name = wethMarket.name();\n storageDataBefore.symbol = wethMarket.symbol();\n storageDataBefore.decimals = wethMarket.decimals();\n storageDataBefore.comptroller = address(wethMarket.comptroller());\n storageDataBefore.interestRateModel = address(wethMarket.interestRateModel());\n storageDataBefore.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataBefore.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataBefore.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataBefore.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataBefore.borrowIndex = wethMarket.borrowIndex();\n storageDataBefore.totalBorrows = wethMarket.totalBorrows();\n storageDataBefore.totalReserves = wethMarket.totalReserves();\n storageDataBefore.totalAdminFees = wethMarket.totalAdminFees();\n storageDataBefore.totalIonicFees = wethMarket.totalIonicFees();\n storageDataBefore.totalSupply = wethMarket.totalSupply();\n storageDataBefore.underlying = wethMarket.underlying();\n storageDataBefore.cash = wethMarket.getCash();\n storageDataBefore.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataBefore.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataBefore.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataBefore.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataBefore.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataBefore.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataBefore.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataBefore.balanceOf = wethMarket.balanceOf(owner);\n storageDataBefore.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataBefore.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n // Upgrade the market\n _upgradeMarket(wethMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n storageDataAfter.ionicAdmin = wethMarket.ionicAdmin();\n storageDataAfter.name = wethMarket.name();\n storageDataAfter.symbol = wethMarket.symbol();\n storageDataAfter.decimals = wethMarket.decimals();\n storageDataAfter.comptroller = address(wethMarket.comptroller());\n storageDataAfter.interestRateModel = address(wethMarket.interestRateModel());\n storageDataAfter.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataAfter.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataAfter.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataAfter.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataAfter.borrowIndex = wethMarket.borrowIndex();\n storageDataAfter.totalBorrows = wethMarket.totalBorrows();\n storageDataAfter.totalReserves = wethMarket.totalReserves();\n storageDataAfter.totalAdminFees = wethMarket.totalAdminFees();\n storageDataAfter.totalIonicFees = wethMarket.totalIonicFees();\n storageDataAfter.totalSupply = wethMarket.totalSupply();\n storageDataAfter.underlying = wethMarket.underlying();\n storageDataAfter.cash = wethMarket.getCash();\n storageDataAfter.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataAfter.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataAfter.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataAfter.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataAfter.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataAfter.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataAfter.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataAfter.balanceOf = wethMarket.balanceOf(owner);\n storageDataAfter.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataAfter.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n emit log_named_address(\"Storage ionicAdmin (before)\", storageDataBefore.ionicAdmin);\n emit log_named_address(\"Storage ionicAdmin (after)\", storageDataAfter.ionicAdmin);\n\n emit log_named_string(\"Storage name (before)\", storageDataBefore.name);\n emit log_named_string(\"Storage name (after)\", storageDataAfter.name);\n\n emit log_named_string(\"Storage symbol (before)\", storageDataBefore.symbol);\n emit log_named_string(\"Storage symbol (after)\", storageDataAfter.symbol);\n\n emit log_named_uint(\"Storage decimals (before)\", storageDataBefore.decimals);\n emit log_named_uint(\"Storage decimals (after)\", storageDataAfter.decimals);\n\n emit log_named_address(\"Storage comptroller (before)\", storageDataBefore.comptroller);\n emit log_named_address(\"Storage comptroller (after)\", storageDataAfter.comptroller);\n\n emit log_named_address(\"Storage interestRateModel (before)\", storageDataBefore.interestRateModel);\n emit log_named_address(\"Storage interestRateModel (after)\", storageDataAfter.interestRateModel);\n\n emit log_named_uint(\"Storage adminFeeMantissa (before)\", storageDataBefore.adminFeeMantissa);\n emit log_named_uint(\"Storage adminFeeMantissa (after)\", storageDataAfter.adminFeeMantissa);\n\n emit log_named_uint(\"Storage ionicFeeMantissa (before)\", storageDataBefore.ionicFeeMantissa);\n emit log_named_uint(\"Storage ionicFeeMantissa (after)\", storageDataAfter.ionicFeeMantissa);\n\n emit log_named_uint(\"Storage reserveFactorMantissa (before)\", storageDataBefore.reserveFactorMantissa);\n emit log_named_uint(\"Storage reserveFactorMantissa (after)\", storageDataAfter.reserveFactorMantissa);\n\n emit log_named_uint(\"Storage accrualBlockNumber (before)\", storageDataBefore.accrualBlockNumber);\n emit log_named_uint(\"Storage accrualBlockNumber (after)\", storageDataAfter.accrualBlockNumber);\n\n emit log_named_uint(\"Storage borrowIndex (before)\", storageDataBefore.borrowIndex);\n emit log_named_uint(\"Storage borrowIndex (after)\", storageDataAfter.borrowIndex);\n\n emit log_named_uint(\"Storage totalBorrows (before)\", storageDataBefore.totalBorrows);\n emit log_named_uint(\"Storage totalBorrows (after)\", storageDataAfter.totalBorrows);\n\n emit log_named_uint(\"Storage totalReserves (before)\", storageDataBefore.totalReserves);\n emit log_named_uint(\"Storage totalReserves (after)\", storageDataAfter.totalReserves);\n\n emit log_named_uint(\"Storage totalAdminFees (before)\", storageDataBefore.totalAdminFees);\n emit log_named_uint(\"Storage totalAdminFees (after)\", storageDataAfter.totalAdminFees);\n\n emit log_named_uint(\"Storage totalIonicFees (before)\", storageDataBefore.totalIonicFees);\n emit log_named_uint(\"Storage totalIonicFees (after)\", storageDataAfter.totalIonicFees);\n\n emit log_named_uint(\"Storage totalSupply (before)\", storageDataBefore.totalSupply);\n emit log_named_uint(\"Storage totalSupply (after)\", storageDataAfter.totalSupply);\n\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (before)\", storageDataBefore.protocolSeizeShareMantissa);\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (after)\", storageDataAfter.protocolSeizeShareMantissa);\n\n emit log_named_uint(\"Storage feeSeizeShareMantissa (before)\", storageDataBefore.feeSeizeShareMantissa);\n emit log_named_uint(\"Storage feeSeizeShareMantissa (after)\", storageDataAfter.feeSeizeShareMantissa);\n\n emit log_named_address(\"Storage underlying (before)\", storageDataBefore.underlying);\n emit log_named_address(\"Storage underlying (after)\", storageDataAfter.underlying);\n\n emit log_named_uint(\"Storage cash (before)\", storageDataBefore.cash);\n emit log_named_uint(\"Storage cash (after)\", storageDataAfter.cash);\n\n emit log_named_uint(\"Storage totalBorrowsCurrent (before)\", storageDataBefore.totalBorrowsCurrent);\n emit log_named_uint(\"Storage totalBorrowsCurrent (after)\", storageDataAfter.totalBorrowsCurrent);\n\n emit log_named_uint(\"Storage balanceOfUnderlying (before)\", storageDataBefore.balanceOfUnderlying);\n emit log_named_uint(\"Storage balanceOfUnderlying (after)\", storageDataAfter.balanceOfUnderlying);\n\n emit log_named_uint(\"Storage borrowBalanceCurrent (before)\", storageDataBefore.borrowBalanceCurrent);\n emit log_named_uint(\"Storage borrowBalanceCurrent (after)\", storageDataAfter.borrowBalanceCurrent);\n\n emit log_named_uint(\"Storage supplyRatePerBlock (before)\", storageDataBefore.supplyRatePerBlock);\n emit log_named_uint(\"Storage supplyRatePerBlock (after)\", storageDataAfter.supplyRatePerBlock);\n\n emit log_named_uint(\"Storage borrowRatePerBlock (before)\", storageDataBefore.borrowRatePerBlock);\n emit log_named_uint(\"Storage borrowRatePerBlock (after)\", storageDataAfter.borrowRatePerBlock);\n\n emit log_named_uint(\"Storage exchangeRateCurrent (before)\", storageDataBefore.exchangeRateCurrent);\n emit log_named_uint(\"Storage exchangeRateCurrent (after)\", storageDataAfter.exchangeRateCurrent);\n\n emit log_named_uint(\"Storage totalUnderlyingSupplied (before)\", storageDataBefore.totalUnderlyingSupplied);\n emit log_named_uint(\"Storage totalUnderlyingSupplied (after)\", storageDataAfter.totalUnderlyingSupplied);\n\n emit log_named_uint(\"Storage allowance (before)\", storageDataBefore.allowance);\n emit log_named_uint(\"Storage allowance (after)\", storageDataAfter.allowance);\n\n emit log_named_uint(\"Storage balanceOf (before)\", storageDataBefore.balanceOf);\n emit log_named_uint(\"Storage balanceOf (after)\", storageDataAfter.balanceOf);\n\n emit log_named_address(\"Storage ap (before)\", storageDataBefore.ap);\n emit log_named_address(\"Storage ap (after)\", storageDataAfter.ap);\n\n assertEq(storageDataBefore.ionicAdmin, storageDataAfter.ionicAdmin, \"Mismatch in ionicAdmin\");\n assertEq(storageDataBefore.name, storageDataAfter.name, \"Mismatch in name\");\n assertEq(storageDataBefore.symbol, storageDataAfter.symbol, \"Mismatch in symbol\");\n assertEq(storageDataBefore.decimals, storageDataAfter.decimals, \"Mismatch in decimals\");\n assertEq(storageDataBefore.comptroller, storageDataAfter.comptroller, \"Mismatch in comptroller\");\n assertEq(storageDataBefore.interestRateModel, storageDataAfter.interestRateModel, \"Mismatch in interestRateModel\");\n assertEq(storageDataBefore.adminFeeMantissa, storageDataAfter.adminFeeMantissa, \"Mismatch in adminFeeMantissa\");\n assertEq(storageDataBefore.ionicFeeMantissa, storageDataAfter.ionicFeeMantissa, \"Mismatch in ionicFeeMantissa\");\n assertEq(\n storageDataBefore.reserveFactorMantissa,\n storageDataAfter.reserveFactorMantissa,\n \"Mismatch in reserveFactorMantissa\"\n );\n assertEq(\n storageDataBefore.accrualBlockNumber,\n storageDataAfter.accrualBlockNumber,\n \"Mismatch in accrualBlockNumber\"\n );\n assertEq(storageDataBefore.borrowIndex, storageDataAfter.borrowIndex, \"Mismatch in borrowIndex\");\n assertEq(storageDataBefore.totalBorrows, storageDataAfter.totalBorrows, \"Mismatch in totalBorrows\");\n assertEq(storageDataBefore.totalReserves, storageDataAfter.totalReserves, \"Mismatch in totalReserves\");\n assertEq(storageDataBefore.totalAdminFees, storageDataAfter.totalAdminFees, \"Mismatch in totalAdminFees\");\n assertEq(storageDataBefore.totalIonicFees, storageDataAfter.totalIonicFees, \"Mismatch in totalIonicFees\");\n assertEq(storageDataBefore.totalSupply, storageDataAfter.totalSupply, \"Mismatch in totalSupply\");\n assertEq(storageDataBefore.underlying, storageDataAfter.underlying, \"Mismatch in underlying\");\n assertEq(storageDataBefore.cash, storageDataAfter.cash, \"Mismatch in cash\");\n assertEq(\n storageDataBefore.totalBorrowsCurrent,\n storageDataAfter.totalBorrowsCurrent,\n \"Mismatch in totalBorrowsCurrent\"\n );\n assertEq(\n storageDataBefore.balanceOfUnderlying,\n storageDataAfter.balanceOfUnderlying,\n \"Mismatch in balanceOfUnderlying\"\n );\n assertEq(\n storageDataBefore.borrowBalanceCurrent,\n storageDataAfter.borrowBalanceCurrent,\n \"Mismatch in borrowBalanceCurrent\"\n );\n assertEq(\n storageDataBefore.supplyRatePerBlock,\n storageDataAfter.supplyRatePerBlock,\n \"Mismatch in supplyRatePerBlock\"\n );\n assertEq(\n storageDataBefore.borrowRatePerBlock,\n storageDataAfter.borrowRatePerBlock,\n \"Mismatch in borrowRatePerBlock\"\n );\n assertEq(\n storageDataBefore.exchangeRateCurrent,\n storageDataAfter.exchangeRateCurrent,\n \"Mismatch in exchangeRateCurrent\"\n );\n assertEq(\n storageDataBefore.totalUnderlyingSupplied,\n storageDataAfter.totalUnderlyingSupplied,\n \"Mismatch in totalUnderlyingSupplied\"\n );\n assertEq(storageDataBefore.balanceOf, storageDataAfter.balanceOf, \"Mismatch in balanceOf\");\n assertEq(\n storageDataBefore.protocolSeizeShareMantissa,\n storageDataAfter.protocolSeizeShareMantissa,\n \"Mismatch in protocolSeizeShareMantissa\"\n );\n assertEq(\n storageDataBefore.feeSeizeShareMantissa,\n storageDataAfter.feeSeizeShareMantissa,\n \"Mismatch in feeSeizeShareMantissa\"\n );\n }\n\n function testCurrentMarkets() public debuggingOnly forkAtBlock(MODE_MAINNET, 10785800) {\n address[] memory ionAddresses = new address[](10);\n\n _upgradeMarket(wethMarket);\n\n ionAddresses[0] = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n ionAddresses[1] = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n ionAddresses[2] = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n ionAddresses[3] = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n ionAddresses[4] = 0x59e710215d45F584f44c0FEe83DA6d43D762D857;\n ionAddresses[5] = 0x959FA710CCBb22c7Ce1e59Da82A247e686629310;\n ionAddresses[6] = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ionAddresses[7] = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18;\n ionAddresses[8] = 0x9a9072302B775FfBd3Db79a7766E75Cf82bcaC0A;\n ionAddresses[9] = 0x19F245782b1258cf3e11Eda25784A378cC18c108;\n\n address ap;\n for (uint i = 0; i < ionAddresses.length; i++) {\n // ap = address(CTokenFirstExtension(ionAddresses[i]).ap());\n ap = address(CTokenFirstExtension(address(wethMarket)).ap());\n emit log_named_address(\"ap\", ap);\n }\n }\n}\n" + }, + "contracts/test/PoolCapsAndBlacklistsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./config/MarketsTest.t.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract PoolCapsAndBlacklistsTest is MarketsTest {\n Comptroller pool;\n ComptrollerFirstExtension asExtension;\n address borrower = 0x28C0208b7144B511C73586Bb07dE2100495e92f3; // ANKR account\n address otherSupplier = 0x2924973E3366690eA7aE3FCdcb2b4e136Cf7f8Cc; // Supplier of ankrBNBAnkrMkt\n ICErc20 ankrBNBAnkrMkt = ICErc20(0x71693C84486B37096192c9942852f542543639Bf);\n ICErc20 ankrBNBMkt = ICErc20(0xb2b01D6f953A28ba6C8f9E22986f5bDDb7653aEa);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n // ankr pool\n pool = Comptroller(payable(0x1851e32F34565cb95754310b031C5a2Fc0a8a905));\n asExtension = ComptrollerFirstExtension(address(pool));\n _upgradeExistingPool(address(pool));\n\n _upgradeMarket(ankrBNBMkt);\n _upgradeMarket(ankrBNBAnkrMkt);\n\n // just some logging\n {\n uint256 borrowedAnkr = ankrBNBMkt.borrowBalanceCurrent(borrower);\n emit log_named_uint(\"ankrBnb borrow balance\", borrowedAnkr);\n uint256 collateralAnkr = ankrBNBAnkrMkt.balanceOf(borrower);\n emit log_named_uint(\"ankrBnb collateral balance of ankrBNB-ANKR\", collateralAnkr);\n\n uint256 borrowedOther = ankrBNBMkt.borrowBalanceCurrent(otherSupplier);\n emit log_named_uint(\"Other supplier borrower balance\", borrowedOther);\n uint256 collateralOther = ankrBNBAnkrMkt.balanceOf(otherSupplier);\n emit log_named_uint(\"Other supplier collateral balance of ankrBNB-ANKR\", collateralOther);\n\n emit log(\"\");\n emit log(\"Before collateral caps\");\n {\n (, , uint256 liq, uint256 sf) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 before setting BC\", liq); // 1366119859198693075092\n emit log_named_uint(\"Shortfall for account 1 before setting BC\", sf); // 0\n emit log(\"\");\n (, , uint256 liq1, uint256 sf1) = pool.getAccountLiquidity(otherSupplier);\n emit log_named_uint(\"Liq for account 2 before setting BC\", liq1); // 24108891649595017\n emit log_named_uint(\"Shortfall for account 2 before setting BC\", sf1); // 0\n\n assertGt(liq, 0, \"expected positive liquidity\");\n assertGt(liq1, 0, \"expected positive liquidity\");\n emit log(\"\");\n }\n }\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapForCollateralWhitelist() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n emit log(\"\");\n emit log(\"Borrow Caps Set\");\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), 1);\n (, , uint256 liqAfter, uint256 sfAfter) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 after setting BC\", liqAfter);\n emit log_named_uint(\"Shortfall for account 1 after setting BC\", sfAfter);\n (, , uint256 liq1After, uint256 sf1After) = pool.getAccountLiquidity(otherSupplier);\n emit log(\"\");\n emit log_named_uint(\"Liq for account 2 after setting BC\", liq1After);\n emit log_named_uint(\"Shortfall for account 2 after setting BC\", sf1After);\n emit log(\"\");\n\n assertGt(sfAfter, 0, \"expected some shortfall for ankr\");\n assertEq(liq1After, 24108891649595017, \"expected liquidity for account 2 to decrease\");\n }\n\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateralWhitelist(address(ankrBNBMkt), address(ankrBNBAnkrMkt), borrower, true);\n\n emit log(\"\");\n (, , uint256 liqAfterWl, uint256 sfAfterWl) = pool.getAccountLiquidity(borrower);\n (, , uint256 liq1AfterWl, uint256 sf1AfterWl) = pool.getAccountLiquidity(otherSupplier);\n assertEq(sfAfterWl, 0, \"expected shortfall to go back to 0\");\n assertEq(liqAfterWl, 1366119859198693075092, \"expected liq to go back to original\");\n\n // expect liq for second (not whitelisted) account to stay reduced\n assertEq(liq1AfterWl, 24108891649595017, \"expected liq to go back to prev value\");\n }\n }\n\n function testBlacklistBorrowingAgainstCollateralWhitelist() public debuggingOnly fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), true);\n\n (, , uint256 liquidityAfterBlacklist, uint256 shortFallAfterBlacklist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertGt(liquidityBefore - liquidityAfterBlacklist, 0, \"should have lower liquidity after bl\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateralWhitelist(\n address(ankrBNBMkt),\n address(ankrBNBAnkrMkt),\n borrower,\n true\n );\n\n (, , uint256 liquidityAfterWhitelist, uint256 shortFallWhitelist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallWhitelist, shortFallBefore, \"should have the same sf after wl\");\n assertEq(liquidityAfterWhitelist, liquidityBefore, \"should have the same liquidity after wl\");\n }\n\n function testSupplyCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.startPrank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n asExtension._setMintPaused(ankrBNBMkt, false);\n asExtension._setMintPaused(ankrBNBAnkrMkt, false);\n vm.stopPrank();\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!supply cap\");\n pool.mintAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.mintAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"mint not allowed after cap whitelist\");\n }\n\n function testBorrowCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketBorrowCaps(markets, asArray(1, 1));\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!borrow:cap\");\n pool.borrowAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._borrowCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.borrowAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"borrow not allowed after cap whitelist\");\n }\n\n function testSupplyCapValue() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, 0, \"should have no liquidity after\");\n assertGt(shortFallAfterCap, 0, \"should have positive shortfall after\");\n }\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[0]), borrower, true);\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[1]), borrower, true);\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, liquidityBefore, \"liquidity after whitelist should match before\");\n assertEq(shortFallAfterCap, shortFallBefore, \"shortfall after whitelist should match before\");\n }\n }\n}\n" + }, + "contracts/test/PoolDirectoryTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract PoolDirectoryTest is BaseTest {\n PoolDirectory fpd;\n\n function afterForkSetUp() internal override {\n address fpdAddress = ap.getAddress(\"PoolDirectory\");\n fpd = PoolDirectory(fpdAddress);\n\n // upgrade to the current changes impl\n {\n PoolDirectory newImpl = new PoolDirectory();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(fpdAddress));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n }\n\n function testDeprecatePool() public fork(BSC_MAINNET) {\n _testDeprecatePool();\n }\n\n function _testDeprecatePool() internal {\n PoolDirectory.Pool[] memory allPools = fpd.getAllPools();\n\n PoolDirectory.Pool memory poolToDeprecate;\n\n // BOMB pool https://app.midascapital.xyz/56/pool/0\n uint256 index = 0;\n\n poolToDeprecate = allPools[index];\n\n vm.prank(fpd.owner());\n fpd._deprecatePool(index);\n\n (, PoolDirectory.Pool[] memory allPoolsAfter) = fpd.getActivePools();\n\n bool poolStillThere = false;\n for (uint256 i = 0; i < allPoolsAfter.length; i++) {\n if (allPoolsAfter[i].comptroller == poolToDeprecate.comptroller) {\n poolStillThere = true;\n break;\n }\n }\n\n assertTrue(!poolStillThere, \"deprecated pool is still there\");\n }\n}\n" + }, + "contracts/test/PoolLensTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./config/BaseTest.t.sol\";\n\nimport { PoolLens } from \"../PoolLens.sol\";\nimport \"../compound/ComptrollerInterface.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\n\ncontract PoolLensTest is BaseTest {\n function testPolygonFPL() public debuggingOnly fork(POLYGON_MAINNET) {\n PoolLens fpl = PoolLens(0xD7225110D8F419b0E8Ad0A536977965E62fB5769);\n fpl.getPoolAssetsWithData(IonicComptroller(0xB08A309eFBFFa41f36A06b2D0C9a4629749b17a2));\n }\n\n function testModeFPL() public debuggingOnly fork(MODE_MAINNET) {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLens fpl = PoolLens(0x611a68618412c2e15A36e3e59C0b979746d87AB8);\n PoolLens.PoolAsset[] memory datas = fpl.getPoolAssetsWithData(pool);\n\n emit log_named_uint(\"ionicFee\", datas[0].ionicFee);\n emit log_named_uint(\"adminFee\", datas[0].adminFee);\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; i++) {\n uint256 totalUnderlyingSupplied = markets[i].getTotalUnderlyingSupplied();\n uint256 totalBorrows = markets[i].totalBorrows();\n uint256 totalReserves = markets[i].totalReserves();\n uint256 cash = markets[i].getCash();\n\n emit log(\"\");\n emit log(markets[i].symbol());\n emit log_named_uint(\"totalUnderlyingSupplied\", totalUnderlyingSupplied);\n emit log_named_uint(\"totalBorrows\", totalBorrows);\n emit log_named_uint(\"totalReserves\", totalReserves);\n emit log_named_uint(\"cash\", cash);\n emit log_named_uint(\"reserves + fees\", cash + totalBorrows - totalUnderlyingSupplied);\n\n JumpRateModel irm = JumpRateModel(markets[i].interestRateModel());\n\n emit log_named_uint(\"blocksPerYear\", irm.blocksPerYear());\n\n emit log_named_uint(\n \"borrow rate per year\",\n irm.blocksPerYear() * irm.getBorrowRate(cash, totalBorrows, totalReserves)\n );\n emit log_named_uint(\n \"supply rate per year\",\n irm.blocksPerYear() * irm.getSupplyRate(cash, totalBorrows, totalReserves, 0.1e18)\n );\n }\n }\n\n function testWhitelistsFPL() public debuggingOnly fork(BSC_CHAPEL) {\n PoolLens fpl = PoolLens(0x604805B587C939042120D2e22398f299547A130c);\n fpl.getSupplyCapsDataForPool(IonicComptroller(0x307BEc9d1368A459E9168fa6296C1e69025ab30f));\n }\n}\n" + }, + "contracts/test/ProtocolAdminTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract ProtocolAdminTest is BaseTest {\n address public expectedAdmin;\n\n function afterForkSetUp() internal virtual override {}\n\n function _checkIfAdmin(address addr, string memory contractName) internal {\n emit log(\"\");\n emit log(contractName);\n assertEq(addr, expectedAdmin, \"not the same admin address\");\n }\n\n function _checkSafeOwnableAdmin(string memory contractName) internal {\n SafeOwnableUpgradeable ownable = SafeOwnableUpgradeable(ap.getAddress(contractName));\n if (address(ownable) != address(0)) {\n _checkIfAdmin(ownable.owner(), contractName);\n }\n }\n\n function _checkOwnableAdmin(string memory contractName) internal {\n Ownable ownable = Ownable(ap.getAddress(contractName));\n if (address(ownable) != address(0)) {\n _checkIfAdmin(ownable.owner(), contractName);\n }\n }\n\n function testModeProtocolAdmin() public debuggingOnly fork(MODE_MAINNET) {\n expectedAdmin = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2; // gnosis safe multisig contract\n _testProtocolAdmin();\n }\n\n function _testProtocolAdmin() internal {\n //expectedAdmin = ap.owner();\n // safe ownable\n _checkSafeOwnableAdmin(\"FeeDistributor\");\n _checkSafeOwnableAdmin(\"PoolDirectory\");\n _checkSafeOwnableAdmin(\"OptimizedVaultsRegistry\");\n _checkSafeOwnableAdmin(\"AnkrCertificateTokenPriceOracle\");\n _checkSafeOwnableAdmin(\"BalancerLpLinearPoolPriceOracle\");\n _checkSafeOwnableAdmin(\"BalancerLpStablePoolPriceOracle\");\n _checkSafeOwnableAdmin(\"BalancerLpTokenPriceOracle\");\n _checkSafeOwnableAdmin(\"BalancerLpTokenPriceOracleNTokens\");\n _checkSafeOwnableAdmin(\"BalancerRateProviderOracle\");\n _checkSafeOwnableAdmin(\"BNBxPriceOracle\");\n _checkSafeOwnableAdmin(\"CurveLpTokenPriceOracleNoRegistry\");\n _checkSafeOwnableAdmin(\"CurveV2LpTokenPriceOracleNoRegistry\");\n _checkSafeOwnableAdmin(\"CurveV2PriceOracle\");\n _checkSafeOwnableAdmin(\"ERC4626Oracle\");\n _checkSafeOwnableAdmin(\"GammaPoolUniswapV3PriceOracle\");\n _checkSafeOwnableAdmin(\"GammaPoolAlgebraPriceOracle\");\n _checkSafeOwnableAdmin(\"PythPriceOracle\");\n _checkSafeOwnableAdmin(\"SimplePriceOracle\");\n _checkSafeOwnableAdmin(\"SolidlyPriceOracle\");\n _checkSafeOwnableAdmin(\"StkBNBPriceOracle\");\n _checkSafeOwnableAdmin(\"WSTEthPriceOracle\");\n _checkSafeOwnableAdmin(\"NativeUSDPriceOracle\");\n\n // ownable 2 step\n _checkSafeOwnableAdmin(\"LiquidatorsRegistry\");\n _checkSafeOwnableAdmin(\"LeveredPositionFactory\");\n _checkSafeOwnableAdmin(\"OptimizedAPRVault\");\n\n _checkOwnableAdmin(\"DefaultProxyAdmin\");\n _checkOwnableAdmin(\"DiaPriceOracle\");\n _checkOwnableAdmin(\"PoolDirectory\");\n\n assertEq(MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")).admin(), expectedAdmin, \"mpo admin incorrect\");\n\n // check all the pool admins and the flywheels owners\n PoolDirectory poolDir = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n PoolDirectory.Pool[] memory pools = poolDir.getAllPools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n assertEq(pool.admin(), expectedAdmin, \"pool admin does not match\");\n\n address[] memory flywheels = pool.getRewardsDistributors();\n for (uint256 j = 0; j < flywheels.length; j++) {\n assertEq(Ownable(flywheels[j]).owner(), expectedAdmin, \"flywheel owner not the admin\");\n }\n }\n }\n}\n" + }, + "contracts/test/SafeOwnableUpgradeableTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract SomeOwnable is SafeOwnableUpgradeable {\n function initialize() public initializer {\n __SafeOwnable_init(msg.sender);\n }\n}\n\ncontract SafeOwnableUpgradeableTest is BaseTest {\n function testSafeOwnableUpgradeable() public {\n SomeOwnable someOwnable = new SomeOwnable();\n // deploy as a proxy/implementation\n {\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(someOwnable),\n address(dpa),\n abi.encodeWithSelector(someOwnable.initialize.selector)\n );\n someOwnable = SomeOwnable(address(proxy));\n }\n\n address joe = address(1234);\n\n address initOwner = someOwnable.owner();\n assertEq(initOwner, address(this), \"owner init value\");\n\n someOwnable._setPendingOwner(joe);\n\n address currentOwner = someOwnable.owner();\n assertEq(currentOwner, address(this), \"owner should not change yet\");\n\n vm.prank(joe);\n someOwnable._acceptOwner();\n\n address ownerAfter = someOwnable.owner();\n\n assertEq(ownerAfter, joe, \"ownership transfer failed\");\n }\n}\n" + }, + "contracts/test/UpgradesBaseTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../compound/CErc20RewardsDelegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nabstract contract UpgradesBaseTest is BaseTest {\n FeeDistributor internal ffd;\n ComptrollerFirstExtension internal poolExt;\n CTokenFirstExtension internal marketExt;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n poolExt = new ComptrollerFirstExtension();\n marketExt = new CTokenFirstExtension();\n }\n\n function _upgradePoolWithExtension(Unitroller asUnitroller) internal {\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n // instantiate the new implementation\n Comptroller newComptrollerImplementation = new Comptroller();\n vm.startPrank(ffd.owner());\n address comptrollerImplementationAddress = address(newComptrollerImplementation);\n ffd._setLatestComptrollerImplementation(address(0), comptrollerImplementationAddress);\n // add the extension to the auto upgrade config\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = poolExt;\n extensions[1] = newComptrollerImplementation;\n ffd._setComptrollerExtensions(comptrollerImplementationAddress, extensions);\n vm.stopPrank();\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n DiamondExtension(comptrollerImplementationAddress),\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function _upgradeMarketWithExtension(ICErc20 market) internal {\n // instantiate the new implementation\n CErc20Delegate newImpl;\n bytes memory becomeImplData = \"\";\n if (compareStrings(\"CErc20Delegate\", market.contractType())) {\n newImpl = new CErc20Delegate();\n } else if (compareStrings(\"CErc20PluginDelegate\", market.contractType())) {\n newImpl = new CErc20PluginDelegate();\n becomeImplData = abi.encode(address(0));\n } else if (compareStrings(\"CErc20RewardsDelegate\", market.contractType())) {\n newImpl = new CErc20RewardsDelegate();\n becomeImplData = abi.encode(address(0));\n } else {\n newImpl = new CErc20PluginRewardsDelegate();\n becomeImplData = abi.encode(address(0));\n }\n\n // set the new delegate as the latest\n vm.startPrank(ffd.owner());\n ffd._setLatestCErc20Delegate(newImpl.delegateType(), address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = marketExt;\n cErc20DelegateExtensions[1] = newImpl;\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n vm.stopPrank();\n\n vm.stopPrank();\n // upgrade to the new delegate\n vm.prank(address(ffd));\n market._setImplementationSafe(address(newImpl), becomeImplData);\n }\n}\n" + }, + "contracts/utils/IMulticall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Multicall interface\n/// @notice Enables calling multiple methods in a single call to the contract\ninterface IMulticall {\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n /// @param data The encoded function data for each of the calls to make to this contract\n /// @return results The results from each of the calls passed in via data\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n}\n" + }, + "contracts/utils/IW_NATIVE.sol": { + "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity >=0.8.0;\n\ninterface IW_NATIVE {\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n function balanceOf(address) external view returns (uint256);\n}\n" + }, + "contracts/utils/Multicall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./IMulticall.sol\";\n\n/// @title Multicall\n/// @notice Enables calling multiple methods in a single call to the contract\nabstract contract Multicall is IMulticall {\n /// @inheritdoc IMulticall\n function multicall(bytes[] calldata data) public payable virtual override returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n if (!success) {\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n if (result.length < 68) revert();\n assembly {\n result := add(result, 0x04)\n }\n revert(abi.decode(result, (string)));\n }\n\n results[i] = result;\n }\n }\n}\n" + }, + "contracts/utils/TOUCHToken.sol": { + "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: UNLICENSED\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract TOUCHToken is ERC20 {\n constructor(uint256 initialSupply, address tokenOwner) ERC20(\"Midas TOUCH Token\", \"TOUCH\", 18) {\n _mint(tokenOwner, initialSupply);\n }\n}\n" + }, + "contracts/utils/TRIBEToken.sol": { + "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: UNLICENSED\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract TRIBEToken is ERC20 {\n constructor(uint256 initialSupply, address tokenOwner) ERC20(\"TRIBE Governance Token\", \"TRIBE\", 18) {\n _mint(tokenOwner, initialSupply);\n }\n}\n" + }, + "ds-test/test.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.5.0;\n\ncontract DSTest {\n event log (string);\n event logs (bytes);\n\n event log_address (address);\n event log_bytes32 (bytes32);\n event log_int (int);\n event log_uint (uint);\n event log_bytes (bytes);\n event log_string (string);\n\n event log_named_address (string key, address val);\n event log_named_bytes32 (string key, bytes32 val);\n event log_named_decimal_int (string key, int val, uint decimals);\n event log_named_decimal_uint (string key, uint val, uint decimals);\n event log_named_int (string key, int val);\n event log_named_uint (string key, uint val);\n event log_named_bytes (string key, bytes val);\n event log_named_string (string key, string val);\n\n bool public IS_TEST = true;\n bool private _failed;\n\n address constant HEVM_ADDRESS =\n address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));\n\n modifier mayRevert() { _; }\n modifier testopts(string memory) { _; }\n\n function failed() public returns (bool) {\n if (_failed) {\n return _failed;\n } else {\n bool globalFailed = false;\n if (hasHEVMContext()) {\n (, bytes memory retdata) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"load(address,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"))\n )\n );\n globalFailed = abi.decode(retdata, (bool));\n }\n return globalFailed;\n }\n }\n\n function fail() internal virtual {\n if (hasHEVMContext()) {\n (bool status, ) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"store(address,bytes32,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"), bytes32(uint256(0x01)))\n )\n );\n status; // Silence compiler warnings\n }\n _failed = true;\n }\n\n function hasHEVMContext() internal view returns (bool) {\n uint256 hevmCodeSize = 0;\n assembly {\n hevmCodeSize := extcodesize(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D)\n }\n return hevmCodeSize > 0;\n }\n\n modifier logs_gas() {\n uint startGas = gasleft();\n _;\n uint endGas = gasleft();\n emit log_named_uint(\"gas\", startGas - endGas);\n }\n\n function assertTrue(bool condition) internal {\n if (!condition) {\n emit log(\"Error: Assertion Failed\");\n fail();\n }\n }\n\n function assertTrue(bool condition, string memory err) internal {\n if (!condition) {\n emit log_named_string(\"Error\", err);\n assertTrue(condition);\n }\n }\n\n function assertEq(address a, address b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [address]\");\n emit log_named_address(\" Left\", a);\n emit log_named_address(\" Right\", b);\n fail();\n }\n }\n function assertEq(address a, address b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes32 a, bytes32 b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bytes32]\");\n emit log_named_bytes32(\" Left\", a);\n emit log_named_bytes32(\" Right\", b);\n fail();\n }\n }\n function assertEq(bytes32 a, bytes32 b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq32(bytes32 a, bytes32 b) internal {\n assertEq(a, b);\n }\n function assertEq32(bytes32 a, bytes32 b, string memory err) internal {\n assertEq(a, b, err);\n }\n\n function assertEq(int a, int b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n fail();\n }\n }\n function assertEq(int a, int b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq(uint a, uint b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n fail();\n }\n }\n function assertEq(uint a, uint b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEqDecimal(int a, int b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n\n function assertGt(uint a, uint b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGt(uint a, uint b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGt(int a, int b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGt(int a, int b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGtDecimal(int a, int b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n\n function assertGe(uint a, uint b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGe(uint a, uint b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGe(int a, int b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGe(int a, int b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGeDecimal(int a, int b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n\n function assertLt(uint a, uint b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLt(uint a, uint b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLt(int a, int b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLt(int a, int b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLtDecimal(int a, int b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n\n function assertLe(uint a, uint b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLe(uint a, uint b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLe(int a, int b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLe(int a, int b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLeDecimal(int a, int b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n\n function assertEq(string memory a, string memory b) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log(\"Error: a == b not satisfied [string]\");\n emit log_named_string(\" Left\", a);\n emit log_named_string(\" Right\", b);\n fail();\n }\n }\n function assertEq(string memory a, string memory b, string memory err) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function checkEq0(bytes memory a, bytes memory b) internal pure returns (bool ok) {\n ok = true;\n if (a.length == b.length) {\n for (uint i = 0; i < a.length; i++) {\n if (a[i] != b[i]) {\n ok = false;\n }\n }\n } else {\n ok = false;\n }\n }\n function assertEq0(bytes memory a, bytes memory b) internal {\n if (!checkEq0(a, b)) {\n emit log(\"Error: a == b not satisfied [bytes]\");\n emit log_named_bytes(\" Left\", a);\n emit log_named_bytes(\" Right\", b);\n fail();\n }\n }\n function assertEq0(bytes memory a, bytes memory b, string memory err) internal {\n if (!checkEq0(a, b)) {\n emit log_named_string(\"Error\", err);\n assertEq0(a, b);\n }\n }\n}\n" + }, + "forge-std/Base.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {StdStorage} from \"./StdStorage.sol\";\nimport {Vm, VmSafe} from \"./Vm.sol\";\n\nabstract contract CommonBase {\n // Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.\n address internal constant VM_ADDRESS = address(uint160(uint256(keccak256(\"hevm cheat code\"))));\n // console.sol and console2.sol work by executing a staticcall to this address.\n address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;\n // Default address for tx.origin and msg.sender, 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38.\n address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256(\"foundry default caller\"))));\n // Address of the test contract, deployed by the DEFAULT_SENDER.\n address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;\n // Deterministic deployment address of the Multicall3 contract.\n address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;\n\n uint256 internal constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n Vm internal constant vm = Vm(VM_ADDRESS);\n StdStorage internal stdstore;\n}\n\nabstract contract TestBase is CommonBase {}\n\nabstract contract ScriptBase is CommonBase {\n // Used when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);\n}\n" + }, + "forge-std/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n }\n\n function logUint(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n }\n\n function log(uint p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n }\n\n function log(uint p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n }\n\n function log(uint p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n }\n\n function log(string memory p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/console2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\n/// @dev The original console.sol uses `int` and `uint` for computing function selectors, but it should\n/// use `int256` and `uint256`. This modified version fixes that. This version is recommended\n/// over `console.sol` if you don't need compatibility with Hardhat as the logs will show up in\n/// forge stack traces. If you do need compatibility with Hardhat, you must use `console.sol`.\n/// Reference: https://github.com/NomicFoundation/hardhat/issues/2178\nlibrary console2 {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, int256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,int256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/interfaces/IMulticall3.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ninterface IMulticall3 {\n struct Call {\n address target;\n bytes callData;\n }\n\n struct Call3 {\n address target;\n bool allowFailure;\n bytes callData;\n }\n\n struct Call3Value {\n address target;\n bool allowFailure;\n uint256 value;\n bytes callData;\n }\n\n struct Result {\n bool success;\n bytes returnData;\n }\n\n function aggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes[] memory returnData);\n\n function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);\n\n function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);\n\n function blockAndAggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n\n function getBasefee() external view returns (uint256 basefee);\n\n function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);\n\n function getBlockNumber() external view returns (uint256 blockNumber);\n\n function getChainId() external view returns (uint256 chainid);\n\n function getCurrentBlockCoinbase() external view returns (address coinbase);\n\n function getCurrentBlockDifficulty() external view returns (uint256 difficulty);\n\n function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);\n\n function getCurrentBlockTimestamp() external view returns (uint256 timestamp);\n\n function getEthBalance(address addr) external view returns (uint256 balance);\n\n function getLastBlockHash() external view returns (bytes32 blockHash);\n\n function tryAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (Result[] memory returnData);\n\n function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n}\n" + }, + "forge-std/StdAssertions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {DSTest} from \"ds-test/test.sol\";\nimport {stdMath} from \"./StdMath.sol\";\n\nabstract contract StdAssertions is DSTest {\n event log_array(uint256[] val);\n event log_array(int256[] val);\n event log_array(address[] val);\n event log_named_array(string key, uint256[] val);\n event log_named_array(string key, int256[] val);\n event log_named_array(string key, address[] val);\n\n function fail(string memory err) internal virtual {\n emit log_named_string(\"Error\", err);\n fail();\n }\n\n function assertFalse(bool data) internal virtual {\n assertTrue(!data);\n }\n\n function assertFalse(bool data, string memory err) internal virtual {\n assertTrue(!data, err);\n }\n\n function assertEq(bool a, bool b) internal virtual {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bool]\");\n emit log_named_string(\" Left\", a ? \"true\" : \"false\");\n emit log_named_string(\" Right\", b ? \"true\" : \"false\");\n fail();\n }\n }\n\n function assertEq(bool a, bool b, string memory err) internal virtual {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes memory a, bytes memory b) internal virtual {\n assertEq0(a, b);\n }\n\n function assertEq(bytes memory a, bytes memory b, string memory err) internal virtual {\n assertEq0(a, b, err);\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [uint[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [int[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(address[] memory a, address[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [address[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(address[] memory a, address[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n // Legacy helper\n function assertEqUint(uint256 a, uint256 b) internal virtual {\n assertEq(uint256(a), uint256(b));\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100%\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals,\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta, string memory err) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual {\n assertEqCall(target, callDataA, target, callDataB, true);\n }\n\n function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)\n internal\n virtual\n {\n assertEqCall(targetA, callDataA, targetB, callDataB, true);\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)\n internal\n virtual\n {\n assertEqCall(target, callDataA, target, callDataB, strictRevertData);\n }\n\n function assertEqCall(\n address targetA,\n bytes memory callDataA,\n address targetB,\n bytes memory callDataB,\n bool strictRevertData\n ) internal virtual {\n (bool successA, bytes memory returnDataA) = address(targetA).call(callDataA);\n (bool successB, bytes memory returnDataB) = address(targetB).call(callDataB);\n\n if (successA && successB) {\n assertEq(returnDataA, returnDataB, \"Call return data does not match\");\n }\n\n if (!successA && !successB && strictRevertData) {\n assertEq(returnDataA, returnDataB, \"Call revert data does not match\");\n }\n\n if (!successA && successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call revert data\", returnDataA);\n emit log_named_bytes(\" Right call return data\", returnDataB);\n fail();\n }\n\n if (successA && !successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call return data\", returnDataA);\n emit log_named_bytes(\" Right call revert data\", returnDataB);\n fail();\n }\n }\n}\n" + }, + "forge-std/StdChains.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n/**\n * StdChains provides information about EVM compatible chains that can be used in scripts/tests.\n * For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are\n * identified by their alias, which is the same as the alias in the `[rpc_endpoints]` section of\n * the `foundry.toml` file. For best UX, ensure the alias in the `foundry.toml` file match the\n * alias used in this contract, which can be found as the first argument to the\n * `setChainWithDefaultRpcUrl` call in the `initialize` function.\n *\n * There are two main ways to use this contract:\n * 1. Set a chain with `setChain(string memory chainAlias, ChainData memory chain)` or\n * `setChain(string memory chainAlias, Chain memory chain)`\n * 2. Get a chain with `getChain(string memory chainAlias)` or `getChain(uint256 chainId)`.\n *\n * The first time either of those are used, chains are initialized with the default set of RPC URLs.\n * This is done in `initialize`, which uses `setChainWithDefaultRpcUrl`. Defaults are recorded in\n * `defaultRpcUrls`.\n *\n * The `setChain` function is straightforward, and it simply saves off the given chain data.\n *\n * The `getChain` methods use `getChainWithUpdatedRpcUrl` to return a chain. For example, let's say\n * we want to retrieve `mainnet`'s RPC URL:\n * - If you haven't set any mainnet chain info with `setChain`, you haven't specified that\n * chain in `foundry.toml` and no env var is set, the default data and RPC URL will be returned.\n * - If you have set a mainnet RPC URL in `foundry.toml` it will return that, if valid (e.g. if\n * a URL is given or if an environment variable is given and that environment variable exists).\n * Otherwise, the default data is returned.\n * - If you specified data with `setChain` it will return that.\n *\n * Summarizing the above, the prioritization hierarchy is `setChain` -> `foundry.toml` -> environment variable -> defaults.\n */\nabstract contract StdChains {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private initialized;\n\n struct ChainData {\n string name;\n uint256 chainId;\n string rpcUrl;\n }\n\n struct Chain {\n // The chain name.\n string name;\n // The chain's Chain ID.\n uint256 chainId;\n // The chain's alias. (i.e. what gets specified in `foundry.toml`).\n string chainAlias;\n // A default RPC endpoint for this chain.\n // NOTE: This default RPC URL is included for convenience to facilitate quick tests and\n // experimentation. Do not use this RPC URL for production test suites, CI, or other heavy\n // usage as you will be throttled and this is a disservice to others who need this endpoint.\n string rpcUrl;\n }\n\n // Maps from the chain's alias (matching the alias in the `foundry.toml` file) to chain data.\n mapping(string => Chain) private chains;\n // Maps from the chain's alias to it's default RPC URL.\n mapping(string => string) private defaultRpcUrls;\n // Maps from a chain ID to it's alias.\n mapping(uint256 => string) private idToAlias;\n\n bool private fallbackToDefaultRpcUrls = true;\n\n // The RPC URL will be fetched from config or defaultRpcUrls if possible.\n function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {\n require(bytes(chainAlias).length != 0, \"StdChains getChain(string): Chain alias cannot be the empty string.\");\n\n initialize();\n chain = chains[chainAlias];\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(string): Chain with alias \\\"\", chainAlias, \"\\\" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {\n require(chainId != 0, \"StdChains getChain(uint256): Chain ID cannot be 0.\");\n initialize();\n string memory chainAlias = idToAlias[chainId];\n\n chain = chains[chainAlias];\n\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(uint256): Chain with ID \", vm.toString(chainId), \" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, ChainData memory chain) internal virtual {\n require(\n bytes(chainAlias).length != 0,\n \"StdChains setChain(string,ChainData): Chain alias cannot be the empty string.\"\n );\n\n require(chain.chainId != 0, \"StdChains setChain(string,ChainData): Chain ID cannot be 0.\");\n\n initialize();\n string memory foundAlias = idToAlias[chain.chainId];\n\n require(\n bytes(foundAlias).length == 0 || keccak256(bytes(foundAlias)) == keccak256(bytes(chainAlias)),\n string(\n abi.encodePacked(\n \"StdChains setChain(string,ChainData): Chain ID \",\n vm.toString(chain.chainId),\n \" already used by \\\"\",\n foundAlias,\n \"\\\".\"\n )\n )\n );\n\n uint256 oldChainId = chains[chainAlias].chainId;\n delete idToAlias[oldChainId];\n\n chains[chainAlias] =\n Chain({name: chain.name, chainId: chain.chainId, chainAlias: chainAlias, rpcUrl: chain.rpcUrl});\n idToAlias[chain.chainId] = chainAlias;\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, Chain memory chain) internal virtual {\n setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));\n }\n\n function _toUpper(string memory str) private pure returns (string memory) {\n bytes memory strb = bytes(str);\n bytes memory copy = new bytes(strb.length);\n for (uint256 i = 0; i < strb.length; i++) {\n bytes1 b = strb[i];\n if (b >= 0x61 && b <= 0x7A) {\n copy[i] = bytes1(uint8(b) - 32);\n } else {\n copy[i] = b;\n }\n }\n return string(copy);\n }\n\n // lookup rpcUrl, in descending order of priority:\n // current -> config (foundry.toml) -> environment variable -> default\n function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private returns (Chain memory) {\n if (bytes(chain.rpcUrl).length == 0) {\n try vm.rpcUrl(chainAlias) returns (string memory configRpcUrl) {\n chain.rpcUrl = configRpcUrl;\n } catch (bytes memory err) {\n string memory envName = string(abi.encodePacked(_toUpper(chainAlias), \"_RPC_URL\"));\n if (fallbackToDefaultRpcUrls) {\n chain.rpcUrl = vm.envOr(envName, defaultRpcUrls[chainAlias]);\n } else {\n chain.rpcUrl = vm.envString(envName);\n }\n // distinguish 'not found' from 'cannot read'\n bytes memory notFoundError =\n abi.encodeWithSignature(\"CheatCodeError\", string(abi.encodePacked(\"invalid rpc url \", chainAlias)));\n if (keccak256(notFoundError) != keccak256(err) || bytes(chain.rpcUrl).length == 0) {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, err), mload(err))\n }\n }\n }\n }\n return chain;\n }\n\n function setFallbackToDefaultRpcUrls(bool useDefault) internal {\n fallbackToDefaultRpcUrls = useDefault;\n }\n\n function initialize() private {\n if (initialized) return;\n\n initialized = true;\n\n // If adding an RPC here, make sure to test the default RPC URL in `testRpcs`\n setChainWithDefaultRpcUrl(\"anvil\", ChainData(\"Anvil\", 31337, \"http://127.0.0.1:8545\"));\n setChainWithDefaultRpcUrl(\n \"mainnet\", ChainData(\"Mainnet\", 1, \"https://mainnet.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"goerli\", ChainData(\"Goerli\", 5, \"https://goerli.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"sepolia\", ChainData(\"Sepolia\", 11155111, \"https://sepolia.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\"optimism\", ChainData(\"Optimism\", 10, \"https://mainnet.optimism.io\"));\n setChainWithDefaultRpcUrl(\"optimism_goerli\", ChainData(\"Optimism Goerli\", 420, \"https://goerli.optimism.io\"));\n setChainWithDefaultRpcUrl(\"arbitrum_one\", ChainData(\"Arbitrum One\", 42161, \"https://arb1.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\n \"arbitrum_one_goerli\", ChainData(\"Arbitrum One Goerli\", 421613, \"https://goerli-rollup.arbitrum.io/rpc\")\n );\n setChainWithDefaultRpcUrl(\"arbitrum_nova\", ChainData(\"Arbitrum Nova\", 42170, \"https://nova.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\"polygon\", ChainData(\"Polygon\", 137, \"https://polygon-rpc.com\"));\n setChainWithDefaultRpcUrl(\n \"polygon_mumbai\", ChainData(\"Polygon Mumbai\", 80001, \"https://rpc-mumbai.maticvigil.com\")\n );\n setChainWithDefaultRpcUrl(\"avalanche\", ChainData(\"Avalanche\", 43114, \"https://api.avax.network/ext/bc/C/rpc\"));\n setChainWithDefaultRpcUrl(\n \"avalanche_fuji\", ChainData(\"Avalanche Fuji\", 43113, \"https://api.avax-test.network/ext/bc/C/rpc\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain\", ChainData(\"BNB Smart Chain\", 56, \"https://bsc-dataseed1.binance.org\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain_testnet\",\n ChainData(\"BNB Smart Chain Testnet\", 97, \"https://rpc.ankr.com/bsc_testnet_chapel\")\n );\n setChainWithDefaultRpcUrl(\"gnosis_chain\", ChainData(\"Gnosis Chain\", 100, \"https://rpc.gnosischain.com\"));\n }\n\n // set chain info, with priority to chainAlias' rpc url in foundry.toml\n function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private {\n string memory rpcUrl = chain.rpcUrl;\n defaultRpcUrls[chainAlias] = rpcUrl;\n chain.rpcUrl = \"\";\n setChain(chainAlias, chain);\n chain.rpcUrl = rpcUrl; // restore argument\n }\n}\n" + }, + "forge-std/StdCheats.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {Vm} from \"./Vm.sol\";\n\nabstract contract StdCheatsSafe {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private gasMeteringOff;\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawTx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n // json value name = function\n string functionSig;\n bytes32 hash;\n // json value name = tx\n RawTx1559Detail txDetail;\n // json value name = type\n string opcode;\n }\n\n struct RawTx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n bytes gas;\n bytes nonce;\n address to;\n bytes txType;\n bytes value;\n }\n\n struct Tx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n bytes32 hash;\n Tx1559Detail txDetail;\n string opcode;\n }\n\n struct Tx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n uint256 gas;\n uint256 nonce;\n address to;\n uint256 txType;\n uint256 value;\n }\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that DO NOT conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct TxLegacy {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n string hash;\n string opcode;\n TxDetailLegacy transaction;\n }\n\n struct TxDetailLegacy {\n AccessList[] accessList;\n uint256 chainId;\n bytes data;\n address from;\n uint256 gas;\n uint256 gasPrice;\n bytes32 hash;\n uint256 nonce;\n bytes1 opcode;\n bytes32 r;\n bytes32 s;\n uint256 txType;\n address to;\n uint8 v;\n uint256 value;\n }\n\n struct AccessList {\n address accessAddress;\n bytes32[] storageKeys;\n }\n\n // Data structures to parse Receipt objects from the broadcast artifact.\n // The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawReceipt {\n bytes32 blockHash;\n bytes blockNumber;\n address contractAddress;\n bytes cumulativeGasUsed;\n bytes effectiveGasPrice;\n address from;\n bytes gasUsed;\n RawReceiptLog[] logs;\n bytes logsBloom;\n bytes status;\n address to;\n bytes32 transactionHash;\n bytes transactionIndex;\n }\n\n struct Receipt {\n bytes32 blockHash;\n uint256 blockNumber;\n address contractAddress;\n uint256 cumulativeGasUsed;\n uint256 effectiveGasPrice;\n address from;\n uint256 gasUsed;\n ReceiptLog[] logs;\n bytes logsBloom;\n uint256 status;\n address to;\n bytes32 transactionHash;\n uint256 transactionIndex;\n }\n\n // Data structures to parse the entire broadcast artifact, assuming the\n // transactions conform to EIP1559.\n\n struct EIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n Receipt[] receipts;\n uint256 timestamp;\n Tx1559[] transactions;\n TxReturn[] txReturns;\n }\n\n struct RawEIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n RawReceipt[] receipts;\n TxReturn[] txReturns;\n uint256 timestamp;\n RawTx1559[] transactions;\n }\n\n struct RawReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n bytes blockNumber;\n bytes data;\n bytes logIndex;\n bool removed;\n bytes32[] topics;\n bytes32 transactionHash;\n bytes transactionIndex;\n bytes transactionLogIndex;\n }\n\n struct ReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n uint256 blockNumber;\n bytes data;\n uint256 logIndex;\n bytes32[] topics;\n uint256 transactionIndex;\n uint256 transactionLogIndex;\n bool removed;\n }\n\n struct TxReturn {\n string internalType;\n string value;\n }\n\n function assumeNoPrecompiles(address addr) internal virtual {\n // Assembly required since `block.chainid` was introduced in 0.8.0.\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n assumeNoPrecompiles(addr, chainId);\n }\n\n function assumeNoPrecompiles(address addr, uint256 chainId) internal pure virtual {\n // Note: For some chains like Optimism these are technically predeploys (i.e. bytecode placed at a specific\n // address), but the same rationale for excluding them applies so we include those too.\n\n // These should be present on all EVM-compatible chains.\n vm.assume(addr < address(0x1) || addr > address(0x9));\n\n // forgefmt: disable-start\n if (chainId == 10 || chainId == 420) {\n // https://github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.go#L6-L21\n vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));\n } else if (chainId == 42161 || chainId == 421613) {\n // https://developer.arbitrum.io/useful-addresses#arbitrum-precompiles-l2-same-on-all-arb-chains\n vm.assume(addr < address(0x0000000000000000000000000000000000000064) || addr > address(0x0000000000000000000000000000000000000068));\n } else if (chainId == 43114 || chainId == 43113) {\n // https://github.com/ava-labs/subnet-evm/blob/47c03fd007ecaa6de2c52ea081596e0a88401f58/precompile/params.go#L18-L59\n vm.assume(addr < address(0x0100000000000000000000000000000000000000) || addr > address(0x01000000000000000000000000000000000000ff));\n vm.assume(addr < address(0x0200000000000000000000000000000000000000) || addr > address(0x02000000000000000000000000000000000000FF));\n vm.assume(addr < address(0x0300000000000000000000000000000000000000) || addr > address(0x03000000000000000000000000000000000000Ff));\n }\n // forgefmt: disable-end\n }\n\n function readEIP1559ScriptArtifact(string memory path)\n internal\n view\n virtual\n returns (EIP1559ScriptArtifact memory)\n {\n string memory data = vm.readFile(path);\n bytes memory parsedData = vm.parseJson(data);\n RawEIP1559ScriptArtifact memory rawArtifact = abi.decode(parsedData, (RawEIP1559ScriptArtifact));\n EIP1559ScriptArtifact memory artifact;\n artifact.libraries = rawArtifact.libraries;\n artifact.path = rawArtifact.path;\n artifact.timestamp = rawArtifact.timestamp;\n artifact.pending = rawArtifact.pending;\n artifact.txReturns = rawArtifact.txReturns;\n artifact.receipts = rawToConvertedReceipts(rawArtifact.receipts);\n artifact.transactions = rawToConvertedEIPTx1559s(rawArtifact.transactions);\n return artifact;\n }\n\n function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory) {\n Tx1559[] memory txs = new Tx1559[](rawTxs.length);\n for (uint256 i; i < rawTxs.length; i++) {\n txs[i] = rawToConvertedEIPTx1559(rawTxs[i]);\n }\n return txs;\n }\n\n function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory) {\n Tx1559 memory transaction;\n transaction.arguments = rawTx.arguments;\n transaction.contractName = rawTx.contractName;\n transaction.functionSig = rawTx.functionSig;\n transaction.hash = rawTx.hash;\n transaction.txDetail = rawToConvertedEIP1559Detail(rawTx.txDetail);\n transaction.opcode = rawTx.opcode;\n return transaction;\n }\n\n function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)\n internal\n pure\n virtual\n returns (Tx1559Detail memory)\n {\n Tx1559Detail memory txDetail;\n txDetail.data = rawDetail.data;\n txDetail.from = rawDetail.from;\n txDetail.to = rawDetail.to;\n txDetail.nonce = _bytesToUint(rawDetail.nonce);\n txDetail.txType = _bytesToUint(rawDetail.txType);\n txDetail.value = _bytesToUint(rawDetail.value);\n txDetail.gas = _bytesToUint(rawDetail.gas);\n txDetail.accessList = rawDetail.accessList;\n return txDetail;\n }\n\n function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".transactions\");\n RawTx1559[] memory rawTxs = abi.decode(parsedDeployData, (RawTx1559[]));\n return rawToConvertedEIPTx1559s(rawTxs);\n }\n\n function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".transactions[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawTx1559 memory rawTx = abi.decode(parsedDeployData, (RawTx1559));\n return rawToConvertedEIPTx1559(rawTx);\n }\n\n // Analogous to readTransactions, but for receipts.\n function readReceipts(string memory path) internal view virtual returns (Receipt[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".receipts\");\n RawReceipt[] memory rawReceipts = abi.decode(parsedDeployData, (RawReceipt[]));\n return rawToConvertedReceipts(rawReceipts);\n }\n\n function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".receipts[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawReceipt memory rawReceipt = abi.decode(parsedDeployData, (RawReceipt));\n return rawToConvertedReceipt(rawReceipt);\n }\n\n function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory) {\n Receipt[] memory receipts = new Receipt[](rawReceipts.length);\n for (uint256 i; i < rawReceipts.length; i++) {\n receipts[i] = rawToConvertedReceipt(rawReceipts[i]);\n }\n return receipts;\n }\n\n function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory) {\n Receipt memory receipt;\n receipt.blockHash = rawReceipt.blockHash;\n receipt.to = rawReceipt.to;\n receipt.from = rawReceipt.from;\n receipt.contractAddress = rawReceipt.contractAddress;\n receipt.effectiveGasPrice = _bytesToUint(rawReceipt.effectiveGasPrice);\n receipt.cumulativeGasUsed = _bytesToUint(rawReceipt.cumulativeGasUsed);\n receipt.gasUsed = _bytesToUint(rawReceipt.gasUsed);\n receipt.status = _bytesToUint(rawReceipt.status);\n receipt.transactionIndex = _bytesToUint(rawReceipt.transactionIndex);\n receipt.blockNumber = _bytesToUint(rawReceipt.blockNumber);\n receipt.logs = rawToConvertedReceiptLogs(rawReceipt.logs);\n receipt.logsBloom = rawReceipt.logsBloom;\n receipt.transactionHash = rawReceipt.transactionHash;\n return receipt;\n }\n\n function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)\n internal\n pure\n virtual\n returns (ReceiptLog[] memory)\n {\n ReceiptLog[] memory logs = new ReceiptLog[](rawLogs.length);\n for (uint256 i; i < rawLogs.length; i++) {\n logs[i].logAddress = rawLogs[i].logAddress;\n logs[i].blockHash = rawLogs[i].blockHash;\n logs[i].blockNumber = _bytesToUint(rawLogs[i].blockNumber);\n logs[i].data = rawLogs[i].data;\n logs[i].logIndex = _bytesToUint(rawLogs[i].logIndex);\n logs[i].topics = rawLogs[i].topics;\n logs[i].transactionIndex = _bytesToUint(rawLogs[i].transactionIndex);\n logs[i].transactionLogIndex = _bytesToUint(rawLogs[i].transactionLogIndex);\n logs[i].removed = rawLogs[i].removed;\n }\n return logs;\n }\n\n // Deploy a contract by fetching the contract bytecode from\n // the artifacts directory\n // e.g. `deployCode(code, abi.encode(arg1,arg2,arg3))`\n function deployCode(string memory what, bytes memory args) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes): Deployment failed.\");\n }\n\n function deployCode(string memory what) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string): Deployment failed.\");\n }\n\n /// @dev deploy contract with value on construction\n function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes,uint256): Deployment failed.\");\n }\n\n function deployCode(string memory what, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,uint256): Deployment failed.\");\n }\n\n // creates a labeled address and the corresponding private key\n function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey) {\n privateKey = uint256(keccak256(abi.encodePacked(name)));\n addr = vm.addr(privateKey);\n vm.label(addr, name);\n }\n\n // creates a labeled address\n function makeAddr(string memory name) internal virtual returns (address addr) {\n (addr,) = makeAddrAndKey(name);\n }\n\n function deriveRememberKey(string memory mnemonic, uint32 index)\n internal\n virtual\n returns (address who, uint256 privateKey)\n {\n privateKey = vm.deriveKey(mnemonic, index);\n who = vm.rememberKey(privateKey);\n }\n\n function _bytesToUint(bytes memory b) private pure returns (uint256) {\n require(b.length <= 32, \"StdCheats _bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n function isFork() internal view virtual returns (bool status) {\n try vm.activeFork() {\n status = true;\n } catch (bytes memory) {}\n }\n\n modifier skipWhenForking() {\n if (!isFork()) {\n _;\n }\n }\n\n modifier skipWhenNotForking() {\n if (isFork()) {\n _;\n }\n }\n\n modifier noGasMetering() {\n vm.pauseGasMetering();\n // To prevent turning gas monitoring back on with nested functions that use this modifier,\n // we check if gasMetering started in the off position. If it did, we don't want to turn\n // it back on until we exit the top level function that used the modifier\n //\n // i.e. funcA() noGasMetering { funcB() }, where funcB has noGasMetering as well.\n // funcA will have `gasStartedOff` as false, funcB will have it as true,\n // so we only turn metering back on at the end of the funcA\n bool gasStartedOff = gasMeteringOff;\n gasMeteringOff = true;\n\n _;\n\n // if gas metering was on when this modifier was called, turn it back on at the end\n if (!gasStartedOff) {\n gasMeteringOff = false;\n vm.resumeGasMetering();\n }\n }\n\n // a cheat for fuzzing addresses that are payable only\n // see https://github.com/foundry-rs/foundry/issues/3631\n function assumePayable(address addr) internal virtual {\n (bool success,) = payable(addr).call{value: 0}(\"\");\n vm.assume(success);\n }\n}\n\n// Wrappers around cheatcodes to avoid footguns\nabstract contract StdCheats is StdCheatsSafe {\n using stdStorage for StdStorage;\n\n StdStorage private stdstore;\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n // Skip forward or rewind time by the specified number of seconds\n function skip(uint256 time) internal virtual {\n vm.warp(block.timestamp + time);\n }\n\n function rewind(uint256 time) internal virtual {\n vm.warp(block.timestamp - time);\n }\n\n // Setup a prank from an address that has some ether\n function hoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender, origin);\n }\n\n function hoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender, origin);\n }\n\n // Start perpetual prank from an address that has some ether\n function startHoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender);\n }\n\n function startHoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender);\n }\n\n // Start perpetual prank from an address that has some ether\n // tx.origin is set to the origin parameter\n function startHoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender, origin);\n }\n\n function startHoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender, origin);\n }\n\n function changePrank(address msgSender) internal virtual {\n vm.stopPrank();\n vm.startPrank(msgSender);\n }\n\n // The same as Vm's `deal`\n // Use the alternative signature for ERC20 tokens\n function deal(address to, uint256 give) internal virtual {\n vm.deal(to, give);\n }\n\n // Set the balance of an account for any ERC20 token\n // Use the alternative signature to update `totalSupply`\n function deal(address token, address to, uint256 give) internal virtual {\n deal(token, to, give, false);\n }\n\n // Set the balance of an account for any ERC1155 token\n // Use the alternative signature to update `totalSupply`\n function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual {\n dealERC1155(token, to, id, give, false);\n }\n\n function deal(address token, address to, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0x18160ddd));\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0x18160ddd).checked_write(totSup);\n }\n }\n\n function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x00fdd58e, to, id));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0xbd85b039, id));\n require(\n totSupData.length != 0,\n \"StdCheats deal(address,address,uint,uint,bool): target contract is not ERC1155Supply.\"\n );\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);\n }\n }\n\n function dealERC721(address token, address to, uint256 id) internal virtual {\n // check if token id is already minted and the actual owner.\n (bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id));\n require(successMinted, \"StdCheats deal(address,address,uint,bool): id not minted.\");\n\n // get owner current balance\n (, bytes memory fromBalData) = token.call(abi.encodeWithSelector(0x70a08231, abi.decode(ownerData, (address))));\n uint256 fromPrevBal = abi.decode(fromBalData, (uint256));\n\n // get new user current balance\n (, bytes memory toBalData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 toPrevBal = abi.decode(toBalData, (uint256));\n\n // update balances\n stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);\n\n // update owner\n stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);\n }\n}\n" + }, + "forge-std/StdError.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Panics work for versions >=0.8.0, but we lowered the pragma to make this compatible with Test\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdError {\n bytes public constant assertionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x01);\n bytes public constant arithmeticError = abi.encodeWithSignature(\"Panic(uint256)\", 0x11);\n bytes public constant divisionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x12);\n bytes public constant enumConversionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x21);\n bytes public constant encodeStorageError = abi.encodeWithSignature(\"Panic(uint256)\", 0x22);\n bytes public constant popError = abi.encodeWithSignature(\"Panic(uint256)\", 0x31);\n bytes public constant indexOOBError = abi.encodeWithSignature(\"Panic(uint256)\", 0x32);\n bytes public constant memOverflowError = abi.encodeWithSignature(\"Panic(uint256)\", 0x41);\n bytes public constant zeroVarError = abi.encodeWithSignature(\"Panic(uint256)\", 0x51);\n}\n" + }, + "forge-std/StdInvariant.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ncontract StdInvariant {\n struct FuzzSelector {\n address addr;\n bytes4[] selectors;\n }\n\n address[] private _excludedContracts;\n address[] private _excludedSenders;\n address[] private _targetedContracts;\n address[] private _targetedSenders;\n\n string[] private _excludedArtifacts;\n string[] private _targetedArtifacts;\n\n FuzzSelector[] private _targetedArtifactSelectors;\n FuzzSelector[] private _targetedSelectors;\n\n // Functions for users:\n // These are intended to be called in tests.\n\n function excludeContract(address newExcludedContract_) internal {\n _excludedContracts.push(newExcludedContract_);\n }\n\n function excludeSender(address newExcludedSender_) internal {\n _excludedSenders.push(newExcludedSender_);\n }\n\n function excludeArtifact(string memory newExcludedArtifact_) internal {\n _excludedArtifacts.push(newExcludedArtifact_);\n }\n\n function targetArtifact(string memory newTargetedArtifact_) internal {\n _targetedArtifacts.push(newTargetedArtifact_);\n }\n\n function targetArtifactSelector(FuzzSelector memory newTargetedArtifactSelector_) internal {\n _targetedArtifactSelectors.push(newTargetedArtifactSelector_);\n }\n\n function targetContract(address newTargetedContract_) internal {\n _targetedContracts.push(newTargetedContract_);\n }\n\n function targetSelector(FuzzSelector memory newTargetedSelector_) internal {\n _targetedSelectors.push(newTargetedSelector_);\n }\n\n function targetSender(address newTargetedSender_) internal {\n _targetedSenders.push(newTargetedSender_);\n }\n\n // Functions for forge:\n // These are called by forge to run invariant tests and don't need to be called in tests.\n\n function excludeArtifacts() public view returns (string[] memory excludedArtifacts_) {\n excludedArtifacts_ = _excludedArtifacts;\n }\n\n function excludeContracts() public view returns (address[] memory excludedContracts_) {\n excludedContracts_ = _excludedContracts;\n }\n\n function excludeSenders() public view returns (address[] memory excludedSenders_) {\n excludedSenders_ = _excludedSenders;\n }\n\n function targetArtifacts() public view returns (string[] memory targetedArtifacts_) {\n targetedArtifacts_ = _targetedArtifacts;\n }\n\n function targetArtifactSelectors() public view returns (FuzzSelector[] memory targetedArtifactSelectors_) {\n targetedArtifactSelectors_ = _targetedArtifactSelectors;\n }\n\n function targetContracts() public view returns (address[] memory targetedContracts_) {\n targetedContracts_ = _targetedContracts;\n }\n\n function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_) {\n targetedSelectors_ = _targetedSelectors;\n }\n\n function targetSenders() public view returns (address[] memory targetedSenders_) {\n targetedSenders_ = _targetedSenders;\n }\n}\n" + }, + "forge-std/StdJson.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n// Helpers for parsing and writing JSON files\n// To parse:\n// ```\n// using stdJson for string;\n// string memory json = vm.readFile(\"some_peth\");\n// json.parseUint(\"\");\n// ```\n// To write:\n// ```\n// using stdJson for string;\n// string memory json = \"deploymentArtifact\";\n// Contract contract = new Contract();\n// json.serialize(\"contractAddress\", address(contract));\n// json = json.serialize(\"deploymentTimes\", uint(1));\n// // store the stringified JSON to the 'json' variable we have been using as a key\n// // as we won't need it any longer\n// string memory json2 = \"finalArtifact\";\n// string memory final = json2.serialize(\"depArtifact\", json);\n// final.write(\"\");\n// ```\n\nlibrary stdJson {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {\n return vm.parseJson(json, key);\n }\n\n function readUint(string memory json, string memory key) internal returns (uint256) {\n return vm.parseJsonUint(json, key);\n }\n\n function readUintArray(string memory json, string memory key) internal returns (uint256[] memory) {\n return vm.parseJsonUintArray(json, key);\n }\n\n function readInt(string memory json, string memory key) internal returns (int256) {\n return vm.parseJsonInt(json, key);\n }\n\n function readIntArray(string memory json, string memory key) internal returns (int256[] memory) {\n return vm.parseJsonIntArray(json, key);\n }\n\n function readBytes32(string memory json, string memory key) internal returns (bytes32) {\n return vm.parseJsonBytes32(json, key);\n }\n\n function readBytes32Array(string memory json, string memory key) internal returns (bytes32[] memory) {\n return vm.parseJsonBytes32Array(json, key);\n }\n\n function readString(string memory json, string memory key) internal returns (string memory) {\n return vm.parseJsonString(json, key);\n }\n\n function readStringArray(string memory json, string memory key) internal returns (string[] memory) {\n return vm.parseJsonStringArray(json, key);\n }\n\n function readAddress(string memory json, string memory key) internal returns (address) {\n return vm.parseJsonAddress(json, key);\n }\n\n function readAddressArray(string memory json, string memory key) internal returns (address[] memory) {\n return vm.parseJsonAddressArray(json, key);\n }\n\n function readBool(string memory json, string memory key) internal returns (bool) {\n return vm.parseJsonBool(json, key);\n }\n\n function readBoolArray(string memory json, string memory key) internal returns (bool[] memory) {\n return vm.parseJsonBoolArray(json, key);\n }\n\n function readBytes(string memory json, string memory key) internal returns (bytes memory) {\n return vm.parseJsonBytes(json, key);\n }\n\n function readBytesArray(string memory json, string memory key) internal returns (bytes[] memory) {\n return vm.parseJsonBytesArray(json, key);\n }\n\n function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory) {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bool[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory) {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory) {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory) {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory) {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory) {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function write(string memory jsonKey, string memory path) internal {\n vm.writeJson(jsonKey, path);\n }\n\n function write(string memory jsonKey, string memory path, string memory valueKey) internal {\n vm.writeJson(jsonKey, path, valueKey);\n }\n}\n" + }, + "forge-std/StdMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdMath {\n int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;\n\n function abs(int256 a) internal pure returns (uint256) {\n // Required or it will fail when `a = type(int256).min`\n if (a == INT256_MIN) {\n return 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n }\n\n return uint256(a > 0 ? a : -a);\n }\n\n function delta(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : b - a;\n }\n\n function delta(int256 a, int256 b) internal pure returns (uint256) {\n // a and b are of the same sign\n // this works thanks to two's complement, the left-most bit is the sign bit\n if ((a ^ b) > -1) {\n return delta(abs(a), abs(b));\n }\n\n // a and b are of opposite signs\n return abs(a) + abs(b);\n }\n\n function percentDelta(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n\n return absDelta * 1e18 / b;\n }\n\n function percentDelta(int256 a, int256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n uint256 absB = abs(b);\n\n return absDelta * 1e18 / absB;\n }\n}\n" + }, + "forge-std/StdStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nstruct StdStorage {\n mapping(address => mapping(bytes4 => mapping(bytes32 => uint256))) slots;\n mapping(address => mapping(bytes4 => mapping(bytes32 => bool))) finds;\n bytes32[] _keys;\n bytes4 _sig;\n uint256 _depth;\n address _target;\n bytes32 _set;\n}\n\nlibrary stdStorageSafe {\n event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);\n event WARNING_UninitedSlot(address who, uint256 slot);\n\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return bytes4(keccak256(bytes(sigStr)));\n }\n\n /// @notice find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against\n // slot complexity:\n // if flat, will be bytes32(uint256(uint));\n // if map, will be keccak256(abi.encode(key, uint(slot)));\n // if deep map, will be keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))));\n // if map struct, will be bytes32(uint256(keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))))) + structFieldDepth);\n function find(StdStorage storage self) internal returns (uint256) {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n // calldata to test against\n if (self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n vm.record();\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n (bytes32[] memory reads,) = vm.accesses(address(who));\n if (reads.length == 1) {\n bytes32 curr = vm.load(who, reads[0]);\n if (curr == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[0]));\n }\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[0]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[0]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n } else if (reads.length > 1) {\n for (uint256 i = 0; i < reads.length; i++) {\n bytes32 prev = vm.load(who, reads[i]);\n if (prev == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[i]));\n }\n // store\n vm.store(who, reads[i], bytes32(hex\"1337\"));\n bool success;\n bytes memory rdat;\n {\n (success, rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n if (success && fdat == bytes32(hex\"1337\")) {\n // we found which of the slots is the actual one\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[i]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[i]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n vm.store(who, reads[i], prev);\n break;\n }\n vm.store(who, reads[i], prev);\n }\n } else {\n revert(\"stdStorage find(StdStorage): No storage use detected for target.\");\n }\n\n require(\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))],\n \"stdStorage find(StdStorage): Slot(s) not found.\"\n );\n\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n self._target = _target;\n return self;\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n self._sig = _sig;\n return self;\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n self._sig = sigs(_sig);\n return self;\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n self._keys.push(bytes32(uint256(uint160(who))));\n return self;\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n self._keys.push(bytes32(amt));\n return self;\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n self._keys.push(key);\n return self;\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n self._depth = _depth;\n return self;\n }\n\n function read(StdStorage storage self) private returns (bytes memory) {\n address t = self._target;\n uint256 s = find(self);\n return abi.encode(vm.load(t, bytes32(s)));\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return abi.decode(read(self), (bytes32));\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n int256 v = read_int(self);\n if (v == 0) return false;\n if (v == 1) return true;\n revert(\"stdStorage read_bool(StdStorage): Cannot decode. Make sure you are reading a bool.\");\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return abi.decode(read(self), (address));\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return abi.decode(read(self), (uint256));\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return abi.decode(read(self), (int256));\n }\n\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n\nlibrary stdStorage {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return stdStorageSafe.sigs(sigStr);\n }\n\n function find(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.find(self);\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n return stdStorageSafe.target(self, _target);\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, who);\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, amt);\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, key);\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n return stdStorageSafe.depth(self, _depth);\n }\n\n function checked_write(StdStorage storage self, address who) internal {\n checked_write(self, bytes32(uint256(uint160(who))));\n }\n\n function checked_write(StdStorage storage self, uint256 amt) internal {\n checked_write(self, bytes32(amt));\n }\n\n function checked_write(StdStorage storage self, bool write) internal {\n bytes32 t;\n /// @solidity memory-safe-assembly\n assembly {\n t := write\n }\n checked_write(self, t);\n }\n\n function checked_write(StdStorage storage self, bytes32 set) internal {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n if (!self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n find(self);\n }\n bytes32 slot = bytes32(self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]);\n\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n bytes32 curr = vm.load(who, slot);\n\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n vm.store(who, slot, set);\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return stdStorageSafe.read_bytes32(self);\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n return stdStorageSafe.read_bool(self);\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return stdStorageSafe.read_address(self);\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.read_uint(self);\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return stdStorageSafe.read_int(self);\n }\n\n // Private function so needs to be copied over\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n // Private function so needs to be copied over\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n" + }, + "forge-std/StdStyle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nlibrary StdStyle {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n string constant RED = \"\\u001b[91m\";\n string constant GREEN = \"\\u001b[92m\";\n string constant YELLOW = \"\\u001b[93m\";\n string constant BLUE = \"\\u001b[94m\";\n string constant MAGENTA = \"\\u001b[95m\";\n string constant CYAN = \"\\u001b[96m\";\n string constant BOLD = \"\\u001b[1m\";\n string constant DIM = \"\\u001b[2m\";\n string constant ITALIC = \"\\u001b[3m\";\n string constant UNDERLINE = \"\\u001b[4m\";\n string constant INVERSE = \"\\u001b[7m\";\n string constant RESET = \"\\u001b[0m\";\n\n function styleConcat(string memory style, string memory self) private pure returns (string memory) {\n return string(abi.encodePacked(style, self, RESET));\n }\n\n function red(string memory self) internal pure returns (string memory) {\n return styleConcat(RED, self);\n }\n\n function red(uint256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(int256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(address self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(bool self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes(bytes memory self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes32(bytes32 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function green(string memory self) internal pure returns (string memory) {\n return styleConcat(GREEN, self);\n }\n\n function green(uint256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(int256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(address self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(bool self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes(bytes memory self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes32(bytes32 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function yellow(string memory self) internal pure returns (string memory) {\n return styleConcat(YELLOW, self);\n }\n\n function yellow(uint256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(int256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(address self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(bool self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes(bytes memory self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes32(bytes32 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function blue(string memory self) internal pure returns (string memory) {\n return styleConcat(BLUE, self);\n }\n\n function blue(uint256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(int256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(address self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(bool self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes(bytes memory self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes32(bytes32 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function magenta(string memory self) internal pure returns (string memory) {\n return styleConcat(MAGENTA, self);\n }\n\n function magenta(uint256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(int256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(address self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(bool self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes(bytes memory self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes32(bytes32 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function cyan(string memory self) internal pure returns (string memory) {\n return styleConcat(CYAN, self);\n }\n\n function cyan(uint256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(int256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(address self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(bool self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes(bytes memory self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes32(bytes32 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function bold(string memory self) internal pure returns (string memory) {\n return styleConcat(BOLD, self);\n }\n\n function bold(uint256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(int256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(address self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(bool self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes(bytes memory self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes32(bytes32 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function dim(string memory self) internal pure returns (string memory) {\n return styleConcat(DIM, self);\n }\n\n function dim(uint256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(int256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(address self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(bool self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes(bytes memory self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes32(bytes32 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function italic(string memory self) internal pure returns (string memory) {\n return styleConcat(ITALIC, self);\n }\n\n function italic(uint256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(int256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(address self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(bool self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes(bytes memory self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes32(bytes32 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function underline(string memory self) internal pure returns (string memory) {\n return styleConcat(UNDERLINE, self);\n }\n\n function underline(uint256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(int256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(address self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(bool self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes(bytes memory self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes32(bytes32 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function inverse(string memory self) internal pure returns (string memory) {\n return styleConcat(INVERSE, self);\n }\n\n function inverse(uint256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(int256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(address self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(bool self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes(bytes memory self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes32(bytes32 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n}\n" + }, + "forge-std/StdUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {IMulticall3} from \"./interfaces/IMulticall3.sol\";\n// TODO Remove import.\nimport {VmSafe} from \"./Vm.sol\";\n\nabstract contract StdUtils {\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n //////////////////////////////////////////////////////////////////////////*/\n\n IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;\n uint256 private constant INT256_MIN_ABS =\n 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n uint256 private constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n // Used by default when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n /*//////////////////////////////////////////////////////////////////////////\n INTERNAL FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result) {\n require(min <= max, \"StdUtils bound(uint256,uint256,uint256): Max is less than min.\");\n // If x is between min and max, return x directly. This is to ensure that dictionary values\n // do not get shifted if the min is nonzero. More info: https://github.com/foundry-rs/forge-std/issues/188\n if (x >= min && x <= max) return x;\n\n uint256 size = max - min + 1;\n\n // If the value is 0, 1, 2, 3, warp that to min, min+1, min+2, min+3. Similarly for the UINT256_MAX side.\n // This helps ensure coverage of the min/max values.\n if (x <= 3 && size > x) return min + x;\n if (x >= UINT256_MAX - 3 && size > UINT256_MAX - x) return max - (UINT256_MAX - x);\n\n // Otherwise, wrap x into the range [min, max], i.e. the range is inclusive.\n if (x > max) {\n uint256 diff = x - max;\n uint256 rem = diff % size;\n if (rem == 0) return max;\n result = min + rem - 1;\n } else if (x < min) {\n uint256 diff = min - x;\n uint256 rem = diff % size;\n if (rem == 0) return min;\n result = max - rem + 1;\n }\n }\n\n function bound(uint256 x, uint256 min, uint256 max) internal view virtual returns (uint256 result) {\n result = _bound(x, min, max);\n console2_log(\"Bound Result\", result);\n }\n\n function bound(int256 x, int256 min, int256 max) internal view virtual returns (int256 result) {\n require(min <= max, \"StdUtils bound(int256,int256,int256): Max is less than min.\");\n\n // Shifting all int256 values to uint256 to use _bound function. The range of two types are:\n // int256 : -(2**255) ~ (2**255 - 1)\n // uint256: 0 ~ (2**256 - 1)\n // So, add 2**255, INT256_MIN_ABS to the integer values.\n //\n // If the given integer value is -2**255, we cannot use `-uint256(-x)` because of the overflow.\n // So, use `~uint256(x) + 1` instead.\n uint256 _x = x < 0 ? (INT256_MIN_ABS - ~uint256(x) - 1) : (uint256(x) + INT256_MIN_ABS);\n uint256 _min = min < 0 ? (INT256_MIN_ABS - ~uint256(min) - 1) : (uint256(min) + INT256_MIN_ABS);\n uint256 _max = max < 0 ? (INT256_MIN_ABS - ~uint256(max) - 1) : (uint256(max) + INT256_MIN_ABS);\n\n uint256 y = _bound(_x, _min, _max);\n\n // To move it back to int256 value, subtract INT256_MIN_ABS at here.\n result = y < INT256_MIN_ABS ? int256(~(INT256_MIN_ABS - y) + 1) : int256(y - INT256_MIN_ABS);\n console2_log(\"Bound result\", vm.toString(result));\n }\n\n function bytesToUint(bytes memory b) internal pure virtual returns (uint256) {\n require(b.length <= 32, \"StdUtils bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n /// @dev Compute the address a contract will be deployed at for a given deployer address and nonce\n /// @notice adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)\n function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address) {\n // forgefmt: disable-start\n // The integer zero is treated as an empty byte string, and as a result it only has a length prefix, 0x80, computed via 0x80 + 0.\n // A one byte integer uses its own value as its length prefix, there is no additional \"0x80 + length\" prefix that comes before it.\n if (nonce == 0x00) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, bytes1(0x80))));\n if (nonce <= 0x7f) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, uint8(nonce))));\n\n // Nonces greater than 1 byte all follow a consistent encoding scheme, where each value is preceded by a prefix of 0x80 + length.\n if (nonce <= 2**8 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd7), bytes1(0x94), deployer, bytes1(0x81), uint8(nonce))));\n if (nonce <= 2**16 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd8), bytes1(0x94), deployer, bytes1(0x82), uint16(nonce))));\n if (nonce <= 2**24 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd9), bytes1(0x94), deployer, bytes1(0x83), uint24(nonce))));\n // forgefmt: disable-end\n\n // More details about RLP encoding can be found here: https://eth.wiki/fundamentals/rlp\n // 0xda = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x84 ++ nonce)\n // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex)\n // 0x84 = 0x80 + 0x04 (0x04 = the bytes length of the nonce, 4 bytes, in hex)\n // We assume nobody can have a nonce large enough to require more than 32 bytes.\n return addressFromLast20Bytes(\n keccak256(abi.encodePacked(bytes1(0xda), bytes1(0x94), deployer, bytes1(0x84), uint32(nonce)))\n );\n }\n\n function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)\n internal\n pure\n virtual\n returns (address)\n {\n return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, initcodeHash)));\n }\n\n /// @dev returns the address of a contract created with CREATE2 using the default CREATE2 deployer\n function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address) {\n return computeCreate2Address(salt, initCodeHash, CREATE2_FACTORY);\n }\n\n /// @dev returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n function hashInitCode(bytes memory creationCode) internal pure returns (bytes32) {\n return hashInitCode(creationCode, \"\");\n }\n\n /// @dev returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n /// @param args the ABI-encoded arguments to the constructor of C\n function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(creationCode, args));\n }\n\n // Performs a single call with Multicall3 to query the ERC-20 token balances of the given addresses.\n function getTokenBalances(address token, address[] memory addresses)\n internal\n virtual\n returns (uint256[] memory balances)\n {\n uint256 tokenCodeSize;\n assembly {\n tokenCodeSize := extcodesize(token)\n }\n require(tokenCodeSize > 0, \"StdUtils getTokenBalances(address,address[]): Token address is not a contract.\");\n\n // ABI encode the aggregate call to Multicall3.\n uint256 length = addresses.length;\n IMulticall3.Call[] memory calls = new IMulticall3.Call[](length);\n for (uint256 i = 0; i < length; ++i) {\n // 0x70a08231 = bytes4(\"balanceOf(address)\"))\n calls[i] = IMulticall3.Call({target: token, callData: abi.encodeWithSelector(0x70a08231, (addresses[i]))});\n }\n\n // Make the aggregate call.\n (, bytes[] memory returnData) = multicall.aggregate(calls);\n\n // ABI decode the return data and return the balances.\n balances = new uint256[](length);\n for (uint256 i = 0; i < length; ++i) {\n balances[i] = abi.decode(returnData[i], (uint256));\n }\n }\n\n /*//////////////////////////////////////////////////////////////////////////\n PRIVATE FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address) {\n return address(uint160(uint256(bytesValue)));\n }\n\n // Used to prevent the compilation of console, which shortens the compilation time when console is not used elsewhere.\n\n function console2_log(string memory p0, uint256 p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n status;\n }\n\n function console2_log(string memory p0, string memory p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n status;\n }\n}\n" + }, + "forge-std/Test.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// 💬 ABOUT\n// Standard Library's default Test\n\n// 🧩 MODULES\nimport {console} from \"./console.sol\";\nimport {console2} from \"./console2.sol\";\nimport {StdAssertions} from \"./StdAssertions.sol\";\nimport {StdChains} from \"./StdChains.sol\";\nimport {StdCheats} from \"./StdCheats.sol\";\nimport {stdError} from \"./StdError.sol\";\nimport {StdInvariant} from \"./StdInvariant.sol\";\nimport {stdJson} from \"./StdJson.sol\";\nimport {stdMath} from \"./StdMath.sol\";\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {StdUtils} from \"./StdUtils.sol\";\nimport {Vm} from \"./Vm.sol\";\nimport {StdStyle} from \"./StdStyle.sol\";\n\n// 📦 BOILERPLATE\nimport {TestBase} from \"./Base.sol\";\nimport {DSTest} from \"ds-test/test.sol\";\n\n// ⭐️ TEST\nabstract contract Test is DSTest, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils, TestBase {\n// Note: IS_TEST() must return true.\n// Note: Must have failure system, https://github.com/dapphub/ds-test/blob/cd98eff28324bfac652e63a239a60632a761790b/src/test.sol#L39-L76.\n}\n" + }, + "forge-std/Vm.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// Cheatcodes are marked as view/pure/none using the following rules:\n// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,\n// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure (you are modifying some state be it the EVM, interpreter, filesystem, etc),\n// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,\n// 3. Otherwise you're `pure`.\n\ninterface VmSafe {\n struct Log {\n bytes32[] topics;\n bytes data;\n address emitter;\n }\n\n struct Rpc {\n string key;\n string url;\n }\n\n struct FsMetadata {\n bool isDir;\n bool isSymlink;\n uint256 length;\n bool readOnly;\n uint256 modified;\n uint256 accessed;\n uint256 created;\n }\n\n // Loads a storage slot from an address\n function load(address target, bytes32 slot) external view returns (bytes32 data);\n // Signs data\n function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);\n // Gets the address for a given private key\n function addr(uint256 privateKey) external pure returns (address keyAddr);\n // Gets the nonce of an account\n function getNonce(address account) external view returns (uint64 nonce);\n // Performs a foreign function call via the terminal\n function ffi(string[] calldata commandInput) external returns (bytes memory result);\n // Sets environment variables\n function setEnv(string calldata name, string calldata value) external;\n // Reads environment variables, (name) => (value)\n function envBool(string calldata name) external view returns (bool value);\n function envUint(string calldata name) external view returns (uint256 value);\n function envInt(string calldata name) external view returns (int256 value);\n function envAddress(string calldata name) external view returns (address value);\n function envBytes32(string calldata name) external view returns (bytes32 value);\n function envString(string calldata name) external view returns (string memory value);\n function envBytes(string calldata name) external view returns (bytes memory value);\n // Reads environment variables as arrays\n function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);\n function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);\n function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);\n function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);\n function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);\n function envString(string calldata name, string calldata delim) external view returns (string[] memory value);\n function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);\n // Read environment variables with default value\n function envOr(string calldata name, bool defaultValue) external returns (bool value);\n function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);\n function envOr(string calldata name, int256 defaultValue) external returns (int256 value);\n function envOr(string calldata name, address defaultValue) external returns (address value);\n function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);\n function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);\n function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);\n // Read environment variables as arrays with default value\n function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)\n external\n returns (bool[] memory value);\n function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)\n external\n returns (uint256[] memory value);\n function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)\n external\n returns (int256[] memory value);\n function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)\n external\n returns (address[] memory value);\n function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)\n external\n returns (bytes32[] memory value);\n function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)\n external\n returns (string[] memory value);\n function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)\n external\n returns (bytes[] memory value);\n // Records all storage reads and writes\n function record() external;\n // Gets all accessed reads and write slot from a recording session, for a given address\n function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);\n // Gets the _creation_ bytecode from an artifact file. Takes in the relative path to the json file\n function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);\n // Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file\n function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);\n // Labels an address in call traces\n function label(address account, string calldata newLabel) external;\n // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain\n function broadcast() external;\n // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain\n function broadcast(address signer) external;\n // Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain\n function broadcast(uint256 privateKey) external;\n // Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain\n function startBroadcast() external;\n // Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain\n function startBroadcast(address signer) external;\n // Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain\n function startBroadcast(uint256 privateKey) external;\n // Stops collecting onchain transactions\n function stopBroadcast() external;\n // Reads the entire content of file to string\n function readFile(string calldata path) external view returns (string memory data);\n // Reads the entire content of file as binary. Path is relative to the project root.\n function readFileBinary(string calldata path) external view returns (bytes memory data);\n // Get the path of the current project root\n function projectRoot() external view returns (string memory path);\n // Get the metadata for a file/directory\n function fsMetadata(string calldata fileOrDir) external returns (FsMetadata memory metadata);\n // Reads next line of file to string\n function readLine(string calldata path) external view returns (string memory line);\n // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n function writeFile(string calldata path, string calldata data) external;\n // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n // Path is relative to the project root.\n function writeFileBinary(string calldata path, bytes calldata data) external;\n // Writes line to file, creating a file if it does not exist.\n function writeLine(string calldata path, string calldata data) external;\n // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n function closeFile(string calldata path) external;\n // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases:\n // - Path points to a directory.\n // - The file doesn't exist.\n // - The user lacks permissions to remove the file.\n function removeFile(string calldata path) external;\n // Convert values to a string\n function toString(address value) external pure returns (string memory stringifiedValue);\n function toString(bytes calldata value) external pure returns (string memory stringifiedValue);\n function toString(bytes32 value) external pure returns (string memory stringifiedValue);\n function toString(bool value) external pure returns (string memory stringifiedValue);\n function toString(uint256 value) external pure returns (string memory stringifiedValue);\n function toString(int256 value) external pure returns (string memory stringifiedValue);\n // Convert values from a string\n function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);\n function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);\n function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);\n function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);\n function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);\n function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);\n // Record all the transaction logs\n function recordLogs() external;\n // Gets all the recorded logs\n function getRecordedLogs() external returns (Log[] memory logs);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path m/44'/60'/0'/0/{index}\n function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at {derivationPath}{index}\n function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)\n external\n pure\n returns (uint256 privateKey);\n // Adds a private key to the local forge wallet and returns the address\n function rememberKey(uint256 privateKey) external returns (address keyAddr);\n //\n // parseJson\n //\n // ----\n // In case the returned value is a JSON object, it's encoded as a ABI-encoded tuple. As JSON objects\n // don't have the notion of ordered, but tuples do, they JSON object is encoded with it's fields ordered in\n // ALPHABETICAL order. That means that in order to successfully decode the tuple, we need to define a tuple that\n // encodes the fields in the same order, which is alphabetical. In the case of Solidity structs, they are encoded\n // as tuples, with the attributes in the order in which they are defined.\n // For example: json = { 'a': 1, 'b': 0xa4tb......3xs}\n // a: uint256\n // b: address\n // To decode that json, we need to define a struct or a tuple as follows:\n // struct json = { uint256 a; address b; }\n // If we defined a json struct with the opposite order, meaning placing the address b first, it would try to\n // decode the tuple in that order, and thus fail.\n // ----\n // Given a string of JSON, return it as ABI-encoded\n function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);\n function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);\n\n // The following parseJson cheatcodes will do type coercion, for the type that they indicate.\n // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12'\n // and hex numbers '0xEF'.\n // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not\n // a JSON object.\n function parseJsonUint(string calldata, string calldata) external returns (uint256);\n function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);\n function parseJsonInt(string calldata, string calldata) external returns (int256);\n function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);\n function parseJsonBool(string calldata, string calldata) external returns (bool);\n function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);\n function parseJsonAddress(string calldata, string calldata) external returns (address);\n function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);\n function parseJsonString(string calldata, string calldata) external returns (string memory);\n function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);\n function parseJsonBytes(string calldata, string calldata) external returns (bytes memory);\n function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory);\n function parseJsonBytes32(string calldata, string calldata) external returns (bytes32);\n function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory);\n\n // Serialize a key and value to a JSON object stored in-memory that can be later written to a file\n // It returns the stringified version of the specific JSON file up to that moment.\n function serializeBool(string calldata objectKey, string calldata valueKey, bool value)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address value)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)\n external\n returns (string memory json);\n\n function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)\n external\n returns (string memory json);\n\n //\n // writeJson\n //\n // ----\n // Write a serialized JSON object to a file. If the file exists, it will be overwritten.\n // Let's assume we want to write the following JSON to a file:\n //\n // { \"boolean\": true, \"number\": 342, \"object\": { \"title\": \"finally json serialization\" } }\n //\n // ```\n // string memory json1 = \"some key\";\n // vm.serializeBool(json1, \"boolean\", true);\n // vm.serializeBool(json1, \"number\", uint256(342));\n // json2 = \"some other key\";\n // string memory output = vm.serializeString(json2, \"title\", \"finally json serialization\");\n // string memory finalJson = vm.serialize(json1, \"object\", output);\n // vm.writeJson(finalJson, \"./output/example.json\");\n // ```\n // The critical insight is that every invocation of serialization will return the stringified version of the JSON\n // up to that point. That means we can construct arbitrary JSON objects and then use the return stringified version\n // to serialize them as values to another JSON object.\n //\n // json1 and json2 are simply keys used by the backend to keep track of the objects. So vm.serializeJson(json1,..)\n // will find the object in-memory that is keyed by \"some key\".\n function writeJson(string calldata json, string calldata path) external;\n // Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \n // This is useful to replace a specific value of a JSON file, without having to parse the entire thing\n function writeJson(string calldata json, string calldata path, string calldata valueKey) external;\n // Returns the RPC url for the given alias\n function rpcUrl(string calldata rpcAlias) external view returns (string memory json);\n // Returns all rpc urls and their aliases `[alias, url][]`\n function rpcUrls() external view returns (string[2][] memory urls);\n // Returns all rpc urls and their aliases as structs.\n function rpcUrlStructs() external view returns (Rpc[] memory urls);\n // If the condition is false, discard this run's fuzz inputs and generate new ones.\n function assume(bool condition) external pure;\n // Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.\n function pauseGasMetering() external;\n // Resumes gas metering (i.e. gas usage is counted again). Noop if already on.\n function resumeGasMetering() external;\n}\n\ninterface Vm is VmSafe {\n // Sets block.timestamp\n function warp(uint256 newTimestamp) external;\n // Sets block.height\n function roll(uint256 newHeight) external;\n // Sets block.basefee\n function fee(uint256 newBasefee) external;\n // Sets block.difficulty\n function difficulty(uint256 newDifficulty) external;\n // Sets block.chainid\n function chainId(uint256 newChainId) external;\n // Stores a value to an address' storage slot.\n function store(address target, bytes32 slot, bytes32 value) external;\n // Sets the nonce of an account; must be higher than the current nonce of the account\n function setNonce(address account, uint64 newNonce) external;\n // Sets the *next* call's msg.sender to be the input address\n function prank(address msgSender) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called\n function startPrank(address msgSender) external;\n // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input\n function prank(address msgSender, address txOrigin) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input\n function startPrank(address msgSender, address txOrigin) external;\n // Resets subsequent calls' msg.sender to be `address(this)`\n function stopPrank() external;\n // Sets an address' balance\n function deal(address account, uint256 newBalance) external;\n // Sets an address' code\n function etch(address target, bytes calldata newRuntimeBytecode) external;\n // Expects an error on next call\n function expectRevert(bytes calldata revertData) external;\n function expectRevert(bytes4 revertData) external;\n function expectRevert() external;\n // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData).\n // Call this function, then emit an event, then call a function. Internally after the call, we check if\n // logs were emitted in the expected order with the expected topics and data (as specified by the booleans)\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)\n external;\n // Mocks a call to an address, returning specified data.\n // Calldata can either be strict or a partial match, e.g. if you only\n // pass a Solidity selector to the expected calldata, then the entire Solidity\n // function will be mocked.\n function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;\n // Mocks a call to an address with a specific msg.value, returning specified data.\n // Calldata match takes precedence over msg.value in case of ambiguity.\n function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;\n // Clears all mocked calls\n function clearMockedCalls() external;\n // Expects a call to an address with the specified calldata.\n // Calldata can either be a strict or a partial match\n function expectCall(address callee, bytes calldata data) external;\n // Expects a call to an address with the specified msg.value and calldata\n function expectCall(address callee, uint256 msgValue, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value, gas, and calldata.\n function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas.\n function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;\n // Sets block.coinbase\n function coinbase(address newCoinbase) external;\n // Snapshot the current state of the evm.\n // Returns the id of the snapshot that was created.\n // To revert a snapshot use `revertTo`\n function snapshot() external returns (uint256 snapshotId);\n // Revert the state of the EVM to a previous snapshot\n // Takes the snapshot id to revert to.\n // This deletes the snapshot and all snapshots taken after the given snapshot id.\n function revertTo(uint256 snapshotId) external returns (bool success);\n // Creates a new fork with the given endpoint and block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction,\n // and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before\n // the transaction, returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.\n function selectFork(uint256 forkId) external;\n /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.\n function activeFork() external view returns (uint256 forkId);\n // Updates the currently active fork to given block number\n // This is similar to `roll` but for the currently active fork\n function rollFork(uint256 blockNumber) external;\n // Updates the currently active fork to given transaction\n // this will `rollFork` with the number of the block the transaction was mined in and replays all transaction mined before it in the block\n function rollFork(bytes32 txHash) external;\n // Updates the given fork to given block number\n function rollFork(uint256 forkId, uint256 blockNumber) external;\n // Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block\n function rollFork(uint256 forkId, bytes32 txHash) external;\n // Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\n // Meaning, changes made to the state of this account will be kept when switching forks\n function makePersistent(address account) external;\n function makePersistent(address account0, address account1) external;\n function makePersistent(address account0, address account1, address account2) external;\n function makePersistent(address[] calldata accounts) external;\n // Revokes persistent status from the address, previously added via `makePersistent`\n function revokePersistent(address account) external;\n function revokePersistent(address[] calldata accounts) external;\n // Returns true if the account is marked as persistent\n function isPersistent(address account) external view returns (bool persistent);\n // In forking mode, explicitly grant the given address cheatcode access\n function allowCheatcodes(address account) external;\n // Fetches the given transaction from the active fork and executes it on the current state\n function transact(bytes32 txHash) external;\n // Fetches the given transaction from the given fork and executes it on the current state\n function transact(uint256 forkId, bytes32 txHash) external;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/interfaces/IERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20Upgradeable.sol\";\nimport \"../token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable {\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed sender,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/proxy/ClonesUpgradeable.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 ClonesUpgradeable {\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 // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n // of the `implementation` address with the bytecode before the address.\n mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n instance := create(0, 0x09, 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 // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n // of the `implementation` address with the bytecode before the address.\n mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n instance := create2(0, 0x09, 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(add(ptr, 0x38), deployer)\n mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)\n mstore(add(ptr, 0x14), implementation)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)\n mstore(add(ptr, 0x58), salt)\n mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))\n predicted := keccak256(add(ptr, 0x43), 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-upgradeable/contracts/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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../interfaces/IERC4626Upgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of\n * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable {\n using MathUpgradeable for uint256;\n\n IERC20Upgradeable private _asset;\n uint8 private _decimals;\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n function __ERC4626_init(IERC20Upgradeable asset_) internal onlyInitializing {\n __ERC4626_init_unchained(asset_);\n }\n\n function __ERC4626_init_unchained(IERC20Upgradeable asset_) internal onlyInitializing {\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n _decimals = success ? assetDecimals : super.decimals();\n _asset = asset_;\n }\n\n /**\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n */\n function _tryGetAssetDecimals(IERC20Upgradeable asset_) private returns (bool, uint8) {\n (bool success, bytes memory encodedDecimals) = address(asset_).call(\n abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector)\n );\n if (success && encodedDecimals.length >= 32) {\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n if (returnedDecimals <= type(uint8).max) {\n return (true, uint8(returnedDecimals));\n }\n }\n return (false, 0);\n }\n\n /**\n * @dev Decimals are read from the underlying asset in the constructor and cached. If this fails (e.g., the asset\n * has not been created yet), the cached value is set to a default obtained by `super.decimals()` (which depends on\n * inheritance but is most likely 18). Override this function in order to set a guaranteed hardcoded value.\n * See {IERC20Metadata-decimals}.\n */\n function decimals() public view virtual override(IERC20MetadataUpgradeable, ERC20Upgradeable) returns (uint8) {\n return _decimals;\n }\n\n /** @dev See {IERC4626-asset}. */\n function asset() public view virtual override returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4626-totalAssets}. */\n function totalAssets() public view virtual override returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4626-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxDeposit}. */\n function maxDeposit(address) public view virtual override returns (uint256) {\n return _isVaultCollateralized() ? type(uint256).max : 0;\n }\n\n /** @dev See {IERC4626-maxMint}. */\n function maxMint(address) public view virtual override returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual override returns (uint256) {\n return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxRedeem}. */\n function maxRedeem(address owner) public view virtual override returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4626-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-previewMint}. */\n function previewMint(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-mint}. */\n function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4626-withdraw}. */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-redeem}. */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n *\n * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset\n * would represent an infinite amount of shares.\n */\n function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) {\n uint256 supply = totalSupply();\n return\n (assets == 0 || supply == 0)\n ? _initialConvertToShares(assets, rounding)\n : assets.mulDiv(supply, totalAssets(), rounding);\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToAssets} when overriding it.\n */\n function _initialConvertToShares(\n uint256 assets,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 shares) {\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 assets) {\n uint256 supply = totalSupply();\n return\n (supply == 0) ? _initialConvertToAssets(shares, rounding) : shares.mulDiv(totalAssets(), supply, rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToShares} when overriding it.\n */\n function _initialConvertToAssets(\n uint256 shares,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 assets) {\n return shares;\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transferred and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transferred, which is a valid state.\n _burn(owner, shares);\n SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _isVaultCollateralized() private view returns (bool) {\n return totalAssets() > 0 || totalSupply() == 0;\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/contracts/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/contracts/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/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2Upgradeable {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(\n uint256 amount,\n bytes32 salt,\n bytes memory bytecode\n ) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(\n bytes32 salt,\n bytes32 bytecodeHash,\n address deployer\n ) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "ops/interfaces/IResolver.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IResolver {\n function checker()\n external\n view\n returns (bool canExec, bytes memory execPayload);\n}\n" + }, + "solidity-bytes-utils/contracts/BytesLib.sol": { + "content": "// SPDX-License-Identifier: Unlicense\n/*\n * @title Solidity Bytes Arrays Utils\n * @author Gonçalo Sá \n *\n * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.\n * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.\n */\npragma solidity >=0.8.0 <0.9.0;\n\n\nlibrary BytesLib {\n function concat(\n bytes memory _preBytes,\n bytes memory _postBytes\n )\n internal\n pure\n returns (bytes memory)\n {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(0x40, and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n ))\n }\n\n return tempBytes;\n }\n\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\n assembly {\n // Read the first 32 bytes of _preBytes storage, which is the length\n // of the array. (We don't need to use the offset into the slot\n // because arrays use the entire slot.)\n let fslot := sload(_preBytes.slot)\n // Arrays of 31 bytes or less have an even value in their slot,\n // while longer arrays have an odd value. The actual length is\n // the slot divided by two for odd values, and the lowest order\n // byte divided by two for even values.\n // If the slot is even, bitwise and the slot with 255 and divide by\n // two to get the length. If the slot is odd, bitwise and the slot\n // with -1 and divide by two.\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n let newlength := add(slength, mlength)\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n switch add(lt(slength, 32), lt(newlength, 32))\n case 2 {\n // Since the new array still fits in the slot, we just need to\n // update the contents of the slot.\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\n sstore(\n _preBytes.slot,\n // all the modifications to the slot are inside this\n // next block\n add(\n // we can just add to the slot contents because the\n // bytes we want to change are the LSBs\n fslot,\n add(\n mul(\n div(\n // load the bytes from memory\n mload(add(_postBytes, 0x20)),\n // zero all bytes to the right\n exp(0x100, sub(32, mlength))\n ),\n // and now shift left the number of bytes to\n // leave space for the length in the slot\n exp(0x100, sub(32, newlength))\n ),\n // increase length by the double of the memory\n // bytes length\n mul(mlength, 2)\n )\n )\n )\n }\n case 1 {\n // The stored value fits in the slot, but the combined value\n // will exceed it.\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // The contents of the _postBytes array start 32 bytes into\n // the structure. Our first read should obtain the `submod`\n // bytes that can fit into the unused space in the last word\n // of the stored array. To get this, we read 32 bytes starting\n // from `submod`, so the data we read overlaps with the array\n // contents by `submod` bytes. Masking the lowest-order\n // `submod` bytes allows us to add that value directly to the\n // stored value.\n\n let submod := sub(32, slength)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(\n sc,\n add(\n and(\n fslot,\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\n ),\n and(mload(mc), mask)\n )\n )\n\n for {\n mc := add(mc, 0x20)\n sc := add(sc, 1)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n default {\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n // Start copying to the last used word of the stored array.\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // Copy over the first `submod` bytes of the new data as in\n // case 1 above.\n let slengthmod := mod(slength, 32)\n let mlengthmod := mod(mlength, 32)\n let submod := sub(32, slengthmod)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\n\n for {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n }\n }\n\n function slice(\n bytes memory _bytes,\n uint256 _start,\n uint256 _length\n )\n internal\n pure\n returns (bytes memory)\n {\n require(_length + 31 >= _length, \"slice_overflow\");\n require(_bytes.length >= _start + _length, \"slice_outOfBounds\");\n\n bytes memory tempBytes;\n\n assembly {\n switch iszero(_length)\n case 0 {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // The first word of the slice result is potentially a partial\n // word read from the original array. To read it, we calculate\n // the length of that partial word and start copying that many\n // bytes into the array. The first word we copy will start with\n // data we don't care about, but the last `lengthmod` bytes will\n // land at the beginning of the contents of the new array. When\n // we're done copying, we overwrite the full first word with\n // the actual length of the slice.\n let lengthmod := and(_length, 31)\n\n // The multiplication in the next line is necessary\n // because when slicing multiples of 32 bytes (lengthmod == 0)\n // the following copy loop was copying the origin's length\n // and then ending prematurely not copying everything it should.\n let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))\n let end := add(mc, _length)\n\n for {\n // The multiplication in the next line has the same exact purpose\n // as the one above.\n let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n mstore(tempBytes, _length)\n\n //update free-memory pointer\n //allocating the array padded to 32 bytes like the compiler does now\n mstore(0x40, and(add(mc, 31), not(31)))\n }\n //if we want a zero-length slice let's just return a zero-length array\n default {\n tempBytes := mload(0x40)\n //zero out the 32 bytes slice we are about to return\n //we need to do it because Solidity does not garbage collect\n mstore(tempBytes, 0)\n\n mstore(0x40, add(tempBytes, 0x20))\n }\n }\n\n return tempBytes;\n }\n\n function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {\n require(_bytes.length >= _start + 20, \"toAddress_outOfBounds\");\n address tempAddress;\n\n assembly {\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\n }\n\n return tempAddress;\n }\n\n function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {\n require(_bytes.length >= _start + 1 , \"toUint8_outOfBounds\");\n uint8 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x1), _start))\n }\n\n return tempUint;\n }\n\n function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {\n require(_bytes.length >= _start + 2, \"toUint16_outOfBounds\");\n uint16 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x2), _start))\n }\n\n return tempUint;\n }\n\n function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {\n require(_bytes.length >= _start + 4, \"toUint32_outOfBounds\");\n uint32 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x4), _start))\n }\n\n return tempUint;\n }\n\n function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {\n require(_bytes.length >= _start + 8, \"toUint64_outOfBounds\");\n uint64 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x8), _start))\n }\n\n return tempUint;\n }\n\n function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {\n require(_bytes.length >= _start + 12, \"toUint96_outOfBounds\");\n uint96 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0xc), _start))\n }\n\n return tempUint;\n }\n\n function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {\n require(_bytes.length >= _start + 16, \"toUint128_outOfBounds\");\n uint128 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x10), _start))\n }\n\n return tempUint;\n }\n\n function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {\n require(_bytes.length >= _start + 32, \"toUint256_outOfBounds\");\n uint256 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x20), _start))\n }\n\n return tempUint;\n }\n\n function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {\n require(_bytes.length >= _start + 32, \"toBytes32_outOfBounds\");\n bytes32 tempBytes32;\n\n assembly {\n tempBytes32 := mload(add(add(_bytes, 0x20), _start))\n }\n\n return tempBytes32;\n }\n\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\n bool success = true;\n\n assembly {\n let length := mload(_preBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(length, mload(_postBytes))\n case 1 {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n let mc := add(_preBytes, 0x20)\n let end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n // the next line is the loop condition:\n // while(uint256(mc < end) + cb == 2)\n } eq(add(lt(mc, end), cb), 2) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // if any of these checks fails then arrays are not equal\n if iszero(eq(mload(mc), mload(cc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n\n function equalStorage(\n bytes storage _preBytes,\n bytes memory _postBytes\n )\n internal\n view\n returns (bool)\n {\n bool success = true;\n\n assembly {\n // we know _preBytes_offset is 0\n let fslot := sload(_preBytes.slot)\n // Decode the length of the stored array like in concatStorage().\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(slength, mlength)\n case 1 {\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n if iszero(iszero(slength)) {\n switch lt(slength, 32)\n case 1 {\n // blank the last byte which is the length\n fslot := mul(div(fslot, 0x100), 0x100)\n\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\n // unsuccess:\n success := 0\n }\n }\n default {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := keccak256(0x0, 0x20)\n\n let mc := add(_postBytes, 0x20)\n let end := add(mc, mlength)\n\n // the next line is the loop condition:\n // while(uint256(mc < end) + cb == 2)\n for {} eq(add(lt(mc, end), cb), 2) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n if iszero(eq(sload(sc), mload(mc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n}\n" + }, + "solmate/auth/Auth.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\nabstract contract Auth {\n event OwnerUpdated(address indexed user, address indexed newOwner);\n\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\n\n address public owner;\n\n Authority public authority;\n\n constructor(address _owner, Authority _authority) {\n owner = _owner;\n authority = _authority;\n\n emit OwnerUpdated(msg.sender, _owner);\n emit AuthorityUpdated(msg.sender, _authority);\n }\n\n modifier requiresAuth() virtual {\n require(isAuthorized(msg.sender, msg.sig), \"UNAUTHORIZED\");\n\n _;\n }\n\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\n\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\n }\n\n function setAuthority(Authority newAuthority) public virtual {\n // We check if the caller is the owner first because we want to ensure they can\n // always swap out the authority even if it's reverting or using up a lot of gas.\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\n\n authority = newAuthority;\n\n emit AuthorityUpdated(msg.sender, newAuthority);\n }\n\n function setOwner(address newOwner) public virtual requiresAuth {\n owner = newOwner;\n\n emit OwnerUpdated(msg.sender, newOwner);\n }\n}\n\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\ninterface Authority {\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n}\n" + }, + "solmate/auth/authorities/RolesAuthority.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {Auth, Authority} from \"../Auth.sol\";\n\n/// @notice Role based Authority that supports up to 256 roles.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\ncontract RolesAuthority is Auth, Authority {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\n\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\n\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\n\n /*//////////////////////////////////////////////////////////////\n ROLE/USER STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(address => bytes32) public getUserRoles;\n\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\n\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\n\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\n }\n\n function doesRoleHaveCapability(\n uint8 role,\n address target,\n bytes4 functionSig\n ) public view virtual returns (bool) {\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\n }\n\n /*//////////////////////////////////////////////////////////////\n AUTHORIZATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) public view virtual override returns (bool) {\n return\n isCapabilityPublic[target][functionSig] ||\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\n }\n\n /*//////////////////////////////////////////////////////////////\n ROLE CAPABILITY CONFIGURATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setPublicCapability(\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n isCapabilityPublic[target][functionSig] = enabled;\n\n emit PublicCapabilityUpdated(target, functionSig, enabled);\n }\n\n function setRoleCapability(\n uint8 role,\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\n } else {\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\n }\n\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\n }\n\n /*//////////////////////////////////////////////////////////////\n USER ROLE ASSIGNMENT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setUserRole(\n address user,\n uint8 role,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getUserRoles[user] |= bytes32(1 << role);\n } else {\n getUserRoles[user] &= ~bytes32(1 << role);\n }\n\n emit UserRoleUpdated(user, role, enabled);\n }\n}\n" + }, + "solmate/mixins/ERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\nimport {FixedPointMathLib} from \"../utils/FixedPointMathLib.sol\";\n\n/// @notice Minimal ERC4626 tokenized Vault implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/mixins/ERC4626.sol)\nabstract contract ERC4626 is ERC20 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /*//////////////////////////////////////////////////////////////\n IMMUTABLES\n //////////////////////////////////////////////////////////////*/\n\n ERC20 public immutable asset;\n\n constructor(\n ERC20 _asset,\n string memory _name,\n string memory _symbol\n ) ERC20(_name, _symbol, _asset.decimals()) {\n asset = _asset;\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n /*//////////////////////////////////////////////////////////////\n ACCOUNTING LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function totalAssets() public view virtual returns (uint256);\n\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\n }\n\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\n }\n\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\n return convertToShares(assets);\n }\n\n function previewMint(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\n }\n\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\n }\n\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\n return convertToAssets(shares);\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function maxDeposit(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxMint(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxWithdraw(address owner) public view virtual returns (uint256) {\n return convertToAssets(balanceOf[owner]);\n }\n\n function maxRedeem(address owner) public view virtual returns (uint256) {\n return balanceOf[owner];\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL HOOKS LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\n}\n" + }, + "solmate/test/utils/mocks/MockERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../../../tokens/ERC20.sol\";\n\ncontract MockERC20 is ERC20 {\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) ERC20(_name, _symbol, _decimals) {}\n\n function mint(address to, uint256 value) public virtual {\n _mint(to, value);\n }\n\n function burn(address from, uint256 value) public virtual {\n _burn(from, value);\n }\n}\n" + }, + "solmate/tokens/ERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" + }, + "solmate/tokens/WETH.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"./ERC20.sol\";\n\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\n\n/// @notice Minimalist and modern Wrapped Ether implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)\n/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)\ncontract WETH is ERC20(\"Wrapped Ether\", \"WETH\", 18) {\n using SafeTransferLib for address;\n\n event Deposit(address indexed from, uint256 amount);\n\n event Withdrawal(address indexed to, uint256 amount);\n\n function deposit() public payable virtual {\n _mint(msg.sender, msg.value);\n\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 amount) public virtual {\n _burn(msg.sender, amount);\n\n emit Withdrawal(msg.sender, amount);\n\n msg.sender.safeTransferETH(amount);\n }\n\n receive() external payable virtual {\n deposit();\n }\n}\n" + }, + "solmate/utils/FixedPointMathLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // Divide z by the denominator.\n z := div(z, denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // First, divide z - 1 by the denominator and add 1.\n // We allow z - 1 to underflow if z is 0, because we multiply the\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n assembly {\n let y := x // We start y at x, which will help us make our initial estimate.\n\n z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n // We check y >= 2^(k + 8) but shift right by k bits\n // each branch to ensure that if x >= 256, then y >= 256.\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n y := shr(128, y)\n z := shl(64, z)\n }\n if iszero(lt(y, 0x1000000000000000000)) {\n y := shr(64, y)\n z := shl(32, z)\n }\n if iszero(lt(y, 0x10000000000)) {\n y := shr(32, y)\n z := shl(16, z)\n }\n if iszero(lt(y, 0x1000000)) {\n y := shr(16, y)\n z := shl(8, z)\n }\n\n // Goal was to get z*z*y within a small factor of x. More iterations could\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n // There is no overflow risk here since y < 2^136 after the first branch above.\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // If x+1 is a perfect square, the Babylonian method cycles between\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n z := sub(z, lt(div(x, z), z))\n }\n }\n\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Mod x by y. Note this will return\n // 0 instead of reverting if y is zero.\n z := mod(x, y)\n }\n }\n\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\n assembly {\n // Divide x by y. Note this will return\n // 0 instead of reverting if y is zero.\n r := div(x, y)\n }\n }\n\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Add 1 to x * y if x % y > 0. Note this will\n // return 0 instead of reverting if y is zero.\n z := add(gt(mod(x, y), 0), div(x, y))\n }\n }\n}\n" + }, + "solmate/utils/SafeCastLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Safe unsigned integer casting library that reverts on overflow.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\nlibrary SafeCastLib {\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\n require(x < 1 << 248);\n\n y = uint248(x);\n }\n\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\n require(x < 1 << 224);\n\n y = uint224(x);\n }\n\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\n require(x < 1 << 192);\n\n y = uint192(x);\n }\n\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\n require(x < 1 << 160);\n\n y = uint160(x);\n }\n\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\n require(x < 1 << 128);\n\n y = uint128(x);\n }\n\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\n require(x < 1 << 96);\n\n y = uint96(x);\n }\n\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\n require(x < 1 << 64);\n\n y = uint64(x);\n }\n\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\n require(x < 1 << 32);\n\n y = uint32(x);\n }\n\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\n require(x < 1 << 24);\n\n y = uint24(x);\n }\n\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\n require(x < 1 << 16);\n\n y = uint16(x);\n }\n\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\n require(x < 1 << 8);\n\n y = uint8(x);\n }\n}\n" + }, + "solmate/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/superseed/solcInputs/5aaea447b85dccd5473e8e0eceb8e2df.json b/packages/contracts/deployments/superseed/solcInputs/5aaea447b85dccd5473e8e0eceb8e2df.json new file mode 100644 index 0000000000..2c7001e80a --- /dev/null +++ b/packages/contracts/deployments/superseed/solcInputs/5aaea447b85dccd5473e8e0eceb8e2df.json @@ -0,0 +1,744 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable2Step.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 \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.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/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "adrastia-periphery/rates/IHistoricalRates.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\nimport \"./RateLibrary.sol\";\n\n/**\n * @title IHistoricalRates\n * @notice An interface that defines a contract that stores historical rates.\n */\ninterface IHistoricalRates {\n /// @notice Gets an rate for a token at a specific index.\n /// @param token The address of the token to get the rates for.\n /// @param index The index of the rate to get, where index 0 contains the latest rate, and the last\n /// index contains the oldest rate (uses reverse chronological ordering).\n /// @return rate The rate for the token at the specified index.\n function getRateAt(address token, uint256 index) external view returns (RateLibrary.Rate memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(address token, uint256 amount) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the latest rates for a token.\n /// @param token The address of the token to get the rates for.\n /// @param amount The number of rates to get.\n /// @param offset The index of the first rate to get (default: 0).\n /// @param increment The increment between rates to get (default: 1).\n /// @return rates The latest rates for the token, in reverse chronological order, from newest to oldest.\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view returns (RateLibrary.Rate[] memory);\n\n /// @notice Gets the number of rates for a token.\n /// @param token The address of the token to get the number of rates for.\n /// @return count The number of rates for the token.\n function getRatesCount(address token) external view returns (uint256);\n\n /// @notice Gets the capacity of rates for a token.\n /// @param token The address of the token to get the capacity of rates for.\n /// @return capacity The capacity of rates for the token.\n function getRatesCapacity(address token) external view returns (uint256);\n\n /// @notice Sets the capacity of rates for a token.\n /// @param token The address of the token to set the capacity of rates for.\n /// @param amount The new capacity of rates for the token.\n function setRatesCapacity(address token, uint256 amount) external;\n}\n" + }, + "adrastia-periphery/rates/RateLibrary.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.5.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nlibrary RateLibrary {\n struct Rate {\n uint64 target;\n uint64 current;\n uint32 timestamp;\n }\n}\n" + }, + "contracts/adrastia/PrudentiaLib.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nlibrary PrudentiaLib {\n struct PrudentiaConfig {\n address controller; // Adrastia Prudentia controller address\n uint8 offset; // Offset for delayed rate activation\n int8 decimalShift; // Positive values scale the rate up (in powers of 10), negative values scale the rate down\n }\n}\n" + }, + "contracts/compound/CarefulMath.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Careful Math\n * @author Compound\n * @notice Derived from OpenZeppelin's SafeMath library\n * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol\n */\ncontract CarefulMath {\n /**\n * @dev Possible error codes that we can return\n */\n enum MathError {\n NO_ERROR,\n DIVISION_BY_ZERO,\n INTEGER_OVERFLOW,\n INTEGER_UNDERFLOW\n }\n\n /**\n * @dev Multiplies two numbers, returns an error on overflow.\n */\n function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (a == 0) {\n return (MathError.NO_ERROR, 0);\n }\n\n uint256 c;\n unchecked {\n c = a * b;\n }\n\n if (c / a != b) {\n return (MathError.INTEGER_OVERFLOW, 0);\n } else {\n return (MathError.NO_ERROR, c);\n }\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b == 0) {\n return (MathError.DIVISION_BY_ZERO, 0);\n }\n\n return (MathError.NO_ERROR, a / b);\n }\n\n /**\n * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).\n */\n function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n if (b <= a) {\n return (MathError.NO_ERROR, a - b);\n } else {\n return (MathError.INTEGER_UNDERFLOW, 0);\n }\n }\n\n /**\n * @dev Adds two numbers, returns an error on overflow.\n */\n function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {\n uint256 c;\n unchecked {\n c = a + b;\n }\n\n if (c >= a) {\n return (MathError.NO_ERROR, c);\n } else {\n return (MathError.INTEGER_OVERFLOW, 0);\n }\n }\n\n /**\n * @dev add a and b and then subtract c\n */\n function addThenSubUInt(\n uint256 a,\n uint256 b,\n uint256 c\n ) internal pure returns (MathError, uint256) {\n (MathError err0, uint256 sum) = addUInt(a, b);\n\n if (err0 != MathError.NO_ERROR) {\n return (err0, 0);\n }\n\n return subUInt(sum, c);\n }\n}\n" + }, + "contracts/compound/CErc20Delegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CToken.sol\";\n\n/**\n * @title Compound's CErc20Delegate Contract\n * @notice CTokens which wrap an EIP-20 underlying and are delegated to\n * @author Compound\n */\ncontract CErc20Delegate is CErc20 {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 3;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.contractType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.delegateType.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._becomeImplementation.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n */\n function _becomeImplementation(bytes memory) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 1;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20Delegate\";\n }\n}\n" + }, + "contracts/compound/CErc20Delegator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ComptrollerInterface.sol\";\nimport \"./InterestRateModel.sol\";\nimport \"../ionic/DiamondExtension.sol\";\nimport { CErc20DelegatorBase, CDelegateInterface } from \"./CTokenInterfaces.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\n/**\n * @title Compound's CErc20Delegator Contract\n * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation\n * @author Compound\n */\ncontract CErc20Delegator is CErc20DelegatorBase, DiamondBase {\n /**\n * @notice Emitted when implementation is changed\n */\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /**\n * @notice Initialize the new money market\n * @param underlying_ The address of the underlying asset\n * @param comptroller_ The address of the Comptroller\n * @param ionicAdmin_ The FeeDistributor contract address.\n * @param interestRateModel_ The address of the interest rate model\n * @param name_ ERC-20 name of this token\n * @param symbol_ ERC-20 symbol of this token\n */\n constructor(\n address underlying_,\n IonicComptroller comptroller_,\n address payable ionicAdmin_,\n InterestRateModel interestRateModel_,\n string memory name_,\n string memory symbol_,\n uint256 reserveFactorMantissa_,\n uint256 adminFeeMantissa_\n ) {\n require(msg.sender == ionicAdmin_, \"!admin\");\n uint8 decimals_ = EIP20Interface(underlying_).decimals();\n {\n ionicAdmin = ionicAdmin_;\n\n // Set initial exchange rate\n initialExchangeRateMantissa = 0.2e18;\n\n // Set the comptroller\n comptroller = comptroller_;\n\n // Initialize block number and borrow index (block number mocks depend on comptroller being set)\n accrualBlockNumber = block.number;\n borrowIndex = 1e18;\n\n // Set the interest rate model (depends on block number / borrow index)\n require(interestRateModel_.isInterestRateModel(), \"!notIrm\");\n interestRateModel = interestRateModel_;\n emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);\n\n name = name_;\n symbol = symbol_;\n decimals = decimals_;\n\n // Set reserve factor\n // Check newReserveFactor ≤ maxReserveFactor\n require(\n reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!rf:set\"\n );\n reserveFactorMantissa = reserveFactorMantissa_;\n emit NewReserveFactor(0, reserveFactorMantissa_);\n\n // Set admin fee\n // Sanitize adminFeeMantissa_\n if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n require(\n reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,\n \"!adminFee:set\"\n );\n adminFeeMantissa = adminFeeMantissa_;\n emit NewAdminFee(0, adminFeeMantissa_);\n ionicFeeMantissa = newIonicFeeMantissa;\n emit NewIonicFee(0, newIonicFeeMantissa);\n\n // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)\n _notEntered = true;\n }\n\n // Set underlying and sanity check it\n underlying = underlying_;\n EIP20Interface(underlying).totalSupply();\n }\n\n function implementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"delegateType()\"))));\n }\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {\n // Check admin rights\n require(hasAdminRights(), \"!admin\");\n\n // Set implementation\n _setImplementationInternal(implementation_, becomeImplementationData);\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external override {\n require(msg.sender == address(this) || hasAdminRights(), \"!self or admin\");\n\n (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature(\"delegateType()\"));\n require(success, \"no delegate type\");\n\n uint8 currentDelegateType = abi.decode(data, (uint8));\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)\n .latestCErc20Delegate(currentDelegateType);\n\n address currentDelegate = implementation();\n if (currentDelegate != latestCErc20Delegate) {\n _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);\n } else {\n // only update the extensions without reinitializing with becomeImplementationData\n _updateExtensions(currentDelegate);\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(msg.sender == address(ionicAdmin), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n /**\n * @dev Internal function to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {\n address delegateBefore = implementation();\n _updateExtensions(implementation_);\n\n _functionCall(\n address(this),\n abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),\n \"!become impl\"\n );\n\n emit NewImplementation(delegateBefore, implementation_);\n }\n\n function _updateExtensions(address newDelegate) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CErc20PluginDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\nimport \"./IERC4626.sol\";\nimport \"../external/uniswap/IUniswapV2Pair.sol\";\n\n/**\n * @title Rari's CErc20Plugin's Contract\n * @notice CToken which outsources token logic to a plugin\n * @author Joey Santoro\n *\n * CErc20PluginDelegate deposits and withdraws from a plugin contract\n * It is also capable of delegating reward functionality to a PluginRewardsDistributor\n */\ncontract CErc20PluginDelegate is CErc20Delegate {\n event NewPluginImplementation(address oldImpl, address newImpl);\n\n /**\n * @notice Plugin address\n */\n IERC4626 public plugin;\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.plugin.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this._updatePlugin.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /**\n * @notice Delegate interface to become the implementation\n * @param data The encoded arguments for becoming\n */\n function _becomeImplementation(bytes memory data) public virtual override {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _becomeImplementation\");\n\n address _plugin = abi.decode(data, (address));\n\n if (_plugin == address(0) && address(plugin) != address(0)) {\n // if no new plugin address is given, use the latest implementation\n _plugin = IFeeDistributor(ionicAdmin).latestPluginImplementation(address(plugin));\n }\n\n if (_plugin != address(0) && _plugin != address(plugin)) {\n _updatePlugin(_plugin);\n }\n }\n\n /**\n * @notice Update the plugin implementation to a whitelisted implementation\n * @param _plugin The address of the plugin implementation to use\n */\n function _updatePlugin(address _plugin) public {\n require(msg.sender == address(this) || hasAdminRights(), \"only self and admins can call _updatePlugin\");\n\n address oldImplementation = address(plugin) != address(0) ? address(plugin) : _plugin;\n\n if (address(plugin) != address(0) && plugin.balanceOf(address(this)) != 0) {\n plugin.redeem(plugin.balanceOf(address(this)), address(this), address(this));\n }\n\n plugin = IERC4626(_plugin);\n\n EIP20Interface(underlying).approve(_plugin, type(uint256).max);\n\n uint256 amount = EIP20Interface(underlying).balanceOf(address(this));\n if (amount != 0) {\n deposit(amount);\n }\n\n emit NewPluginImplementation(oldImplementation, _plugin);\n }\n\n /*** CToken Overrides ***/\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of the plugin in terms of the underlying\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view override returns (uint256) {\n return plugin.previewRedeem(plugin.balanceOf(address(this)));\n }\n\n /**\n * @notice Transfer the underlying to the cToken and trigger a deposit\n * @param from Address to transfer funds from\n * @param amount Amount of underlying to transfer\n * @return The actual amount that is transferred\n */\n function doTransferIn(address from, uint256 amount) internal override returns (uint256) {\n // Perform the EIP-20 transfer in\n require(EIP20Interface(underlying).transferFrom(from, address(this), amount), \"send\");\n\n deposit(amount);\n return amount;\n }\n\n function deposit(uint256 amount) internal {\n plugin.deposit(amount, address(this));\n }\n\n /**\n * @notice Transfer the underlying from plugin to destination\n * @param to Address to transfer funds to\n * @param amount Amount of underlying to transfer\n */\n function doTransferOut(address to, uint256 amount) internal override {\n plugin.withdraw(amount, to, address(this));\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 2;\n }\n\n function contractType() external pure virtual override returns (string memory) {\n return \"CErc20PluginDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20PluginRewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20PluginDelegate.sol\";\n\ncontract CErc20PluginRewardsDelegate is CErc20PluginDelegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying && _token != address(plugin), \"!token\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 4;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20PluginRewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/CErc20RewardsDelegate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CErc20Delegate.sol\";\nimport \"./EIP20Interface.sol\";\n\ncontract CErc20RewardsDelegate is CErc20Delegate {\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 2;\n\n bytes4[] memory superFunctionSelectors = super._getExtensionFunctions();\n functionSelectors = new bytes4[](superFunctionSelectors.length + fnsCount);\n\n for (uint256 i = 0; i < superFunctionSelectors.length; i++) {\n functionSelectors[i] = superFunctionSelectors[i];\n }\n\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.claim.selector;\n functionSelectors[--fnsCount + superFunctionSelectors.length] = this.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n \n /// @notice A reward token claim function\n /// to be overridden for use cases where rewardToken needs to be pulled in\n function claim() external {}\n\n /// @notice token approval function\n function approve(address _token, address _spender) external {\n require(hasAdminRights(), \"!admin\");\n require(_token != underlying, \"!underlying\");\n\n EIP20Interface(_token).approve(_spender, type(uint256).max);\n }\n\n function delegateType() public pure virtual override returns (uint8) {\n return 3;\n }\n\n function contractType() external pure override returns (string memory) {\n return \"CErc20RewardsDelegate\";\n }\n}\n" + }, + "contracts/compound/Comptroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./Unitroller.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { IIonicFlywheel } from \"../ionic/strategies/flywheel/IIonicFlywheel.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, ComptrollerInterface } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n * @dev This contract should not to be deployed alone; instead, deploy `Unitroller` (proxy contract) on top of this `Comptroller` (logic/implementation contract).\n */\ncontract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorReporter, Exponential, DiamondExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when an admin supports a market\n event MarketListed(ICErc20 cToken);\n\n /// @notice Emitted when an account enters a market\n event MarketEntered(ICErc20 cToken, address account);\n\n /// @notice Emitted when an account exits a market\n event MarketExited(ICErc20 cToken, address account);\n\n /// @notice Emitted when close factor is changed by admin\n event NewCloseFactor(uint256 oldCloseFactorMantissa, uint256 newCloseFactorMantissa);\n\n /// @notice Emitted when a collateral factor is changed by admin\n event NewCollateralFactor(ICErc20 cToken, uint256 oldCollateralFactorMantissa, uint256 newCollateralFactorMantissa);\n\n /// @notice Emitted when liquidation incentive is changed by admin\n event NewLiquidationIncentive(uint256 oldLiquidationIncentiveMantissa, uint256 newLiquidationIncentiveMantissa);\n\n /// @notice Emitted when price oracle is changed\n event NewPriceOracle(BasePriceOracle oldPriceOracle, BasePriceOracle newPriceOracle);\n\n /// @notice Emitted when the whitelist enforcement is changed\n event WhitelistEnforcementChanged(bool enforce);\n\n /// @notice Emitted when a new RewardsDistributor contract is added to hooks\n event AddedRewardsDistributor(address rewardsDistributor);\n\n // closeFactorMantissa must be strictly greater than this value\n uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05\n\n // closeFactorMantissa must not exceed this value\n uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9\n\n // No collateralFactorMantissa may exceed this value\n uint256 internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9\n\n // liquidationIncentiveMantissa must be no less than this value\n uint256 internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0\n\n // liquidationIncentiveMantissa must be no greater than this value\n uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5\n\n modifier isAuthorized() {\n require(IFeeDistributor(ionicAdmin).canCall(address(this), msg.sender, address(this), msg.sig), \"not authorized\");\n _;\n }\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 supplyCap) {\n return ComptrollerBase.effectiveSupplyCaps(cToken);\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(\n address cToken\n ) public view override(ComptrollerBase, ComptrollerInterface) returns (uint256 borrowCap) {\n return ComptrollerBase.effectiveBorrowCaps(cToken);\n }\n\n /*** Assets You Are In ***/\n\n /**\n * @notice Returns the assets an account has entered\n * @param account The address of the account to pull assets for\n * @return A dynamic list with the assets the account has entered\n */\n function getAssetsIn(address account) external view returns (ICErc20[] memory) {\n ICErc20[] memory assetsIn = accountAssets[account];\n\n return assetsIn;\n }\n\n /**\n * @notice Returns whether the given account is entered in the given asset\n * @param account The address of the account to check\n * @param cToken The cToken to check\n * @return True if the account is in the asset, otherwise false.\n */\n function checkMembership(address account, ICErc20 cToken) external view returns (bool) {\n return markets[address(cToken)].accountMembership[account];\n }\n\n /**\n * @notice Add assets to be included in account liquidity calculation\n * @param cTokens The list of addresses of the cToken markets to be enabled\n * @return Success indicator for whether each corresponding market was entered\n */\n function enterMarkets(address[] memory cTokens) public override isAuthorized returns (uint256[] memory) {\n uint256 len = cTokens.length;\n\n uint256[] memory results = new uint256[](len);\n for (uint256 i = 0; i < len; i++) {\n ICErc20 cToken = ICErc20(cTokens[i]);\n\n results[i] = uint256(addToMarketInternal(cToken, msg.sender));\n }\n\n return results;\n }\n\n /**\n * @notice Add the market to the borrower's \"assets in\" for liquidity calculations\n * @param cToken The market to enter\n * @param borrower The address of the account to modify\n * @return Success indicator for whether the market was entered\n */\n function addToMarketInternal(ICErc20 cToken, address borrower) internal returns (Error) {\n Market storage marketToJoin = markets[address(cToken)];\n\n if (!marketToJoin.isListed) {\n // market is not listed, cannot join\n return Error.MARKET_NOT_LISTED;\n }\n\n if (marketToJoin.accountMembership[borrower] == true) {\n // already joined\n return Error.NO_ERROR;\n }\n\n // survived the gauntlet, add to list\n // NOTE: we store these somewhat redundantly as a significant optimization\n // this avoids having to iterate through the list for the most common use cases\n // that is, only when we need to perform liquidity checks\n // and not whenever we want to check if an account is in a particular market\n marketToJoin.accountMembership[borrower] = true;\n accountAssets[borrower].push(cToken);\n\n // Add to allBorrowers\n if (!borrowers[borrower]) {\n allBorrowers.push(borrower);\n borrowers[borrower] = true;\n borrowerIndexes[borrower] = allBorrowers.length - 1;\n }\n\n emit MarketEntered(cToken, borrower);\n\n return Error.NO_ERROR;\n }\n\n /**\n * @notice Removes asset from sender's account liquidity calculation\n * @dev Sender must not have an outstanding borrow balance in the asset,\n * or be providing necessary collateral for an outstanding borrow.\n * @param cTokenAddress The address of the asset to be removed\n * @return Whether or not the account successfully exited the market\n */\n function exitMarket(address cTokenAddress) external override isAuthorized returns (uint256) {\n // TODO\n require(markets[cTokenAddress].isListed, \"!Comptroller:exitMarket\");\n\n ICErc20 cToken = ICErc20(cTokenAddress);\n /* Get sender tokensHeld and amountOwed underlying from the cToken */\n (uint256 oErr, uint256 tokensHeld, uint256 amountOwed, ) = cToken.getAccountSnapshot(msg.sender);\n require(oErr == 0, \"!exitMarket\"); // semi-opaque error code\n\n /* Fail if the sender has a borrow balance */\n if (amountOwed != 0) {\n return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);\n }\n\n /* Fail if the sender is not permitted to redeem all of their tokens */\n uint256 allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);\n if (allowed != 0) {\n return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);\n }\n\n Market storage marketToExit = markets[cTokenAddress];\n\n /* Return true if the sender is not already ‘in’ the market */\n if (!marketToExit.accountMembership[msg.sender]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Set cToken account membership to false */\n delete marketToExit.accountMembership[msg.sender];\n\n /* Delete cToken from the account’s list of assets */\n // load into memory for faster iteration\n ICErc20[] memory userAssetList = accountAssets[msg.sender];\n uint256 len = userAssetList.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (userAssetList[i] == ICErc20(cTokenAddress)) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n ICErc20[] storage storedList = accountAssets[msg.sender];\n storedList[assetIndex] = storedList[storedList.length - 1];\n storedList.pop();\n\n // If the user has exited all markets, remove them from the `allBorrowers` array\n if (storedList.length == 0) {\n allBorrowers[borrowerIndexes[msg.sender]] = allBorrowers[allBorrowers.length - 1]; // Copy last item in list to location of item to be removed\n allBorrowers.pop(); // Reduce length by 1\n borrowerIndexes[allBorrowers[borrowerIndexes[msg.sender]]] = borrowerIndexes[msg.sender]; // Set borrower index of moved item to correct index\n borrowerIndexes[msg.sender] = 0; // Reset sender borrower index to 0 for a gas refund\n borrowers[msg.sender] = false; // Tell the contract that the sender is no longer a borrower (so it knows to add the borrower back if they enter a market in the future)\n }\n\n emit MarketExited(ICErc20(cTokenAddress), msg.sender);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Policy Hooks ***/\n\n /**\n * @notice Checks if the account should be allowed to mint tokens in the given market\n * @param cTokenAddress The market to verify the mint against\n * @param minter The account which would get the minted tokens\n * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens\n * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function mintAllowed(address cTokenAddress, address minter, uint256 mintAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!mintGuardianPaused[cTokenAddress], \"!mint:paused\");\n\n // Make sure market is listed\n if (!markets[cTokenAddress].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure minter is whitelisted\n if (enforceWhitelist && !whitelist[minter]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 supplyCap = effectiveSupplyCaps(cTokenAddress);\n\n // Supply cap of 0 corresponds to unlimited supplying\n if (supplyCap != 0 && !supplyCapWhitelist[cTokenAddress].contains(minter)) {\n uint256 totalUnderlyingSupply = ICErc20(cTokenAddress).getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = asComptrollerExtension().getWhitelistedSuppliersSupply(cTokenAddress);\n uint256 nonWhitelistedTotalSupply;\n if (whitelistedSuppliersSupply >= totalUnderlyingSupply) nonWhitelistedTotalSupply = 0;\n else nonWhitelistedTotalSupply = totalUnderlyingSupply - whitelistedSuppliersSupply;\n\n require(nonWhitelistedTotalSupply + mintAmount < supplyCap, \"!supply cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cTokenAddress, minter);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to redeem tokens in the given market\n * @param cToken The market to verify the redeem against\n * @param redeemer The account which would redeem the tokens\n * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market\n * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external override returns (uint256) {\n uint256 allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreSupplierAction(cToken, redeemer);\n\n return uint256(Error.NO_ERROR);\n }\n\n function redeemAllowedInternal(\n address cToken,\n address redeemer,\n uint256 redeemTokens\n ) internal view returns (uint256) {\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */\n if (!markets[cToken].accountMembership[redeemer]) {\n return uint256(Error.NO_ERROR);\n }\n\n /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n redeemer,\n ICErc20(cToken),\n redeemTokens,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Validates mint and reverts on rejection. May emit logs.\n * @param cToken Asset being minted\n * @param minter The address minting the tokens\n * @param actualMintAmount The amount of the underlying asset being minted\n * @param mintTokens The number of tokens being minted\n */\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external {\n // Add minter to suppliers mapping\n suppliers[minter] = true;\n }\n\n /**\n * @notice Validates redeem and reverts on rejection. May emit logs.\n * @param cToken Asset being redeemed\n * @param redeemer The address redeeming the tokens\n * @param redeemAmount The amount of the underlying asset being redeemed\n * @param redeemTokens The number of tokens being redeemed\n */\n function redeemVerify(\n address cToken,\n address redeemer,\n uint256 redeemAmount,\n uint256 redeemTokens\n ) external override {\n require(markets[msg.sender].isListed, \"!market\");\n\n // Require tokens is zero or amount is also zero\n if (redeemTokens == 0 && redeemAmount > 0) {\n revert(\"!zero\");\n }\n }\n\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) external view override returns (uint256) {\n address cToken = address(cTokenModify);\n // Accrue interest\n uint256 balanceOfUnderlying = cTokenModify.balanceOfUnderlying(account);\n\n // Get account liquidity\n (Error err, , uint256 liquidity, uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n account,\n isBorrow ? cTokenModify : ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n require(err == Error.NO_ERROR, \"!liquidity\");\n if (shortfall > 0) return 0; // Shortfall, so no more borrow/redeem\n\n // Get max borrow/redeem\n uint256 maxBorrowOrRedeemAmount;\n\n if (!isBorrow && !markets[cToken].accountMembership[account]) {\n // Max redeem = balance of underlying if not used as collateral\n maxBorrowOrRedeemAmount = balanceOfUnderlying;\n } else {\n // Avoid \"stack too deep\" error by separating this logic\n maxBorrowOrRedeemAmount = _getMaxRedeemOrBorrow(liquidity, cTokenModify, isBorrow);\n\n // Redeem only: max out at underlying balance\n if (!isBorrow && balanceOfUnderlying < maxBorrowOrRedeemAmount) maxBorrowOrRedeemAmount = balanceOfUnderlying;\n }\n\n // Get max borrow or redeem considering cToken liquidity\n uint256 cTokenLiquidity = cTokenModify.getCash();\n\n // Return the minimum of the two maximums\n return maxBorrowOrRedeemAmount <= cTokenLiquidity ? maxBorrowOrRedeemAmount : cTokenLiquidity;\n }\n\n /**\n * @dev Portion of the logic in `getMaxRedeemOrBorrow` above separated to avoid \"stack too deep\" errors.\n */\n function _getMaxRedeemOrBorrow(\n uint256 liquidity,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal view returns (uint256) {\n if (liquidity == 0) return 0; // No available account liquidity, so no more borrow/redeem\n\n // Get the normalized price of the asset\n uint256 conversionFactor = oracle.getUnderlyingPrice(cTokenModify);\n require(conversionFactor > 0, \"!oracle\");\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n if (!isBorrow) {\n uint256 collateralFactorMantissa = markets[address(cTokenModify)].collateralFactorMantissa;\n conversionFactor = (collateralFactorMantissa * conversionFactor) / 1e18;\n }\n\n // Get max borrow or redeem considering excess account liquidity\n return (liquidity * 1e18) / conversionFactor;\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken The market to verify the borrow against\n * @param borrower The account which would borrow the asset\n * @param borrowAmount The amount of underlying the account would borrow\n * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!borrowGuardianPaused[cToken], \"!borrow:paused\");\n\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n if (!markets[cToken].accountMembership[borrower]) {\n // only cTokens may call borrowAllowed if borrower not in market\n require(msg.sender == cToken, \"!ctoken\");\n\n // attempt to add borrower to the market\n Error err = addToMarketInternal(ICErc20(msg.sender), borrower);\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n // it should be impossible to break the important invariant\n assert(markets[cToken].accountMembership[borrower]);\n }\n\n // Make sure oracle price is available\n if (oracle.getUnderlyingPrice(ICErc20(cToken)) == 0) {\n return uint256(Error.PRICE_ERROR);\n }\n\n // Make sure borrower is whitelisted\n if (enforceWhitelist && !whitelist[borrower]) {\n return uint256(Error.SUPPLIER_NOT_WHITELISTED);\n }\n\n uint256 borrowCap = effectiveBorrowCaps(cToken);\n\n // Borrow cap of 0 corresponds to unlimited borrowing\n if (borrowCap != 0 && !borrowCapWhitelist[cToken].contains(borrower)) {\n uint256 totalBorrows = ICErc20(cToken).totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = asComptrollerExtension().getWhitelistedBorrowersBorrows(cToken);\n uint256 nonWhitelistedTotalBorrows;\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n\n require(nonWhitelistedTotalBorrows + borrowAmount < borrowCap, \"!borrow:cap\");\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n // Perform a hypothetical liquidity check to guard against shortfall\n (uint256 err, , , uint256 shortfall) = this.getHypotheticalAccountLiquidity(borrower, cToken, 0, borrowAmount, 0);\n if (err != uint256(Error.NO_ERROR)) {\n return err;\n }\n if (shortfall > 0) {\n return uint256(Error.INSUFFICIENT_LIQUIDITY);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to borrow the underlying asset of the given market\n * @param cToken Asset whose underlying is being borrowed\n * @param accountBorrowsNew The user's new borrow balance of the underlying asset\n */\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view override returns (uint256) {\n // Check if min borrow exists\n uint256 minBorrowEth = IFeeDistributor(ionicAdmin).minBorrowEth();\n\n if (minBorrowEth > 0) {\n // Get new underlying borrow balance of account for this cToken\n uint256 oraclePriceMantissa = oracle.getUnderlyingPrice(ICErc20(cToken));\n if (oraclePriceMantissa == 0) return uint256(Error.PRICE_ERROR);\n (MathError mathErr, uint256 borrowBalanceEth) = mulScalarTruncate(\n Exp({ mantissa: oraclePriceMantissa }),\n accountBorrowsNew\n );\n if (mathErr != MathError.NO_ERROR) return uint256(Error.MATH_ERROR);\n\n // Check against min borrow\n if (borrowBalanceEth < minBorrowEth) return uint256(Error.BORROW_BELOW_MIN);\n }\n\n // Return no error\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to repay a borrow in the given market\n * @param cToken The market to verify the repay against\n * @param payer The account which would repay the asset\n * @param borrower The account which would borrowed the asset\n * @param repayAmount The amount of the underlying asset the account would repay\n * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure market is listed\n if (!markets[cToken].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Keep the flywheel moving\n flywheelPreBorrowerAction(cToken, borrower);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the liquidation should be allowed to occur\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param repayAmount The amount of underlying being repaid\n */\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external override returns (uint256) {\n // Make sure markets are listed\n if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Get borrowers' underlying borrow balance\n uint256 borrowBalance = ICErc20(cTokenBorrowed).borrowBalanceCurrent(borrower);\n\n /* allow accounts to be liquidated if the market is deprecated */\n if (isDeprecated(ICErc20(cTokenBorrowed))) {\n require(borrowBalance >= repayAmount, \"!borrow>repay\");\n } else {\n /* The borrower must have shortfall in order to be liquidateable */\n (Error err, , , uint256 shortfall) = getHypotheticalAccountLiquidityInternal(\n borrower,\n ICErc20(address(0)),\n 0,\n 0,\n 0\n );\n if (err != Error.NO_ERROR) {\n return uint256(err);\n }\n\n if (shortfall == 0) {\n return uint256(Error.INSUFFICIENT_SHORTFALL);\n }\n\n /* The liquidator may not repay more than what is allowed by the closeFactor */\n uint256 maxClose = mul_ScalarTruncate(Exp({ mantissa: closeFactorMantissa }), borrowBalance);\n if (repayAmount > maxClose) {\n return uint256(Error.TOO_MUCH_REPAY);\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the seizing of assets should be allowed to occur\n * @param cTokenCollateral Asset which was used as collateral and will be seized\n * @param cTokenBorrowed Asset which was borrowed by the borrower\n * @param liquidator The address repaying the borrow and seizing the collateral\n * @param borrower The address of the borrower\n * @param seizeTokens The number of collateral tokens to seize\n */\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!seizeGuardianPaused, \"!seize:paused\");\n\n // Make sure markets are listed\n if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {\n return uint256(Error.MARKET_NOT_LISTED);\n }\n\n // Make sure cToken Comptrollers are identical\n if (ICErc20(cTokenCollateral).comptroller() != ICErc20(cTokenBorrowed).comptroller()) {\n return uint256(Error.COMPTROLLER_MISMATCH);\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cTokenCollateral, borrower, liquidator);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Checks if the account should be allowed to transfer tokens in the given market\n * @param cToken The market to verify the transfer against\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n * @param transferTokens The number of cTokens to transfer\n * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)\n */\n function transferAllowed(\n address cToken,\n address src,\n address dst,\n uint256 transferTokens\n ) external override returns (uint256) {\n // Pausing is a very serious situation - we revert to sound the alarms\n require(!transferGuardianPaused, \"!transfer:paused\");\n\n // Currently the only consideration is whether or not\n // the src is allowed to redeem this many tokens\n uint256 allowed = redeemAllowedInternal(cToken, src, transferTokens);\n if (allowed != uint256(Error.NO_ERROR)) {\n return allowed;\n }\n\n // Keep the flywheel moving\n flywheelPreTransferAction(cToken, src, dst);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Flywheel Hooks ***/\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreSupplierAction(cToken, supplier);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreBorrowerAction(cToken, borrower);\n }\n\n /**\n * @notice Keeps the flywheel moving pre-transfer and pre-seize\n * @param cToken The relevant market\n * @param src The account which sources the tokens\n * @param dst The account which receives the tokens\n */\n function flywheelPreTransferAction(address cToken, address src, address dst) internal {\n for (uint256 i = 0; i < rewardsDistributors.length; i++)\n IIonicFlywheel(rewardsDistributors[i]).flywheelPreTransferAction(cToken, src, dst);\n }\n\n /*** Liquidity/Liquidation Calculations ***/\n\n /**\n * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.\n * Note that `cTokenBalance` is the number of cTokens the account owns in the market,\n * whereas `borrowBalance` is the amount of underlying that the account has borrowed.\n */\n struct AccountLiquidityLocalVars {\n ICErc20 asset;\n uint256 sumCollateral;\n uint256 sumBorrowPlusEffects;\n uint256 cTokenBalance;\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n uint256 oraclePriceMantissa;\n Exp collateralFactor;\n Exp exchangeRate;\n Exp oraclePrice;\n Exp tokensToDenom;\n uint256 borrowCapForCollateral;\n uint256 borrowedAssetPrice;\n uint256 assetAsCollateralValueCap;\n }\n\n function getAccountLiquidity(address account) public view override returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(account, ICErc20(address(0)), 0, 0, 0);\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code (semi-opaque),\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256, uint256, uint256, uint256) {\n (\n Error err,\n uint256 collateralValue,\n uint256 liquidity,\n uint256 shortfall\n ) = getHypotheticalAccountLiquidityInternal(\n account,\n ICErc20(cTokenModify),\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n return (uint256(err), collateralValue, liquidity, shortfall);\n }\n\n /**\n * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed\n * @param cTokenModify The market to hypothetically redeem/borrow in\n * @param account The account to determine liquidity for\n * @param redeemTokens The number of tokens to hypothetically redeem\n * @param borrowAmount The amount of underlying to hypothetically borrow\n * @return (possible error code,\n hypothetical account collateral value,\n hypothetical account liquidity in excess of collateral requirements,\n * hypothetical account shortfall below collateral requirements)\n */\n function getHypotheticalAccountLiquidityInternal(\n address account,\n ICErc20 cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) internal view returns (Error, uint256, uint256, uint256) {\n AccountLiquidityLocalVars memory vars; // Holds all our calculation results\n\n if (address(cTokenModify) != address(0)) {\n vars.borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n }\n\n // For each asset the account is in\n for (uint256 i = 0; i < accountAssets[account].length; i++) {\n vars.asset = accountAssets[account][i];\n\n {\n // Read the balances and exchange rate from the cToken\n uint256 oErr;\n (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = vars.asset.getAccountSnapshot(\n account\n );\n if (oErr != 0) {\n // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades\n return (Error.SNAPSHOT_ERROR, 0, 0, 0);\n }\n }\n {\n vars.collateralFactor = Exp({ mantissa: markets[address(vars.asset)].collateralFactorMantissa });\n vars.exchangeRate = Exp({ mantissa: vars.exchangeRateMantissa });\n\n // Get the normalized price of the asset\n vars.oraclePriceMantissa = oracle.getUnderlyingPrice(vars.asset);\n if (vars.oraclePriceMantissa == 0) {\n return (Error.PRICE_ERROR, 0, 0, 0);\n }\n vars.oraclePrice = Exp({ mantissa: vars.oraclePriceMantissa });\n\n // Pre-compute a conversion factor from tokens -> ether (normalized price value)\n vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);\n }\n {\n // Exclude the asset-to-be-borrowed from the liquidity, except for when redeeming\n vars.assetAsCollateralValueCap = asComptrollerExtension().getAssetAsCollateralValueCap(\n vars.asset,\n cTokenModify,\n redeemTokens > 0,\n account\n );\n\n // accumulate the collateral value to sumCollateral\n uint256 assetCollateralValue = mul_ScalarTruncate(vars.tokensToDenom, vars.cTokenBalance);\n if (assetCollateralValue > vars.assetAsCollateralValueCap)\n assetCollateralValue = vars.assetAsCollateralValueCap;\n vars.sumCollateral += assetCollateralValue;\n }\n\n // sumBorrowPlusEffects += oraclePrice * borrowBalance\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n vars.borrowBalance,\n vars.sumBorrowPlusEffects\n );\n\n // Calculate effects of interacting with cTokenModify\n if (vars.asset == cTokenModify) {\n // redeem effect\n // sumBorrowPlusEffects += tokensToDenom * redeemTokens\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.tokensToDenom,\n redeemTokens,\n vars.sumBorrowPlusEffects\n );\n\n // borrow effect\n // sumBorrowPlusEffects += oraclePrice * borrowAmount\n vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(\n vars.oraclePrice,\n borrowAmount,\n vars.sumBorrowPlusEffects\n );\n\n uint256 repayEffect = mul_ScalarTruncate(vars.oraclePrice, repayAmount);\n if (repayEffect >= vars.sumBorrowPlusEffects) {\n vars.sumBorrowPlusEffects = 0;\n } else {\n vars.sumBorrowPlusEffects -= repayEffect;\n }\n }\n }\n\n // These are safe, as the underflow condition is checked first\n if (vars.sumCollateral > vars.sumBorrowPlusEffects) {\n return (Error.NO_ERROR, vars.sumCollateral, vars.sumCollateral - vars.sumBorrowPlusEffects, 0);\n } else {\n return (Error.NO_ERROR, vars.sumCollateral, 0, vars.sumBorrowPlusEffects - vars.sumCollateral);\n }\n }\n\n /**\n * @notice Calculate number of tokens of collateral asset to seize given an underlying amount\n * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)\n * @param cTokenBorrowed The address of the borrowed cToken\n * @param cTokenCollateral The address of the collateral cToken\n * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens\n * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)\n */\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 actualRepayAmount\n ) external view override returns (uint256, uint256) {\n /* Read oracle prices for borrowed and collateral markets */\n uint256 priceBorrowedMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenBorrowed));\n uint256 priceCollateralMantissa = oracle.getUnderlyingPrice(ICErc20(cTokenCollateral));\n if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {\n return (uint256(Error.PRICE_ERROR), 0);\n }\n\n /*\n * Get the exchange rate and calculate the number of collateral tokens to seize:\n * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral\n * seizeTokens = seizeAmount / exchangeRate\n * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)\n */\n ICErc20 collateralCToken = ICErc20(cTokenCollateral);\n uint256 exchangeRateMantissa = collateralCToken.exchangeRateCurrent();\n uint256 seizeTokens;\n Exp memory numerator;\n Exp memory denominator;\n Exp memory ratio;\n\n uint256 protocolSeizeShareMantissa = collateralCToken.protocolSeizeShareMantissa();\n uint256 feeSeizeShareMantissa = collateralCToken.feeSeizeShareMantissa();\n\n /*\n * The liquidation penalty includes\n * - the liquidator incentive\n * - the protocol fees (Ionic admin fees)\n * - the market fee\n */\n Exp memory totalPenaltyMantissa = add_(\n add_(Exp({ mantissa: liquidationIncentiveMantissa }), Exp({ mantissa: protocolSeizeShareMantissa })),\n Exp({ mantissa: feeSeizeShareMantissa })\n );\n\n numerator = mul_(totalPenaltyMantissa, Exp({ mantissa: priceBorrowedMantissa }));\n denominator = mul_(Exp({ mantissa: priceCollateralMantissa }), Exp({ mantissa: exchangeRateMantissa }));\n ratio = div_(numerator, denominator);\n\n seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);\n return (uint256(Error.NO_ERROR), seizeTokens);\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Add a RewardsDistributor contracts.\n * @dev Admin function to add a RewardsDistributor contract\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _addRewardsDistributor(address distributor) external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n\n // Check marker method\n require(IIonicFlywheel(distributor).isRewardsDistributor(), \"!isRewardsDistributor\");\n\n // Check for existing RewardsDistributor\n for (uint256 i = 0; i < rewardsDistributors.length; i++) require(distributor != rewardsDistributors[i], \"!added\");\n\n // Add RewardsDistributor to array\n rewardsDistributors.push(distributor);\n emit AddedRewardsDistributor(distributor);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist enforcement for the comptroller\n * @dev Admin function to set a new whitelist enforcement boolean\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistEnforcement(bool enforce) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_ENFORCEMENT_OWNER_CHECK);\n }\n\n // Check if `enforceWhitelist` already equals `enforce`\n if (enforceWhitelist == enforce) {\n return uint256(Error.NO_ERROR);\n }\n\n // Set comptroller's `enforceWhitelist` to `enforce`\n enforceWhitelist = enforce;\n\n // Emit WhitelistEnforcementChanged(bool enforce);\n emit WhitelistEnforcementChanged(enforce);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the whitelist `statuses` for `suppliers`\n * @dev Admin function to set the whitelist `statuses` for `suppliers`\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_WHITELIST_STATUS_OWNER_CHECK);\n }\n\n // Set whitelist statuses for suppliers\n for (uint256 i = 0; i < suppliers.length; i++) {\n address supplier = suppliers[i];\n\n if (statuses[i]) {\n // If not already whitelisted, add to whitelist\n if (!whitelist[supplier]) {\n whitelist[supplier] = true;\n whitelistArray.push(supplier);\n whitelistIndexes[supplier] = whitelistArray.length - 1;\n }\n } else {\n // If whitelisted, remove from whitelist\n if (whitelist[supplier]) {\n whitelistArray[whitelistIndexes[supplier]] = whitelistArray[whitelistArray.length - 1]; // Copy last item in list to location of item to be removed\n whitelistArray.pop(); // Reduce length by 1\n whitelistIndexes[whitelistArray[whitelistIndexes[supplier]]] = whitelistIndexes[supplier]; // Set whitelist index of moved item to correct index\n whitelistIndexes[supplier] = 0; // Reset supplier whitelist index to 0 for a gas refund\n whitelist[supplier] = false; // Tell the contract that the supplier is no longer whitelisted\n }\n }\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets a new price oracle for the comptroller\n * @dev Admin function to set a new price oracle\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPriceOracle(BasePriceOracle newOracle) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK);\n }\n\n // Track the old oracle for the comptroller\n BasePriceOracle oldOracle = oracle;\n\n // Set comptroller's oracle to newOracle\n oracle = newOracle;\n\n // Emit NewPriceOracle(oldOracle, newOracle)\n emit NewPriceOracle(oldOracle, newOracle);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the closeFactor used when liquidating borrows\n * @dev Admin function to set closeFactor\n * @param newCloseFactorMantissa New close factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK);\n }\n\n // Check limits\n Exp memory newCloseFactorExp = Exp({ mantissa: newCloseFactorMantissa });\n Exp memory lowLimit = Exp({ mantissa: closeFactorMinMantissa });\n if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n Exp memory highLimit = Exp({ mantissa: closeFactorMaxMantissa });\n if (lessThanExp(highLimit, newCloseFactorExp)) {\n return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION);\n }\n\n // Set pool close factor to new close factor, remember old value\n uint256 oldCloseFactorMantissa = closeFactorMantissa;\n closeFactorMantissa = newCloseFactorMantissa;\n\n // Emit event\n emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets the collateralFactor for a market\n * @dev Admin function to set per-market collateralFactor\n * @param cToken The market to set the factor on\n * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setCollateralFactor(ICErc20 cToken, uint256 newCollateralFactorMantissa) public returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);\n }\n\n // Verify market is listed\n Market storage market = markets[address(cToken)];\n if (!market.isListed) {\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);\n }\n\n Exp memory newCollateralFactorExp = Exp({ mantissa: newCollateralFactorMantissa });\n\n // Check collateral factor <= 0.9\n Exp memory highLimit = Exp({ mantissa: collateralFactorMaxMantissa });\n if (lessThanExp(highLimit, newCollateralFactorExp)) {\n return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);\n }\n\n // If collateral factor != 0, fail if price == 0\n if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) {\n return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);\n }\n\n // Set market's collateral factor to new collateral factor, remember old value\n uint256 oldCollateralFactorMantissa = market.collateralFactorMantissa;\n market.collateralFactorMantissa = newCollateralFactorMantissa;\n\n // Emit event with asset, old collateral factor, and new collateral factor\n emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sets liquidationIncentive\n * @dev Admin function to set liquidationIncentive\n * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18\n * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)\n */\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK);\n }\n\n // Check de-scaled min <= newLiquidationIncentive <= max\n Exp memory newLiquidationIncentive = Exp({ mantissa: newLiquidationIncentiveMantissa });\n Exp memory minLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMinMantissa });\n if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n Exp memory maxLiquidationIncentive = Exp({ mantissa: liquidationIncentiveMaxMantissa });\n if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) {\n return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);\n }\n\n // Save current value for use in log\n uint256 oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;\n\n // Set liquidation incentive to new incentive\n liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;\n\n // Emit event with old incentive, new incentive\n emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Add the market to the markets mapping and set it as listed\n * @dev Admin function to set isListed and add support for the market\n * @param cToken The address of the market (token) to list\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _supportMarket(ICErc20 cToken) internal returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Is market already listed?\n if (markets[address(cToken)].isListed) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // Check cToken.comptroller == this\n require(address(cToken.comptroller()) == address(this), \"!comptroller\");\n\n // Make sure market is not already listed\n address underlying = ICErc20(address(cToken)).underlying();\n\n if (address(cTokensByUnderlying[underlying]) != address(0)) {\n return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS);\n }\n\n // List market and emit event\n Market storage market = markets[address(cToken)];\n market.isListed = true;\n market.collateralFactorMantissa = 0;\n allMarkets.push(cToken);\n cTokensByUnderlying[underlying] = cToken;\n emit MarketListed(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Deploy cToken, add the market to the markets mapping, and set it as listed and set the collateral factor\n * @dev Admin function to deploy cToken, set isListed, and add support for the market and set the collateral factor\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _deployMarket(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK);\n }\n\n // Temporarily enable Ionic admin rights for asset deployment (storing the original value)\n bool oldIonicAdminHasRights = ionicAdminHasRights;\n ionicAdminHasRights = true;\n\n // Deploy via Ionic admin\n ICErc20 cToken = ICErc20(IFeeDistributor(ionicAdmin).deployCErc20(delegateType, constructorData, becomeImplData));\n // Reset Ionic admin rights to the original value\n ionicAdminHasRights = oldIonicAdminHasRights;\n // Support market here in the Comptroller\n uint256 err = _supportMarket(cToken);\n\n IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));\n\n // Set collateral factor\n return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;\n }\n\n function _becomeImplementation() external {\n require(msg.sender == address(this), \"!self call\");\n\n if (!_notEnteredInitialized) {\n _notEntered = true;\n _notEnteredInitialized = true;\n }\n }\n\n /*** Helper Functions ***/\n\n /**\n * @notice Returns true if the given cToken market has been deprecated\n * @dev All borrows in a deprecated cToken market can be immediately liquidated\n * @param cToken The market to check if deprecated\n */\n function isDeprecated(ICErc20 cToken) public view returns (bool) {\n return\n markets[address(cToken)].collateralFactorMantissa == 0 &&\n borrowGuardianPaused[address(cToken)] == true &&\n add_(add_(cToken.reserveFactorMantissa(), cToken.adminFeeMantissa()), cToken.ionicFeeMantissa()) == 1e18;\n }\n\n function asComptrollerExtension() internal view returns (ComptrollerExtensionInterface) {\n return ComptrollerExtensionInterface(address(this));\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory functionSelectors) {\n uint8 fnsCount = 32;\n\n functionSelectors = new bytes4[](fnsCount);\n\n functionSelectors[--fnsCount] = this.isDeprecated.selector;\n functionSelectors[--fnsCount] = this._deployMarket.selector;\n functionSelectors[--fnsCount] = this.getAssetsIn.selector;\n functionSelectors[--fnsCount] = this.checkMembership.selector;\n functionSelectors[--fnsCount] = this._setPriceOracle.selector;\n functionSelectors[--fnsCount] = this._setCloseFactor.selector;\n functionSelectors[--fnsCount] = this._setCollateralFactor.selector;\n functionSelectors[--fnsCount] = this._setLiquidationIncentive.selector;\n functionSelectors[--fnsCount] = this._setWhitelistEnforcement.selector;\n functionSelectors[--fnsCount] = this._setWhitelistStatuses.selector;\n functionSelectors[--fnsCount] = this._addRewardsDistributor.selector;\n functionSelectors[--fnsCount] = this.getHypotheticalAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.getMaxRedeemOrBorrow.selector;\n functionSelectors[--fnsCount] = this.enterMarkets.selector;\n functionSelectors[--fnsCount] = this.exitMarket.selector;\n functionSelectors[--fnsCount] = this.mintAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemAllowed.selector;\n functionSelectors[--fnsCount] = this.redeemVerify.selector;\n functionSelectors[--fnsCount] = this.borrowAllowed.selector;\n functionSelectors[--fnsCount] = this.borrowWithinLimits.selector;\n functionSelectors[--fnsCount] = this.repayBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrowAllowed.selector;\n functionSelectors[--fnsCount] = this.seizeAllowed.selector;\n functionSelectors[--fnsCount] = this.transferAllowed.selector;\n functionSelectors[--fnsCount] = this.mintVerify.selector;\n functionSelectors[--fnsCount] = this.getAccountLiquidity.selector;\n functionSelectors[--fnsCount] = this.liquidateCalculateSeizeTokens.selector;\n functionSelectors[--fnsCount] = this._beforeNonReentrant.selector;\n functionSelectors[--fnsCount] = this._afterNonReentrant.selector;\n functionSelectors[--fnsCount] = this._becomeImplementation.selector;\n functionSelectors[--fnsCount] = this.effectiveSupplyCaps.selector;\n functionSelectors[--fnsCount] = this.effectiveBorrowCaps.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n }\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n /**\n * @dev Called by cTokens before a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _beforeNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_beforeNonReentrant\");\n require(_notEntered, \"!reentered\");\n _notEntered = false;\n }\n\n /**\n * @dev Called by cTokens after a non-reentrant function for pool-wide reentrancy prevention.\n * Prevents pool-wide/cross-asset reentrancy exploits like AMP on Cream.\n */\n function _afterNonReentrant() external override {\n require(markets[msg.sender].isListed, \"!Comptroller:_afterNonReentrant\");\n _notEntered = true; // get a gas-refund post-Istanbul\n }\n}\n" + }, + "contracts/compound/ComptrollerFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from \"./ComptrollerInterface.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ComptrollerFirstExtension is\n DiamondExtension,\n ComptrollerBase,\n ComptrollerExtensionInterface,\n ComptrollerErrorReporter\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /// @notice Emitted when supply cap for a cToken is changed\n event NewSupplyCap(ICErc20 indexed cToken, uint256 newSupplyCap);\n\n /// @notice Emitted when borrow cap for a cToken is changed\n event NewBorrowCap(ICErc20 indexed cToken, uint256 newBorrowCap);\n\n /// @notice Emitted when borrow cap guardian is changed\n event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);\n\n /// @notice Emitted when pause guardian is changed\n event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);\n\n /// @notice Emitted when an action is paused globally\n event ActionPaused(string action, bool pauseState);\n\n /// @notice Emitted when an action is paused on a market\n event MarketActionPaused(ICErc20 cToken, string action, bool pauseState);\n\n /// @notice Emitted when an admin unsupports a market\n event MarketUnlisted(ICErc20 cToken);\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 33;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector;\n functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector;\n functionSelectors[--fnsCount] = this._setMarketBorrowCaps.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateralWhitelist.selector;\n functionSelectors[--fnsCount] = this._supplyCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._borrowCapWhitelist.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapGuardian.selector;\n functionSelectors[--fnsCount] = this._setPauseGuardian.selector;\n functionSelectors[--fnsCount] = this._setMintPaused.selector;\n functionSelectors[--fnsCount] = this._setBorrowPaused.selector;\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this._unsupportMarket.selector;\n functionSelectors[--fnsCount] = this.getAllMarkets.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowers.selector;\n functionSelectors[--fnsCount] = this.getAllBorrowersCount.selector;\n functionSelectors[--fnsCount] = this.getPaginatedBorrowers.selector;\n functionSelectors[--fnsCount] = this.getWhitelist.selector;\n functionSelectors[--fnsCount] = this.getRewardsDistributors.selector;\n functionSelectors[--fnsCount] = this.isUserOfPool.selector;\n functionSelectors[--fnsCount] = this.getAccruingFlywheels.selector;\n functionSelectors[--fnsCount] = this._removeFlywheel.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapForCollateral.selector;\n functionSelectors[--fnsCount] = this._blacklistBorrowingAgainstCollateral.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapForCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBlacklistBorrowingAgainstCollateralWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isSupplyCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.isBorrowCapWhitelisted.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector;\n functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /**\n * @notice Returns true if the accruing flyhwheel was found and replaced\n * @dev Adds a flywheel to the non-accruing list and if already in the accruing, removes it from that list\n * @param flywheelAddress The address of the flywheel to add to the non-accruing\n */\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n require(flywheelAddress != nonAccruingRewardsDistributors[i], \"!alreadyadded\");\n }\n\n // add it to the non-accruing\n nonAccruingRewardsDistributors.push(flywheelAddress);\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256) {\n if (address(collateral) == address(cTokenModify) && !redeeming) {\n // the collateral asset counts as 0 liquidity when borrowed\n return 0;\n }\n\n uint256 assetAsCollateralValueCap = type(uint256).max;\n if (address(cTokenModify) != address(0)) {\n // if the borrowed asset is blacklisted against this collateral & account is not whitelisted\n if (\n borrowingAgainstCollateralBlacklist[address(cTokenModify)][address(collateral)] &&\n !borrowingAgainstCollateralBlacklistWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n assetAsCollateralValueCap = 0;\n } else {\n // for each user the value of this kind of collateral is capped regardless of the amount borrowed\n // denominated in the borrowed asset\n uint256 borrowCapForCollateral = borrowCapForCollateral[address(cTokenModify)][address(collateral)];\n // check if set to any value & account is not whitelisted\n if (\n borrowCapForCollateral != 0 &&\n !borrowCapForCollateralWhitelist[address(cTokenModify)][address(collateral)].contains(account)\n ) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(cTokenModify);\n // this asset usage as collateral is capped at the native value of the borrow cap\n assetAsCollateralValueCap = (borrowCapForCollateral * borrowedAssetPrice) / 1e18;\n }\n }\n }\n\n uint256 supplyCap = effectiveSupplyCaps(address(collateral));\n\n // if there is any supply cap, don't allow donations to the market/plugin to go around it\n if (supplyCap > 0 && !supplyCapWhitelist[address(collateral)].contains(account)) {\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateral);\n uint256 supplyCapValue = (supplyCap * collateralAssetPrice) / 1e18;\n supplyCapValue = (supplyCapValue * markets[address(collateral)].collateralFactorMantissa) / 1e18;\n if (supplyCapValue < assetAsCollateralValueCap) assetAsCollateralValueCap = supplyCapValue;\n }\n\n return assetAsCollateralValueCap;\n }\n\n /**\n * @notice Set the given supply caps for the given cToken markets. Supplying that brings total underlying supply to or above supply cap will revert.\n * @dev Admin or borrowCapGuardian function to set the supply caps. A supply cap of 0 corresponds to unlimited supplying.\n * @param cTokens The addresses of the markets (tokens) to change the supply caps for\n * @param newSupplyCaps The new supply cap values in underlying to be set. A value of 0 corresponds to unlimited supplying.\n */\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numSupplyCaps = newSupplyCaps.length;\n\n require(numMarkets != 0 && numMarkets == numSupplyCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n supplyCaps[address(cTokens[i])] = newSupplyCaps[i];\n emit NewSupplyCap(cTokens[i], newSupplyCaps[i]);\n }\n }\n\n /**\n * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.\n * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.\n * @param cTokens The addresses of the markets (tokens) to change the borrow caps for\n * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.\n */\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n uint256 numMarkets = cTokens.length;\n uint256 numBorrowCaps = newBorrowCaps.length;\n\n require(numMarkets != 0 && numMarkets == numBorrowCaps, \"!input\");\n\n for (uint256 i = 0; i < numMarkets; i++) {\n borrowCaps[address(cTokens[i])] = newBorrowCaps[i];\n emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);\n }\n }\n\n /**\n * @notice Admin function to change the Borrow Cap Guardian\n * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian\n */\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external {\n require(msg.sender == admin, \"!admin\");\n\n // Save current value for inclusion in log\n address oldBorrowCapGuardian = borrowCapGuardian;\n\n // Store borrowCapGuardian with value newBorrowCapGuardian\n borrowCapGuardian = newBorrowCapGuardian;\n\n // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)\n emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);\n }\n\n /**\n * @notice Admin function to change the Pause Guardian\n * @param newPauseGuardian The address of the new Pause Guardian\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _setPauseGuardian(address newPauseGuardian) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);\n }\n\n // Save current value for inclusion in log\n address oldPauseGuardian = pauseGuardian;\n\n // Store pauseGuardian with value newPauseGuardian\n pauseGuardian = newPauseGuardian;\n\n // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)\n emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setMintPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n mintGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Mint\", state);\n return state;\n }\n\n function _setBorrowPaused(ICErc20 cToken, bool state) public returns (bool) {\n require(markets[address(cToken)].isListed, \"!market\");\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n borrowGuardianPaused[address(cToken)] = state;\n emit MarketActionPaused(cToken, \"Borrow\", state);\n return state;\n }\n\n function _setTransferPaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n transferGuardianPaused = state;\n emit ActionPaused(\"Transfer\", state);\n return state;\n }\n\n function _setSeizePaused(bool state) public returns (bool) {\n require(msg.sender == pauseGuardian || hasAdminRights(), \"!guardian\");\n require(hasAdminRights() || state == true, \"!admin\");\n\n seizeGuardianPaused = state;\n emit ActionPaused(\"Seize\", state);\n return state;\n }\n\n /**\n * @notice Removed a market from the markets mapping and sets it as unlisted\n * @dev Admin function unset isListed and collateralFactorMantissa and unadd support for the market\n * @param cToken The address of the market (token) to unlist\n * @return uint 0=success, otherwise a failure. (See enum Error for details)\n */\n function _unsupportMarket(ICErc20 cToken) external returns (uint256) {\n // Check admin rights\n if (!hasAdminRights()) return fail(Error.UNAUTHORIZED, FailureInfo.UNSUPPORT_MARKET_OWNER_CHECK);\n\n // Check if market is already unlisted\n if (!markets[address(cToken)].isListed)\n return fail(Error.MARKET_NOT_LISTED, FailureInfo.UNSUPPORT_MARKET_DOES_NOT_EXIST);\n\n // Check if market is in use\n if (cToken.totalSupply() > 0) return fail(Error.NONZERO_TOTAL_SUPPLY, FailureInfo.UNSUPPORT_MARKET_IN_USE);\n\n // Unlist market\n delete markets[address(cToken)];\n\n /* Delete cToken from allMarkets */\n // load into memory for faster iteration\n ICErc20[] memory _allMarkets = allMarkets;\n uint256 len = _allMarkets.length;\n uint256 assetIndex = len;\n for (uint256 i = 0; i < len; i++) {\n if (_allMarkets[i] == cToken) {\n assetIndex = i;\n break;\n }\n }\n\n // We *must* have found the asset in the list or our redundant data structure is broken\n assert(assetIndex < len);\n\n // copy last item in list to location of item to be removed, reduce length by 1\n allMarkets[assetIndex] = allMarkets[allMarkets.length - 1];\n allMarkets.pop();\n\n cTokensByUnderlying[ICErc20(address(cToken)).underlying()] = ICErc20(address(0));\n emit MarketUnlisted(cToken);\n\n return uint256(Error.NO_ERROR);\n }\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) public {\n require(hasAdminRights(), \"!admin\");\n borrowCapForCollateral[cTokenBorrow][cTokenCollateral] = borrowCap;\n }\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowCapForCollateralWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n borrowingAgainstCollateralBlacklist[cTokenBorrow][cTokenCollateral] = blacklisted;\n }\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].add(account);\n else borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].remove(account);\n }\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) public view returns (bool) {\n return borrowingAgainstCollateralBlacklistWhitelist[cTokenBorrow][cTokenCollateral].contains(account);\n }\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) supplyCapWhitelist[cToken].add(account);\n else supplyCapWhitelist[cToken].remove(account);\n }\n\n function isSupplyCapWhitelisted(address cToken, address account) public view returns (bool) {\n return supplyCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedSuppliersSupply(address cToken) public view returns (uint256 supplied) {\n address[] memory whitelistedSuppliers = supplyCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedSuppliers.length; i++) {\n supplied += ICErc20(cToken).balanceOfUnderlying(whitelistedSuppliers[i]);\n }\n }\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) public {\n require(hasAdminRights(), \"!admin\");\n\n if (whitelisted) borrowCapWhitelist[cToken].add(account);\n else borrowCapWhitelist[cToken].remove(account);\n }\n\n function isBorrowCapWhitelisted(address cToken, address account) public view returns (bool) {\n return borrowCapWhitelist[cToken].contains(account);\n }\n\n function getWhitelistedBorrowersBorrows(address cToken) public view returns (uint256 borrowed) {\n address[] memory whitelistedBorrowers = borrowCapWhitelist[cToken].values();\n for (uint256 i = 0; i < whitelistedBorrowers.length; i++) {\n borrowed += ICErc20(cToken).borrowBalanceCurrent(whitelistedBorrowers[i]);\n }\n }\n\n /**\n * @notice Return all of the markets\n * @dev The automatic getter may be used to access an individual market.\n * @return The list of market addresses\n */\n function getAllMarkets() public view returns (ICErc20[] memory) {\n return allMarkets;\n }\n\n /**\n * @notice Return all of the borrowers\n * @dev The automatic getter may be used to access an individual borrower.\n * @return The list of borrower account addresses\n */\n function getAllBorrowers() public view returns (address[] memory) {\n return allBorrowers;\n }\n\n function getAllBorrowersCount() public view returns (uint256) {\n return allBorrowers.length;\n }\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) public view returns (uint256 _totalPages, address[] memory _pageOfBorrowers) {\n uint256 allBorrowersCount = allBorrowers.length;\n if (allBorrowersCount == 0) {\n return (0, new address[](0));\n }\n\n if (pageSize == 0) pageSize = 300;\n uint256 currentPageSize = pageSize;\n uint256 sizeOfPageFromRemainder = allBorrowersCount % pageSize;\n\n _totalPages = allBorrowersCount / pageSize;\n if (sizeOfPageFromRemainder > 0) {\n _totalPages++;\n if (page + 1 == _totalPages) {\n currentPageSize = sizeOfPageFromRemainder;\n }\n }\n\n if (page + 1 > _totalPages) {\n return (_totalPages, new address[](0));\n }\n\n uint256 offset = page * pageSize;\n _pageOfBorrowers = new address[](currentPageSize);\n for (uint256 i = 0; i < currentPageSize; i++) {\n _pageOfBorrowers[i] = allBorrowers[i + offset];\n }\n }\n\n /**\n * @notice Return all of the whitelist\n * @dev The automatic getter may be used to access an individual whitelist status.\n * @return The list of borrower account addresses\n */\n function getWhitelist() external view returns (address[] memory) {\n return whitelistArray;\n }\n\n /**\n * @notice Returns an array of all accruing and non-accruing flywheels\n */\n function getRewardsDistributors() external view returns (address[] memory) {\n address[] memory allFlywheels = new address[](rewardsDistributors.length + nonAccruingRewardsDistributors.length);\n\n uint8 i = 0;\n while (i < rewardsDistributors.length) {\n allFlywheels[i] = rewardsDistributors[i];\n i++;\n }\n uint8 j = 0;\n while (j < nonAccruingRewardsDistributors.length) {\n allFlywheels[i + j] = nonAccruingRewardsDistributors[j];\n j++;\n }\n\n return allFlywheels;\n }\n\n function getAccruingFlywheels() external view returns (address[] memory) {\n return rewardsDistributors;\n }\n\n /**\n * @dev Removes a flywheel from the accruing or non-accruing array\n * @param flywheelAddress The address of the flywheel to remove from the accruing or non-accruing array\n * @return true if the flywheel was found and removed\n */\n function _removeFlywheel(address flywheelAddress) external returns (bool) {\n require(hasAdminRights(), \"!admin\");\n require(flywheelAddress != address(0), \"!flywheel\");\n\n // remove it from the accruing\n for (uint256 i = 0; i < rewardsDistributors.length; i++) {\n if (flywheelAddress == rewardsDistributors[i]) {\n rewardsDistributors[i] = rewardsDistributors[rewardsDistributors.length - 1];\n rewardsDistributors.pop();\n return true;\n }\n }\n\n // or remove it from the non-accruing\n for (uint256 i = 0; i < nonAccruingRewardsDistributors.length; i++) {\n if (flywheelAddress == nonAccruingRewardsDistributors[i]) {\n nonAccruingRewardsDistributors[i] = nonAccruingRewardsDistributors[nonAccruingRewardsDistributors.length - 1];\n nonAccruingRewardsDistributors.pop();\n return true;\n }\n }\n\n return false;\n }\n\n function isUserOfPool(address user) external view returns (bool) {\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address marketAddress = address(allMarkets[i]);\n if (markets[marketAddress].accountMembership[user]) {\n return true;\n }\n }\n\n return false;\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights(), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n\n for (uint256 i = 0; i < allMarkets.length; i++) {\n allMarkets[i].registerInSFS();\n }\n\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/ComptrollerInterface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BasePriceOracle } from \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerV4Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\nimport { IHistoricalRates } from \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\ninterface ComptrollerInterface {\n function isDeprecated(ICErc20 cToken) external view returns (bool);\n\n function _becomeImplementation() external;\n\n function _deployMarket(\n uint8 delegateType,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getAssetsIn(address account) external view returns (ICErc20[] memory);\n\n function checkMembership(address account, ICErc20 cToken) external view returns (bool);\n\n function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _addRewardsDistributor(address distributor) external returns (uint256);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) external view returns (uint256, uint256, uint256, uint256);\n\n function getMaxRedeemOrBorrow(address account, ICErc20 cToken, bool isBorrow) external view returns (uint256);\n\n /*** Assets You Are In ***/\n\n function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cToken) external returns (uint256);\n\n /*** Policy Hooks ***/\n\n function mintAllowed(address cToken, address minter, uint256 mintAmount) external returns (uint256);\n\n function redeemAllowed(address cToken, address redeemer, uint256 redeemTokens) external returns (uint256);\n\n function redeemVerify(address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens) external;\n\n function borrowAllowed(address cToken, address borrower, uint256 borrowAmount) external returns (uint256);\n\n function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);\n\n function repayBorrowAllowed(\n address cToken,\n address payer,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function liquidateBorrowAllowed(\n address cTokenBorrowed,\n address cTokenCollateral,\n address liquidator,\n address borrower,\n uint256 repayAmount\n ) external returns (uint256);\n\n function seizeAllowed(\n address cTokenCollateral,\n address cTokenBorrowed,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n function transferAllowed(address cToken, address src, address dst, uint256 transferTokens) external returns (uint256);\n\n function mintVerify(address cToken, address minter, uint256 actualMintAmount, uint256 mintTokens) external;\n\n /*** Liquidity/Liquidation Calculations ***/\n\n function getAccountLiquidity(\n address account\n ) external view returns (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall);\n\n function liquidateCalculateSeizeTokens(\n address cTokenBorrowed,\n address cTokenCollateral,\n uint256 repayAmount\n ) external view returns (uint256, uint256);\n\n /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/\n\n function _beforeNonReentrant() external;\n\n function _afterNonReentrant() external;\n\n /*** New supply and borrow cap view functions ***/\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) external view returns (uint256 supplyCap);\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) external view returns (uint256 borrowCap);\n}\n\ninterface ComptrollerStorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function pendingAdmin() external view returns (address);\n\n function oracle() external view returns (BasePriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function enforceWhitelist() external view returns (bool);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function suppliers(address account) external view returns (bool);\n\n function cTokensByUnderlying(address) external view returns (address);\n\n /**\n * Gets the supply cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the supply cap. Instead, use\n * `effectiveSupplyCaps` to get the correct supply cap.\n * @param cToken The address of the cToken.\n * @return The supply cap in the units of the underlying asset.\n */\n function supplyCaps(address cToken) external view returns (uint256);\n\n /**\n * Gets the borrow cap of a cToken in the units of the underlying asset.\n * @dev WARNING: This function is misleading if Adrastia Prudentia is being used for the borrow cap. Instead, use\n * `effectiveBorrowCaps` to get the correct borrow cap.\n * @param cToken The address of the cToken.\n * @return The borrow cap in the units of the underlying asset.\n */\n function borrowCaps(address cToken) external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function accountAssets(address, uint256) external view returns (address);\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function rewardsDistributors(uint256) external view returns (address);\n}\n\ninterface SFSRegister {\n function register(address _recipient) external returns (uint256 tokenId);\n}\n\ninterface ComptrollerExtensionInterface {\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function getAllBorrowersCount() external view returns (uint256);\n\n function getPaginatedBorrowers(\n uint256 page,\n uint256 pageSize\n ) external view returns (uint256 _totalPages, address[] memory _pageOfBorrowers);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAccruingFlywheels() external view returns (address[] memory);\n\n function _supplyCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function _setBorrowCapForCollateral(address cTokenBorrow, address cTokenCollateral, uint256 borrowCap) external;\n\n function _setBorrowCapForCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBorrowCapForCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function _blacklistBorrowingAgainstCollateral(\n address cTokenBorrow,\n address cTokenCollateral,\n bool blacklisted\n ) external;\n\n function _blacklistBorrowingAgainstCollateralWhitelist(\n address cTokenBorrow,\n address cTokenCollateral,\n address account,\n bool whitelisted\n ) external;\n\n function isBlacklistBorrowingAgainstCollateralWhitelisted(\n address cTokenBorrow,\n address cTokenCollateral,\n address account\n ) external view returns (bool);\n\n function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _borrowCapWhitelist(address cToken, address account, bool whitelisted) external;\n\n function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);\n\n function _removeFlywheel(address flywheelAddress) external returns (bool);\n\n function getWhitelist() external view returns (address[] memory);\n\n function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);\n\n function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;\n\n function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;\n\n function _setBorrowCapGuardian(address newBorrowCapGuardian) external;\n\n function _setPauseGuardian(address newPauseGuardian) external returns (uint256);\n\n function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);\n\n function _setTransferPaused(bool state) external returns (bool);\n\n function _setSeizePaused(bool state) external returns (bool);\n\n function _unsupportMarket(ICErc20 cToken) external returns (uint256);\n\n function getAssetAsCollateralValueCap(\n ICErc20 collateral,\n ICErc20 cTokenModify,\n bool redeeming,\n address account\n ) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Retrieves Adrastia Prudentia borrow cap config from storage.\n * @return The config.\n */\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Retrieves Adrastia Prudentia supply cap config from storage.\n * @return The config.\n */\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory);\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native supply caps.\n * @param newConfig The new config.\n */\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n\n /**\n * @notice Sets the Adrastia Prudentia supply cap config.\n * @dev Specifying a zero address for the `controller` parameter will make the Comptroller use the native borrow caps.\n * @param newConfig The new config.\n */\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external;\n}\n\ninterface UnitrollerInterface {\n function comptrollerImplementation() external view returns (address);\n\n function _upgrade() external;\n\n function _acceptAdmin() external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n\n function _toggleAdminRights(bool hasRights) external returns (uint256);\n}\n\ninterface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}\n\n//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}\n\ninterface IonicComptroller is\n ComptrollerInterface,\n ComptrollerExtensionInterface,\n UnitrollerInterface,\n ComptrollerStorageInterface\n{\n\n}\n\nabstract contract ComptrollerBase is ComptrollerV4Storage {\n /// @notice Indicator that this is a Comptroller contract (for inspection)\n bool public constant isComptroller = true;\n\n /**\n * @notice Gets the supply cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveSupplyCaps(address cToken) public view virtual returns (uint256 supplyCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = supplyCapConfig;\n\n // Check if we're using Adrastia Prudentia for the supply cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the supply cap from Adrastia Prudentia\n supplyCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n supplyCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n supplyCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local supply cap\n\n // Get the supply cap from the local supply cap\n supplyCap = supplyCaps[cToken];\n }\n }\n\n /**\n * @notice Gets the borrow cap of a cToken in the units of the underlying asset.\n * @param cToken The address of the cToken.\n */\n function effectiveBorrowCaps(address cToken) public view virtual returns (uint256 borrowCap) {\n PrudentiaLib.PrudentiaConfig memory capConfig = borrowCapConfig;\n\n // Check if we're using Adrastia Prudentia for the borrow cap\n if (capConfig.controller != address(0)) {\n // We have a controller, so we're using Adrastia Prudentia\n\n address underlyingToken = ICErc20(cToken).underlying();\n\n // Get the borrow cap from Adrastia Prudentia\n borrowCap = IHistoricalRates(capConfig.controller).getRateAt(underlyingToken, capConfig.offset).current;\n\n // Prudentia trims decimal points from amounts while our code requires the mantissa amount, so we\n // must scale the supply cap to get the correct amount\n\n int256 scaleByDecimals = 18;\n // Not all ERC20s implement decimals(), so we use a staticcall and check the return data\n (bool success, bytes memory data) = underlyingToken.staticcall(abi.encodeWithSignature(\"decimals()\"));\n if (success && data.length == 32) {\n scaleByDecimals = int256(uint256(abi.decode(data, (uint8))));\n }\n\n scaleByDecimals += capConfig.decimalShift;\n\n if (scaleByDecimals >= 0) {\n // We're scaling up, so we need to multiply\n borrowCap *= 10 ** uint256(scaleByDecimals);\n } else {\n // We're scaling down, so we need to divide\n borrowCap /= 10 ** uint256(-scaleByDecimals);\n }\n } else {\n // We don't have a controller, so we're using the local borrow cap\n borrowCap = borrowCaps[cToken];\n }\n }\n}\n" + }, + "contracts/compound/ComptrollerPrudentiaCapsExt.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { ComptrollerPrudentiaCapsExtInterface, ComptrollerBase } from \"./ComptrollerInterface.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\n/**\n * @title ComptrollerPrudentiaCapsExt\n * @author Tyler Loewen (TRILEZ SOFTWARE INC. dba. Adrastia)\n * @notice A diamond extension that allows the Comptroller to use Adrastia Prudentia to control supply and borrow caps.\n */\ncontract ComptrollerPrudentiaCapsExt is DiamondExtension, ComptrollerBase, ComptrollerPrudentiaCapsExtInterface {\n /**\n * @notice Emitted when the Adrastia Prudentia supply cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /**\n * @notice Emitted when the Adrastia Prudentia borrow cap config is changed.\n * @param oldConfig The old config.\n * @param newConfig The new config.\n */\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setSupplyCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = supplyCapConfig;\n supplyCapConfig = newConfig;\n\n emit NewSupplyCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function _setBorrowCapConfig(PrudentiaLib.PrudentiaConfig calldata newConfig) external {\n require(msg.sender == admin || msg.sender == borrowCapGuardian, \"!admin\");\n\n PrudentiaLib.PrudentiaConfig memory oldConfig = borrowCapConfig;\n borrowCapConfig = newConfig;\n\n emit NewBorrowCapConfig(oldConfig, newConfig);\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getBorrowCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return borrowCapConfig;\n }\n\n /// @inheritdoc ComptrollerPrudentiaCapsExtInterface\n function getSupplyCapConfig() external view returns (PrudentiaLib.PrudentiaConfig memory) {\n return supplyCapConfig;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setSupplyCapConfig.selector;\n functionSelectors[--fnsCount] = this._setBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getBorrowCapConfig.selector;\n functionSelectors[--fnsCount] = this.getSupplyCapConfig.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n" + }, + "contracts/compound/ComptrollerStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IFeeDistributor.sol\";\nimport \"../oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { PrudentiaLib } from \"../adrastia/PrudentiaLib.sol\";\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract UnitrollerAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n\n /**\n * @notice Administrator for this contract\n */\n address public admin;\n\n /**\n * @notice Pending administrator for this contract\n */\n address public pendingAdmin;\n\n /**\n * @notice Whether or not the Ionic admin has admin rights\n */\n bool public ionicAdminHasRights = true;\n\n /**\n * @notice Whether or not the admin has admin rights\n */\n bool public adminHasRights = true;\n\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);\n }\n}\n\ncontract ComptrollerV1Storage is UnitrollerAdminStorage {\n /**\n * @notice Oracle which gives the price of any given asset\n */\n BasePriceOracle public oracle;\n\n /**\n * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow\n */\n uint256 public closeFactorMantissa;\n\n /**\n * @notice Multiplier representing the discount on collateral that a liquidator receives\n */\n uint256 public liquidationIncentiveMantissa;\n\n /*\n * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)\n */\n uint256 internal maxAssets;\n\n /**\n * @notice Per-account mapping of \"assets you are in\", capped by maxAssets\n */\n mapping(address => ICErc20[]) public accountAssets;\n}\n\ncontract ComptrollerV2Storage is ComptrollerV1Storage {\n struct Market {\n // Whether or not this market is listed\n bool isListed;\n // Multiplier representing the most one can borrow against their collateral in this market.\n // For instance, 0.9 to allow borrowing 90% of collateral value.\n // Must be between 0 and 1, and stored as a mantissa.\n uint256 collateralFactorMantissa;\n // Per-market mapping of \"accounts in this asset\"\n mapping(address => bool) accountMembership;\n }\n\n /**\n * @notice Official mapping of cTokens -> Market metadata\n * @dev Used e.g. to determine if a market is supported\n */\n mapping(address => Market) public markets;\n\n /// @notice A list of all markets\n ICErc20[] public allMarkets;\n\n /**\n * @dev Maps borrowers to booleans indicating if they have entered any markets\n */\n mapping(address => bool) internal borrowers;\n\n /// @notice A list of all borrowers who have entered markets\n address[] public allBorrowers;\n\n // Indexes of borrower account addresses in the `allBorrowers` array\n mapping(address => uint256) internal borrowerIndexes;\n\n /**\n * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets\n */\n mapping(address => bool) public suppliers;\n\n /// @notice All cTokens addresses mapped by their underlying token addresses\n mapping(address => ICErc20) public cTokensByUnderlying;\n\n /// @notice Whether or not the supplier whitelist is enforced\n bool public enforceWhitelist;\n\n /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)\n mapping(address => bool) public whitelist;\n\n /// @notice An array of all whitelisted accounts\n address[] public whitelistArray;\n\n // Indexes of account addresses in the `whitelistArray` array\n mapping(address => uint256) internal whitelistIndexes;\n\n /**\n * @notice The Pause Guardian can pause certain actions as a safety mechanism.\n * Actions which allow users to remove their own assets cannot be paused.\n * Liquidation / seizing / transfer can only be paused globally, not by market.\n */\n address public pauseGuardian;\n bool public _mintGuardianPaused;\n bool public _borrowGuardianPaused;\n bool public transferGuardianPaused;\n bool public seizeGuardianPaused;\n mapping(address => bool) public mintGuardianPaused;\n mapping(address => bool) public borrowGuardianPaused;\n}\n\ncontract ComptrollerV3Storage is ComptrollerV2Storage {\n /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.\n /// @dev If Adrastia Prudentia is enabled, the values the borrow cap guardian sets are ignored.\n address public borrowCapGuardian;\n\n /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveBorrowCaps` instead.\n mapping(address => uint256) public borrowCaps;\n\n /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.\n /// @dev If Adrastia Prudentia is enabled, this value is ignored. Use `effectiveSupplyCaps` instead.\n mapping(address => uint256) public supplyCaps;\n\n /// @notice RewardsDistributor contracts to notify of flywheel changes.\n address[] public rewardsDistributors;\n\n /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks\n bool internal _notEntered;\n\n /// @dev Whether or not _notEntered has been initialized\n bool internal _notEnteredInitialized;\n\n /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.\n address[] public nonAccruingRewardsDistributors;\n\n /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset\n mapping(address => mapping(address => uint256)) public borrowCapForCollateral;\n\n /// @dev blacklist to disallow the borrowing of an asset against specific collateral\n mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap\n mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => mapping(address => EnumerableSet.AddressSet))\n internal borrowingAgainstCollateralBlacklistWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the supply cap\n mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;\n\n /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap\n mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;\n}\n\ncontract ComptrollerV4Storage is ComptrollerV3Storage {\n /// @dev Adrastia Prudentia config for controlling borrow caps.\n PrudentiaLib.PrudentiaConfig internal borrowCapConfig;\n\n /// @dev Adrastia Prudentia config for controlling supply caps.\n PrudentiaLib.PrudentiaConfig internal supplyCapConfig;\n}\n" + }, + "contracts/compound/CToken.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { CTokenSecondExtensionBase, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { DiamondExtension, LibDiamond } from \"../ionic/DiamondExtension.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\n/**\n * @title Compound's CErc20 Contract\n * @notice CTokens which wrap an EIP-20 underlying\n * @dev This contract should not to be deployed on its own; instead, deploy `CErc20Delegator` (proxy contract) and `CErc20Delegate` (logic/implementation contract).\n * @author Compound\n */\nabstract contract CErc20 is CTokenOracleProtected, CTokenSecondExtensionBase, TokenErrorReporter, Exponential, DiamondExtension {\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n modifier isMinHFThresholdExceeded(address borrower) {\n PoolLens lens = PoolLens(ap.getAddress(\"PoolLens\"));\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n if (lens.getHealthFactor(borrower, comptroller) > liquidator.healthFactorThreshold()) {\n require(msg.sender == address(liquidator), \"Health factor not low enough for non-permissioned liquidations\");\n _;\n } else {\n _;\n }\n }\n\n function _getExtensionFunctions() public pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 13;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.mint.selector;\n functionSelectors[--fnsCount] = this.redeem.selector;\n functionSelectors[--fnsCount] = this.redeemUnderlying.selector;\n functionSelectors[--fnsCount] = this.borrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrow.selector;\n functionSelectors[--fnsCount] = this.repayBorrowBehalf.selector;\n functionSelectors[--fnsCount] = this.liquidateBorrow.selector;\n functionSelectors[--fnsCount] = this.getCash.selector;\n functionSelectors[--fnsCount] = this.seize.selector;\n functionSelectors[--fnsCount] = this.selfTransferOut.selector;\n functionSelectors[--fnsCount] = this.selfTransferIn.selector;\n functionSelectors[--fnsCount] = this._withdrawIonicFees.selector;\n functionSelectors[--fnsCount] = this._withdrawAdminFees.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*** User Interface ***/\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function mint(uint256 mintAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = mintInternal(mintAmount);\n return err;\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeem(uint256 redeemTokens) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemInternal(redeemTokens);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to redeem\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlying(uint256 redeemAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return redeemUnderlyingInternal(redeemAmount);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrow(uint256 borrowAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n return borrowInternal(borrowAmount);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrow(uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowInternal(repayAmount);\n return err;\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external override isAuthorized onlyOracleApprovedAllowEOA returns (uint256) {\n (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);\n return err;\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external override isAuthorized onlyOracleApprovedAllowEOA isMinHFThresholdExceeded(borrower) returns (uint256) {\n (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral);\n return err;\n }\n\n /**\n * @notice Get cash balance of this cToken in the underlying asset\n * @return The quantity of underlying asset owned by this contract\n */\n function getCash() external view override returns (uint256) {\n return getCashInternal();\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Will fail unless called by another cToken during the process of liquidation.\n * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external override nonReentrant(true) onlyOracleApprovedAllowEOA returns (uint256) {\n return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);\n }\n\n function selfTransferOut(address to, uint256 amount) external override {\n require(msg.sender == address(this), \"!self\");\n doTransferOut(to, amount);\n }\n\n function selfTransferIn(address from, uint256 amount) external override returns (uint256) {\n require(msg.sender == address(this), \"!self\");\n return doTransferIn(from, amount);\n }\n\n /**\n * @notice Accrues interest and reduces Ionic fees by transferring to Ionic\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawIonicFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_IONIC_FEES_FRESH_CHECK);\n }\n\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalIonicFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_IONIC_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n uint256 totalIonicFeesNew = totalIonicFees - withdrawAmount;\n totalIonicFees = totalIonicFeesNew;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(address(ionicAdmin), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accrues interest and reduces admin fees by transferring to admin\n * @param withdrawAmount Amount of fees to withdraw\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _withdrawAdminFees(uint256 withdrawAmount) external override nonReentrant(false) onlyOracleApproved returns (uint256) {\n asCTokenExtension().accrueInterest();\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.WITHDRAW_ADMIN_FEES_FRESH_CHECK);\n }\n\n // Fail gracefully if protocol has insufficient underlying cash\n if (getCashInternal() < withdrawAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE);\n }\n\n if (withdrawAmount > totalAdminFees) {\n return fail(Error.BAD_INPUT, FailureInfo.WITHDRAW_ADMIN_FEES_VALIDATION);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n totalAdminFees = totalAdminFees - withdrawAmount;\n\n // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n doTransferOut(ComptrollerV3Storage(address(comptroller)).admin(), withdrawAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /*** Safe Token ***/\n\n /**\n * @notice Gets balance of this contract in terms of the underlying\n * @dev This excludes the value of the current message, if any\n * @return The quantity of underlying tokens owned by this contract\n */\n function getCashInternal() internal view virtual returns (uint256) {\n return EIP20Interface(underlying).balanceOf(address(this));\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.\n * This will revert due to insufficient balance or insufficient allowance.\n * This function returns the actual amount received,\n * which may be less than `amount` if there is a fee attached to the transfer.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferIn(address from, uint256 amount) internal virtual returns (uint256) {\n uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this));\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transferFrom.selector, from, address(this), amount),\n \"TOKEN_TRANSFER_IN_FAILED\"\n );\n\n // Calculate the amount that was *actually* transferred\n uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this));\n require(balanceAfter >= balanceBefore, \"TOKEN_TRANSFER_IN_OVERFLOW\");\n return balanceAfter - balanceBefore; // underflow already checked above, just subtract\n }\n\n /**\n * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory\n * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to\n * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified\n * it is >= amount, this should not revert in normal conditions.\n *\n * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.\n * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca\n */\n function doTransferOut(address to, uint256 amount) internal virtual {\n _callOptionalReturn(\n abi.encodeWithSelector(EIP20Interface.transfer.selector, to, amount),\n \"TOKEN_TRANSFER_OUT_FAILED\"\n );\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _callOptionalReturn(bytes memory data, string memory errorMessage) internal {\n bytes memory returndata = _functionCall(underlying, data, errorMessage);\n if (returndata.length > 0) require(abi.decode(returndata, (bool)), errorMessage);\n }\n\n /**\n * @notice Sender supplies assets into the market and receives cTokens in exchange\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintInternal(uint256 mintAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to\n return mintFresh(msg.sender, mintAmount);\n }\n\n struct MintLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 mintTokens;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n uint256 actualMintAmount;\n }\n\n /**\n * @notice User supplies assets into the market and receives cTokens in exchange\n * @dev Assumes interest has already been accrued up to the current block\n * @param minter The address of the account which is supplying the assets\n * @param mintAmount The amount of the underlying asset to supply\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.\n */\n function mintFresh(address minter, uint256 mintAmount) internal returns (uint256, uint256) {\n /* Fail if mint not allowed */\n uint256 allowed = comptroller.mintAllowed(address(this), minter, mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);\n }\n\n MintLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n // Check max supply\n // unused function\n /* allowed = comptroller.mintWithinLimits(address(this), vars.exchangeRateMantissa, accountTokens[minter], mintAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);\n } */\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call `doTransferIn` for the minter and the mintAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * `doTransferIn` reverts if anything goes wrong, since we can't be sure if\n * side-effects occurred. The function returns the amount actually transferred,\n * in case of a fee. On success, the cToken holds an additional `actualMintAmount`\n * of cash.\n */\n vars.actualMintAmount = doTransferIn(minter, mintAmount);\n\n /*\n * We get the current exchange rate and calculate the number of cTokens to be minted:\n * mintTokens = actualMintAmount / exchangeRate\n */\n\n // mintTokens is rounded down here - correct\n (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(\n vars.actualMintAmount,\n Exp({ mantissa: vars.exchangeRateMantissa })\n );\n require(vars.mathErr == MathError.NO_ERROR, \"MINT_EXCHANGE_CALCULATION_FAILED\");\n require(vars.mintTokens > 0, \"MINT_ZERO_CTOKENS_REJECTED\");\n\n /*\n * We calculate the new total supply of cTokens and minter token balance, checking for overflow:\n * totalSupplyNew = totalSupply + mintTokens\n * accountTokensNew = accountTokens[minter] + mintTokens\n */\n vars.totalSupplyNew = totalSupply + vars.mintTokens;\n\n vars.accountTokensNew = accountTokens[minter] + vars.mintTokens;\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[minter] = vars.accountTokensNew;\n\n /* We emit a Mint event, and a Transfer event */\n emit Mint(minter, vars.actualMintAmount, vars.mintTokens);\n emit Transfer(address(this), minter, vars.mintTokens);\n\n /* We call the defense hook */\n comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);\n\n return (uint256(Error.NO_ERROR), vars.actualMintAmount);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for the underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemTokens The number of cTokens to redeem into underlying\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemInternal(uint256 redeemTokens) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, redeemTokens, 0);\n }\n\n /**\n * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset\n * @dev Accrues interest whether or not the operation succeeds, unless reverted\n * @param redeemAmount The amount of underlying to receive from redeeming cTokens\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // redeemFresh emits redeem-specific logs on errors, so we don't need to\n return redeemFresh(msg.sender, 0, redeemAmount);\n }\n\n struct RedeemLocalVars {\n Error err;\n MathError mathErr;\n uint256 exchangeRateMantissa;\n uint256 redeemTokens;\n uint256 redeemAmount;\n uint256 totalSupplyNew;\n uint256 accountTokensNew;\n }\n\n function divRoundUp(uint256 x, uint256 y) internal pure returns (uint256 res) {\n res = (x * 1e18) / y;\n if (x % y != 0) res += 1;\n }\n\n /**\n * @notice User redeems cTokens in exchange for the underlying asset\n * @dev Assumes interest has already been accrued up to the current block\n * @param redeemer The address of the account which is redeeming the tokens\n * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function redeemFresh(\n address redeemer,\n uint256 redeemTokensIn,\n uint256 redeemAmountIn\n ) internal returns (uint256) {\n require(redeemTokensIn == 0 || redeemAmountIn == 0, \"!redeem tokens or amount\");\n\n RedeemLocalVars memory vars;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n if (redeemTokensIn > 0) {\n // don't allow dust tokens/assets to be left after\n if (totalSupply - redeemTokensIn < 5000) redeemTokensIn = totalSupply;\n\n /*\n * We calculate the exchange rate and the amount of underlying to be redeemed:\n * redeemTokens = redeemTokensIn\n * redeemAmount = redeemTokensIn x exchangeRateCurrent\n */\n vars.redeemTokens = redeemTokensIn;\n\n (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n redeemTokensIn\n );\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n } else {\n if (redeemAmountIn == type(uint256).max) {\n redeemAmountIn = comptroller.getMaxRedeemOrBorrow(redeemer, ICErc20(address(this)), false);\n }\n\n // don't allow dust tokens/assets to be left after\n uint256 totalUnderlyingSupplied = asCTokenExtension().getTotalUnderlyingSupplied();\n if (totalUnderlyingSupplied - redeemAmountIn < 1000) redeemAmountIn = totalUnderlyingSupplied;\n\n /*\n * We get the current exchange rate and calculate the amount to be redeemed:\n * redeemTokens = redeemAmountIn / exchangeRate\n * redeemAmount = redeemAmountIn\n */\n\n vars.redeemTokens = divRoundUp(redeemAmountIn, vars.exchangeRateMantissa);\n\n // don't allow dust tokens/assets to be left after\n if (totalSupply - vars.redeemTokens < 1000) vars.redeemTokens = totalSupply;\n\n vars.redeemAmount = redeemAmountIn;\n }\n\n /* Fail if redeem not allowed */\n uint256 allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);\n }\n\n /*\n * We calculate the new total supply and redeemer balance, checking for underflow:\n * totalSupplyNew = totalSupply - redeemTokens\n * accountTokensNew = accountTokens[redeemer] - redeemTokens\n */\n (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /* Fail gracefully if protocol has insufficient cash */\n if (getCashInternal() < vars.redeemAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write previously calculated values into storage */\n totalSupply = vars.totalSupplyNew;\n accountTokens[redeemer] = vars.accountTokensNew;\n\n /*\n * We invoke doTransferOut for the redeemer and the redeemAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken has redeemAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(redeemer, vars.redeemAmount);\n\n /* We emit a Transfer event, and a Redeem event */\n emit Transfer(redeemer, address(this), vars.redeemTokens);\n emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);\n\n /* We call the defense hook */\n comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender borrows assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowInternal(uint256 borrowAmount) internal nonReentrant(false) returns (uint256) {\n asCTokenExtension().accrueInterest();\n // borrowFresh emits borrow-specific logs on errors, so we don't need to\n return borrowFresh(msg.sender, borrowAmount);\n }\n\n struct BorrowLocalVars {\n MathError mathErr;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n }\n\n /**\n * @notice Users borrow assets from the protocol to their own address\n * @param borrowAmount The amount of the underlying asset to borrow\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function borrowFresh(address borrower, uint256 borrowAmount) internal returns (uint256) {\n /* Fail if borrow not allowed */\n uint256 allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK);\n }\n\n /* Fail gracefully if protocol has insufficient underlying cash */\n uint256 cashPrior = getCashInternal();\n\n if (cashPrior < borrowAmount) {\n return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE);\n }\n\n BorrowLocalVars memory vars;\n\n /*\n * We calculate the new borrower and total borrow balances, failing on overflow:\n * accountBorrowsNew = accountBorrows + borrowAmount\n * totalBorrowsNew = totalBorrows + borrowAmount\n */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(\n Error.MATH_ERROR,\n FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n uint256(vars.mathErr)\n );\n }\n\n // Check min borrow for this user for this asset\n allowed = comptroller.borrowWithinLimits(address(this), vars.accountBorrowsNew);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed);\n }\n\n (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);\n if (vars.mathErr != MathError.NO_ERROR) {\n return\n failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /*\n * We invoke doTransferOut for the borrower and the borrowAmount.\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken borrowAmount less of cash.\n * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.\n */\n doTransferOut(borrower, borrowAmount);\n\n /* We emit a Borrow event */\n emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.borrowVerify(address(this), borrower, borrowAmount);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Sender repays their own borrow\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowInternal(uint256 repayAmount) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n }\n\n /**\n * @notice Sender repays a borrow belonging to borrower\n * @param borrower the account with the debt being payed off\n * @param repayAmount The amount to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)\n internal\n nonReentrant(false)\n returns (uint256, uint256)\n {\n asCTokenExtension().accrueInterest();\n // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to\n return repayBorrowFresh(msg.sender, borrower, repayAmount);\n }\n\n struct RepayBorrowLocalVars {\n Error err;\n MathError mathErr;\n uint256 repayAmount;\n uint256 borrowerIndex;\n uint256 accountBorrows;\n uint256 accountBorrowsNew;\n uint256 totalBorrowsNew;\n uint256 actualRepayAmount;\n }\n\n /**\n * @notice Borrows are repaid by another user (possibly the borrower).\n * @param payer the account paying off the borrow\n * @param borrower the account with the debt being payed off\n * @param repayAmount the amount of undelrying tokens being returned\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function repayBorrowFresh(\n address payer,\n address borrower,\n uint256 repayAmount\n ) internal returns (uint256, uint256) {\n /* Fail if repayBorrow not allowed */\n uint256 allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount);\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n }\n\n RepayBorrowLocalVars memory vars;\n\n /* We remember the original borrowerIndex for verification purposes */\n vars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n /* We fetch the amount the borrower owes, with accumulated interest */\n vars.accountBorrows = asCTokenExtension().borrowBalanceCurrent(borrower);\n\n /* If repayAmount == -1, repayAmount = accountBorrows */\n if (repayAmount == type(uint256).max) {\n vars.repayAmount = vars.accountBorrows;\n } else {\n vars.repayAmount = repayAmount;\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /*\n * We call doTransferIn for the payer and the repayAmount\n * Note: The cToken must handle variations between ERC-20 and ETH underlying.\n * On success, the cToken holds an additional repayAmount of cash.\n * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred.\n * it returns the amount actually transferred, in case of a fee.\n */\n vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount);\n\n /*\n * We calculate the new borrower and total borrow balances, failing on underflow:\n * accountBorrowsNew = accountBorrows - actualRepayAmount\n * totalBorrowsNew = totalBorrows - actualRepayAmount\n */\n (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED\");\n\n (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount);\n require(vars.mathErr == MathError.NO_ERROR, \"REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED\");\n\n /* We write the previously calculated values into storage */\n accountBorrows[borrower].principal = vars.accountBorrowsNew;\n accountBorrows[borrower].interestIndex = borrowIndex;\n totalBorrows = vars.totalBorrowsNew;\n\n /* We emit a RepayBorrow event */\n emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);\n\n return (uint256(Error.NO_ERROR), vars.actualRepayAmount);\n }\n\n /**\n * @notice The sender liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowInternal(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal nonReentrant(false) returns (uint256, uint256) {\n asCTokenExtension().accrueInterest();\n ICErc20(cTokenCollateral).accrueInterest();\n // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to\n return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);\n }\n\n /**\n * @notice The liquidator liquidates the borrowers collateral.\n * The collateral seized is transferred to the liquidator.\n * @param borrower The borrower of this cToken to be liquidated\n * @param liquidator The address repaying the borrow and seizing collateral\n * @param cTokenCollateral The market in which to seize collateral from the borrower\n * @param repayAmount The amount of the underlying borrowed asset to repay\n * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.\n */\n function liquidateBorrowFresh(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) internal returns (uint256, uint256) {\n /* Fail if liquidate not allowed */\n uint256 allowed = comptroller.liquidateBorrowAllowed(\n address(this),\n cTokenCollateral,\n liquidator,\n borrower,\n repayAmount\n );\n if (allowed != 0) {\n return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0);\n }\n\n /* Verify market's block number equals current block number */\n if (accrualBlockNumber != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0);\n }\n\n /* Verify cTokenCollateral market's block number equals current block number */\n if (CErc20(cTokenCollateral).accrualBlockNumber() != block.number) {\n return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0);\n }\n\n /* Fail if repayAmount = 0 */\n if (repayAmount == 0) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0);\n }\n\n /* Fail if repayAmount = -1 */\n if (repayAmount == type(uint256).max) {\n return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0);\n }\n\n /* Fail if repayBorrow fails */\n (uint256 repayBorrowError, uint256 actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount);\n if (repayBorrowError != uint256(Error.NO_ERROR)) {\n return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We calculate the number of collateral tokens that will be seized */\n (uint256 amountSeizeError, uint256 seizeTokens) = comptroller.liquidateCalculateSeizeTokens(\n address(this),\n cTokenCollateral,\n actualRepayAmount\n );\n require(amountSeizeError == uint256(Error.NO_ERROR), \"LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED\");\n\n /* Revert if borrower collateral token balance < seizeTokens */\n require(ICErc20(cTokenCollateral).balanceOf(borrower) >= seizeTokens, \"LIQUIDATE_SEIZE_TOO_MUCH\");\n\n // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call\n uint256 seizeError;\n if (cTokenCollateral == address(this)) {\n seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);\n } else {\n seizeError = CErc20(cTokenCollateral).seize(liquidator, borrower, seizeTokens);\n }\n\n /* Revert if seize tokens fails (since we cannot be sure of side effects) */\n require(seizeError == uint256(Error.NO_ERROR), \"!seize\");\n\n /* We emit a LiquidateBorrow event */\n emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, cTokenCollateral, seizeTokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.liquidateBorrowVerify(address(this), cTokenCollateral, liquidator, borrower, actualRepayAmount, seizeTokens);\n\n return (uint256(Error.NO_ERROR), actualRepayAmount);\n }\n\n struct SeizeInternalLocalVars {\n MathError mathErr;\n uint256 borrowerTokensNew;\n uint256 liquidatorTokensNew;\n uint256 liquidatorSeizeTokens;\n uint256 protocolSeizeTokens;\n uint256 protocolSeizeAmount;\n uint256 exchangeRateMantissa;\n uint256 totalReservesNew;\n uint256 totalIonicFeeNew;\n uint256 totalSupplyNew;\n uint256 feeSeizeTokens;\n uint256 feeSeizeAmount;\n }\n\n /**\n * @notice Transfers collateral tokens (this market) to the liquidator.\n * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.\n * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.\n * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)\n * @param liquidator The account receiving seized collateral\n * @param borrower The account having collateral seized\n * @param seizeTokens The number of cTokens to seize\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function seizeInternal(\n address seizerToken,\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) internal returns (uint256) {\n /* Fail if seize not allowed */\n uint256 allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Fail if borrower = liquidator */\n if (borrower == liquidator) {\n return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);\n }\n\n SeizeInternalLocalVars memory vars;\n\n /*\n * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:\n * borrowerTokensNew = accountTokens[borrower] - seizeTokens\n * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens\n */\n (vars.mathErr, vars.borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr));\n }\n\n vars.protocolSeizeTokens = mul_(seizeTokens, Exp({ mantissa: protocolSeizeShareMantissa }));\n vars.feeSeizeTokens = mul_(seizeTokens, Exp({ mantissa: feeSeizeShareMantissa }));\n vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n\n vars.exchangeRateMantissa = asCTokenExtension().exchangeRateCurrent();\n\n vars.protocolSeizeAmount = mul_ScalarTruncate(\n Exp({ mantissa: vars.exchangeRateMantissa }),\n vars.protocolSeizeTokens\n );\n vars.feeSeizeAmount = mul_ScalarTruncate(Exp({ mantissa: vars.exchangeRateMantissa }), vars.feeSeizeTokens);\n\n vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount;\n vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens - vars.feeSeizeTokens;\n vars.totalIonicFeeNew = totalIonicFees + vars.feeSeizeAmount;\n\n (vars.mathErr, vars.liquidatorTokensNew) = addUInt(accountTokens[liquidator], vars.liquidatorSeizeTokens);\n if (vars.mathErr != MathError.NO_ERROR) {\n return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr));\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n /* We write the previously calculated values into storage */\n totalReserves = vars.totalReservesNew;\n totalSupply = vars.totalSupplyNew;\n totalIonicFees = vars.totalIonicFeeNew;\n\n accountTokens[borrower] = vars.borrowerTokensNew;\n accountTokens[liquidator] = vars.liquidatorTokensNew;\n\n /* Emit a Transfer event */\n emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);\n emit Transfer(borrower, address(this), vars.protocolSeizeTokens);\n emit ReservesAdded(address(this), vars.protocolSeizeAmount, vars.totalReservesNew);\n\n /* We call the defense hook */\n // unused function\n // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n function asCTokenExtension() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\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 * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * @param data The call data (encoded using abi.encode or one of its variants).\n * @param errorMessage The revert string to return on failure.\n */\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n}\n" + }, + "contracts/compound/CTokenFirstExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { IFlashLoanReceiver } from \"../ionic/IFlashLoanReceiver.sol\";\nimport { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from \"./CTokenInterfaces.sol\";\nimport { SFSRegister } from \"./ComptrollerInterface.sol\";\nimport { TokenErrorReporter } from \"./ErrorReporter.sol\";\nimport { Exponential } from \"./Exponential.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { CTokenOracleProtected } from \"./CTokenOracleProtected.sol\";\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport { Multicall } from \"../utils/Multicall.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenFirstExtension is\n CTokenOracleProtected,\n CErc20FirstExtensionBase,\n TokenErrorReporter,\n Exponential,\n DiamondExtension,\n Multicall\n{\n modifier isAuthorized() {\n require(\n IFeeDistributor(ionicAdmin).canCall(address(comptroller), msg.sender, address(this), msg.sig),\n \"not authorized\"\n );\n _;\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 25;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.transfer.selector;\n functionSelectors[--fnsCount] = this.transferFrom.selector;\n functionSelectors[--fnsCount] = this.allowance.selector;\n functionSelectors[--fnsCount] = this.approve.selector;\n functionSelectors[--fnsCount] = this.balanceOf.selector;\n functionSelectors[--fnsCount] = this._setAdminFee.selector;\n functionSelectors[--fnsCount] = this._setInterestRateModel.selector;\n functionSelectors[--fnsCount] = this._setNameAndSymbol.selector;\n functionSelectors[--fnsCount] = this._setAddressesProvider.selector;\n functionSelectors[--fnsCount] = this._setReserveFactor.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlock.selector;\n functionSelectors[--fnsCount] = this.exchangeRateCurrent.selector;\n functionSelectors[--fnsCount] = this.accrueInterest.selector;\n functionSelectors[--fnsCount] = this.totalBorrowsCurrent.selector;\n functionSelectors[--fnsCount] = this.balanceOfUnderlying.selector;\n functionSelectors[--fnsCount] = this.multicall.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterDeposit.selector;\n functionSelectors[--fnsCount] = this.supplyRatePerBlockAfterWithdraw.selector;\n functionSelectors[--fnsCount] = this.borrowRatePerBlockAfterBorrow.selector;\n functionSelectors[--fnsCount] = this.getTotalUnderlyingSupplied.selector;\n functionSelectors[--fnsCount] = this.flash.selector;\n functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;\n functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;\n functionSelectors[--fnsCount] = this.registerInSFS.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getTotalUnderlyingSupplied() public view override returns (uint256) {\n // (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees))\n return asCToken().getCash() + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees);\n }\n\n /* ERC20 fns */\n /**\n * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`\n * @dev Called by both `transfer` and `transferFrom` internally\n * @param spender The address of the account performing the transfer\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param tokens The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {\n /* Fail if transfer not allowed */\n uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);\n if (allowed != 0) {\n return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed);\n }\n\n /* Do not allow self-transfers */\n if (src == dst) {\n return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n /* Get the allowance, infinite for the account owner */\n uint256 startingAllowance = 0;\n if (spender == src) {\n startingAllowance = type(uint256).max;\n } else {\n startingAllowance = transferAllowances[src][spender];\n }\n\n /* Do the calculations, checking for {under,over}flow */\n MathError mathErr;\n uint256 allowanceNew;\n uint256 srcTokensNew;\n uint256 dstTokensNew;\n\n (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);\n }\n\n (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);\n }\n\n (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);\n if (mathErr != MathError.NO_ERROR) {\n return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);\n }\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n\n accountTokens[src] = srcTokensNew;\n accountTokens[dst] = dstTokensNew;\n\n /* Eat some of the allowance (if necessary) */\n if (startingAllowance != type(uint256).max) {\n transferAllowances[src][spender] = allowanceNew;\n }\n\n /* We emit a Transfer event */\n emit Transfer(src, dst, tokens);\n\n /* We call the defense hook */\n // unused function\n // comptroller.transferVerify(address(this), src, dst, tokens);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transfer(\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) public override nonReentrant(false) isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return Whether or not the approval succeeded\n */\n function approve(\n address spender,\n uint256 amount\n ) public override isAuthorized onlyOracleApprovedAllowEOA returns (bool) {\n address src = msg.sender;\n transferAllowances[src][spender] = amount;\n emit Approval(src, spender, amount);\n return true;\n }\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) public view override returns (uint256) {\n return transferAllowances[owner][spender];\n }\n\n /**\n * @notice Get the token balance of the `owner`\n * @param owner The address of the account to query\n * @return The number of tokens owned by `owner`\n */\n function balanceOf(address owner) public view override returns (uint256) {\n return accountTokens[owner];\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice updates the cToken ERC20 name and symbol\n * @dev Admin function to update the cToken ERC20 name and symbol\n * @param _name the new ERC20 token name to use\n * @param _symbol the new ERC20 token symbol to use\n */\n function _setNameAndSymbol(string calldata _name, string calldata _symbol) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n // Set ERC20 name and symbol\n name = _name;\n symbol = _symbol;\n }\n\n function _setAddressesProvider(address _ap) external {\n // Check caller is admin\n require(hasAdminRights(), \"!admin\");\n\n ap = AddressesProvider(_ap);\n }\n\n /**\n * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh\n * @dev Admin function to accrue interest and set a new reserve factor\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setReserveFactor(\n uint256 newReserveFactorMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK);\n }\n\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK);\n }\n\n // Check newReserveFactor ≤ maxReserveFactor\n if (newReserveFactorMantissa + adminFeeMantissa + ionicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK);\n }\n\n uint256 oldReserveFactorMantissa = reserveFactorMantissa;\n reserveFactorMantissa = newReserveFactorMantissa;\n\n emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and sets a new admin fee for the protocol using _setAdminFeeFresh\n * @dev Admin function to accrue interest and set a new admin fee\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setAdminFee(\n uint256 newAdminFeeMantissa\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n // Verify market's block number equals current block number\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_ADMIN_FEE_FRESH_CHECK);\n }\n\n // Sanitize newAdminFeeMantissa\n if (newAdminFeeMantissa == type(uint256).max) newAdminFeeMantissa = adminFeeMantissa;\n\n // Get latest Ionic fee\n uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();\n\n // Check reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa ≤ reserveFactorPlusFeesMaxMantissa\n if (reserveFactorMantissa + newAdminFeeMantissa + newIonicFeeMantissa > reserveFactorPlusFeesMaxMantissa) {\n return fail(Error.BAD_INPUT, FailureInfo.SET_ADMIN_FEE_BOUNDS_CHECK);\n }\n\n // If setting admin fee\n if (adminFeeMantissa != newAdminFeeMantissa) {\n // Check caller is admin\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_ADMIN_FEE_ADMIN_CHECK);\n }\n\n // Set admin fee\n uint256 oldAdminFeeMantissa = adminFeeMantissa;\n adminFeeMantissa = newAdminFeeMantissa;\n\n // Emit event\n emit NewAdminFee(oldAdminFeeMantissa, newAdminFeeMantissa);\n }\n\n // If setting Ionic fee\n if (ionicFeeMantissa != newIonicFeeMantissa) {\n // Set Ionic fee\n uint256 oldIonicFeeMantissa = ionicFeeMantissa;\n ionicFeeMantissa = newIonicFeeMantissa;\n\n // Emit event\n emit NewIonicFee(oldIonicFeeMantissa, newIonicFeeMantissa);\n }\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh\n * @dev Admin function to accrue interest and update the interest rate model\n * @param newInterestRateModel the new interest rate model to use\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setInterestRateModel(\n InterestRateModel newInterestRateModel\n ) public override nonReentrant(false) returns (uint256) {\n accrueInterest();\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);\n }\n\n if (accrualBlockNumber != block.number) {\n return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);\n }\n\n require(newInterestRateModel.isInterestRateModel(), \"!notIrm\");\n\n InterestRateModel oldInterestRateModel = interestRateModel;\n interestRateModel = newInterestRateModel;\n emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current per-block borrow interest rate for this cToken\n * @return The borrow interest rate per block, scaled by 1e18\n */\n function borrowRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getBorrowRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) public view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= borrowAmount, \"market cash not enough\");\n\n return\n interestRateModel.getBorrowRate(\n cash - borrowAmount,\n totalBorrows + borrowAmount,\n totalReserves + totalAdminFees + totalIonicFees\n );\n }\n\n /**\n * @notice Returns the current per-block supply interest rate for this cToken\n * @return The supply interest rate per block, scaled by 1e18\n */\n function supplyRatePerBlock() public view override returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash(),\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256) {\n return\n interestRateModel.getSupplyRate(\n asCToken().getCash() + mintAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256) {\n uint256 cash = asCToken().getCash();\n require(cash >= withdrawAmount, \"market cash not enough\");\n return\n interestRateModel.getSupplyRate(\n cash - withdrawAmount,\n totalBorrows,\n totalReserves + totalAdminFees + totalIonicFees,\n reserveFactorMantissa + ionicFeeMantissa + adminFeeMantissa\n );\n }\n\n /**\n * @notice Accrue interest then return the up-to-date exchange rate\n * @return Calculated exchange rate scaled by 1e18\n */\n function exchangeRateCurrent() public view override returns (uint256) {\n if (block.number == accrualBlockNumber) {\n return\n _exchangeRateHypothetical(\n totalSupply,\n initialExchangeRateMantissa,\n asCToken().getCash(),\n totalBorrows,\n totalReserves,\n totalAdminFees,\n totalIonicFees\n );\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n\n return\n _exchangeRateHypothetical(\n accrual.totalSupply,\n initialExchangeRateMantissa,\n cashPrior,\n accrual.totalBorrows,\n accrual.totalReserves,\n accrual.totalAdminFees,\n accrual.totalIonicFees\n );\n }\n }\n\n function _exchangeRateHypothetical(\n uint256 _totalSupply,\n uint256 _initialExchangeRateMantissa,\n uint256 _totalCash,\n uint256 _totalBorrows,\n uint256 _totalReserves,\n uint256 _totalAdminFees,\n uint256 _totalIonicFees\n ) internal pure returns (uint256) {\n if (_totalSupply == 0) {\n /*\n * If there are no tokens minted:\n * exchangeRate = initialExchangeRate\n */\n return _initialExchangeRateMantissa;\n } else {\n /*\n * Otherwise:\n * exchangeRate = (totalCash + totalBorrows - (totalReserves + totalIonicFees + totalAdminFees)) / totalSupply\n */\n uint256 cashPlusBorrowsMinusReserves;\n Exp memory exchangeRate;\n MathError mathErr;\n\n (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(\n _totalCash,\n _totalBorrows,\n _totalReserves + _totalAdminFees + _totalIonicFees\n );\n require(mathErr == MathError.NO_ERROR, \"!addThenSubUInt overflow check failed\");\n\n (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply);\n require(mathErr == MathError.NO_ERROR, \"!getExp overflow check failed\");\n\n return exchangeRate.mantissa;\n }\n }\n\n struct InterestAccrual {\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalSupply;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n uint256 interestAccumulated;\n }\n\n function _accrueInterestHypothetical(\n uint256 blockNumber,\n uint256 cashPrior\n ) internal view returns (InterestAccrual memory accrual) {\n uint256 totalFees = totalAdminFees + totalIonicFees;\n uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);\n if (borrowRateMantissa > borrowRateMaxMantissa) {\n if (cashPrior > totalFees) revert(\"!borrowRate\");\n else borrowRateMantissa = borrowRateMaxMantissa;\n }\n (MathError mathErr, uint256 blockDelta) = subUInt(blockNumber, accrualBlockNumber);\n require(mathErr == MathError.NO_ERROR, \"!blockDelta\");\n\n /*\n * Calculate the interest accumulated into borrows and reserves and the new index:\n * simpleInterestFactor = borrowRate * blockDelta\n * interestAccumulated = simpleInterestFactor * totalBorrows\n * totalBorrowsNew = interestAccumulated + totalBorrows\n * totalReservesNew = interestAccumulated * reserveFactor + totalReserves\n * totalIonicFeesNew = interestAccumulated * ionicFee + totalIonicFees\n * totalAdminFeesNew = interestAccumulated * adminFee + totalAdminFees\n * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex\n */\n\n accrual.accrualBlockNumber = blockNumber;\n accrual.totalSupply = totalSupply;\n Exp memory simpleInterestFactor = mul_(Exp({ mantissa: borrowRateMantissa }), blockDelta);\n accrual.interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, totalBorrows);\n accrual.totalBorrows = accrual.interestAccumulated + totalBorrows;\n accrual.totalReserves = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: reserveFactorMantissa }),\n accrual.interestAccumulated,\n totalReserves\n );\n accrual.totalIonicFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: ionicFeeMantissa }),\n accrual.interestAccumulated,\n totalIonicFees\n );\n accrual.totalAdminFees = mul_ScalarTruncateAddUInt(\n Exp({ mantissa: adminFeeMantissa }),\n accrual.interestAccumulated,\n totalAdminFees\n );\n accrual.borrowIndex = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndex, borrowIndex);\n }\n\n /**\n * @notice Applies accrued interest to total borrows and reserves\n * @dev This calculates interest accrued from the last checkpointed block\n * up to the current block and writes new checkpoint to storage.\n */\n function accrueInterest() public override returns (uint256) {\n /* Remember the initial block number */\n uint256 currentBlockNumber = block.number;\n\n /* Short-circuit accumulating 0 interest */\n if (accrualBlockNumber == currentBlockNumber) {\n return uint256(Error.NO_ERROR);\n }\n\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(currentBlockNumber, cashPrior);\n\n /////////////////////////\n // EFFECTS & INTERACTIONS\n // (No safe failures beyond this point)\n accrualBlockNumber = currentBlockNumber;\n borrowIndex = accrual.borrowIndex;\n totalBorrows = accrual.totalBorrows;\n totalReserves = accrual.totalReserves;\n totalIonicFees = accrual.totalIonicFees;\n totalAdminFees = accrual.totalAdminFees;\n emit AccrueInterest(cashPrior, accrual.interestAccumulated, borrowIndex, totalBorrows);\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Returns the current total borrows plus accrued interest\n * @return The total borrows with interest\n */\n function totalBorrowsCurrent() external view override returns (uint256) {\n if (accrualBlockNumber == block.number) {\n return totalBorrows;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n return accrual.totalBorrows;\n }\n }\n\n /**\n * @notice Get a snapshot of the account's balances, and the cached exchange rate\n * @dev This is used by comptroller to more efficiently perform liquidity checks.\n * @param account Address of the account to snapshot\n * @return (possible error, token balance, borrow balance, exchange rate mantissa)\n */\n function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {\n uint256 cTokenBalance = accountTokens[account];\n uint256 borrowBalance;\n uint256 exchangeRateMantissa;\n\n borrowBalance = borrowBalanceCurrent(account);\n\n exchangeRateMantissa = exchangeRateCurrent();\n\n return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa);\n }\n\n /**\n * @notice calculate the borrowIndex and the account's borrow balance using the fresh borrowIndex\n * @param account The address whose balance should be calculated after recalculating the borrowIndex\n * @return The calculated balance\n */\n function borrowBalanceCurrent(address account) public view override returns (uint256) {\n uint256 _borrowIndex;\n if (accrualBlockNumber == block.number) {\n _borrowIndex = borrowIndex;\n } else {\n uint256 cashPrior = asCToken().getCash();\n InterestAccrual memory accrual = _accrueInterestHypothetical(block.number, cashPrior);\n _borrowIndex = accrual.borrowIndex;\n }\n\n /* Note: we do not assert that the market is up to date */\n MathError mathErr;\n uint256 principalTimesIndex;\n uint256 result;\n\n /* Get borrowBalance and borrowIndex */\n BorrowSnapshot storage borrowSnapshot = accountBorrows[account];\n\n /* If borrowBalance = 0 then borrowIndex is likely also 0.\n * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.\n */\n if (borrowSnapshot.principal == 0) {\n return 0;\n }\n\n /* Calculate new borrow balance using the interest index:\n * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex\n */\n (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, _borrowIndex);\n require(mathErr == MathError.NO_ERROR, \"!mulUInt overflow check failed\");\n\n (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex);\n require(mathErr == MathError.NO_ERROR, \"!divUInt overflow check failed\");\n\n return result;\n }\n\n /**\n * @notice Get the underlying balance of the `owner`\n * @param owner The address of the account to query\n * @return The amount of underlying owned by `owner`\n */\n function balanceOfUnderlying(address owner) external view override returns (uint256) {\n Exp memory exchangeRate = Exp({ mantissa: exchangeRateCurrent() });\n (MathError mErr, uint256 balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);\n require(mErr == MathError.NO_ERROR, \"!balance\");\n return balance;\n }\n\n function flash(uint256 amount, bytes calldata data) public override isAuthorized onlyOracleApprovedAllowEOA {\n accrueInterest();\n\n totalBorrows += amount;\n asCToken().selfTransferOut(msg.sender, amount);\n\n IFlashLoanReceiver(msg.sender).receiveFlashLoan(underlying, amount, data);\n\n asCToken().selfTransferIn(msg.sender, amount);\n totalBorrows -= amount;\n\n emit Flash(msg.sender, amount);\n }\n\n /*** Reentrancy Guard ***/\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n */\n modifier nonReentrant(bool localOnly) {\n _beforeNonReentrant(localOnly);\n _;\n _afterNonReentrant(localOnly);\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 1500 bytes of that valuable 24 KB limit.\n */\n function _beforeNonReentrant(bool localOnly) private {\n require(_notEntered, \"re-entered\");\n if (!localOnly) comptroller._beforeNonReentrant();\n _notEntered = false;\n }\n\n /**\n * @dev Split off from `nonReentrant` to keep contract below the 24 KB size limit.\n * Saves space because function modifier code is \"inlined\" into every function with the modifier).\n * In this specific case, the optimization saves around 150 bytes of that valuable 24 KB limit.\n */\n function _afterNonReentrant(bool localOnly) private {\n _notEntered = true; // get a gas-refund post-Istanbul\n if (!localOnly) comptroller._afterNonReentrant();\n }\n\n function asCToken() internal view returns (ICErc20) {\n return ICErc20(address(this));\n }\n\n function multicall(\n bytes[] calldata data\n ) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {\n return Multicall.multicall(data);\n }\n\n function registerInSFS() external returns (uint256) {\n require(hasAdminRights() || msg.sender == address(comptroller), \"!admin\");\n SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020);\n return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);\n }\n}\n" + }, + "contracts/compound/CTokenInterfaces.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller } from \"./ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"./InterestRateModel.sol\";\nimport { ComptrollerV3Storage } from \"./ComptrollerStorage.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\n\nabstract contract CTokenAdminStorage {\n /*\n * Administrator for Ionic\n */\n address payable public ionicAdmin;\n}\n\nabstract contract CErc20Storage is CTokenAdminStorage {\n /**\n * @dev Guard variable for re-entrancy checks\n */\n bool internal _notEntered;\n\n /**\n * @notice EIP-20 token name for this token\n */\n string public name;\n\n /**\n * @notice EIP-20 token symbol for this token\n */\n string public symbol;\n\n /**\n * @notice EIP-20 token decimals for this token\n */\n uint8 public decimals;\n\n /*\n * Maximum borrow rate that can ever be applied (.0005% / block)\n */\n uint256 internal constant borrowRateMaxMantissa = 0.0005e16;\n\n /*\n * Maximum fraction of interest that can be set aside for reserves + fees\n */\n uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;\n\n /**\n * @notice Contract which oversees inter-cToken operations\n */\n IonicComptroller public comptroller;\n\n /**\n * @notice Model which tells what the current interest rate should be\n */\n InterestRateModel public interestRateModel;\n\n /*\n * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)\n */\n uint256 internal initialExchangeRateMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for admin fees\n */\n uint256 public adminFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for Ionic fees\n */\n uint256 public ionicFeeMantissa;\n\n /**\n * @notice Fraction of interest currently set aside for reserves\n */\n uint256 public reserveFactorMantissa;\n\n /**\n * @notice Block number that interest was last accrued at\n */\n uint256 public accrualBlockNumber;\n\n /**\n * @notice Accumulator of the total earned interest rate since the opening of the market\n */\n uint256 public borrowIndex;\n\n /**\n * @notice Total amount of outstanding borrows of the underlying in this market\n */\n uint256 public totalBorrows;\n\n /**\n * @notice Total amount of reserves of the underlying held in this market\n */\n uint256 public totalReserves;\n\n /**\n * @notice Total amount of admin fees of the underlying held in this market\n */\n uint256 public totalAdminFees;\n\n /**\n * @notice Total amount of Ionic fees of the underlying held in this market\n */\n uint256 public totalIonicFees;\n\n /**\n * @notice Total number of tokens in circulation\n */\n uint256 public totalSupply;\n\n /*\n * Official record of token balances for each account\n */\n mapping(address => uint256) internal accountTokens;\n\n /*\n * Approved token transfer amounts on behalf of others\n */\n mapping(address => mapping(address => uint256)) internal transferAllowances;\n\n /**\n * @notice Container for borrow balance information\n * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action\n * @member interestIndex Global borrowIndex as of the most recent balance-changing action\n */\n struct BorrowSnapshot {\n uint256 principal;\n uint256 interestIndex;\n }\n\n /*\n * Mapping of account addresses to outstanding borrow balances\n */\n mapping(address => BorrowSnapshot) internal accountBorrows;\n\n /*\n * Share of seized collateral that is added to reserves\n */\n uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%\n\n /*\n * Share of seized collateral taken as fees\n */\n uint256 public constant feeSeizeShareMantissa = 1e17; //10%\n\n /**\n * @notice Underlying asset for this CToken\n */\n address public underlying;\n\n /**\n * @notice Addresses Provider\n */\n AddressesProvider public ap;\n}\n\nabstract contract CTokenBaseEvents {\n /* ERC20 */\n\n /**\n * @notice EIP20 Transfer event\n */\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /*** Admin Events ***/\n\n /**\n * @notice Event emitted when interestRateModel is changed\n */\n event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);\n\n /**\n * @notice Event emitted when the reserve factor is changed\n */\n event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);\n\n /**\n * @notice Event emitted when the admin fee is changed\n */\n event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);\n\n /**\n * @notice Event emitted when the Ionic fee is changed\n */\n event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);\n\n /**\n * @notice EIP20 Approval event\n */\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /**\n * @notice Event emitted when interest is accrued\n */\n event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);\n}\n\nabstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {\n event Flash(address receiver, uint256 amount);\n}\n\nabstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {\n /*** Market Events ***/\n\n /**\n * @notice Event emitted when tokens are minted\n */\n event Mint(address minter, uint256 mintAmount, uint256 mintTokens);\n\n /**\n * @notice Event emitted when tokens are redeemed\n */\n event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);\n\n /**\n * @notice Event emitted when underlying is borrowed\n */\n event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is repaid\n */\n event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);\n\n /**\n * @notice Event emitted when a borrow is liquidated\n */\n event LiquidateBorrow(\n address liquidator,\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral,\n uint256 seizeTokens\n );\n\n /**\n * @notice Event emitted when the reserves are added\n */\n event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);\n\n /**\n * @notice Event emitted when the reserves are reduced\n */\n event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);\n}\n\ninterface CTokenFirstExtensionInterface {\n /*** User Interface ***/\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n /*** Admin Functions ***/\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n\n function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);\n\n function getAccountSnapshot(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256\n );\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function exchangeRateCurrent() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function totalBorrowsCurrent() external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external view returns (uint256);\n\n function getTotalUnderlyingSupplied() external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external view returns (uint256);\n\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n\n function flash(uint256 amount, bytes calldata data) external;\n\n function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);\n\n function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);\n\n function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);\n\n function registerInSFS() external returns (uint256);\n}\n\ninterface CTokenSecondExtensionInterface {\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);\n\n function liquidateBorrow(\n address borrower,\n uint256 repayAmount,\n address cTokenCollateral\n ) external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function seize(\n address liquidator,\n address borrower,\n uint256 seizeTokens\n ) external returns (uint256);\n\n /*** Admin Functions ***/\n\n function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);\n\n function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);\n\n function selfTransferOut(address to, uint256 amount) external;\n\n function selfTransferIn(address from, uint256 amount) external returns (uint256);\n}\n\ninterface CDelegatorInterface {\n function implementation() external view returns (address);\n\n /**\n * @notice Called by the admin to update the implementation of the delegator\n * @param implementation_ The address of the new implementation for delegation\n * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation\n */\n function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external;\n}\n\ninterface CDelegateInterface {\n /**\n * @notice Called by the delegator on a delegate to initialize it for duty\n * @dev Should revert if any issues arise which make it unfit for delegation\n * @param data The encoded bytes data for any initialization\n */\n function _becomeImplementation(bytes calldata data) external;\n\n function delegateType() external pure returns (uint8);\n\n function contractType() external pure returns (string memory);\n}\n\nabstract contract CErc20AdminBase is CErc20Storage {\n /**\n * @notice Returns a boolean indicating if the sender has admin rights\n */\n function hasAdminRights() internal view returns (bool) {\n ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));\n return\n (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||\n (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());\n }\n}\n\nabstract contract CErc20FirstExtensionBase is\n CErc20AdminBase,\n CTokenFirstExtensionEvents,\n CTokenFirstExtensionInterface\n{}\n\nabstract contract CTokenSecondExtensionBase is\n CErc20AdminBase,\n CTokenSecondExtensionEvents,\n CTokenSecondExtensionInterface,\n CDelegateInterface\n{}\n\nabstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}\n\ninterface CErc20StorageInterface {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdmin() external view returns (address);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function comptroller() external view returns (IonicComptroller);\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function accrualBlockNumber() external view returns (uint256);\n\n function underlying() external view returns (address);\n\n function borrowIndex() external view returns (uint256);\n\n function interestRateModel() external view returns (address);\n}\n\ninterface CErc20PluginStorageInterface is CErc20StorageInterface {\n function plugin() external view returns (address);\n}\n\ninterface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {\n function approve(address, address) external;\n}\n\ninterface ICErc20 is\n CErc20StorageInterface,\n CTokenSecondExtensionInterface,\n CTokenFirstExtensionInterface,\n CDelegatorInterface,\n CDelegateInterface\n{}\n\ninterface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {\n function _updatePlugin(address _plugin) external;\n}\n\ninterface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}\n" + }, + "contracts/compound/CTokenOracleProtected.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { CErc20Storage } from \"./CTokenInterfaces.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\n\ncontract CTokenOracleProtected is CErc20Storage {\n error InteractionNotAllowed();\n error CallerIsNotEOA();\n\n modifier onlyOracleApproved() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\n _;\n }\n\n modifier onlyOracleApprovedAllowEOA() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n oracle.validateBlacklistedAccountInteraction(msg.sender);\n if (tx.origin == msg.sender) {\n _;\n return;\n }\n\n oracle.validateForbiddenContextInteraction(tx.origin, msg.sender);\n _;\n }\n\n modifier onlyNotBlacklistedEOA() {\n address oracleAddress = ap.getAddress(\"HYPERNATIVE_ORACLE\");\n\n if (oracleAddress == address(0)) {\n _;\n return;\n }\n\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n if (msg.sender != tx.origin) {\n revert CallerIsNotEOA();\n }\n oracle.validateBlacklistedAccountInteraction(msg.sender);\n _;\n }\n}\n" + }, + "contracts/compound/EIP20Interface.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title ERC 20 Token Standard Interface\n * https://eips.ethereum.org/EIPS/eip-20\n */\ninterface EIP20Interface {\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint8);\n\n /**\n * @notice Get the total number of tokens in circulation\n * @return uint256 The supply of tokens\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice Gets the balance of the specified address\n * @param owner The address from which the balance will be retrieved\n * @return balance uint256 The balance\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @notice Transfer `amount` tokens from `msg.sender` to `dst`\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transfer(address dst, uint256 amount) external returns (bool success);\n\n /**\n * @notice Transfer `amount` tokens from `src` to `dst`\n * @param src The address of the source account\n * @param dst The address of the destination account\n * @param amount The number of tokens to transfer\n * @return success bool Whether or not the transfer succeeded\n */\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool success);\n\n /**\n * @notice Approve `spender` to transfer up to `amount` from `src`\n * @dev This will overwrite the approval amount for `spender`\n * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)\n * @param spender The address of the account which may transfer tokens\n * @param amount The number of tokens that are approved (-1 means infinite)\n * @return success bool Whether or not the approval succeeded\n */\n function approve(address spender, uint256 amount) external returns (bool success);\n\n /**\n * @notice Get the current allowance from `owner` for `spender`\n * @param owner The address of the account which owns the tokens to be spent\n * @param spender The address of the account which may transfer tokens\n * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)\n */\n function allowance(address owner, address spender) external view returns (uint256 remaining);\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n}\n" + }, + "contracts/compound/ErrorReporter.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ncontract ComptrollerErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n COMPTROLLER_MISMATCH,\n INSUFFICIENT_SHORTFALL,\n INSUFFICIENT_LIQUIDITY,\n INVALID_CLOSE_FACTOR,\n INVALID_COLLATERAL_FACTOR,\n INVALID_LIQUIDATION_INCENTIVE,\n MARKET_NOT_LISTED,\n MARKET_ALREADY_LISTED,\n MATH_ERROR,\n NONZERO_BORROW_BALANCE,\n PRICE_ERROR,\n REJECTION,\n SNAPSHOT_ERROR,\n TOO_MANY_ASSETS,\n TOO_MUCH_REPAY,\n SUPPLIER_NOT_WHITELISTED,\n BORROW_BELOW_MIN,\n SUPPLY_ABOVE_MAX,\n NONZERO_TOTAL_SUPPLY\n }\n\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,\n ADD_REWARDS_DISTRIBUTOR_OWNER_CHECK,\n EXIT_MARKET_BALANCE_OWED,\n EXIT_MARKET_REJECTION,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n TOGGLE_AUTO_IMPLEMENTATIONS_ENABLED_OWNER_CHECK,\n SET_CLOSE_FACTOR_OWNER_CHECK,\n SET_CLOSE_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_NO_EXISTS,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COLLATERAL_FACTOR_WITHOUT_PRICE,\n SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,\n SET_LIQUIDATION_INCENTIVE_VALIDATION,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_PENDING_IMPLEMENTATION_CONTRACT_CHECK,\n SET_PENDING_IMPLEMENTATION_OWNER_CHECK,\n SET_PRICE_ORACLE_OWNER_CHECK,\n SET_WHITELIST_ENFORCEMENT_OWNER_CHECK,\n SET_WHITELIST_STATUS_OWNER_CHECK,\n SUPPORT_MARKET_EXISTS,\n SUPPORT_MARKET_OWNER_CHECK,\n SET_PAUSE_GUARDIAN_OWNER_CHECK,\n UNSUPPORT_MARKET_OWNER_CHECK,\n UNSUPPORT_MARKET_DOES_NOT_EXIST,\n UNSUPPORT_MARKET_IN_USE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return uint256(err);\n }\n}\n\ncontract TokenErrorReporter {\n enum Error {\n NO_ERROR,\n UNAUTHORIZED,\n BAD_INPUT,\n COMPTROLLER_REJECTION,\n COMPTROLLER_CALCULATION_ERROR,\n INTEREST_RATE_MODEL_ERROR,\n INVALID_ACCOUNT_PAIR,\n INVALID_CLOSE_AMOUNT_REQUESTED,\n INVALID_COLLATERAL_FACTOR,\n MATH_ERROR,\n MARKET_NOT_FRESH,\n MARKET_NOT_LISTED,\n TOKEN_INSUFFICIENT_ALLOWANCE,\n TOKEN_INSUFFICIENT_BALANCE,\n TOKEN_INSUFFICIENT_CASH,\n TOKEN_TRANSFER_IN_FAILED,\n TOKEN_TRANSFER_OUT_FAILED,\n UTILIZATION_ABOVE_MAX\n }\n\n /*\n * Note: FailureInfo (but not Error) is kept in alphabetical order\n * This is because FailureInfo grows significantly faster, and\n * the order of Error has some meaning, while the order of FailureInfo\n * is entirely arbitrary.\n */\n enum FailureInfo {\n ACCEPT_ADMIN_PENDING_ADMIN_CHECK,\n ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,\n ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_IONIC_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_NEW_TOTAL_ADMIN_FEES_CALCULATION_FAILED,\n ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,\n BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n BORROW_ACCRUE_INTEREST_FAILED,\n BORROW_CASH_NOT_AVAILABLE,\n BORROW_FRESHNESS_CHECK,\n BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n BORROW_MARKET_NOT_LISTED,\n BORROW_COMPTROLLER_REJECTION,\n LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,\n LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,\n LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,\n LIQUIDATE_COMPTROLLER_REJECTION,\n LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,\n LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,\n LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,\n LIQUIDATE_FRESHNESS_CHECK,\n LIQUIDATE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_REPAY_BORROW_FRESH_FAILED,\n LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,\n LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,\n LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,\n LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,\n LIQUIDATE_SEIZE_TOO_MUCH,\n MINT_ACCRUE_INTEREST_FAILED,\n MINT_COMPTROLLER_REJECTION,\n MINT_EXCHANGE_CALCULATION_FAILED,\n MINT_EXCHANGE_RATE_READ_FAILED,\n MINT_FRESHNESS_CHECK,\n MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n MINT_TRANSFER_IN_FAILED,\n MINT_TRANSFER_IN_NOT_POSSIBLE,\n NEW_UTILIZATION_RATE_ABOVE_MAX,\n REDEEM_ACCRUE_INTEREST_FAILED,\n REDEEM_COMPTROLLER_REJECTION,\n REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,\n REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,\n REDEEM_EXCHANGE_RATE_READ_FAILED,\n REDEEM_FRESHNESS_CHECK,\n REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,\n REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,\n REDEEM_TRANSFER_OUT_NOT_POSSIBLE,\n WITHDRAW_IONIC_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_IONIC_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_IONIC_FEES_FRESH_CHECK,\n WITHDRAW_IONIC_FEES_VALIDATION,\n WITHDRAW_ADMIN_FEES_ACCRUE_INTEREST_FAILED,\n WITHDRAW_ADMIN_FEES_CASH_NOT_AVAILABLE,\n WITHDRAW_ADMIN_FEES_FRESH_CHECK,\n WITHDRAW_ADMIN_FEES_VALIDATION,\n REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,\n REDUCE_RESERVES_ADMIN_CHECK,\n REDUCE_RESERVES_CASH_NOT_AVAILABLE,\n REDUCE_RESERVES_FRESH_CHECK,\n REDUCE_RESERVES_VALIDATION,\n REPAY_BEHALF_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCRUE_INTEREST_FAILED,\n REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_COMPTROLLER_REJECTION,\n REPAY_BORROW_FRESHNESS_CHECK,\n REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,\n REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,\n SET_COLLATERAL_FACTOR_OWNER_CHECK,\n SET_COLLATERAL_FACTOR_VALIDATION,\n SET_COMPTROLLER_OWNER_CHECK,\n SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,\n SET_INTEREST_RATE_MODEL_FRESH_CHECK,\n SET_INTEREST_RATE_MODEL_OWNER_CHECK,\n TOGGLE_ADMIN_RIGHTS_OWNER_CHECK,\n SET_PENDING_ADMIN_OWNER_CHECK,\n SET_ADMIN_FEE_ACCRUE_INTEREST_FAILED,\n SET_ADMIN_FEE_ADMIN_CHECK,\n SET_ADMIN_FEE_FRESH_CHECK,\n SET_ADMIN_FEE_BOUNDS_CHECK,\n SET_IONIC_FEE_ACCRUE_INTEREST_FAILED,\n SET_IONIC_FEE_FRESH_CHECK,\n SET_IONIC_FEE_BOUNDS_CHECK,\n SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,\n SET_RESERVE_FACTOR_ADMIN_CHECK,\n SET_RESERVE_FACTOR_FRESH_CHECK,\n SET_RESERVE_FACTOR_BOUNDS_CHECK,\n TRANSFER_COMPTROLLER_REJECTION,\n TRANSFER_NOT_ALLOWED,\n TRANSFER_NOT_ENOUGH,\n TRANSFER_TOO_MUCH,\n ADD_RESERVES_ACCRUE_INTEREST_FAILED,\n ADD_RESERVES_FRESH_CHECK,\n ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE\n }\n\n /**\n * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary\n * contract-specific code that enables us to report opaque error codes from upgradeable contracts.\n **/\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n /**\n * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator\n */\n function fail(Error err, FailureInfo info) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), 0);\n\n return uint256(err);\n }\n\n /**\n * @dev use this when reporting an opaque error from an upgradeable collaborator contract\n */\n function failOpaque(\n Error err,\n FailureInfo info,\n uint256 opaqueError\n ) internal returns (uint256) {\n emit Failure(uint256(err), uint256(info), opaqueError);\n\n return err == Error.COMPTROLLER_REJECTION ? 1000 + opaqueError : uint256(err);\n }\n}\n" + }, + "contracts/compound/Exponential.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CarefulMath.sol\";\nimport \"./ExponentialNoError.sol\";\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract Exponential is CarefulMath, ExponentialNoError {\n /**\n * @dev Creates an exponential from numerator and denominator values.\n * Note: Returns an error if (`num` * 10e18) > MAX_INT,\n * or if `denom` is zero.\n */\n function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: rational }));\n }\n\n /**\n * @dev Adds two exponentials, returning a new exponential.\n */\n function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Subtracts two exponentials, returning a new exponential.\n */\n function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa);\n\n return (error, Exp({ mantissa: result }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, returning a new Exp.\n */\n function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: scaledMantissa }));\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory product) = mulScalar(a, scalar);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(product));\n }\n\n /**\n * @dev Divide an Exp by a scalar, returning a new Exp.\n */\n function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n return (MathError.NO_ERROR, Exp({ mantissa: descaledMantissa }));\n }\n\n /**\n * @dev Divide a scalar by an Exp, returning a new Exp.\n */\n function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) {\n /*\n We are doing this as:\n getExp(mulUInt(expScale, scalar), divisor.mantissa)\n\n How it works:\n Exp = a / b;\n Scalar = s;\n `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`\n */\n (MathError err0, uint256 numerator) = mulUInt(expScale, scalar);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n return getExp(numerator, divisor.mantissa);\n }\n\n /**\n * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.\n */\n function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) {\n (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);\n if (err != MathError.NO_ERROR) {\n return (err, 0);\n }\n\n return (MathError.NO_ERROR, truncate(fraction));\n }\n\n /**\n * @dev Multiplies two exponentials, returning a new exponential.\n */\n function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);\n if (err0 != MathError.NO_ERROR) {\n return (err0, Exp({ mantissa: 0 }));\n }\n\n // We add half the scale before dividing so that we get rounding instead of truncation.\n // See \"Listing 6\" and text above it at https://accu.org/index.php/journals/1717\n // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.\n (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);\n if (err1 != MathError.NO_ERROR) {\n return (err1, Exp({ mantissa: 0 }));\n }\n\n (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale);\n // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.\n assert(err2 == MathError.NO_ERROR);\n\n return (MathError.NO_ERROR, Exp({ mantissa: product }));\n }\n\n /**\n * @dev Multiplies two exponentials given their mantissas, returning a new exponential.\n */\n function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) {\n return mulExp(Exp({ mantissa: a }), Exp({ mantissa: b }));\n }\n\n /**\n * @dev Multiplies three exponentials, returning a new exponential.\n */\n function mulExp3(\n Exp memory a,\n Exp memory b,\n Exp memory c\n ) internal pure returns (MathError, Exp memory) {\n (MathError err, Exp memory ab) = mulExp(a, b);\n if (err != MathError.NO_ERROR) {\n return (err, ab);\n }\n return mulExp(ab, c);\n }\n\n /**\n * @dev Divides two exponentials, returning a new exponential.\n * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,\n * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)\n */\n function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) {\n return getExp(a.mantissa, b.mantissa);\n }\n}\n" + }, + "contracts/compound/ExponentialNoError.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Exponential module for storing fixed-precision decimals\n * @author Compound\n * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.\n * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:\n * `Exp({mantissa: 5100000000000000000})`.\n */\ncontract ExponentialNoError {\n uint256 constant expScale = 1e18;\n uint256 constant doubleScale = 1e36;\n uint256 constant halfExpScale = expScale / 2;\n uint256 constant mantissaOne = expScale;\n\n struct Exp {\n uint256 mantissa;\n }\n\n struct Double {\n uint256 mantissa;\n }\n\n /**\n * @dev Truncates the given exp to a whole number value.\n * For example, truncate(Exp{mantissa: 15 * expScale}) = 15\n */\n function truncate(Exp memory exp) internal pure returns (uint256) {\n // Note: We are not using careful math here as we're performing a division that cannot fail\n return exp.mantissa / expScale;\n }\n\n /**\n * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.\n */\n function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return truncate(product);\n }\n\n /**\n * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.\n */\n function mul_ScalarTruncateAddUInt(\n Exp memory a,\n uint256 scalar,\n uint256 addend\n ) internal pure returns (uint256) {\n Exp memory product = mul_(a, scalar);\n return add_(truncate(product), addend);\n }\n\n /**\n * @dev Checks if first Exp is less than second Exp.\n */\n function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa < right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp <= right Exp.\n */\n function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa <= right.mantissa;\n }\n\n /**\n * @dev Checks if left Exp > right Exp.\n */\n function greaterThanExp(Exp memory left, Exp memory right) internal pure returns (bool) {\n return left.mantissa > right.mantissa;\n }\n\n /**\n * @dev returns true if Exp is exactly zero\n */\n function isZeroExp(Exp memory value) internal pure returns (bool) {\n return value.mantissa == 0;\n }\n\n function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) {\n require(n < 2**224, errorMessage);\n return uint224(n);\n }\n\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2**32, errorMessage);\n return uint32(n);\n }\n\n function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: add_(a.mantissa, b.mantissa) });\n }\n\n function add_(uint256 a, uint256 b) internal pure returns (uint256) {\n return add_(a, b, \"addition overflow\");\n }\n\n function add_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: sub_(a.mantissa, b.mantissa) });\n }\n\n function sub_(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub_(a, b, \"subtraction underflow\");\n }\n\n function sub_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b.mantissa) / expScale });\n }\n\n function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / expScale;\n }\n\n function mul_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b.mantissa) / doubleScale });\n }\n\n function mul_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: mul_(a.mantissa, b) });\n }\n\n function mul_(uint256 a, Double memory b) internal pure returns (uint256) {\n return mul_(a, b.mantissa) / doubleScale;\n }\n\n function mul_(uint256 a, uint256 b) internal pure returns (uint256) {\n return mul_(a, b, \"multiplication overflow\");\n }\n\n function mul_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n if (a == 0 || b == 0) {\n return 0;\n }\n uint256 c = a * b;\n require(c / a == b, errorMessage);\n return c;\n }\n\n function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(mul_(a.mantissa, expScale), b.mantissa) });\n }\n\n function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) {\n return Exp({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Exp memory b) internal pure returns (uint256) {\n return div_(mul_(a, expScale), b.mantissa);\n }\n\n function div_(Double memory a, Double memory b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa) });\n }\n\n function div_(Double memory a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(a.mantissa, b) });\n }\n\n function div_(uint256 a, Double memory b) internal pure returns (uint256) {\n return div_(mul_(a, doubleScale), b.mantissa);\n }\n\n function div_(uint256 a, uint256 b) internal pure returns (uint256) {\n return div_(a, b, \"divide by zero\");\n }\n\n function div_(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n function fraction(uint256 a, uint256 b) internal pure returns (Double memory) {\n return Double({ mantissa: div_(mul_(a, doubleScale), b) });\n }\n}\n" + }, + "contracts/compound/IERC4626.sol": { + "content": "pragma solidity >=0.8.0;\npragma experimental ABIEncoderV2;\n\nimport { EIP20Interface } from \"./EIP20Interface.sol\";\n\ninterface IERC4626 is EIP20Interface {\n /*----------------------------------------------------------------\n Events\n ----------------------------------------------------------------*/\n\n event Deposit(address indexed from, address indexed to, uint256 value);\n\n event Withdraw(address indexed from, address indexed to, uint256 value);\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n /**\n @notice Deposit a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to deposit.\n @param to The address to receive shares corresponding to the deposit\n @return shares The shares in the vault credited to `to`\n */\n function deposit(uint256 underlyingAmount, address to) external returns (uint256 shares);\n\n /**\n @notice Mint an exact amount of shares for a variable amount of underlying tokens.\n @param shareAmount The amount of vault shares to mint.\n @param to The address to receive shares corresponding to the mint.\n @return underlyingAmount The amount of the underlying tokens deposited from the mint call.\n */\n function mint(uint256 shareAmount, address to) external returns (uint256 underlyingAmount);\n\n /**\n @notice Withdraw a specific amount of underlying tokens.\n @param underlyingAmount The amount of the underlying token to withdraw.\n @param to The address to receive underlying corresponding to the withdrawal.\n @param from The address to burn shares from corresponding to the withdrawal.\n @return shares The shares in the vault burned from sender\n */\n function withdraw(\n uint256 underlyingAmount,\n address to,\n address from\n ) external returns (uint256 shares);\n\n /**\n @notice Redeem a specific amount of shares for underlying tokens.\n @param shareAmount The amount of shares to redeem.\n @param to The address to receive underlying corresponding to the redemption.\n @param from The address to burn shares from corresponding to the redemption.\n @return value The underlying amount transferred to `to`.\n */\n function redeem(\n uint256 shareAmount,\n address to,\n address from\n ) external returns (uint256 value);\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n /** \n @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n @return the address of the asset\n */\n function asset() external view returns (address);\n\n /** \n @notice Returns a user's Vault balance in underlying tokens.\n @param user The user to get the underlying balance of.\n @return balance The user's Vault balance in underlying tokens.\n */\n function balanceOfUnderlying(address user) external view returns (uint256 balance);\n\n /** \n @notice Calculates the total amount of underlying tokens the Vault manages.\n @return The total amount of underlying tokens the Vault manages.\n */\n function totalAssets() external view returns (uint256);\n\n /** \n @notice Returns the value in underlying terms of one vault token. \n */\n function exchangeRate() external view returns (uint256);\n\n /**\n @notice Returns the amount of vault tokens that would be obtained if depositing a given amount of underlying tokens in a `deposit` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a deposit call with `underlyingAmount` in\n */\n function previewDeposit(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be deposited if minting a given amount of shares in a `mint` call.\n @param shareAmount the amount of shares from a mint call.\n @return underlyingAmount the amount of underlying tokens corresponding to the mint call\n */\n function previewMint(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n\n /**\n @notice Returns the amount of vault tokens that would be burned if withdrawing a given amount of underlying tokens in a `withdraw` call.\n @param underlyingAmount the input amount of underlying tokens\n @return shareAmount the corresponding amount of shares out from a withdraw call with `underlyingAmount` in\n */\n function previewWithdraw(uint256 underlyingAmount) external view returns (uint256 shareAmount);\n\n /**\n @notice Returns the amount of underlying tokens that would be obtained if redeeming a given amount of shares in a `redeem` call.\n @param shareAmount the amount of shares from a redeem call.\n @return underlyingAmount the amount of underlying tokens corresponding to the redeem call\n */\n function previewRedeem(uint256 shareAmount) external view returns (uint256 underlyingAmount);\n}\n" + }, + "contracts/compound/IFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../ionic/AuthoritiesRegistry.sol\";\n\ninterface IFeeDistributor {\n function minBorrowEth() external view returns (uint256);\n\n function maxUtilizationRate() external view returns (uint256);\n\n function interestFeeRate() external view returns (uint256);\n\n function latestComptrollerImplementation(address oldImplementation) external view returns (address);\n\n function latestCErc20Delegate(uint8 delegateType)\n external\n view\n returns (address cErc20Delegate, bytes memory becomeImplementationData);\n\n function latestPluginImplementation(address oldImplementation) external view returns (address);\n\n function getComptrollerExtensions(address comptroller) external view returns (address[] memory);\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);\n\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address);\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n\n function authoritiesRegistry() external view returns (AuthoritiesRegistry);\n\n fallback() external payable;\n\n receive() external payable;\n}\n" + }, + "contracts/compound/InterestRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's InterestRateModel Interface\n * @author Compound\n */\nabstract contract InterestRateModel {\n /// @notice Indicator that this is an InterestRateModel contract (for inspection)\n bool public constant isInterestRateModel = true;\n\n /**\n * @notice Calculates the current borrow interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @return The borrow rate per block (as a percentage, and scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view virtual returns (uint256);\n\n /**\n * @notice Calculates the current supply interest rate per block\n * @param cash The total amount of cash the market has\n * @param borrows The total amount of borrows the market has outstanding\n * @param reserves The total amount of reserves the market has\n * @param reserveFactorMantissa The current reserve factor the market has\n * @return The supply rate per block (as a percentage, and scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual returns (uint256);\n}\n" + }, + "contracts/compound/JumpRateModel.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./InterestRateModel.sol\";\n\n/**\n * @title Compound's JumpRateModel Contract\n * @author Compound\n */\ncontract JumpRateModel is InterestRateModel {\n event NewInterestParams(\n uint256 baseRatePerBlock,\n uint256 multiplierPerBlock,\n uint256 jumpMultiplierPerBlock,\n uint256 kink\n );\n\n /**\n * @notice The approximate number of blocks per year that is assumed by the interest rate model\n */\n uint256 public blocksPerYear;\n\n /**\n * @notice The multiplier of utilization rate that gives the slope of the interest rate\n */\n uint256 public multiplierPerBlock;\n\n /**\n * @notice The base interest rate which is the y-intercept when utilization rate is 0\n */\n uint256 public baseRatePerBlock;\n\n /**\n * @notice The multiplierPerBlock after hitting a specified utilization point\n */\n uint256 public jumpMultiplierPerBlock;\n\n /**\n * @notice The utilization point at which the jump multiplier is applied\n */\n uint256 public kink;\n\n /**\n * @notice Construct an interest rate model\n * @param _blocksPerYear The approximate number of blocks per year\n * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)\n * @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)\n * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point\n * @param kink_ The utilization point at which the jump multiplier is applied\n */\n constructor(\n uint256 _blocksPerYear,\n uint256 baseRatePerYear,\n uint256 multiplierPerYear,\n uint256 jumpMultiplierPerYear,\n uint256 kink_\n ) {\n blocksPerYear = _blocksPerYear;\n baseRatePerBlock = baseRatePerYear / blocksPerYear;\n multiplierPerBlock = multiplierPerYear / blocksPerYear;\n jumpMultiplierPerBlock = jumpMultiplierPerYear / blocksPerYear;\n kink = kink_;\n\n emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);\n }\n\n /**\n * @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market (currently unused)\n * @return The utilization rate as a mantissa between [0, 1e18]\n */\n function utilizationRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public pure returns (uint256) {\n // Utilization rate is 0 when there are no borrows\n if (borrows == 0) {\n return 0;\n }\n\n return (borrows * 1e18) / (cash + borrows - reserves);\n }\n\n /**\n * @notice Calculates the current borrow rate per block, with the error code expected by the market\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @return The borrow rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getBorrowRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves\n ) public view override returns (uint256) {\n uint256 util = utilizationRate(cash, borrows, reserves);\n\n if (util <= kink) {\n return ((util * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n } else {\n uint256 normalRate = ((kink * multiplierPerBlock) / 1e18) + baseRatePerBlock;\n uint256 excessUtil = util - kink;\n return ((excessUtil * jumpMultiplierPerBlock) / 1e18) + normalRate;\n }\n }\n\n /**\n * @notice Calculates the current supply rate per block\n * @param cash The amount of cash in the market\n * @param borrows The amount of borrows in the market\n * @param reserves The amount of reserves in the market\n * @param reserveFactorMantissa The current reserve factor for the market\n * @return The supply rate percentage per block as a mantissa (scaled by 1e18)\n */\n function getSupplyRate(\n uint256 cash,\n uint256 borrows,\n uint256 reserves,\n uint256 reserveFactorMantissa\n ) public view virtual override returns (uint256) {\n uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;\n uint256 borrowRate = getBorrowRate(cash, borrows, reserves);\n uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;\n return (utilizationRate(cash, borrows, reserves) * rateToPool) / 1e18;\n }\n}\n" + }, + "contracts/compound/Unitroller.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./ErrorReporter.sol\";\nimport \"./ComptrollerStorage.sol\";\nimport \"./Comptroller.sol\";\nimport { DiamondExtension, DiamondBase, LibDiamond } from \"../ionic/DiamondExtension.sol\";\n\n/**\n * @title Unitroller\n * @dev Storage for the comptroller is at this address, while execution is delegated via the Diamond Extensions\n * CTokens should reference this contract as their comptroller.\n */\ncontract Unitroller is ComptrollerV3Storage, ComptrollerErrorReporter, DiamondBase {\n /**\n * @notice Event emitted when the admin rights are changed\n */\n event AdminRightsToggled(bool hasRights);\n\n /**\n * @notice Emitted when pendingAdmin is changed\n */\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /**\n * @notice Emitted when pendingAdmin is accepted, which means admin is updated\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n constructor(address payable _ionicAdmin) {\n admin = msg.sender;\n ionicAdmin = _ionicAdmin;\n }\n\n /*** Admin Functions ***/\n\n /**\n * @notice Toggles admin rights.\n * @param hasRights Boolean indicating if the admin is to have rights.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _toggleAdminRights(bool hasRights) external returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.TOGGLE_ADMIN_RIGHTS_OWNER_CHECK);\n }\n\n // Check that rights have not already been set to the desired value\n if (adminHasRights == hasRights) return uint256(Error.NO_ERROR);\n\n adminHasRights = hasRights;\n emit AdminRightsToggled(hasRights);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _setPendingAdmin(address newPendingAdmin) public returns (uint256) {\n if (!hasAdminRights()) {\n return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);\n }\n\n address oldPendingAdmin = pendingAdmin;\n pendingAdmin = newPendingAdmin;\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)\n */\n function _acceptAdmin() public returns (uint256) {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n if (msg.sender != pendingAdmin || msg.sender == address(0)) {\n return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);\n }\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n admin = pendingAdmin;\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n\n return uint256(Error.NO_ERROR);\n }\n\n function comptrollerImplementation() public view returns (address) {\n return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes(\"_deployMarket(uint8,bytes,bytes,uint256)\"))));\n }\n\n /**\n * @dev upgrades the implementation if necessary\n */\n function _upgrade() external {\n require(msg.sender == address(this) || hasAdminRights(), \"!self || !admin\");\n\n address currentImplementation = comptrollerImplementation();\n address latestComptrollerImplementation = IFeeDistributor(ionicAdmin).latestComptrollerImplementation(\n currentImplementation\n );\n\n _updateExtensions(latestComptrollerImplementation);\n\n if (currentImplementation != latestComptrollerImplementation) {\n // reinitialize\n _functionCall(address(this), abi.encodeWithSignature(\"_becomeImplementation()\"), \"!become impl\");\n }\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function _updateExtensions(address currentComptroller) internal {\n address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getComptrollerExtensions(currentComptroller);\n address[] memory currentExtensions = LibDiamond.listExtensions();\n\n // removed the current (old) extensions\n for (uint256 i = 0; i < currentExtensions.length; i++) {\n LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));\n }\n // add the new extensions\n for (uint256 i = 0; i < latestExtensions.length; i++) {\n LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));\n }\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {\n require(hasAdminRights(), \"!unauthorized\");\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/external/aerodrome/IAerodromeRouter.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.10;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20_Router {\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(address from, address to, uint256 amount) external returns (bool);\n}\n\ninterface IWETH is IERC20_Router {\n function deposit() external payable;\n\n function withdraw(uint256) external;\n}\n\ninterface IRouter_Aerodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n address factory;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientAmountAOptimal();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidAmountInForETHDeposit();\n error InvalidTokenInForETHDeposit();\n error InvalidPath();\n error InvalidRouteA();\n error InvalidRouteB();\n error OnlyWETH();\n error PoolDoesNotExist();\n error PoolFactoryDoesNotExist();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of FactoryRegistry.sol\n function factoryRegistry() external view returns (address);\n\n /// @notice Address of Protocol PoolFactory.sol\n function defaultFactory() external view returns (address);\n\n /// @notice Address of Voter.sol\n function voter() external view returns (address);\n\n /// @notice Interface of WETH contract used for WETH => ETH wrapping/unwrapping\n function weth() external view returns (IWETH);\n\n /// @dev Represents Ether. Used by zapper to determine whether to return assets as ETH/WETH.\n function ETHER() external view returns (address);\n\n /// @dev Struct containing information necessary to zap in and out of pools\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable Stable or volatile pool\n /// @param factory factory of pool\n /// @param amountOutMinA Minimum amount expected from swap leg of zap via routesA\n /// @param amountOutMinB Minimum amount expected from swap leg of zap via routesB\n /// @param amountAMin Minimum amount of tokenA expected from liquidity leg of zap\n /// @param amountBMin Minimum amount of tokenB expected from liquidity leg of zap\n struct Zap {\n address tokenA;\n address tokenB;\n bool stable;\n address factory;\n uint256 amountOutMinA;\n uint256 amountOutMinB;\n uint256 amountAMin;\n uint256 amountBMin;\n }\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// Used by all Router functions containing a `Route[]` or `_factory` argument.\n /// Reverts if _factory is not approved by the FactoryRegistry\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of factory which created the pool\n function poolFor(address tokenA, address tokenB, bool stable, address _factory) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param _factory Address of PoolFactory for tokenA and tokenB\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n // **** SWAP ****\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap one token for another without slippage protection\n /// @return amounts Array of amounts to swap per route\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function UNSAFE_swapExactTokensForTokens(\n uint256[] memory amounts,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n // **** SWAP (supporting fee-on-transfer tokens) ****\n\n /// @notice Swap one token for another supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Swap ETH for a token supporting fee-on-transfer tokens\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable;\n\n /// @notice Swap a token for WETH (returned as ETH) supporting fee-on-transfer tokens\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external;\n\n /// @notice Zap a token A into a pool (B, C). (A can be equal to B or C).\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the initial swap.\n /// Additional slippage may be required when adding liquidity as the\n /// price of the token may have changed.\n /// @param tokenIn Token you are zapping in from (i.e. input token).\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param zapInPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @param to Address you wish to mint liquidity to.\n /// @param stake Auto-stake liquidity in corresponding gauge.\n /// @return liquidity Amount of LP tokens created from zapping in.\n function zapIn(\n address tokenIn,\n uint256 amountInA,\n uint256 amountInB,\n Zap calldata zapInPool,\n Route[] calldata routesA,\n Route[] calldata routesB,\n address to,\n bool stake\n ) external payable returns (uint256 liquidity);\n\n /// @notice Zap out a pool (B, C) into A.\n /// Supports standard ERC20 tokens only (i.e. not fee-on-transfer tokens etc).\n /// Slippage is required for the removal of liquidity.\n /// Additional slippage may be required on the swap as the\n /// price of the token may have changed.\n /// @param tokenOut Token you are zapping out to (i.e. output token).\n /// @param liquidity Amount of liquidity you wish to remove.\n /// @param zapOutPool Contains zap struct information. See Zap struct.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n function zapOut(\n address tokenOut,\n uint256 liquidity,\n Zap calldata zapOutPool,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external;\n\n /// @notice Used to generate params required for zapping in.\n /// Zap in => remove liquidity then swap.\n /// Apply slippage to expected swap values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap in from.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param amountInA Amount of input token you wish to send down routesA\n /// @param amountInB Amount of input token you wish to send down routesB\n /// @param routesA Route used to convert input token to tokenA\n /// @param routesB Route used to convert input token to tokenB\n /// @return amountOutMinA Minimum output expected from swapping input token to tokenA.\n /// @return amountOutMinB Minimum output expected from swapping input token to tokenB.\n /// @return amountAMin Minimum amount of tokenA expected from depositing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from depositing liquidity.\n function generateZapInParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 amountInA,\n uint256 amountInB,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used to generate params required for zapping out.\n /// Zap out => swap then add liquidity.\n /// Apply slippage to expected liquidity values to account for changes in reserves in between.\n /// @dev Output token refers to the token you want to zap out of.\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable .\n /// @param _factory .\n /// @param liquidity Amount of liquidity being zapped out of into a given output token.\n /// @param routesA Route used to convert tokenA into output token.\n /// @param routesB Route used to convert tokenB into output token.\n /// @return amountOutMinA Minimum output expected from swapping tokenA into output token.\n /// @return amountOutMinB Minimum output expected from swapping tokenB into output token.\n /// @return amountAMin Minimum amount of tokenA expected from withdrawing liquidity.\n /// @return amountBMin Minimum amount of tokenB expected from withdrawing liquidity.\n function generateZapOutParams(\n address tokenA,\n address tokenB,\n bool stable,\n address _factory,\n uint256 liquidity,\n Route[] calldata routesA,\n Route[] calldata routesB\n ) external view returns (uint256 amountOutMinA, uint256 amountOutMinB, uint256 amountAMin, uint256 amountBMin);\n\n /// @notice Used by zapper to determine appropriate ratio of A to B to deposit liquidity. Assumes stable pool.\n /// @dev Returns stable liquidity ratio of B to (A + B).\n /// E.g. if ratio is 0.4, it means there is more of A than there is of B.\n /// Therefore you should deposit more of token A than B.\n /// @param tokenA tokenA of stable pool you are zapping into.\n /// @param tokenB tokenB of stable pool you are zapping into.\n /// @param factory Factory that created stable pool.\n /// @return ratio Ratio of token0 to token1 required to deposit into zap.\n function quoteStableLiquidityRatio(\n address tokenA,\n address tokenB,\n address factory\n ) external view returns (uint256 ratio);\n}\n" + }, + "contracts/external/aerodrome/IAerodromeSwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.10;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via CL\ninterface ISwapRouter_Aerodrome {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n int24 tickSpacing;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/algebra/IAlgebraSwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IAlgebraPoolActions#swap\n/// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces\ninterface IAlgebraSwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call\n function algebraSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/algebra/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport \"./IAlgebraSwapCallback.sol\";\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Algebra\n/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:\n/// https://github.com/Uniswap/v3-periphery\ninterface IAlgebraSwapRouter is IAlgebraSwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 limitSqrtPrice;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Unlike standard swaps, handles transferring from user before the actual swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingleSupportingFeeOnTransferTokens(ExactInputSingleParams calldata params)\n external\n returns (uint256 amountOut);\n}\n" + }, + "contracts/external/balancer/IBalancerPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IBalancerVault } from \"./IBalancerVault.sol\";\n\ninterface IBalancerPool {\n function getFinalTokens() external view returns (address[] memory);\n\n function getNormalizedWeight(address token) external view returns (uint256);\n\n function getNormalizedWeights() external view returns (uint256[] memory);\n\n function getSwapFee() external view returns (uint256);\n\n function getNumTokens() external view returns (uint256);\n\n function getBalance(address token) external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function getPoolId() external view returns (bytes32);\n\n function getVault() external view returns (IBalancerVault);\n\n function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;\n\n function swapExactAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n address tokenOut,\n uint256 minAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter);\n\n function swapExactAmountOut(\n address tokenIn,\n uint256 maxAmountIn,\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPrice\n ) external returns (uint256 tokenAmountIn, uint256 spotPriceAfter);\n\n function joinswapExternAmountIn(\n address tokenIn,\n uint256 tokenAmountIn,\n uint256 minPoolAmountOut\n ) external returns (uint256 poolAmountOut);\n\n function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;\n\n function exitswapExternAmountOut(\n address tokenOut,\n uint256 tokenAmountOut,\n uint256 maxPoolAmountIn\n ) external returns (uint256 poolAmountIn);\n}\n" + }, + "contracts/external/balancer/IBalancerVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IAsset {}\n\nenum UserBalanceOpKind {\n DEPOSIT_INTERNAL,\n WITHDRAW_INTERNAL,\n TRANSFER_INTERNAL,\n TRANSFER_EXTERNAL\n}\n\nenum SwapKind {\n GIVEN_IN,\n GIVEN_OUT\n}\n\nenum ExitKind {\n EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,\n EXACT_BPT_IN_FOR_TOKENS_OUT,\n BPT_IN_FOR_EXACT_TOKENS_OUT,\n MANAGEMENT_FEE_TOKENS_OUT\n}\n\nstruct UserBalanceOp {\n UserBalanceOpKind kind;\n IAsset asset;\n uint256 amount;\n address sender;\n address payable recipient;\n}\nstruct FundManagement {\n address sender;\n bool fromInternalBalance;\n address payable recipient;\n bool toInternalBalance;\n}\n\nstruct SingleSwap {\n bytes32 poolId;\n SwapKind kind;\n IAsset assetIn;\n IAsset assetOut;\n uint256 amount;\n bytes userData;\n}\n\nstruct ExitPoolRequest {\n IERC20Upgradeable[] assets;\n uint256[] minAmountsOut;\n bytes userData;\n bool toInternalBalance;\n}\n\ninterface IBalancerVault {\n function swap(\n SingleSwap memory singleSwap,\n FundManagement memory funds,\n uint256 limit,\n uint256 deadline\n ) external returns (uint256 amountCalculated);\n\n function manageUserBalance(UserBalanceOp[] memory ops) external payable;\n\n function getPoolTokens(bytes32 poolId)\n external\n view\n returns (\n IERC20Upgradeable[] memory tokens,\n uint256[] memory balances,\n uint256 lastChangeBlock\n );\n\n function exitPool(\n bytes32 poolId,\n address sender,\n address payable recipient,\n ExitPoolRequest memory request\n ) external;\n}\n" + }, + "contracts/external/chainlink/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" + }, + "contracts/external/compound/IComptroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./IPriceOracle.sol\";\nimport \"./ICToken.sol\";\nimport \"./IUnitroller.sol\";\nimport \"./IRewardsDistributor.sol\";\n\n/**\n * @title Compound's Comptroller Contract\n * @author Compound\n */\ninterface IComptroller {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function oracle() external view returns (IPriceOracle);\n\n function pauseGuardian() external view returns (address);\n\n function closeFactorMantissa() external view returns (uint256);\n\n function liquidationIncentiveMantissa() external view returns (uint256);\n\n function markets(address cToken) external view returns (bool, uint256);\n\n function getAssetsIn(address account) external view returns (ICToken[] memory);\n\n function checkMembership(address account, ICToken cToken) external view returns (bool);\n\n function getHypotheticalAccountLiquidity(\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n )\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function getAccountLiquidity(address account)\n external\n view\n returns (\n uint256,\n uint256,\n uint256\n );\n\n function _setPriceOracle(IPriceOracle newOracle) external returns (uint256);\n\n function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);\n\n function _setCollateralFactor(ICToken market, uint256 newCollateralFactorMantissa) external returns (uint256);\n\n function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);\n\n function _become(IUnitroller unitroller) external;\n\n function borrowGuardianPaused(address cToken) external view returns (bool);\n\n function mintGuardianPaused(address cToken) external view returns (bool);\n\n function getRewardsDistributors() external view returns (address[] memory);\n\n function getAllMarkets() external view returns (ICToken[] memory);\n\n function getAllBorrowers() external view returns (address[] memory);\n\n function suppliers(address account) external view returns (bool);\n\n function supplyCaps(address cToken) external view returns (uint256);\n\n function borrowCaps(address cToken) external view returns (uint256);\n\n function enforceWhitelist() external view returns (bool);\n\n function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);\n\n function exitMarket(address cTokenAddress) external returns (uint256);\n\n function autoImplementation() external view returns (bool);\n\n function isUserOfPool(address user) external view returns (bool);\n\n function whitelist(address account) external view returns (bool);\n\n function _setWhitelistEnforcement(bool enforce) external returns (uint256);\n\n function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);\n\n function _toggleAutoImplementations(bool enabled) external returns (uint256);\n\n function _deployMarket(\n bool isCEther,\n bytes memory constructorData,\n bytes calldata becomeImplData,\n uint256 collateralFactorMantissa\n ) external returns (uint256);\n\n function getMaxRedeemOrBorrow(\n address account,\n ICToken cTokenModify,\n bool isBorrow\n ) external view returns (uint256);\n\n function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);\n\n function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);\n\n function isDeprecated(ICToken cToken) external view returns (bool);\n\n function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);\n\n function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);\n}\n" + }, + "contracts/external/compound/ICToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title Compound's CToken Contract\n * @notice Abstract base for CTokens\n * @author Compound\n */\ninterface ICToken {\n function admin() external view returns (address);\n\n function adminHasRights() external view returns (bool);\n\n function ionicAdminHasRights() external view returns (bool);\n\n function symbol() external view returns (string memory);\n\n function comptroller() external view returns (address);\n\n function adminFeeMantissa() external view returns (uint256);\n\n function ionicFeeMantissa() external view returns (uint256);\n\n function reserveFactorMantissa() external view returns (uint256);\n\n function totalReserves() external view returns (uint256);\n\n function totalAdminFees() external view returns (uint256);\n\n function totalIonicFees() external view returns (uint256);\n\n function isCToken() external view returns (bool);\n\n function isCEther() external view returns (bool);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function balanceOfUnderlying(address owner) external returns (uint256);\n\n function borrowRatePerBlock() external view returns (uint256);\n\n function supplyRatePerBlock() external view returns (uint256);\n\n function totalBorrowsCurrent() external returns (uint256);\n\n function totalBorrows() external view returns (uint256);\n\n function totalSupply() external view returns (uint256);\n\n function borrowBalanceStored(address account) external view returns (uint256);\n\n function borrowBalanceCurrent(address account) external returns (uint256);\n\n function exchangeRateCurrent() external returns (uint256);\n\n function exchangeRateStored() external view returns (uint256);\n\n function accrueInterest() external returns (uint256);\n\n function getCash() external view returns (uint256);\n\n function mint(uint256 mintAmount) external returns (uint256);\n\n function redeem(uint256 redeemTokens) external returns (uint256);\n\n function redeemUnderlying(uint256 redeemAmount) external returns (uint256);\n\n function borrow(uint256 borrowAmount) external returns (uint256);\n\n function repayBorrow(uint256 repayAmount) external returns (uint256);\n\n function protocolSeizeShareMantissa() external view returns (uint256);\n\n function feeSeizeShareMantissa() external view returns (uint256);\n\n function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);\n\n function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);\n}\n" + }, + "contracts/external/compound/IPriceOracle.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\ninterface IPriceOracle {\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICToken cToken) external view returns (uint256);\n}\n" + }, + "contracts/external/compound/IRewardsDistributor.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\nimport \"./ICToken.sol\";\n\n/**\n * @title RewardsDistributor\n * @author Compound\n */\ninterface IRewardsDistributor {\n /// @dev The token to reward (i.e., COMP)\n function rewardToken() external view returns (address);\n\n /// @notice The portion of compRate that each market currently receives\n function compSupplySpeeds(address) external view returns (uint256);\n\n /// @notice The portion of compRate that each market currently receives\n function compBorrowSpeeds(address) external view returns (uint256);\n\n /// @notice The COMP accrued but not yet transferred to each user\n function compAccrued(address) external view returns (uint256);\n\n /**\n * @notice Keeps the flywheel moving pre-mint and pre-redeem\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param supplier The minter/redeemer\n */\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n /**\n * @notice Keeps the flywheel moving pre-borrow and pre-repay\n * @dev Called by the Comptroller\n * @param cToken The relevant market\n * @param borrower The borrower\n */\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n /**\n * @notice Returns an array of all markets.\n */\n function getAllMarkets() external view returns (ICToken[] memory);\n}\n" + }, + "contracts/external/compound/IUnitroller.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity >=0.8.0;\n\n/**\n * @title ComptrollerCore\n * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.\n * CTokens should reference this contract as their comptroller.\n */\ninterface IUnitroller {\n function _setPendingImplementation(address newPendingImplementation) external returns (uint256);\n\n function _setPendingAdmin(address newPendingAdmin) external returns (uint256);\n}\n" + }, + "contracts/external/curve/ICurvePool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ICurvePool is IERC20Upgradeable {\n function get_virtual_price() external view returns (uint256);\n\n function remove_liquidity_one_coin(\n uint256 _token_amount,\n int128 i,\n uint256 min_amount\n ) external;\n\n function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);\n\n function add_liquidity(uint256[2] calldata _amounts, uint256 _min_mint_amount) external returns (uint256);\n\n function exchange(\n int128 i,\n int128 j,\n uint256 dx,\n uint256 min_dy\n ) external returns (uint256);\n\n function get_dy(\n int128 i,\n int128 j,\n uint256 _dx\n ) external view returns (uint256);\n\n function coins(uint256 index) external view returns (address);\n\n function lp_token() external view returns (address);\n}\n" + }, + "contracts/external/curve/ICurveV2Pool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICurvePool } from \"./ICurvePool.sol\";\n\ninterface ICurveV2Pool is ICurvePool {\n function price_oracle() external view returns (uint256);\n\n function lp_price() external view returns (uint256);\n\n function coins(uint256 arg0) external view returns (address);\n}\n" + }, + "contracts/external/hypernative/interfaces/IHypernativeOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\ninterface IHypernativeOracle {\n function register(address account, bool isStrictMode) external;\n function validateForbiddenAccountInteraction(address sender) external view;\n function validateForbiddenContextInteraction(address origin, address sender) external view;\n function validateBlacklistedAccountInteraction(address sender) external;\n}" + }, + "contracts/external/jarvis/ISynthereumDeployment.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./ISynthereumFinder.sol\";\n\n/**\n * @title Interface that a pool MUST have in order to be included in the deployer\n */\ninterface ISynthereumDeployment {\n /**\n * @notice Get Synthereum finder of the pool/self-minting derivative\n * @return finder Returns finder contract\n */\n function synthereumFinder() external view returns (ISynthereumFinder finder);\n\n /**\n * @notice Get Synthereum version\n * @return poolVersion Returns the version of this pool/self-minting derivative\n */\n function version() external view returns (uint8 poolVersion);\n\n /**\n * @notice Get the collateral token of this pool/self-minting derivative\n * @return collateralCurrency The ERC20 collateral token\n */\n function collateralToken() external view returns (IERC20Upgradeable collateralCurrency);\n\n /**\n * @notice Get the synthetic token associated to this pool/self-minting derivative\n * @return syntheticCurrency The ERC20 synthetic token\n */\n function syntheticToken() external view returns (IERC20Upgradeable syntheticCurrency);\n\n /**\n * @notice Get the synthetic token symbol associated to this pool/self-minting derivative\n * @return symbol The ERC20 synthetic token symbol\n */\n function syntheticTokenSymbol() external view returns (string memory symbol);\n}\n" + }, + "contracts/external/jarvis/ISynthereumFinder.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\n/**\n * @title Provides addresses of the contracts implementing certain interfaces.\n */\ninterface ISynthereumFinder {\n /**\n * @notice Updates the address of the contract that implements `interfaceName`.\n * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.\n * @param implementationAddress address of the deployed contract that implements the interface.\n */\n function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;\n\n /**\n * @notice Gets the address of the contract that implements the given `interfaceName`.\n * @param interfaceName queried interface.\n * @return implementationAddress Address of the deployed contract that implements the interface.\n */\n function getImplementationAddress(bytes32 interfaceName) external view returns (address);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPool.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumLiquidityPoolGeneral.sol\";\n\n//import {\n//IEmergencyShutdown\n//} from '../../../common/interfaces/IEmergencyShutdown.sol';\n//import {ISynthereumLiquidityPoolGeneral} from './ILiquidityPoolGeneral.sol';\n//import {ISynthereumLiquidityPoolStorage} from './ILiquidityPoolStorage.sol';\n//import {ITypology} from '../../../common/interfaces/ITypology.sol';\n\n/**\n * @title Token Issuer Contract Interface\n */\n//ITypology,\n//IEmergencyShutdown,\ninterface ISynthereumLiquidityPool is ISynthereumLiquidityPoolGeneral {\n struct MintParams {\n // Minimum amount of synthetic tokens that a user wants to mint using collateral (anti-slippage)\n uint256 minNumTokens;\n // Amount of collateral that a user wants to spend for minting\n uint256 collateralAmount;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send synthetic tokens minted\n address recipient;\n }\n\n struct RedeemParams {\n // Amount of synthetic tokens that user wants to use for redeeming\n uint256 numTokens;\n // Minimium amount of collateral that user wants to redeem (anti-slippage)\n uint256 minCollateral;\n // Expiration time of the transaction\n uint256 expiration;\n // Address to which send collateral tokens redeemed\n address recipient;\n }\n\n // struct ExchangeParams {\n // // Destination pool\n // ISynthereumLiquidityPoolGeneral destPool;\n // // Amount of source synthetic tokens that user wants to use for exchanging\n // uint256 numTokens;\n // // Minimum Amount of destination synthetic tokens that user wants to receive (anti-slippage)\n // uint256 minDestNumTokens;\n // // Expiration time of the transaction\n // uint256 expiration;\n // // Address to which send synthetic tokens exchanged\n // address recipient;\n // }\n\n /**\n * @notice Mint synthetic tokens using fixed amount of collateral\n * @notice This calculate the price using on chain price feed\n * @notice User must approve collateral transfer for the mint request to succeed\n * @param mintParams Input parameters for minting (see MintParams struct)\n * @return syntheticTokensMinted Amount of synthetic tokens minted by a user\n * @return feePaid Amount of collateral paid by the user as fee\n */\n function mint(MintParams calldata mintParams) external returns (uint256 syntheticTokensMinted, uint256 feePaid);\n\n /**\n * @notice Redeem amount of collateral using fixed number of synthetic token\n * @notice This calculate the price using on chain price feed\n * @notice User must approve synthetic token transfer for the redeem request to succeed\n * @param redeemParams Input parameters for redeeming (see RedeemParams struct)\n * @return collateralRedeemed Amount of collateral redeem by user\n * @return feePaid Amount of collateral paid by user as fee\n */\n function redeem(RedeemParams calldata redeemParams) external returns (uint256 collateralRedeemed, uint256 feePaid);\n\n // /**\n // * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool\n // * @notice This calculate the price using on chain price feed\n // * @notice User must approve synthetic token transfer for the redeem request to succeed\n // * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct)\n // * @return destNumTokensMinted Amount of collateral redeem by user\n // * @return feePaid Amount of collateral paid by user as fee\n // */\n // function exchange(ExchangeParams calldata exchangeParams)\n // external\n // returns (uint256 destNumTokensMinted, uint256 feePaid);\n\n /**\n * @notice Withdraw unused deposited collateral by the LP\n * @notice Only a sender with LP role can call this function\n * @param collateralAmount Collateral to be withdrawn\n * @return remainingLiquidity Remaining unused collateral in the pool\n */\n function withdrawLiquidity(uint256 collateralAmount) external returns (uint256 remainingLiquidity);\n\n /**\n * @notice Increase collaterallization of Lp position\n * @notice Only a sender with LP role can call this function\n * @param collateralToTransfer Collateral to be transferred before increase collateral in the position\n * @param collateralToIncrease Collateral to be added to the position\n * @return newTotalCollateral New total collateral amount\n */\n function increaseCollateral(uint256 collateralToTransfer, uint256 collateralToIncrease)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Decrease collaterallization of Lp position\n * @notice Check that final poosition is not undercollateralized\n * @notice Only a sender with LP role can call this function\n * @param collateralToDecrease Collateral to decreased from the position\n * @param collateralToWithdraw Collateral to be transferred to the LP\n * @return newTotalCollateral New total collateral amount\n */\n function decreaseCollateral(uint256 collateralToDecrease, uint256 collateralToWithdraw)\n external\n returns (uint256 newTotalCollateral);\n\n /**\n * @notice Withdraw fees gained by the sender\n * @return feeClaimed Amount of fee claimed\n */\n function claimFee() external returns (uint256 feeClaimed);\n\n /**\n * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized\n * @notice Revert if position is not undercollateralized\n * @param numSynthTokens Number of synthetic tokens that user wants to liquidate\n * @return synthTokensLiquidated Amount of synthetic tokens liquidated\n * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated\n * @return rewardAmount Amount of received collateral as reward for the liquidation\n */\n function liquidate(uint256 numSynthTokens)\n external\n returns (\n uint256 synthTokensLiquidated,\n uint256 collateralReceived,\n uint256 rewardAmount\n );\n\n /**\n * @notice Redeem tokens after emergency shutdown\n * @return synthTokensSettled Amount of synthetic tokens liquidated\n * @return collateralSettled Amount of collateral withdrawn after emergency shutdown\n */\n function settleEmergencyShutdown() external returns (uint256 synthTokensSettled, uint256 collateralSettled);\n\n // /**\n // * @notice Update the fee percentage, recipients and recipient proportions\n // * @notice Only the maintainer can call this function\n // * @param _feeData Fee info (percentage + recipients + weigths)\n // */\n // function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData)\n // external;\n\n /**\n * @notice Update the fee percentage\n * @notice Only the maintainer can call this function\n * @param _feePercentage The new fee percentage\n */\n function setFeePercentage(uint256 _feePercentage) external;\n\n /**\n * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive\n * @notice Only the maintainer can call this function\n * @param feeRecipients An array of the addresses of recipients that will receive generated fees\n * @param feeProportions An array of the proportions of fees generated each recipient will receive\n */\n function setFeeRecipients(address[] calldata feeRecipients, uint32[] calldata feeProportions) external;\n\n /**\n * @notice Update the overcollateralization percentage\n * @notice Only the maintainer can call this function\n * @param _overCollateralization Overcollateralization percentage\n */\n function setOverCollateralization(uint256 _overCollateralization) external;\n\n /**\n * @notice Update the liquidation reward percentage\n * @notice Only the maintainer can call this function\n * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator\n */\n function setLiquidationReward(uint256 _liquidationReward) external;\n\n /**\n * @notice Returns fee percentage set by the maintainer\n * @return Fee percentage\n */\n function feePercentage() external view returns (uint256);\n\n /**\n * @notice Returns fee recipients info\n * @return Addresses, weigths and total of weigths\n */\n function feeRecipientsInfo()\n external\n view\n returns (\n address[] memory,\n uint32[] memory,\n uint256\n );\n\n /**\n * @notice Returns total number of synthetic tokens generated by this pool\n * @return Number of synthetic tokens\n */\n function totalSyntheticTokens() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP)\n * @return Total collateral amount\n */\n function totalCollateralAmount() external view returns (uint256);\n\n /**\n * @notice Returns the total amount of fees to be withdrawn\n * @return Total fee amount\n */\n function totalFeeAmount() external view returns (uint256);\n\n /**\n * @notice Returns the user's fee to be withdrawn\n * @param user User's address\n * @return User's fee\n */\n function userFee(address user) external view returns (uint256);\n\n /**\n * @notice Returns the percentage of overcollateralization to which a liquidation can triggered\n * @return Percentage of overcollateralization\n */\n function collateralRequirement() external view returns (uint256);\n\n /**\n * @notice Returns the percentage of reward for correct liquidation by a liquidator\n * @return Percentage of reward\n */\n function liquidationReward() external view returns (uint256);\n\n /**\n * @notice Returns the price of the pair at the moment of the shutdown\n * @return Price of the pair\n */\n function emergencyShutdownPrice() external view returns (uint256);\n\n /**\n * @notice Returns the timestamp (unix time) at the moment of the shutdown\n * @return Timestamp\n */\n function emergencyShutdownTimestamp() external view returns (uint256);\n\n /**\n * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price\n * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized))\n */\n function collateralCoverage() external returns (bool, uint256);\n\n /**\n * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param inputCollateral Input collateral amount to be exchanged\n * @return synthTokensReceived Synthetic tokens will be minted\n * @return feePaid Collateral fee will be paid\n */\n function getMintTradeInfo(uint256 inputCollateral)\n external\n view\n returns (uint256 synthTokensReceived, uint256 feePaid);\n\n /**\n * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n * @param syntheticTokens Amount of synthetic tokens to be exchanged\n * @return collateralAmountReceived Collateral amount will be received by the user\n * @return feePaid Collateral fee will be paid\n */\n function getRedeemTradeInfo(uint256 syntheticTokens)\n external\n view\n returns (uint256 collateralAmountReceived, uint256 feePaid);\n\n // /**\n // * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens\n // * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions\n // * @param syntheticTokens Amount of synthetic tokens to be exchanged\n // * @param destinationPool Pool in which mint the destination synthetic token\n // * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool\n // * @return feePaid Collateral fee will be paid\n // */\n // function getExchangeTradeInfo(\n // uint256 syntheticTokens,\n // ISynthereumLiquidityPoolGeneral destinationPool\n // )\n // external\n // view\n // returns (uint256 destSyntheticTokensReceived, uint256 feePaid);\n /**\n * @notice Shutdown the pool or self-minting-derivative in case of emergency\n * @notice Only Synthereum manager contract can call this function\n * @return timestamp Timestamp of emergency shutdown transaction\n * @return price Price of the pair at the moment of shutdown execution\n */\n function emergencyShutdown() external returns (uint256 timestamp, uint256 price);\n}\n" + }, + "contracts/external/jarvis/ISynthereumLiquidityPoolGeneral.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.4;\n\nimport \"./ISynthereumDeployment.sol\";\n\ninterface ISynthereumLiquidityPoolGeneral is\n ISynthereumDeployment\n //,\n //ISynthereumLiquidityPoolInteraction\n{}\n" + }, + "contracts/external/pyth/IExpressRelay.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelay {\n // Check if the combination of protocol and permissionKey is allowed within this transaction.\n // This will return true if and only if it's being called while executing the auction winner(s) call.\n // @param protocolFeeReceiver The address of the protocol that is gating an action behind this permission\n // @param permissionId The id that represents the action being gated\n // @return permissioned True if the permission is allowed, false otherwise\n function isPermissioned(\n address protocolFeeReceiver,\n bytes calldata permissionId\n ) external view returns (bool permissioned);\n}\n" + }, + "contracts/external/pyth/IExpressRelayFeeReceiver.sol": { + "content": "// SPDX-License-Identifier: Apache 2\npragma solidity ^0.8.0;\n\ninterface IExpressRelayFeeReceiver {\n // Receive the proceeds of an auction.\n // @param permissionKey The permission key where the auction was conducted on.\n function receiveAuctionProceedings(\n bytes calldata permissionKey\n ) external payable;\n}\n" + }, + "contracts/external/redstone/IRedstoneOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IRedstoneOracle {\n function priceOf(address asset) external view returns (uint256);\n\n function priceOfETH() external view returns (uint256);\n\n function getDataFeedIdForAsset(address asset) external view returns (bytes32);\n\n function getDataFeedIds() external view returns (bytes32[] memory dataFeedIds);\n}\n" + }, + "contracts/external/solidly/IPair.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nstruct Observation {\n uint256 timestamp;\n uint256 reserve0Cumulative;\n uint256 reserve1Cumulative;\n}\n\ninterface IPair {\n function observations(uint256 index) external pure returns (Observation memory);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function metadata()\n external\n view\n returns (\n uint256 dec0,\n uint256 dec1,\n uint256 r0,\n uint256 r1,\n bool st,\n address t0,\n address t1\n );\n\n function claimFees() external returns (uint256, uint256);\n\n function tokens() external returns (address, address);\n\n function stable() external view returns (bool);\n\n function observationLength() external view returns (uint256);\n\n function lastObservation() external view returns (Observation memory);\n\n function current(address tokenIn, uint256 amountIn) external view returns (uint256 amountOut);\n\n function currentCumulativePrices()\n external\n view\n returns (\n uint256 reserve0Cumulative,\n uint256 reserve1Cumulative,\n uint256 blockTimestamp\n );\n\n function transferFrom(\n address src,\n address dst,\n uint256 amount\n ) external returns (bool);\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 function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function sync() external;\n\n function transfer(address dst, uint256 amount) external returns (bool);\n\n function getReserves()\n external\n view\n returns (\n uint256 _reserve0,\n uint256 _reserve1,\n uint256 _blockTimestampLast\n );\n\n function getAmountOut(uint256, address) external view returns (uint256);\n}\n" + }, + "contracts/external/solidly/IRouter.sol": { + "content": "pragma solidity >=0.8.0;\n\ninterface IRouter {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n function isPair(address pair) external view returns (bool);\n\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n function pairFor(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (address pair);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function swapExactTokensForTokensSimple(\n uint256 amountIn,\n uint256 amountOutMin,\n address tokenFrom,\n address tokenTo,\n bool stable,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n )\n external\n view\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n}\n" + }, + "contracts/external/uniswap/FullMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Rewrite unary negation of denominator, which is a uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = a * b\n // Compute the product mod 2**256 and mod 2**256 - 1\n // then use the Chinese Remainder Theorem to reconstruct\n // the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2**256 + prod0\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(a, b, not(0))\n prod0 := mul(a, b)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division\n if (prod1 == 0) {\n require(denominator > 0);\n assembly {\n result := div(prod0, denominator)\n }\n return result;\n }\n\n // Make sure the result is less than 2**256.\n // Also prevents denominator == 0\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0]\n // Compute remainder using mulmod\n uint256 remainder;\n assembly {\n remainder := mulmod(a, b, denominator)\n }\n // Subtract 256 bit number from 512 bit number\n assembly {\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator\n // Compute largest power of two divisor of denominator.\n // Always >= 1.\n uint256 twos = denominator & (~denominator + 1);\n\n // Divide denominator by power of two\n assembly {\n denominator := div(denominator, twos)\n }\n\n // Divide [prod1 prod0] by the factors of two\n assembly {\n prod0 := div(prod0, twos)\n }\n // Shift in bits from prod1 into prod0. For this we need\n // to flip `twos` such that it is 2**256 / twos.\n // If twos is zero, then it becomes one\n assembly {\n twos := add(div(sub(0, twos), twos), 1)\n }\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2**256\n // Now that denominator is an odd number, it has an inverse\n // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n // Compute the inverse by starting with a seed that is correct\n // correct for four bits. That is, denominator * inv = 1 mod 2**4\n uint256 inv = (3 * denominator) ^ 2;\n // Now use Newton-Raphson iteration to improve the precision.\n // Thanks to Hensel's lifting lemma, this also works in modular\n // arithmetic, doubling the correct bits in each step.\n inv *= 2 - denominator * inv; // inverse mod 2**8\n inv *= 2 - denominator * inv; // inverse mod 2**16\n inv *= 2 - denominator * inv; // inverse mod 2**32\n inv *= 2 - denominator * inv; // inverse mod 2**64\n inv *= 2 - denominator * inv; // inverse mod 2**128\n inv *= 2 - denominator * inv; // inverse mod 2**256\n\n // Because the division is now exact we can divide by multiplying\n // with the modular inverse of denominator. This will give us the\n // correct result modulo 2**256. Since the precoditions guarantee\n // that the outcome is less than 2**256, this is the final result.\n // We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inv;\n return result;\n }\n }\n\n /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n /// @param a The multiplicand\n /// @param b The multiplier\n /// @param denominator The divisor\n /// @return result The 256-bit result\n function mulDivRoundingUp(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n result = mulDiv(a, b, denominator);\n if (mulmod(a, b, denominator) > 0) {\n require(result < type(uint256).max);\n result++;\n }\n }\n }\n}\n" + }, + "contracts/external/uniswap/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n function exactInput(ExactInputParams calldata params) external returns (uint256 amountOut);\n\n function exactOutputSingle(ExactOutputSingleParams calldata params) external returns (uint256 amountIn);\n\n function exactOutput(ExactOutputParams calldata params) external returns (uint256 amountIn);\n\n function factory() external returns (address);\n\n function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Callee.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Callee {\n function uniswapV2Call(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint256);\n\n function feeTo() external view returns (address);\n\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n\n function allPairs(uint256) external view returns (address pair);\n\n function allPairsLength() external view returns (uint256);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n\n function setFeeToSetter(address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Pair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint256 value);\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n function name() external pure returns (string memory);\n\n function symbol() external pure returns (string memory);\n\n function decimals() external pure returns (uint8);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n function nonces(address owner) external view returns (uint256);\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 event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint256 amount0In,\n uint256 amount1In,\n uint256 amount0Out,\n uint256 amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\n\n function factory() external view returns (address);\n\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n\n function price0CumulativeLast() external view returns (uint256);\n\n function price1CumulativeLast() external view returns (uint256);\n\n function kLast() external view returns (uint256);\n\n function mint(address to) external returns (uint256 liquidity);\n\n function burn(address to) external returns (uint256 amount0, uint256 amount1);\n\n function swap(\n uint256 amount0Out,\n uint256 amount1Out,\n address to,\n bytes calldata data\n ) external;\n\n function skim(address to) external;\n\n function sync() external;\n\n function initialize(address, address) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router01.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (\n uint256 amountToken,\n uint256 amountETH,\n uint256 liquidity\n );\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);\n}\n" + }, + "contracts/external/uniswap/IUniswapV2Router02.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Router01.sol\";\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n address referrer,\n uint256 deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Factory.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title The interface for the Uniswap V3 Factory\n/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees\ninterface IUniswapV3Factory {\n /// @notice Emitted when the owner of the factory is changed\n /// @param oldOwner The owner before the owner was changed\n /// @param newOwner The owner after the owner was changed\n event OwnerChanged(address indexed oldOwner, address indexed newOwner);\n\n /// @notice Emitted when a pool is created\n /// @param token0 The first token of the pool by address sort order\n /// @param token1 The second token of the pool by address sort order\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks\n /// @param pool The address of the created pool\n event PoolCreated(\n address indexed token0,\n address indexed token1,\n uint24 indexed fee,\n int24 tickSpacing,\n address pool\n );\n\n /// @notice Emitted when a new fee amount is enabled for pool creation via the factory\n /// @param fee The enabled fee, denominated in hundredths of a bip\n /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee\n event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);\n\n /// @notice Returns the current owner of the factory\n /// @dev Can be changed by the current owner via setOwner\n /// @return The address of the factory owner\n function owner() external view returns (address);\n\n /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled\n /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context\n /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee\n /// @return The tick spacing\n function feeAmountTickSpacing(uint24 fee) external view returns (int24);\n\n /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist\n /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order\n /// @param tokenA The contract address of either token0 or token1\n /// @param tokenB The contract address of the other token\n /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip\n /// @return pool The pool address\n function getPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external view returns (address pool);\n\n /// @notice Creates a pool for the given two tokens and fee\n /// @param tokenA One of the two tokens in the desired pool\n /// @param tokenB The other of the two tokens in the desired pool\n /// @param fee The desired fee for the pool\n /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved\n /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments\n /// are invalid.\n /// @return pool The address of the newly created pool\n function createPool(\n address tokenA,\n address tokenB,\n uint24 fee\n ) external returns (address pool);\n\n /// @notice Updates the owner of the factory\n /// @dev Must be called by the current owner\n /// @param _owner The new owner of the factory\n function setOwner(address _owner) external;\n\n /// @notice Enables a fee amount with the given tickSpacing\n /// @dev Fee amounts may never be removed once enabled\n /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)\n /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount\n function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3FlashCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#flash\n/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface\ninterface IUniswapV3FlashCallback {\n /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.\n /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// @param fee0 The fee amount in token0 due to the pool by the end of the flash\n /// @param fee1 The fee amount in token1 due to the pool by the end of the flash\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call\n function uniswapV3FlashCallback(\n uint256 fee0,\n uint256 fee1,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV3PoolActions.sol\";\n\ninterface IUniswapV3Pool is IUniswapV3PoolActions {\n function token0() external view returns (address);\n\n function token1() external view returns (address);\n\n function fee() external view returns (uint24);\n\n function slot0()\n external\n view\n returns (\n uint160 sqrtPriceX96,\n int24 tick,\n uint16 observationIndex,\n uint16 observationCardinality,\n uint16 observationCardinalityNext,\n uint8 feeProtocol,\n bool unlocked\n );\n\n function liquidity() external view returns (uint128);\n\n function observe(uint32[] calldata secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives, uint160[] memory liquidityCumulatives);\n\n function observations(uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 liquidityCumulative,\n bool initialized\n );\n\n function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n function ticks(int24 tick)\n external\n view\n returns (\n uint128 liquidityGross,\n int128 liquidityNet,\n uint256 feeGrowthOutside0X128,\n uint256 feeGrowthOutside1X128,\n int56 tickCumulativeOutside,\n uint160 secondsPerLiquidityOutsideX128,\n uint32 secondsOutside,\n bool initialized\n );\n\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n\n function positions(bytes32 key)\n external\n view\n returns (\n uint128 _liquidity,\n uint256 feeGrowthInside0LastX128,\n uint256 feeGrowthInside1LastX128,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n /// @notice Sets the initial price for the pool\n /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n function initialize(uint160 sqrtPriceX96) external;\n\n /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n /// @param recipient The address for which the liquidity will be created\n /// @param tickLower The lower tick of the position in which to add liquidity\n /// @param tickUpper The upper tick of the position in which to add liquidity\n /// @param amount The amount of liquidity to mint\n /// @param data Any data that should be passed through to the callback\n /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n function mint(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount,\n bytes calldata data\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Collects tokens owed to a position\n /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n /// @param recipient The address which should receive the fees collected\n /// @param tickLower The lower tick of the position for which to collect fees\n /// @param tickUpper The upper tick of the position for which to collect fees\n /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n /// @return amount0 The amount of fees collected in token0\n /// @return amount1 The amount of fees collected in token1\n function collect(\n address recipient,\n int24 tickLower,\n int24 tickUpper,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n\n /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n /// @dev Fees must be collected separately via a call to #collect\n /// @param tickLower The lower tick of the position for which to burn liquidity\n /// @param tickUpper The upper tick of the position for which to burn liquidity\n /// @param amount How much liquidity to burn\n /// @return amount0 The amount of token0 sent to the recipient\n /// @return amount1 The amount of token1 sent to the recipient\n function burn(\n int24 tickLower,\n int24 tickUpper,\n uint128 amount\n ) external returns (uint256 amount0, uint256 amount1);\n\n /// @notice Swap token0 for token1, or token1 for token0\n /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n /// @param recipient The address to receive the output of the swap\n /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n /// @param data Any data to be passed through to the callback\n /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n\n /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n /// @param recipient The address which will receive the token0 and token1 amounts\n /// @param amount0 The amount of token0 to send\n /// @param amount1 The amount of token1 to send\n /// @param data Any data to be passed through to the callback\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external;\n\n /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n /// the input observationCardinalityNext.\n /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n" + }, + "contracts/external/uniswap/IUniswapV3PoolImmutables.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n /// @return The contract address\n function factory() external view returns (address);\n\n /// @notice The first of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token0() external view returns (address);\n\n /// @notice The second of the two tokens of the pool, sorted by address\n /// @return The token contract address\n function token1() external view returns (address);\n\n /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n /// @return The fee\n function fee() external view returns (uint24);\n\n /// @notice The pool tick spacing\n /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n /// This value is an int24 to avoid casting even though it is always positive.\n /// @return The tick spacing\n function tickSpacing() external view returns (int24);\n\n /// @notice The maximum amount of position liquidity that can use any tick in the range\n /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n /// @return The max amount of liquidity per tick\n function maxLiquidityPerTick() external view returns (uint128);\n}\n" + }, + "contracts/external/uniswap/IUniswapV3SwapCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/external/uniswap/IV3SwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport './IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IV3SwapRouter is IUniswapV3SwapCallback {\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,\n /// and swap the entire amount, enabling contracts to send tokens before calling this function.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// that may remain in the router after the swap.\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IQuoter.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IQuoter {\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) external view returns (uint256);\n}\n" + }, + "contracts/external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Quoter Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IUniswapV3Quoter {\n /// @notice Returns the amount out received for a given exact input swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee\n /// @param amountIn The amount of the first token to swap\n /// @return amountOut The amount of the last token that would be received\n function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\n\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountIn The desired input amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountOut The amount of `tokenOut` that would be received\n function quoteExactInputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountIn,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountOut);\n\n /// @notice Returns the amount in required for a given exact output swap without executing the swap\n /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n /// @param amountOut The amount of the last token to receive\n /// @return amountIn The amount of first token required to be paid\n function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\n\n /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n /// @param tokenIn The token being swapped in\n /// @param tokenOut The token being swapped out\n /// @param fee The fee of the token pool to consider for the pair\n /// @param amountOut The desired output amount\n /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n function quoteExactOutputSingle(\n address tokenIn,\n address tokenOut,\n uint24 fee,\n uint256 amountOut,\n uint160 sqrtPriceLimitX96\n ) external returns (uint256 amountIn);\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/BitMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title BitMath\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\nlibrary BitMath {\n /// @notice Returns the index of the most significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\n /// @param x the value for which to compute the most significant bit, must be greater than 0\n /// @return r the index of the most significant bit\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n if (x >= 0x100000000000000000000000000000000) {\n x >>= 128;\n r += 128;\n }\n if (x >= 0x10000000000000000) {\n x >>= 64;\n r += 64;\n }\n if (x >= 0x100000000) {\n x >>= 32;\n r += 32;\n }\n if (x >= 0x10000) {\n x >>= 16;\n r += 16;\n }\n if (x >= 0x100) {\n x >>= 8;\n r += 8;\n }\n if (x >= 0x10) {\n x >>= 4;\n r += 4;\n }\n if (x >= 0x4) {\n x >>= 2;\n r += 2;\n }\n if (x >= 0x2) r += 1;\n }\n\n /// @notice Returns the index of the least significant bit of the number,\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\n /// @dev The function satisfies the property:\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\n /// @param x the value for which to compute the least significant bit, must be greater than 0\n /// @return r the index of the least significant bit\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\n require(x > 0);\n\n r = 255;\n if (x & type(uint128).max > 0) {\n r -= 128;\n } else {\n x >>= 128;\n }\n if (x & type(uint64).max > 0) {\n r -= 64;\n } else {\n x >>= 64;\n }\n if (x & type(uint32).max > 0) {\n r -= 32;\n } else {\n x >>= 32;\n }\n if (x & type(uint16).max > 0) {\n r -= 16;\n } else {\n x >>= 16;\n }\n if (x & type(uint8).max > 0) {\n r -= 8;\n } else {\n x >>= 8;\n }\n if (x & 0xf > 0) {\n r -= 4;\n } else {\n x >>= 4;\n }\n if (x & 0x3 > 0) {\n r -= 2;\n } else {\n x >>= 2;\n }\n if (x & 0x1 > 0) r -= 1;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/FixedPoint96.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n uint8 internal constant RESOLUTION = 96;\n uint256 internal constant Q96 = 0x1000000000000000000000000; // 2^96\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LiquidityMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math library for liquidity\nlibrary LiquidityMath {\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\n /// @param x The liquidity before change\n /// @param y The delta by which liquidity should be changed\n /// @return z The liquidity delta\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\n if (y < 0) {\n require((z = x - uint128(-y)) < x, \"LS\");\n } else {\n require((z = x + uint128(y)) >= x, \"LA\");\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/LowGasSafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\n/// @title Optimized overflow and underflow safe math operations\n/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost\nlibrary LowGasSafeMath {\n /// @notice Returns x + y, reverts if sum overflows uint256\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x + y) >= x);\n }\n\n /// @notice Returns x - y, reverts if underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require((z = x - y) <= x);\n }\n\n /// @notice Returns x * y, reverts if overflows\n /// @param x The multiplicand\n /// @param y The multiplier\n /// @return z The product of x and y\n function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {\n require(x == 0 || (z = x * y) / x == y);\n }\n\n /// @notice Returns x + y, reverts if overflows or underflows\n /// @param x The augend\n /// @param y The addend\n /// @return z The sum of x and y\n function add(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x + y) >= x == (y >= 0));\n }\n\n /// @notice Returns x - y, reverts if overflows or underflows\n /// @param x The minuend\n /// @param y The subtrahend\n /// @return z The difference of x and y\n function sub(int256 x, int256 y) internal pure returns (int256 z) {\n require((z = x - y) <= x == (y >= 0));\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Safe casting methods\n/// @notice Contains methods for safely casting between types\nlibrary SafeCast {\n /// @notice Cast a uint256 to a uint160, revert on overflow\n /// @param y The uint256 to be downcasted\n /// @return z The downcasted integer, now type uint160\n function toUint160(uint256 y) internal pure returns (uint160 z) {\n require((z = uint160(y)) == y);\n }\n\n /// @notice Cast a int256 to a int128, revert on overflow or underflow\n /// @param y The int256 to be downcasted\n /// @return z The downcasted integer, now type int128\n function toInt128(int256 y) internal pure returns (int128 z) {\n require((z = int128(y)) == y);\n }\n\n /// @notice Cast a uint256 to a int256, revert on overflow\n /// @param y The uint256 to be casted\n /// @return z The casted integer, now type int256\n function toInt256(uint256 y) internal pure returns (int256 z) {\n require(y < 2**255);\n z = int256(y);\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SqrtPriceMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../FullMath.sol\";\nimport \"./UnsafeMath.sol\";\nimport \"./FixedPoint96.sol\";\nimport \"./BitMath.sol\";\n\n/// @title Functions based on Q64.96 sqrt price and liquidity\n/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas\nlibrary SqrtPriceMath {\n using LowGasSafeMath for uint256;\n using SafeCast for uint256;\n\n /// @notice Gets the next sqrt price given a delta of token0\n /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the\n /// price less in order to not send too much output.\n /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),\n /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).\n /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token0 to add or remove from virtual reserves\n /// @param add Whether to add or remove the amount of token0\n /// @return The price after adding or removing amount, depending on add\n function getNextSqrtPriceFromAmount0RoundingUp(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price\n if (amount == 0) return sqrtPX96;\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n\n bool overflow = false;\n if (numerator1 != 0 && sqrtPX96 != 0)\n overflow = uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(sqrtPX96)) >= 254;\n\n if (add) {\n uint256 product;\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 + product;\n if (denominator >= numerator1) {\n // always fits in 160 bits\n return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));\n }\n }\n\n return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));\n } else {\n uint256 product;\n // if the product overflows, we know the denominator underflows\n // in addition, we must check that the denominator does not underflow\n require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);\n product = overflow ? FullMath.mulDivRoundingUp(amount, sqrtPX96, uint256(liquidity)) : product;\n numerator1 = overflow ? FixedPoint96.Q96 : numerator1;\n uint256 denominator = numerator1 - product;\n return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();\n }\n }\n\n /// @notice Gets the next sqrt price given a delta of token1\n /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least\n /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the\n /// price less in order to not send too much output.\n /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity\n /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta\n /// @param liquidity The amount of usable liquidity\n /// @param amount How much of token1 to add, or remove, from virtual reserves\n /// @param add Whether to add, or remove, the amount of token1\n /// @return The price after adding or removing `amount`\n function getNextSqrtPriceFromAmount1RoundingDown(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amount,\n bool add\n ) internal pure returns (uint160) {\n // if we're adding (subtracting), rounding down requires rounding the quotient down (up)\n // in both cases, avoid a mulDiv for most inputs\n if (add) {\n uint256 quotient = (\n amount <= type(uint160).max\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\n );\n\n return uint256(sqrtPX96).add(quotient).toUint160();\n } else {\n uint256 quotient = (\n amount <= type(uint160).max\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\n );\n\n require(sqrtPX96 > quotient);\n // always fits 160 bits\n return uint160(sqrtPX96 - quotient);\n }\n }\n\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountIn How much of token0, or token1, is being swapped in\n /// @param zeroForOne Whether the amount in is token0 or token1\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\n function getNextSqrtPriceFromInput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountIn,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we don't pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\n }\n\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\n /// @param sqrtPX96 The starting price before accounting for the output amount\n /// @param liquidity The amount of usable liquidity\n /// @param amountOut How much of token0, or token1, is being swapped out\n /// @param zeroForOne Whether the amount out is token0 or token1\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\n function getNextSqrtPriceFromOutput(\n uint160 sqrtPX96,\n uint128 liquidity,\n uint256 amountOut,\n bool zeroForOne\n ) internal pure returns (uint160 sqrtQX96) {\n require(sqrtPX96 > 0);\n require(liquidity > 0);\n\n // round to make sure that we pass the target price\n return\n zeroForOne\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\n }\n\n /// @notice Gets the amount0 delta between two prices\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up or down\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount0) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\n require(sqrtRatioAX96 > 0);\n\n bool overflow = false;\n if (numerator1 != 0 && numerator2 != 0)\n overflow =\n uint256(BitMath.mostSignificantBit(numerator1)) + uint256(BitMath.mostSignificantBit(numerator2)) >= 254;\n\n if (overflow) {\n return\n roundUp\n ? FullMath.mulDivRoundingUp(\n FullMath.mulDivRoundingUp(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n )\n : FullMath.mulDiv(\n FullMath.mulDiv(uint256(liquidity), numerator2, sqrtRatioBX96),\n FixedPoint96.Q96,\n sqrtRatioAX96\n );\n } else {\n return\n roundUp\n ? UnsafeMath.divRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), sqrtRatioAX96)\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\n }\n }\n\n /// @notice Gets the amount1 delta between two prices\n /// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The amount of usable liquidity\n /// @param roundUp Whether to round the amount up, or down\n /// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity,\n bool roundUp\n ) internal pure returns (uint256 amount1) {\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n return\n roundUp\n ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)\n : FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n }\n\n /// @notice Helper that gets signed token0 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount0 delta\n /// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices\n function getAmount0Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount0) {\n return\n liquidity < 0\n ? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n\n /// @notice Helper that gets signed token1 delta\n /// @param sqrtRatioAX96 A sqrt price\n /// @param sqrtRatioBX96 Another sqrt price\n /// @param liquidity The change in liquidity for which to compute the amount1 delta\n /// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices\n function getAmount1Delta(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n int128 liquidity\n ) internal pure returns (int256 amount1) {\n return\n liquidity < 0\n ? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()\n : getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/SwapMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"../../FullMath.sol\";\nimport \"./SqrtPriceMath.sol\";\n\n/// @title Computes the result of a swap within ticks\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\nlibrary SwapMath {\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\n /// @param liquidity The usable liquidity\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\n /// @return feeAmount The amount of input that will be taken as a fee\n function computeSwapStep(\n uint160 sqrtRatioCurrentX96,\n uint160 sqrtRatioTargetX96,\n uint128 liquidity,\n int256 amountRemaining,\n uint24 feePips,\n bool zeroForOne\n )\n internal\n pure\n returns (\n uint160 sqrtRatioNextX96,\n uint256 amountIn,\n uint256 amountOut,\n uint256 feeAmount\n )\n {\n require(zeroForOne == sqrtRatioCurrentX96 >= sqrtRatioTargetX96, \"SPD\");\n bool exactIn = amountRemaining >= 0;\n\n if (exactIn) {\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\n amountIn = zeroForOne\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\n sqrtRatioCurrentX96,\n liquidity,\n amountRemainingLessFee,\n zeroForOne\n );\n } else {\n amountOut = zeroForOne\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\n\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\n else\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\n sqrtRatioCurrentX96,\n liquidity,\n uint256(-amountRemaining),\n zeroForOne\n );\n }\n\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\n\n // get the input/output amounts\n if (zeroForOne) {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\n } else {\n amountIn = max && exactIn\n ? amountIn\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\n amountOut = max && !exactIn\n ? amountOut\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\n }\n\n // cap the output amount to not exceed the remaining output amount\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\n amountOut = uint256(-amountRemaining);\n }\n\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\n // we didn't reach the target, so take the remainder of the maximum input as fee\n feeAmount = uint256(amountRemaining) - amountIn;\n } else {\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/Tick.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./LowGasSafeMath.sol\";\nimport \"./SafeCast.sol\";\n\nimport \"../../TickMath.sol\";\nimport \"./LiquidityMath.sol\";\n\n/// @title Tick\n/// @notice Contains functions for managing tick processes and relevant calculations\n\n/// Ithil to modify it, since it does not have access to storage arrays\nlibrary Tick {\n using LowGasSafeMath for int256;\n using SafeCast for int256;\n\n // info stored for each initialized individual tick\n struct Info {\n // the total position liquidity that references this tick\n uint128 liquidityGross;\n // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),\n int128 liquidityNet;\n // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint256 feeGrowthOutside0X128;\n uint256 feeGrowthOutside1X128;\n // the cumulative tick value on the other side of the tick\n int56 tickCumulativeOutside;\n // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint160 secondsPerLiquidityOutsideX128;\n // the seconds spent on the other side of the tick (relative to the current tick)\n // only has relative meaning, not absolute — the value depends on when the tick is initialized\n uint32 secondsOutside;\n // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0\n // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks\n bool initialized;\n }\n\n /// @notice Derives max liquidity per tick from given tick spacing\n /// @dev Executed within the pool constructor\n /// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`\n /// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...\n /// @return The max liquidity per tick\n function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing) internal pure returns (uint128) {\n int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;\n int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;\n uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;\n return type(uint128).max / numTicks;\n }\n\n /// @notice Retrieves fee growth data\n /// Ithil: only use it with lower = self[tickLower] and upper = self[tickUpper]\n /// @param lower The info of the lower tick boundary of the position\n /// @param upper The info of the upper tick boundary of the position\n /// @param tickLower The lower tick boundary of the position\n /// @param tickUpper The upper tick boundary of the position\n /// @param tickCurrent The current tick\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @return feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries\n /// @return feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries\n function getFeeGrowthInside(\n Tick.Info memory lower,\n Tick.Info memory upper,\n int24 tickLower,\n int24 tickUpper,\n int24 tickCurrent,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128\n ) internal pure returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n // calculate fee growth below\n uint256 feeGrowthBelow0X128;\n uint256 feeGrowthBelow1X128;\n if (tickCurrent >= tickLower) {\n feeGrowthBelow0X128 = lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = lower.feeGrowthOutside1X128;\n } else {\n feeGrowthBelow0X128 = feeGrowthGlobal0X128 - lower.feeGrowthOutside0X128;\n feeGrowthBelow1X128 = feeGrowthGlobal1X128 - lower.feeGrowthOutside1X128;\n }\n\n // calculate fee growth above\n uint256 feeGrowthAbove0X128;\n uint256 feeGrowthAbove1X128;\n if (tickCurrent < tickUpper) {\n feeGrowthAbove0X128 = upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = upper.feeGrowthOutside1X128;\n } else {\n feeGrowthAbove0X128 = feeGrowthGlobal0X128 - upper.feeGrowthOutside0X128;\n feeGrowthAbove1X128 = feeGrowthGlobal1X128 - upper.feeGrowthOutside1X128;\n }\n\n feeGrowthInside0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128 - feeGrowthAbove0X128;\n feeGrowthInside1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128 - feeGrowthAbove1X128;\n }\n\n /// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa\n /// Ithil: always use with info = self[tick]\n /// @param info The info tick that will be updated\n /// @param tick The tick that will be updated\n /// @param tickCurrent The current tick\n /// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The all-time seconds per max(1, liquidity) of the pool\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block timestamp cast to a uint32\n /// @param upper true for updating a position's upper tick, or false for updating a position's lower tick\n /// @param maxLiquidity The maximum liquidity allocation for a single tick\n /// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa\n function update(\n Tick.Info memory info,\n int24 tick,\n int24 tickCurrent,\n int128 liquidityDelta,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time,\n bool upper,\n uint128 maxLiquidity\n ) internal pure returns (bool flipped) {\n uint128 liquidityGrossBefore = info.liquidityGross;\n uint128 liquidityGrossAfter = LiquidityMath.addDelta(liquidityGrossBefore, liquidityDelta);\n\n require(liquidityGrossAfter <= maxLiquidity, \"LO\");\n\n flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);\n\n if (liquidityGrossBefore == 0) {\n // by convention, we assume that all growth before a tick was initialized happened _below_ the tick\n if (tick <= tickCurrent) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;\n info.tickCumulativeOutside = tickCumulative;\n info.secondsOutside = time;\n }\n info.initialized = true;\n }\n\n info.liquidityGross = liquidityGrossAfter;\n\n // when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)\n info.liquidityNet = upper\n ? int256(info.liquidityNet).sub(liquidityDelta).toInt128()\n : int256(info.liquidityNet).add(liquidityDelta).toInt128();\n }\n\n /// @notice Transitions to next tick as needed by price movement\n /// @param info The result of the mapping containing all tick information for initialized ticks\n /// @param feeGrowthGlobal0X128 The all-time global fee growth, per unit of liquidity, in token0\n /// @param feeGrowthGlobal1X128 The all-time global fee growth, per unit of liquidity, in token1\n /// @param secondsPerLiquidityCumulativeX128 The current seconds per liquidity\n /// @param tickCumulative The tick * time elapsed since the pool was first initialized\n /// @param time The current block.timestamp\n /// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)\n function cross(\n Tick.Info memory info,\n uint256 feeGrowthGlobal0X128,\n uint256 feeGrowthGlobal1X128,\n uint160 secondsPerLiquidityCumulativeX128,\n int56 tickCumulative,\n uint32 time\n ) internal pure returns (int128 liquidityNet) {\n info.feeGrowthOutside0X128 = feeGrowthGlobal0X128 - info.feeGrowthOutside0X128;\n info.feeGrowthOutside1X128 = feeGrowthGlobal1X128 - info.feeGrowthOutside1X128;\n info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128 - info.secondsPerLiquidityOutsideX128;\n info.tickCumulativeOutside = tickCumulative - info.tickCumulativeOutside;\n info.secondsOutside = time - info.secondsOutside;\n liquidityNet = info.liquidityNet;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/TickBitmap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\nimport \"./BitMath.sol\";\n\n/// @title Packed tick initialized state library\n/// @notice Stores a packed mapping of tick index to its initialized state\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\nlibrary TickBitmap {\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\n /// @param tick The tick for which to compute the position\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\n /// @return bitPos The bit position in the word where the flag is stored\n /// @dev simply divides @param tick by 256 with remainder: tick = wordPos * 256 + bitPos\n function position(int24 tick) internal pure returns (int16 wordPos, uint8 bitPos) {\n wordPos = int16(tick >> 8);\n bitPos = uint8(int8(tick % 256));\n }\n\n /// Written by Ithil\n function computeWordPos(\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int16 wordPos) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n (wordPos, ) = lte ? position(compressed) : position(compressed + 1);\n }\n\n /// @notice Flips the initialized state for a given tick from false to true, or vice versa\n /// @param selfResult The result of the mapping in which to flip the tick (Ithil modified)\n /// @param tick The tick to flip\n /// @param tickSpacing The spacing between usable ticks\n function flipTick(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing\n ) internal pure {\n require(tick % tickSpacing == 0); // ensure that the tick is spaced\n (, uint8 bitPos) = position(tick / tickSpacing);\n uint256 mask = 1 << bitPos;\n selfResult ^= mask;\n }\n\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\n /// to the left (less than or equal to) or right (greater than) of the given tick\n /// @param selfResult The result of the mapping in which to compute the next initialized tick (Ithil modified)\n /// @param tick The starting tick\n /// @param tickSpacing The spacing between usable ticks\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\n function nextInitializedTickWithinOneWord(\n uint256 selfResult,\n int24 tick,\n int24 tickSpacing,\n bool lte\n ) internal pure returns (int24 next, bool initialized) {\n int24 compressed = tick / tickSpacing;\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n if (lte) {\n (, uint8 bitPos) = position(compressed);\n // all the 1s at or to the right of the current bitPos\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed - int24(uint24(bitPos) - uint24(BitMath.mostSignificantBit(masked)))) * tickSpacing\n : (compressed - int24(uint24(bitPos))) * tickSpacing;\n } else {\n // start from the word of the next tick, since the current tick state doesn't matter\n (, uint8 bitPos) = position(compressed + 1);\n // all the 1s at or to the left of the bitPos\n uint256 mask = ~((1 << bitPos) - 1);\n uint256 masked = selfResult & mask;\n\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\n initialized = masked != 0;\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\n next = initialized\n ? (compressed + 1 + int24(uint24(BitMath.leastSignificantBit(masked) - bitPos))) * tickSpacing\n : (compressed + 1 + int24(uint24(type(uint8).max - bitPos))) * tickSpacing;\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/libraries/UnsafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.5.0;\n\n/// @title Math functions that do not check inputs or outputs\n/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks\nlibrary UnsafeMath {\n /// @notice Returns ceil(x / y)\n /// @dev division by 0 has unspecified behavior, and must be checked externally\n /// @param x The dividend\n /// @param y The divisor\n /// @return z The quotient, ceil(x / y)\n function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n z := add(div(x, y), gt(mod(x, y), 0))\n }\n }\n}\n" + }, + "contracts/external/uniswap/quoter/Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../IUniswapV3Factory.sol\";\nimport \"./interfaces/IQuoter.sol\";\nimport \"./UniswapV3Quoter.sol\";\n\ncontract Quoter is IQuoter, UniswapV3Quoter {\n IUniswapV3Factory internal uniV3Factory; // TODO should it be immutable?\n\n constructor(address _uniV3Factory) {\n uniV3Factory = IUniswapV3Factory(_uniV3Factory);\n }\n\n // This should be equal to quoteExactInputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMaxSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateOutputSingle(_toToken, _fromToken, _amount, pool);\n }\n\n // This should be equal to quoteExactOutputSingle(_fromToken, _toToken, _poolFee, _amount, 0)\n // todo: add price limit\n function estimateMinSwapUniswapV3(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n uint24 _poolFee\n ) public view override returns (uint256) {\n address pool = uniV3Factory.getPool(_fromToken, _toToken, _poolFee);\n\n return _estimateInputSingle(_fromToken, _toToken, _amount, pool);\n }\n\n // todo: add price limit\n function _estimateOutputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken > _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n else amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n }\n\n // todo: add price limit\n function _estimateInputSingle(\n address _fromToken,\n address _toToken,\n uint256 _amount,\n address _pool\n ) internal view returns (uint256 amountOut) {\n bool zeroForOne = _fromToken < _toToken;\n // todo: price limit?\n (int256 amount0, int256 amount1) = quoteSwap(\n _pool,\n -int256(_amount),\n zeroForOne ? (TickMath.MIN_SQRT_RATIO + 1) : (TickMath.MAX_SQRT_RATIO - 1),\n zeroForOne\n );\n if (zeroForOne) amountOut = amount0 > 0 ? uint256(amount0) : uint256(-amount0);\n else amountOut = amount1 > 0 ? uint256(amount1) : uint256(-amount1);\n }\n\n function doesPoolExist(address _token0, address _token1) external view returns (bool) {\n // try 0.05%\n address pool = uniV3Factory.getPool(_token0, _token1, 500);\n if (pool != address(0)) return true;\n\n // try 0.3%\n pool = uniV3Factory.getPool(_token0, _token1, 3000);\n if (pool != address(0)) return true;\n\n // try 1%\n pool = uniV3Factory.getPool(_token0, _token1, 10000);\n if (pool != address(0)) return true;\n else return false;\n }\n}\n" + }, + "contracts/external/uniswap/quoter/UniswapV3Quoter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.6;\n\nimport \"./libraries/LowGasSafeMath.sol\";\nimport \"./libraries/SafeCast.sol\";\nimport \"./libraries/Tick.sol\";\nimport \"./libraries/TickBitmap.sol\";\n\nimport \"../FullMath.sol\";\nimport \"../TickMath.sol\";\nimport \"./libraries/LiquidityMath.sol\";\nimport \"./libraries/SqrtPriceMath.sol\";\nimport \"./libraries/SwapMath.sol\";\n\nimport \"./interfaces/IUniswapV3Quoter.sol\";\nimport \"../IUniswapV3Pool.sol\";\nimport \"../IUniswapV3PoolImmutables.sol\";\n\ncontract UniswapV3Quoter {\n using LowGasSafeMath for int256;\n using SafeCast for uint256;\n using Tick for mapping(int24 => Tick.Info);\n\n struct PoolState {\n // the current price\n uint160 sqrtPriceX96;\n // the current tick\n int24 tick;\n // the tick spacing\n int24 tickSpacing;\n // the pool's fee\n uint24 fee;\n // the pool's liquidity\n uint128 liquidity;\n // whether the pool is locked\n bool unlocked;\n }\n\n // accumulated protocol fees in token0/token1 units\n struct ProtocolFees {\n uint128 token0;\n uint128 token1;\n }\n\n // the top level state of the swap, the results of which are recorded in storage at the end\n struct SwapState {\n // the amount remaining to be swapped in/out of the input/output asset\n int256 amountSpecifiedRemaining;\n // the amount already swapped out/in of the output/input asset\n int256 amountCalculated;\n // current sqrt(price)\n uint160 sqrtPriceX96;\n // the tick associated with the current price\n int24 tick;\n // the current liquidity in range\n uint128 liquidity;\n }\n\n struct StepComputations {\n // the price at the beginning of the step\n uint160 sqrtPriceStartX96;\n // the next tick to swap to from the current tick in the swap direction\n int24 tickNext;\n // whether tickNext is initialized or not\n bool initialized;\n // sqrt(price) for the next tick (1/0)\n uint160 sqrtPriceNextX96;\n // how much is being swapped in in this step\n uint256 amountIn;\n // how much is being swapped out\n uint256 amountOut;\n // how much fee is being paid in\n uint256 feeAmount;\n }\n\n struct InitialState {\n address poolAddress;\n PoolState poolState;\n uint256 feeGrowthGlobal0X128;\n uint256 feeGrowthGlobal1X128;\n }\n\n struct NextTickPassage {\n int24 tick;\n int24 tickSpacing;\n }\n\n function fetchState(address _pool) internal view returns (PoolState memory poolState) {\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\n (uint160 sqrtPriceX96, int24 tick, , , , , bool unlocked) = pool.slot0(); // external call\n uint128 liquidity = pool.liquidity(); // external call\n int24 tickSpacing = IUniswapV3PoolImmutables(_pool).tickSpacing(); // external call\n uint24 fee = IUniswapV3PoolImmutables(_pool).fee(); // external call\n poolState = PoolState(sqrtPriceX96, tick, tickSpacing, fee, liquidity, unlocked);\n }\n\n function setInitialState(\n PoolState memory initialPoolState,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n )\n internal\n pure\n returns (\n SwapState memory state,\n uint128 liquidity,\n uint160 sqrtPriceX96\n )\n {\n liquidity = initialPoolState.liquidity;\n\n sqrtPriceX96 = initialPoolState.sqrtPriceX96;\n\n require(\n zeroForOne\n ? sqrtPriceLimitX96 < initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO\n : sqrtPriceLimitX96 > initialPoolState.sqrtPriceX96 && sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO,\n \"SPL\"\n );\n\n state = SwapState({\n amountSpecifiedRemaining: amountSpecified,\n amountCalculated: 0,\n sqrtPriceX96: initialPoolState.sqrtPriceX96,\n tick: initialPoolState.tick,\n liquidity: 0 // to be modified after initialization\n });\n }\n\n function getNextTickAndPrice(\n int24 tickSpacing,\n int24 currentTick,\n IUniswapV3Pool pool,\n bool zeroForOne\n )\n internal\n view\n returns (\n int24 tickNext,\n bool initialized,\n uint160 sqrtPriceNextX96\n )\n {\n int24 compressed = currentTick / tickSpacing;\n if (!zeroForOne) compressed++;\n if (currentTick < 0 && currentTick % tickSpacing != 0) compressed--; // round towards negative infinity\n\n uint256 selfResult = pool.tickBitmap(int16(compressed >> 8)); // external call\n\n (tickNext, initialized) = TickBitmap.nextInitializedTickWithinOneWord(\n selfResult,\n currentTick,\n tickSpacing,\n zeroForOne\n );\n\n if (tickNext < TickMath.MIN_TICK) {\n tickNext = TickMath.MIN_TICK;\n } else if (tickNext > TickMath.MAX_TICK) {\n tickNext = TickMath.MAX_TICK;\n }\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\n }\n\n function processSwapWithinTick(\n IUniswapV3Pool pool,\n PoolState memory initialPoolState,\n SwapState memory state,\n uint160 firstSqrtPriceX96,\n uint128 firstLiquidity,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne,\n bool exactAmount\n )\n internal\n view\n returns (\n uint160 sqrtPriceNextX96,\n uint160 finalSqrtPriceX96,\n uint128 finalLiquidity\n )\n {\n StepComputations memory step;\n\n step.sqrtPriceStartX96 = firstSqrtPriceX96;\n\n (step.tickNext, step.initialized, sqrtPriceNextX96) = getNextTickAndPrice(\n initialPoolState.tickSpacing,\n state.tick,\n pool,\n zeroForOne\n );\n\n (finalSqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\n firstSqrtPriceX96,\n (zeroForOne ? sqrtPriceNextX96 < sqrtPriceLimitX96 : sqrtPriceNextX96 > sqrtPriceLimitX96)\n ? sqrtPriceLimitX96\n : sqrtPriceNextX96,\n firstLiquidity,\n state.amountSpecifiedRemaining,\n initialPoolState.fee,\n zeroForOne\n );\n\n if (exactAmount) {\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\n } else {\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\n }\n\n if (finalSqrtPriceX96 == sqrtPriceNextX96) {\n if (step.initialized) {\n (, int128 liquidityNet, , , , , , ) = pool.ticks(step.tickNext);\n if (zeroForOne) liquidityNet = -liquidityNet;\n finalLiquidity = LiquidityMath.addDelta(firstLiquidity, liquidityNet);\n }\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\n } else if (finalSqrtPriceX96 != step.sqrtPriceStartX96) {\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\n state.tick = TickMath.getTickAtSqrtRatio(finalSqrtPriceX96);\n }\n }\n\n function returnedAmount(\n SwapState memory state,\n int256 amountSpecified,\n bool zeroForOne\n ) internal pure returns (int256 amount0, int256 amount1) {\n if (amountSpecified > 0) {\n (amount0, amount1) = zeroForOne\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\n } else {\n (amount0, amount1) = zeroForOne\n ? (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining)\n : (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated);\n }\n }\n\n function quoteSwap(\n address poolAddress,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool zeroForOne\n ) internal view returns (int256 amount0, int256 amount1) {\n bool exactAmount = amountSpecified > 0;\n\n PoolState memory initialPoolState = fetchState(poolAddress);\n uint160 sqrtPriceNextX96;\n\n (SwapState memory state, uint128 liquidity, uint160 sqrtPriceX96) = setInitialState(\n initialPoolState,\n amountSpecified,\n sqrtPriceLimitX96,\n zeroForOne\n );\n\n while (state.amountSpecifiedRemaining != 0 && sqrtPriceX96 != sqrtPriceLimitX96)\n (sqrtPriceNextX96, sqrtPriceX96, liquidity) = processSwapWithinTick(\n IUniswapV3Pool(poolAddress),\n initialPoolState,\n state,\n sqrtPriceX96,\n liquidity,\n sqrtPriceLimitX96,\n zeroForOne,\n exactAmount\n );\n\n (amount0, amount1) = returnedAmount(state, amountSpecified, zeroForOne);\n }\n}\n" + }, + "contracts/external/uniswap/TickMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\n// From Uniswap3 Core\n\n// Updated to Solidity 0.8 by Midas Capital:\n// * Cast MAX_TICK to int256 before casting to uint\n// * Wrapped function bodies with \"unchecked {}\" so as to not add any extra gas costs\n\npragma solidity ^0.8.0;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n int24 internal constant MIN_TICK = -887272;\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n int24 internal constant MAX_TICK = -MIN_TICK;\n\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\n /// @dev Throws if |tick| > max tick\n /// @param tick The input tick for the above formula\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n /// at the given tick\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n unchecked {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;\n if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n if (tick > 0) ratio = type(uint256).max / ratio;\n\n // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));\n }\n }\n\n /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n /// ever return.\n /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {\n unchecked {\n // second inequality must be < because the price can never reach the price at the max tick\n require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, \"R\");\n uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n uint256 r = ratio;\n uint256 msb = 0;\n\n assembly {\n let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(5, gt(r, 0xFFFFFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(4, gt(r, 0xFFFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(3, gt(r, 0xFF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(2, gt(r, 0xF))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := shl(1, gt(r, 0x3))\n msb := or(msb, f)\n r := shr(f, r)\n }\n assembly {\n let f := gt(r, 0x1)\n msb := or(msb, f)\n }\n\n if (msb >= 128) r = ratio >> (msb - 127);\n else r = ratio << (127 - msb);\n\n int256 log_2 = (int256(msb) - 128) << 64;\n\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(63, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(62, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(61, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(60, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(59, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(58, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(57, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(56, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(55, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(54, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(53, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(52, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(51, f))\n r := shr(f, r)\n }\n assembly {\n r := shr(127, mul(r, r))\n let f := shr(128, r)\n log_2 := or(log_2, shl(50, f))\n }\n\n int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);\n int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);\n\n tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;\n }\n }\n}\n" + }, + "contracts/external/uniswap/UniswapV2Library.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.8.0;\n\nimport \"./IUniswapV2Pair.sol\";\nimport \"./IUniswapV2Factory.sol\";\n\nlibrary UniswapV2Library {\n // returns sorted token addresses, used to handle return values from pairs sorted in this order\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, \"UniswapV2Library: IDENTICAL_ADDRESSES\");\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), \"UniswapV2Library: ZERO_ADDRESS\");\n }\n\n function pairFor(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (address pair) {\n return IUniswapV2Factory(factory).getPair(tokenA, tokenB);\n }\n\n // fetches and sorts the reserves for a pair\n function getReserves(\n address factory,\n address tokenA,\n address tokenB\n ) internal view returns (uint256 reserveA, uint256 reserveB) {\n (address token0, ) = sortTokens(tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();\n (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n }\n\n // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) internal pure returns (uint256 amountB) {\n require(amountA > 0, \"UniswapV2Library: INSUFFICIENT_AMOUNT\");\n require(reserveA > 0 && reserveB > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n amountB = (amountA * reserveB) / reserveA;\n }\n\n // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountOut) {\n require(amountIn > 0, \"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 amountInWithFee = amountIn * (10000 - flashSwapFee);\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = reserveIn * 10000 + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n // given an output amount of an asset and pair reserves, returns a required input amount of the other asset\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut,\n uint8 flashSwapFee\n ) internal pure returns (uint256 amountIn) {\n require(amountOut > 0, \"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 numerator = reserveIn * amountOut * 10000;\n uint256 denominator = (reserveOut - amountOut) * (10000 - flashSwapFee);\n amountIn = numerator / denominator + 1;\n }\n\n // performs chained getAmountOut calculations on any number of pairs\n function getAmountsOut(\n address factory,\n uint256 amountIn,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[0] = amountIn;\n for (uint256 i; i < path.length - 1; i++) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);\n amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n\n // performs chained getAmountIn calculations on any number of pairs\n function getAmountsIn(\n address factory,\n uint256 amountOut,\n address[] memory path,\n uint8 flashSwapFee\n ) internal view returns (uint256[] memory amounts) {\n require(path.length >= 2, \"UniswapV2Library: INVALID_PATH\");\n amounts = new uint256[](path.length);\n amounts[amounts.length - 1] = amountOut;\n for (uint256 i = path.length - 1; i > 0; i--) {\n (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);\n amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut, flashSwapFee);\n }\n }\n}\n" + }, + "contracts/external/velodrome/IVelodromeRouter.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRouter_Velodrome {\n struct Route {\n address from;\n address to;\n bool stable;\n }\n\n error ETHTransferFailed();\n error Expired();\n error InsufficientAmount();\n error InsufficientAmountA();\n error InsufficientAmountB();\n error InsufficientAmountADesired();\n error InsufficientAmountBDesired();\n error InsufficientLiquidity();\n error InsufficientOutputAmount();\n error InvalidPath();\n error OnlyWETH();\n error SameAddresses();\n error ZeroAddress();\n\n /// @notice Address of Velodrome v2 pool factory\n function factory() external view returns (address);\n\n /// @notice Address of Velodrome v2 pool implementation\n function poolImplementation() external view returns (address);\n\n /// @notice Sort two tokens by which address value is less than the other\n /// @param tokenA Address of token to sort\n /// @param tokenB Address of token to sort\n /// @return token0 Lower address value between tokenA and tokenB\n /// @return token1 Higher address value between tokenA and tokenB\n function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1);\n\n /// @notice Calculate the address of a pool by its' factory.\n /// @dev Returns a randomly generated address for a nonexistent pool\n /// @param tokenA Address of token to query\n /// @param tokenB Address of token to query\n /// @param stable True if pool is stable, false if volatile\n function poolFor(address tokenA, address tokenB, bool stable) external view returns (address pool);\n\n /// @notice Fetch and sort the reserves for a pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @return reserveA Amount of reserves of the sorted token A\n /// @return reserveB Amount of reserves of the sorted token B\n function getReserves(\n address tokenA,\n address tokenB,\n bool stable\n ) external view returns (uint256 reserveA, uint256 reserveB);\n\n /// @notice Perform chained getAmountOut calculations on any number of pools\n function getAmountsOut(uint256 amountIn, Route[] memory routes) external view returns (uint256[] memory amounts);\n\n // **** ADD LIQUIDITY ****\n\n /// @notice Quote the amount deposited into a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function quoteAddLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired\n ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Quote the amount of liquidity removed from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function quoteRemoveLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity\n ) external view returns (uint256 amountA, uint256 amountB);\n\n /// @notice Add liquidity of two tokens to a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountADesired Amount of tokenA desired to deposit\n /// @param amountBDesired Amount of tokenB desired to deposit\n /// @param amountAMin Minimum amount of tokenA to deposit\n /// @param amountBMin Minimum amount of tokenB to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountA Amount of tokenA to actually deposit\n /// @return amountB Amount of tokenB to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n /// @notice Add liquidity of a token and WETH (transferred as ETH) to a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param amountTokenDesired Amount of token desired to deposit\n /// @param amountTokenMin Minimum amount of token to deposit\n /// @param amountETHMin Minimum amount of ETH to deposit\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to add liquidity\n /// @return amountToken Amount of token to actually deposit\n /// @return amountETH Amount of tokenETH to actually deposit\n /// @return liquidity Amount of liquidity token returned from deposit\n function addLiquidityETH(\n address token,\n bool stable,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n // **** REMOVE LIQUIDITY ****\n\n /// @notice Remove liquidity of two tokens from a Pool\n /// @param tokenA .\n /// @param tokenB .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountAMin Minimum amount of tokenA to receive\n /// @param amountBMin Minimum amount of tokenB to receive\n /// @param to Recipient of tokens received\n /// @param deadline Deadline to remove liquidity\n /// @return amountA Amount of tokenA received\n /// @return amountB Amount of tokenB received\n function removeLiquidity(\n address tokenA,\n address tokenB,\n bool stable,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n /// @notice Remove liquidity of a token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountToken Amount of token received\n /// @return amountETH Amount of ETH received\n function removeLiquidityETH(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n /// @notice Remove liquidity of a fee-on-transfer token and WETH (returned as ETH) from a Pool\n /// @param token .\n /// @param stable True if pool is stable, false if volatile\n /// @param liquidity Amount of liquidity to remove\n /// @param amountTokenMin Minimum amount of token to receive\n /// @param amountETHMin Minimum amount of ETH to receive\n /// @param to Recipient of liquidity token\n /// @param deadline Deadline to receive liquidity\n /// @return amountETH Amount of ETH received\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n bool stable,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n /// @notice Swap one token for another\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /// @notice Swap ETH for a token\n /// @param amountOutMin Minimum amount of desired token received\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactETHForTokens(\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n /// @notice Swap a token for WETH (returned as ETH)\n /// @param amountIn Amount of token in\n /// @param amountOutMin Minimum amount of desired ETH\n /// @param routes Array of trade routes used in the swap\n /// @param to Recipient of the tokens received\n /// @param deadline Deadline to receive tokens\n /// @return amounts Array of amounts returned per route\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n Route[] calldata routes,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n}\n" + }, + "contracts/FeeDistributor.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { CErc20Delegator } from \"./compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"./compound/CErc20PluginDelegate.sol\";\nimport { SafeOwnableUpgradeable } from \"./ionic/SafeOwnableUpgradeable.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { DiamondExtension, DiamondBase } from \"./ionic/DiamondExtension.sol\";\nimport { AuthoritiesRegistry } from \"./ionic/AuthoritiesRegistry.sol\";\n\ncontract FeeDistributorStorage {\n struct CDelegateUpgradeData {\n address implementation;\n bytes becomeImplementationData;\n }\n\n /**\n * @notice Maps Unitroller (Comptroller proxy) addresses to the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n * @dev A value of 0 means unset whereas a negative value means 0.\n */\n mapping(address => int256) public customInterestFeeRates;\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n mapping(address => address) internal _latestComptrollerImplementation;\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n mapping(uint8 => CDelegateUpgradeData) internal _latestCErc20Delegate;\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n mapping(address => address) internal _latestPluginImplementation;\n\n mapping(address => DiamondExtension[]) public comptrollerExtensions;\n\n mapping(address => DiamondExtension[]) public cErc20DelegateExtensions;\n\n AuthoritiesRegistry public authoritiesRegistry;\n\n /**\n * @dev used as salt for the creation of new markets\n */\n uint256 public marketsCounter;\n\n /**\n * @dev Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n */\n uint256 public minBorrowEth;\n\n /**\n * @dev Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n * No longer used as of `Rari-Capital/compound-protocol` version `fuse-v1.1.0`.\n */\n uint256 public maxUtilizationRate;\n\n /**\n * @notice The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n uint256 public defaultInterestFeeRate;\n}\n\n/**\n * @title FeeDistributor\n * @author David Lucid (https://github.com/davidlucid)\n * @notice FeeDistributor controls and receives protocol fees from Ionic pools and relays admin actions to Ionic pools.\n */\ncontract FeeDistributor is SafeOwnableUpgradeable, FeeDistributorStorage {\n using AddressUpgradeable for address;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Initializer that sets initial values of state variables.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function initialize(uint256 _defaultInterestFeeRate) public initializer {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n __SafeOwnable_init(msg.sender);\n defaultInterestFeeRate = _defaultInterestFeeRate;\n maxUtilizationRate = type(uint256).max;\n }\n\n function reinitialize(AuthoritiesRegistry _ar) public onlyOwnerOrAdmin {\n authoritiesRegistry = _ar;\n }\n\n /**\n * @dev Sets the default proportion of Ionic pool interest taken as a protocol fee.\n * @param _defaultInterestFeeRate The default proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setDefaultInterestFeeRate(uint256 _defaultInterestFeeRate) external onlyOwner {\n require(_defaultInterestFeeRate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n defaultInterestFeeRate = _defaultInterestFeeRate;\n }\n\n /**\n * @dev Withdraws accrued fees on interest.\n * @param erc20Contract The ERC20 token address to withdraw. Set to the zero address to withdraw ETH.\n */\n function _withdrawAssets(address erc20Contract) external {\n if (erc20Contract == address(0)) {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No balance available to withdraw.\");\n (bool success, ) = owner().call{ value: balance }(\"\");\n require(success, \"Failed to transfer ETH balance to msg.sender.\");\n } else {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 balance = token.balanceOf(address(this));\n require(balance > 0, \"No token balance available to withdraw.\");\n token.safeTransfer(owner(), balance);\n }\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param _minBorrowEth Minimum borrow balance (in ETH) per user per Ionic pool asset (only checked on new borrows, not redemptions).\n * @param _maxUtilizationRate Maximum utilization rate (scaled by 1e18) for Ionic pool assets (only checked on new borrows, not redemptions).\n */\n function _setPoolLimits(uint256 _minBorrowEth, uint256 _maxUtilizationRate) external onlyOwner {\n minBorrowEth = _minBorrowEth;\n maxUtilizationRate = _maxUtilizationRate;\n }\n\n function getMinBorrowEth(ICErc20 _ctoken) public view returns (uint256) {\n (, , uint256 borrowBalance, ) = _ctoken.getAccountSnapshot(_msgSender());\n if (borrowBalance == 0) return minBorrowEth;\n IonicComptroller comptroller = IonicComptroller(address(_ctoken.comptroller()));\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPriceEth = oracle.price(ICErc20(address(_ctoken)).underlying());\n uint256 underlyingDecimals = _ctoken.decimals();\n uint256 borrowBalanceEth = (underlyingPriceEth * borrowBalance) / 10**underlyingDecimals;\n if (borrowBalanceEth > minBorrowEth) {\n return 0;\n }\n return minBorrowEth - borrowBalanceEth;\n }\n\n /**\n * @dev Receives native fees.\n */\n receive() external payable {}\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes[] calldata data) external onlyOwner {\n require(targets.length > 0 && targets.length == data.length, \"Array lengths must be equal and greater than 0.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data[i]);\n }\n\n /**\n * @dev Sends data to a contract.\n * @param targets The contracts to which `data` will be sent.\n * @param data The data to be sent to each of `targets`.\n */\n function _callPool(address[] calldata targets, bytes calldata data) external onlyOwner {\n require(targets.length > 0, \"No target addresses specified.\");\n for (uint256 i = 0; i < targets.length; i++) targets[i].functionCall(data);\n }\n\n /**\n * @dev Deploys a CToken for an underlying ERC20\n * @param constructorData Encoded construction data for `CToken initialize()`\n */\n function deployCErc20(\n uint8 delegateType,\n bytes calldata constructorData,\n bytes calldata becomeImplData\n ) external returns (address) {\n // Make sure comptroller == msg.sender\n (address underlying, address comptroller) = abi.decode(constructorData[0:64], (address, address));\n require(comptroller == msg.sender, \"Comptroller is not sender.\");\n\n // Deploy CErc20Delegator using msg.sender, underlying, and block.number as a salt\n bytes32 salt = keccak256(abi.encodePacked(msg.sender, underlying, ++marketsCounter));\n\n bytes memory cErc20DelegatorCreationCode = abi.encodePacked(type(CErc20Delegator).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(0, salt, cErc20DelegatorCreationCode);\n\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n DiamondExtension delegateAsExtension = DiamondExtension(data.implementation);\n // register the first extension\n DiamondBase(proxy)._registerExtension(delegateAsExtension, DiamondExtension(address(0)));\n // derive and configure the other extensions\n DiamondExtension[] memory ctokenExts = cErc20DelegateExtensions[address(delegateAsExtension)];\n for (uint256 i = 0; i < ctokenExts.length; i++) {\n if (ctokenExts[i] == delegateAsExtension) continue;\n DiamondBase(proxy)._registerExtension(ctokenExts[i], DiamondExtension(address(0)));\n }\n CErc20PluginDelegate(address(proxy))._becomeImplementation(becomeImplData);\n\n return proxy;\n }\n\n /**\n * @dev Latest Comptroller implementation for each existing implementation.\n */\n function latestComptrollerImplementation(address oldImplementation) external view returns (address) {\n return\n _latestComptrollerImplementation[oldImplementation] != address(0)\n ? _latestComptrollerImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest `Comptroller` upgrade implementation address.\n * @param oldImplementation The old `Comptroller` implementation address to upgrade from.\n * @param newImplementation Latest `Comptroller` implementation address.\n */\n function _setLatestComptrollerImplementation(address oldImplementation, address newImplementation)\n external\n onlyOwner\n {\n _latestComptrollerImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Latest CErc20Delegate implementation for each existing implementation.\n */\n function latestCErc20Delegate(uint8 delegateType) external view returns (address, bytes memory) {\n CDelegateUpgradeData memory data = _latestCErc20Delegate[delegateType];\n bytes memory emptyBytes;\n return\n data.implementation != address(0)\n ? (data.implementation, data.becomeImplementationData)\n : (address(0), emptyBytes);\n }\n\n /**\n * @dev Sets the latest `CErc20Delegate` upgrade implementation address and data.\n * @param delegateType The old `CErc20Delegate` implementation address to upgrade from.\n * @param newImplementation Latest `CErc20Delegate` implementation address.\n * @param becomeImplementationData Data passed to the new implementation via `becomeImplementation` after upgrade.\n */\n function _setLatestCErc20Delegate(\n uint8 delegateType,\n address newImplementation,\n bytes calldata becomeImplementationData\n ) external onlyOwner {\n _latestCErc20Delegate[delegateType] = CDelegateUpgradeData(newImplementation, becomeImplementationData);\n }\n\n /**\n * @dev Latest Plugin implementation for each existing implementation.\n */\n function latestPluginImplementation(address oldImplementation) external view returns (address) {\n return\n _latestPluginImplementation[oldImplementation] != address(0)\n ? _latestPluginImplementation[oldImplementation]\n : oldImplementation;\n }\n\n /**\n * @dev Sets the latest plugin upgrade implementation address.\n * @param oldImplementation The old plugin implementation address to upgrade from.\n * @param newImplementation Latest plugin implementation address.\n */\n function _setLatestPluginImplementation(address oldImplementation, address newImplementation) external onlyOwner {\n _latestPluginImplementation[oldImplementation] = newImplementation;\n }\n\n /**\n * @dev Upgrades a plugin of a CErc20PluginDelegate market to the latest implementation\n * @param cDelegator the proxy address\n * @return if the plugin was upgraded or not\n */\n function _upgradePluginToLatestImplementation(address cDelegator) external onlyOwner returns (bool) {\n CErc20PluginDelegate market = CErc20PluginDelegate(cDelegator);\n\n address oldPluginAddress = address(market.plugin());\n market._updatePlugin(_latestPluginImplementation[oldPluginAddress]);\n address newPluginAddress = address(market.plugin());\n\n return newPluginAddress != oldPluginAddress;\n }\n\n /**\n * @notice Returns the proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function interestFeeRate() external view returns (uint256) {\n (bool success, bytes memory data) = msg.sender.staticcall(abi.encodeWithSignature(\"comptroller()\"));\n\n if (success && data.length == 32) {\n address comptroller = abi.decode(data, (address));\n int256 customRate = customInterestFeeRates[comptroller];\n if (customRate > 0) return uint256(customRate);\n if (customRate < 0) return 0;\n }\n\n return defaultInterestFeeRate;\n }\n\n /**\n * @dev Sets the proportion of Ionic pool interest taken as a protocol fee.\n * @param comptroller The Unitroller (Comptroller proxy) address.\n * @param rate The proportion of Ionic pool interest taken as a protocol fee (scaled by 1e18).\n */\n function _setCustomInterestFeeRate(address comptroller, int256 rate) external onlyOwner {\n require(rate <= 1e18, \"Interest fee rate cannot be more than 100%.\");\n customInterestFeeRates[comptroller] = rate;\n }\n\n function getComptrollerExtensions(address comptroller) external view returns (DiamondExtension[] memory) {\n return comptrollerExtensions[comptroller];\n }\n\n function _setComptrollerExtensions(address comptroller, DiamondExtension[] calldata extensions) external onlyOwner {\n comptrollerExtensions[comptroller] = extensions;\n }\n\n function _registerComptrollerExtension(\n address payable pool,\n DiamondExtension extensionToAdd,\n DiamondExtension extensionToReplace\n ) external onlyOwner {\n DiamondBase(pool)._registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (DiamondExtension[] memory) {\n return cErc20DelegateExtensions[cErc20Delegate];\n }\n\n function _setCErc20DelegateExtensions(address cErc20Delegate, DiamondExtension[] calldata extensions)\n external\n onlyOwner\n {\n cErc20DelegateExtensions[cErc20Delegate] = extensions;\n }\n\n function autoUpgradePool(IonicComptroller pool) external onlyOwner {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n // auto upgrade the pool\n pool._upgrade();\n\n for (uint8 i = 0; i < markets.length; i++) {\n // upgrade the market\n markets[i]._upgrade();\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n return authoritiesRegistry.canCall(pool, user, target, functionSig);\n }\n}\n" + }, + "contracts/ILiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\n\ninterface ILiquidator {\n /**\n * borrower The borrower's Ethereum address.\n * repayAmount The amount to repay to liquidate the unhealthy loan.\n * cErc20 The borrowed CErc20 contract to repay.\n * cTokenCollateral The cToken collateral contract to be liquidated.\n * minProfitAmount The minimum amount of profit required for execution (in terms of `exchangeProfitTo`). Reverts if this condition is not met.\n * redemptionStrategies The IRedemptionStrategy contracts to use, if any, to redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * strategyData The data for the chosen IRedemptionStrategy contracts, if any.\n */\n struct LiquidateToTokensWithFlashSwapVars {\n address borrower;\n uint256 repayAmount;\n ICErc20 cErc20;\n ICErc20 cTokenCollateral;\n address flashSwapContract;\n uint256 minProfitAmount;\n IRedemptionStrategy[] redemptionStrategies;\n bytes[] strategyData;\n IFundsConversionStrategy[] debtFundingStrategies;\n bytes[] debtFundingStrategiesData;\n }\n\n function redemptionStrategiesWhitelist(address strategy) external view returns (bool);\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256);\n\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n returns (uint256);\n\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external;\n\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external;\n\n function setExpressRelay(address _expressRelay) external;\n\n function setPoolLens(address _poolLens) external;\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external;\n}\n" + }, + "contracts/ionic/AddressesProvider.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\n\n/**\n * @title AddressesProvider\n * @notice The Addresses Provider serves as a central storage of system internal and external\n * contract addresses that change between deploys and across chains\n * @author Veliko Minkov \n */\ncontract AddressesProvider is SafeOwnableUpgradeable {\n mapping(string => address) private _addresses;\n mapping(address => Contract) public plugins;\n mapping(address => Contract) public flywheelRewards;\n mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;\n mapping(address => FundingStrategy) public fundingStrategiesConfig;\n JarvisPool[] public jarvisPoolsConfig;\n CurveSwapPool[] public curveSwapPoolsConfig;\n mapping(address => mapping(address => address)) public balancerPoolForTokens;\n\n /// @dev Initializer to set the admin that can set and change contracts addresses\n function initialize(address owner) public initializer {\n __SafeOwnable_init(owner);\n }\n\n /**\n * @dev The contract address and a string that uniquely identifies the contract's interface\n */\n struct Contract {\n address addr;\n string contractInterface;\n }\n\n struct RedemptionStrategy {\n address addr;\n string contractInterface;\n address outputToken;\n }\n\n struct FundingStrategy {\n address addr;\n string contractInterface;\n address inputToken;\n }\n\n struct JarvisPool {\n address syntheticToken;\n address collateralToken;\n address liquidityPool;\n uint256 expirationTime;\n }\n\n struct CurveSwapPool {\n address poolAddress;\n address[] coins;\n }\n\n /**\n * @dev sets the address and contract interface ID of the flywheel for the reward token\n * @param rewardToken the reward token address\n * @param flywheelRewardsModule the flywheel rewards module address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFlywheelRewards(\n address rewardToken,\n address flywheelRewardsModule,\n string calldata contractInterface\n ) public onlyOwner {\n flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset\n * @param asset the asset address\n * @param plugin the ERC4626 plugin address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setPlugin(\n address asset,\n address plugin,\n string calldata contractInterface\n ) public onlyOwner {\n plugins[asset] = Contract(plugin, contractInterface);\n }\n\n /**\n * @dev sets the address and contract interface ID of the redemption strategy for the asset\n * @param asset the asset address\n * @param strategy redemption strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setRedemptionStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address outputToken\n ) public onlyOwner {\n redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);\n }\n\n function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {\n return redemptionStrategiesConfig[asset];\n }\n\n /**\n * @dev sets the address and contract interface ID of the funding strategy for the asset\n * @param asset the asset address\n * @param strategy funding strategy address\n * @param contractInterface a string that uniquely identifies the contract's interface\n */\n function setFundingStrategy(\n address asset,\n address strategy,\n string calldata contractInterface,\n address inputToken\n ) public onlyOwner {\n fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);\n }\n\n function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {\n return fundingStrategiesConfig[asset];\n }\n\n /**\n * @dev configures the Jarvis pool of a Jarvis synthetic token\n * @param syntheticToken the synthetic token address\n * @param collateralToken the collateral token address\n * @param liquidityPool the liquidity pool address\n * @param expirationTime the operation expiration time\n */\n function setJarvisPool(\n address syntheticToken,\n address collateralToken,\n address liquidityPool,\n uint256 expirationTime\n ) public onlyOwner {\n jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));\n }\n\n function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {\n curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));\n }\n\n /**\n * @dev Sets an address for an id replacing the address saved in the addresses map\n * @param id The id\n * @param newAddress The address to set\n */\n function setAddress(string calldata id, address newAddress) external onlyOwner {\n _addresses[id] = newAddress;\n }\n\n /**\n * @dev Returns an address by id\n * @return The address\n */\n function getAddress(string calldata id) public view returns (address) {\n return _addresses[id];\n }\n\n function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {\n return curveSwapPoolsConfig;\n }\n\n function getJarvisPools() public view returns (JarvisPool[] memory) {\n return jarvisPoolsConfig;\n }\n\n function setBalancerPoolForTokens(\n address inputToken,\n address outputToken,\n address pool\n ) external onlyOwner {\n balancerPoolForTokens[inputToken][outputToken] = pool;\n }\n\n function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {\n return balancerPoolForTokens[inputToken][outputToken];\n }\n}\n" + }, + "contracts/ionic/AuthoritiesRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { SafeOwnableUpgradeable } from \"../ionic/SafeOwnableUpgradeable.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract AuthoritiesRegistry is SafeOwnableUpgradeable {\n mapping(address => PoolRolesAuthority) public poolsAuthorities;\n PoolRolesAuthority public poolAuthLogic;\n address public leveredPositionsFactory;\n bool public noAuthRequired;\n\n function initialize(address _leveredPositionsFactory) public initializer {\n __SafeOwnable_init(msg.sender);\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n }\n\n function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {\n leveredPositionsFactory = _leveredPositionsFactory;\n poolAuthLogic = new PoolRolesAuthority();\n // for Neon the auth is not required\n noAuthRequired = block.chainid == 245022934;\n }\n\n function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {\n require(address(poolsAuthorities[pool]) == address(0), \"already created\");\n\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), \"\");\n auth = PoolRolesAuthority(address(proxy));\n auth.initialize(address(this));\n poolsAuthorities[pool] = auth;\n\n auth.openPoolSupplierCapabilities(IonicComptroller(pool));\n auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);\n // sets the registry owner as the auth owner\n reconfigureAuthority(pool);\n }\n\n function reconfigureAuthority(address poolAddress) public {\n IonicComptroller pool = IonicComptroller(poolAddress);\n PoolRolesAuthority auth = poolsAuthorities[address(pool)];\n\n if (msg.sender != poolAddress || address(auth) != address(0)) {\n require(address(auth) != address(0), \"no such authority\");\n require(msg.sender == owner() || msg.sender == poolAddress, \"not owner or pool\");\n\n auth.configureRegistryCapabilities();\n auth.configurePoolSupplierCapabilities(pool);\n auth.configurePoolBorrowerCapabilities(pool);\n // everyone can be a liquidator\n auth.configureOpenPoolLiquidatorCapabilities(pool);\n auth.configureLeveredPositionCapabilities(pool);\n\n if (auth.owner() != owner()) {\n auth.setOwner(owner());\n }\n }\n }\n\n function canCall(\n address pool,\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool) {\n PoolRolesAuthority authorityForPool = poolsAuthorities[pool];\n if (address(authorityForPool) == address(0)) {\n return noAuthRequired;\n } else {\n // allow only if an auth exists and it allows the action\n return authorityForPool.canCall(user, target, functionSig);\n }\n }\n\n function setUserRole(\n address pool,\n address user,\n uint8 role,\n bool enabled\n ) external {\n PoolRolesAuthority poolAuth = poolsAuthorities[pool];\n\n require(address(poolAuth) != address(0), \"auth does not exist\");\n require(msg.sender == owner() || msg.sender == leveredPositionsFactory, \"not owner or factory\");\n require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), \"only lev pos role\");\n\n poolAuth.setUserRole(user, role, enabled);\n }\n}\n" + }, + "contracts/ionic/CollateralSwap.sol": { + "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.22;\n\nimport { IERC20, SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nimport { IFlashLoanReceiver } from \"./IFlashLoanReceiver.sol\";\nimport { Exponential } from \"../compound/Exponential.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\ncontract CollateralSwap is Ownable2Step, Exponential, IFlashLoanReceiver {\n using SafeERC20 for IERC20;\n\n uint256 public feeBps;\n address public feeRecipient;\n IonicComptroller public comptroller;\n mapping(address => bool) public allowedSwapTargets;\n\n error SwapCollateralFailed();\n error TransferFailed(address market, address user, address target);\n error MintFailed(address market, uint256 errorCode);\n error RedeemFailed(address market, uint256 errorCode);\n error InvalidFlashloanCaller(address caller);\n error InvalidSwapTarget(address target);\n\n constructor(\n uint256 _feeBps,\n address _feeRecipient,\n address _comptroller,\n address[] memory _allowedSwapTargets\n ) Ownable2Step() {\n feeBps = _feeBps;\n feeRecipient = _feeRecipient;\n comptroller = IonicComptroller(_comptroller);\n for (uint256 i = 0; i < _allowedSwapTargets.length; i++) {\n allowedSwapTargets[_allowedSwapTargets[i]] = true;\n }\n }\n\n // ADMIN FUNCTIONS\n\n function setFeeBps(uint256 _feeBps) public onlyOwner {\n feeBps = _feeBps;\n }\n\n function setFeeRecipient(address _feeRecipient) public onlyOwner {\n feeRecipient = _feeRecipient;\n }\n\n function setAllowedSwapTarget(address _target, bool _allowed) public onlyOwner {\n allowedSwapTargets[_target] = _allowed;\n }\n\n function sweep(address token) public onlyOwner {\n IERC20(token).safeTransfer(owner(), IERC20(token).balanceOf(address(this)));\n }\n\n // PUBLIC FUNCTIONS\n\n function swapCollateral(\n uint256 amountUnderlying,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes calldata swapData\n ) public {\n oldCollateralMarket.flash(\n amountUnderlying,\n abi.encode(msg.sender, oldCollateralMarket, newCollateralMarket, swapTarget, swapData)\n );\n }\n\n function receiveFlashLoan(address borrowedAsset, uint256 borrowedAmount, bytes calldata data) external {\n // make sure the caller is a valid market\n {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n bool isAllowed = false;\n for (uint256 i = 0; i < markets.length; i++) {\n if (msg.sender == address(markets[i])) {\n isAllowed = true;\n break;\n }\n }\n if (!isAllowed) {\n revert InvalidFlashloanCaller(msg.sender);\n }\n }\n\n (\n address borrower,\n ICErc20 oldCollateralMarket,\n ICErc20 newCollateralMarket,\n address swapTarget,\n bytes memory swapData\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes));\n\n // swap the collateral\n {\n if (!allowedSwapTargets[swapTarget]) {\n revert InvalidSwapTarget(swapTarget);\n }\n IERC20(borrowedAsset).approve(swapTarget, borrowedAmount);\n (bool success, ) = swapTarget.call(swapData);\n if (!success) {\n revert SwapCollateralFailed();\n }\n }\n\n // mint the new collateral\n {\n IERC20 newCollateralAsset = IERC20(newCollateralMarket.underlying());\n uint256 outputAmount = newCollateralAsset.balanceOf(address(this));\n uint256 fee = (outputAmount * feeBps) / 10_000;\n outputAmount -= fee;\n if (fee > 0) {\n newCollateralAsset.safeTransfer(feeRecipient, fee);\n }\n newCollateralAsset.approve(address(newCollateralMarket), outputAmount);\n uint256 mintResult = newCollateralMarket.mint(outputAmount);\n if (mintResult != 0) {\n revert MintFailed(address(newCollateralMarket), mintResult);\n }\n }\n\n // transfer the new collateral to the borrower\n {\n uint256 cTokenBalance = IERC20(address(newCollateralMarket)).balanceOf(address(this));\n IERC20(address(newCollateralMarket)).safeTransfer(borrower, cTokenBalance);\n }\n\n // withdraw the old collateral\n {\n (MathError mErr, uint256 amountCTokensToSwap) = divScalarByExpTruncate(\n borrowedAmount,\n Exp({ mantissa: oldCollateralMarket.exchangeRateCurrent() })\n );\n require(mErr == MathError.NO_ERROR, \"exchange rate error\");\n bool transferStatus = oldCollateralMarket.transferFrom(borrower, address(this), amountCTokensToSwap + 1);\n if (!transferStatus) {\n revert TransferFailed(address(oldCollateralMarket), borrower, address(this));\n }\n uint256 redeemResult = oldCollateralMarket.redeemUnderlying(type(uint256).max);\n if (redeemResult != 0) {\n revert RedeemFailed(address(oldCollateralMarket), redeemResult);\n }\n IERC20(borrowedAsset).approve(address(oldCollateralMarket), borrowedAmount);\n }\n // flashloan gets paid back from redeemed collateral\n }\n}\n" + }, + "contracts/ionic/DiamondExtension.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\n/**\n * @notice a base contract for logic extensions that use the diamond pattern storage\n * to map the functions when looking up the extension contract to delegate to.\n */\nabstract contract DiamondExtension {\n /**\n * @return a list of all the function selectors that this logic extension exposes\n */\n function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);\n}\n\n// When no function exists for function called\nerror FunctionNotFound(bytes4 _functionSelector);\n\n// When no extension exists for function called\nerror ExtensionNotFound(bytes4 _functionSelector);\n\n// When the function is already added\nerror FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);\n\nabstract contract DiamondBase {\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;\n\n function _listExtensions() public view returns (address[] memory) {\n return LibDiamond.listExtensions();\n }\n\n fallback() external {\n address extension = LibDiamond.getExtensionForFunction(msg.sig);\n if (extension == address(0)) revert FunctionNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n\n/**\n * @notice a library to use in a contract, whose logic is extended with diamond extension\n */\nlibrary LibDiamond {\n bytes32 constant DIAMOND_STORAGE_POSITION = keccak256(\"diamond.extensions.diamond.storage\");\n\n struct Function {\n address extension;\n bytes4 selector;\n }\n\n struct LogicStorage {\n Function[] functions;\n address[] extensions;\n }\n\n function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {\n return getExtensionForSelector(msgSig, diamondStorage());\n }\n\n function diamondStorage() internal pure returns (LogicStorage storage ds) {\n bytes32 position = DIAMOND_STORAGE_POSITION;\n assembly {\n ds.slot := position\n }\n }\n\n function listExtensions() internal view returns (address[] memory) {\n return diamondStorage().extensions;\n }\n\n function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {\n if (address(extensionToReplace) != address(0)) {\n removeExtension(extensionToReplace);\n }\n addExtension(extensionToAdd);\n }\n\n function removeExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n // remove all functions of the extension to replace\n removeExtensionFunctions(extension);\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n if (ds.extensions[i] == address(extension)) {\n ds.extensions[i] = ds.extensions[ds.extensions.length - 1];\n ds.extensions.pop();\n }\n }\n }\n\n function addExtension(DiamondExtension extension) internal {\n LogicStorage storage ds = diamondStorage();\n for (uint8 i = 0; i < ds.extensions.length; i++) {\n require(ds.extensions[i] != address(extension), \"extension already added\");\n }\n addExtensionFunctions(extension);\n ds.extensions.push(address(extension));\n }\n\n function removeExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToRemove = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n for (uint16 i = 0; i < fnsToRemove.length; i++) {\n bytes4 selectorToRemove = fnsToRemove[i];\n // must never fail\n assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));\n // swap with the last element in the selectorAtIndex array and remove the last element\n uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);\n ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];\n ds.functions.pop();\n }\n }\n\n function addExtensionFunctions(DiamondExtension extension) internal {\n bytes4[] memory fnsToAdd = extension._getExtensionFunctions();\n LogicStorage storage ds = diamondStorage();\n uint16 functionsCount = uint16(ds.functions.length);\n for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {\n bytes4 selector = fnsToAdd[functionsIndex];\n address oldImplementation = getExtensionForSelector(selector, ds);\n if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);\n ds.functions.push(Function(address(extension), selector));\n functionsCount++;\n }\n }\n\n function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {\n uint256 fnsLen = ds.functions.length;\n for (uint256 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return ds.functions[i].extension;\n }\n\n return address(0);\n }\n\n function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {\n uint16 fnsLen = uint16(ds.functions.length);\n for (uint16 i = 0; i < fnsLen; i++) {\n if (ds.functions[i].selector == selector) return i;\n }\n\n return type(uint16).max;\n }\n}\n" + }, + "contracts/ionic/IFlashLoanReceiver.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\ninterface IFlashLoanReceiver {\n function receiveFlashLoan(\n address borrowedAsset,\n uint256 borrowedAmount,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/ionic/levered/ILeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILeveredPositionFactoryStorage {\n function feeDistributor() external view returns (IFeeDistributor);\n\n function liquidatorsRegistry() external view returns (ILiquidatorsRegistry);\n\n function blocksPerYear() external view returns (uint256);\n\n function owner() external view returns (address);\n}\n\ninterface ILeveredPositionFactoryBase {\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external;\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external;\n}\n\ninterface ILeveredPositionFactoryFirstExtension {\n function getRedemptionStrategies(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getMinBorrowNative() external view returns (uint256);\n\n function removeClosedPosition(address closedPosition) external returns (bool removed);\n\n function closeAndRemoveUserPosition(LeveredPosition position) external returns (bool);\n\n function getPositionsByAccount(address account) external view returns (address[] memory, bool[] memory);\n\n function getAccountsWithOpenPositions() external view returns (address[] memory);\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory);\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory);\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address);\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external;\n}\n\ninterface ILeveredPositionFactorySecondExtension {\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) external returns (LeveredPosition);\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) external returns (LeveredPosition);\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition);\n}\n\ninterface ILeveredPositionFactoryExtension is\n ILeveredPositionFactoryFirstExtension,\n ILeveredPositionFactorySecondExtension\n{}\n\ninterface ILeveredPositionFactory is\n ILeveredPositionFactoryStorage,\n ILeveredPositionFactoryBase,\n ILeveredPositionFactoryExtension\n{}\n" + }, + "contracts/ionic/levered/LeveredPosition.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IFlashLoanReceiver } from \"../IFlashLoanReceiver.sol\";\nimport { IonicFlywheel } from \"../../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { LeveredPositionStorage } from \"./LeveredPositionStorage.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFlywheelLensRouter_LP {\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory);\n}\n\ncontract LeveredPosition is LeveredPositionStorage, IFlashLoanReceiver {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error OnlyWhenClosed();\n error NotPositionOwner();\n error OnlyFactoryOwner();\n error AssetNotRescuable();\n error RepayFlashLoanFailed(address asset, uint256 currentBalance, uint256 repayAmount);\n\n error ConvertFundsFailed();\n error ExitFailed(uint256 errorCode);\n error RedeemFailed(uint256 errorCode);\n error SupplyCollateralFailed(uint256 errorCode);\n error BorrowStableFailed(uint256 errorCode);\n error RepayBorrowFailed(uint256 errorCode);\n error RedeemCollateralFailed(uint256 errorCode);\n error ExtNotFound(bytes4 _functionSelector);\n\n constructor(\n address _positionOwner,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket\n ) LeveredPositionStorage(_positionOwner) {\n IonicComptroller collateralPool = _collateralMarket.comptroller();\n IonicComptroller stablePool = _stableMarket.comptroller();\n require(collateralPool == stablePool, \"markets pools differ\");\n pool = collateralPool;\n\n collateralMarket = _collateralMarket;\n collateralAsset = IERC20Upgradeable(_collateralMarket.underlying());\n stableMarket = _stableMarket;\n stableAsset = IERC20Upgradeable(_stableMarket.underlying());\n\n factory = ILeveredPositionFactory(msg.sender);\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function fundPosition(IERC20Upgradeable fundingAsset, uint256 amount) public {\n fundingAsset.safeTransferFrom(msg.sender, address(this), amount);\n _supplyCollateral(fundingAsset);\n\n if (!pool.checkMembership(address(this), collateralMarket)) {\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(collateralMarket);\n pool.enterMarkets(cTokens);\n }\n }\n\n function closePosition() public returns (uint256) {\n return closePosition(msg.sender);\n }\n\n function closePosition(address withdrawTo) public returns (uint256 withdrawAmount) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n _leverDown(1e18);\n\n // calling accrue and exit allows to redeem the full underlying balance\n collateralMarket.accrueInterest();\n uint256 errorCode = pool.exitMarket(address(collateralMarket));\n if (errorCode != 0) revert ExitFailed(errorCode);\n\n // redeem all cTokens should leave no dust\n errorCode = collateralMarket.redeem(collateralMarket.balanceOf(address(this)));\n if (errorCode != 0) revert RedeemFailed(errorCode);\n\n if (stableAsset.balanceOf(address(this)) > 0) {\n // convert all overborrowed leftovers/profits to the collateral asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // withdraw the redeemed collateral\n withdrawAmount = collateralAsset.balanceOf(address(this));\n collateralAsset.safeTransfer(withdrawTo, withdrawAmount);\n }\n\n function adjustLeverageRatio(uint256 targetRatioMantissa) public returns (uint256) {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n // anything under 1x means removing the leverage\n if (targetRatioMantissa <= 1e18) _leverDown(1e18);\n\n if (getCurrentLeverageRatio() < targetRatioMantissa) _leverUp(targetRatioMantissa);\n else _leverDown(targetRatioMantissa);\n\n // return the de facto achieved ratio\n return getCurrentLeverageRatio();\n }\n\n function receiveFlashLoan(\n address assetAddress,\n uint256 borrowedAmount,\n bytes calldata data\n ) external override {\n if (msg.sender == address(collateralMarket)) {\n // increasing the leverage ratio\n uint256 stableBorrowAmount = abi.decode(data, (uint256));\n _leverUpPostFL(stableBorrowAmount);\n uint256 positionCollateralBalance = collateralAsset.balanceOf(address(this));\n if (positionCollateralBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(collateralAsset), positionCollateralBalance, borrowedAmount);\n } else if (msg.sender == address(stableMarket)) {\n // decreasing the leverage ratio\n uint256 amountToRedeem = abi.decode(data, (uint256));\n _leverDownPostFL(borrowedAmount, amountToRedeem);\n uint256 positionStableBalance = stableAsset.balanceOf(address(this));\n if (positionStableBalance < borrowedAmount)\n revert RepayFlashLoanFailed(address(stableAsset), positionStableBalance, borrowedAmount);\n } else {\n revert(\"!fl not from either markets\");\n }\n\n // repay FL\n IERC20Upgradeable(assetAddress).approve(msg.sender, borrowedAmount);\n }\n\n function withdrawStableLeftovers(address withdrawTo) public returns (uint256) {\n if (msg.sender != positionOwner) revert NotPositionOwner();\n if (!isPositionClosed()) revert OnlyWhenClosed();\n\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n stableAsset.safeTransfer(withdrawTo, stableLeftovers);\n return stableLeftovers;\n }\n\n function claimRewards() public {\n claimRewards(msg.sender);\n }\n\n function claimRewards(address withdrawTo) public {\n if (msg.sender != positionOwner && msg.sender != address(factory)) revert NotPositionOwner();\n\n address[] memory flywheels = pool.getRewardsDistributors();\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n fw.claimRewards(address(this));\n ERC20 rewardToken = fw.rewardToken();\n uint256 rewardsAccrued = rewardToken.balanceOf(address(this));\n if (rewardsAccrued > 0) {\n rewardToken.transfer(withdrawTo, rewardsAccrued);\n }\n }\n }\n\n function rescueTokens(IERC20Upgradeable asset) external {\n if (msg.sender != factory.owner()) revert OnlyFactoryOwner();\n if (asset == stableAsset || asset == collateralAsset) revert AssetNotRescuable();\n\n asset.transfer(positionOwner, asset.balanceOf(address(this)));\n }\n\n function claimRewardsFromRouter(address _flr) external returns (address[] memory, uint256[] memory) {\n IFlywheelLensRouter_LP flr = IFlywheelLensRouter_LP(_flr);\n (address[] memory rewardTokens, uint256[] memory rewards) = flr.claimAllRewardTokens(address(this));\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n IERC20Upgradeable(rewardTokens[i]).safeTransfer(positionOwner, rewards[i]);\n }\n return (rewardTokens, rewards);\n }\n\n fallback() external {\n address extension = factory.getPositionsExtension(msg.sig);\n if (extension == address(0)) revert ExtNotFound(msg.sig);\n // Execute external function from extension using delegatecall and return any value.\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 0, calldatasize())\n // execute function call using the extension\n let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getAccruedRewards()\n external\n returns (\n /*view*/\n ERC20[] memory rewardTokens,\n uint256[] memory amounts\n )\n {\n address[] memory flywheels = pool.getRewardsDistributors();\n\n rewardTokens = new ERC20[](flywheels.length);\n amounts = new uint256[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n IonicFlywheel fw = IonicFlywheel(flywheels[i]);\n fw.accrue(ERC20(address(collateralMarket)), address(this));\n fw.accrue(ERC20(address(stableMarket)), address(this));\n rewardTokens[i] = fw.rewardToken();\n amounts[i] = fw.rewardsAccrued(address(this));\n }\n }\n\n function getCurrentLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtValue = 0;\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n if (debtAmount > 0) {\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n }\n\n // TODO check if positionValue > debtValue\n // s / ( s - b )\n return (positionValue * 1e18) / (positionValue - debtValue);\n }\n\n function getMinLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 minStableBorrowAmount = (factory.getMinBorrowNative() * 1e18) / borrowedAssetPrice;\n return _getLeverageRatioAfterBorrow(minStableBorrowAmount, positionSupplyAmount, 0);\n }\n\n function getMaxLeverageRatio() public view returns (uint256) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n if (positionSupplyAmount == 0) return 0;\n\n uint256 maxBorrow = pool.getMaxRedeemOrBorrow(address(this), stableMarket, true);\n uint256 positionBorrowAmount = stableMarket.borrowBalanceCurrent(address(this));\n return _getLeverageRatioAfterBorrow(maxBorrow, positionSupplyAmount, positionBorrowAmount);\n }\n\n function _getLeverageRatioAfterBorrow(\n uint256 newBorrowsAmount,\n uint256 positionSupplyAmount,\n uint256 positionBorrowAmount\n ) internal view returns (uint256 r) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentBorrowsValue = (positionBorrowAmount * stableAssetPrice) / 1e18;\n uint256 newBorrowsValue = (newBorrowsAmount * stableAssetPrice) / 1e18;\n uint256 positionValue = (positionSupplyAmount * collateralAssetPrice) / 1e18;\n\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n {\n // add 10 bps just to not go under the min borrow value\n assumedSlippage += 10;\n }\n uint256 topUpCollateralValue = (newBorrowsValue * 10000) / (10000 + assumedSlippage);\n\n int256 s = int256(positionValue);\n int256 b = int256(currentBorrowsValue);\n int256 x = int256(topUpCollateralValue);\n\n r = uint256(((s + x) * 1e18) / (s + x - b - int256(newBorrowsValue)));\n }\n\n function isPositionClosed() public view returns (bool) {\n return collateralMarket.balanceOfUnderlying(address(this)) == 0;\n }\n\n function getEquityAmount() external view returns (uint256 equityAmount) {\n BasePriceOracle oracle = pool.oracle();\n uint256 borrowedAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 positionValue = (collateralAssetPrice * positionSupplyAmount) / 1e18;\n\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 debtValue = (borrowedAssetPrice * debtAmount) / 1e18;\n\n uint256 equityValue = positionValue - debtValue;\n equityAmount = (equityValue * 1e18) / collateralAssetPrice;\n }\n\n function getSupplyAmountDelta(uint256 targetRatio) public view returns (uint256, uint256) {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n uint256 currentRatio = getCurrentLeverageRatio();\n bool up = targetRatio > currentRatio;\n return _getSupplyAmountDelta(up, targetRatio, collateralAssetPrice, stableAssetPrice);\n }\n\n function _getSupplyAmountDelta(\n bool up,\n uint256 targetRatio,\n uint256 collateralAssetPrice,\n uint256 borrowedAssetPrice\n ) internal view returns (uint256 supplyDelta, uint256 borrowsDelta) {\n uint256 positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(this));\n uint256 debtAmount = stableMarket.borrowBalanceCurrent(address(this));\n uint256 assumedSlippage;\n if (up) assumedSlippage = factory.liquidatorsRegistry().getSlippage(stableAsset, collateralAsset);\n else assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 slippageFactor = (1e18 * (10000 + assumedSlippage)) / 10000;\n\n uint256 supplyValueDeltaAbs;\n {\n // s = supply value before\n // b = borrow value before\n // r = target ratio after\n // c = borrow value coefficient to account for the slippage\n int256 s = int256((collateralAssetPrice * positionSupplyAmount) / 1e18);\n int256 b = int256((borrowedAssetPrice * debtAmount) / 1e18);\n int256 r = int256(targetRatio);\n int256 r1 = r - 1e18;\n int256 c = int256(slippageFactor);\n\n // some math magic here\n // https://www.wolframalpha.com/input?i2d=true&i=r%3D%5C%2840%29Divide%5B%5C%2840%29s%2Bx%5C%2841%29%2C%5C%2840%29s%2Bx-b-c*x%5C%2841%29%5D+%5C%2841%29+solve+for+x\n\n // x = supplyValueDelta\n int256 supplyValueDelta = (((r1 * s) - (b * r)) * 1e18) / ((c * r) - (1e18 * r1));\n supplyValueDeltaAbs = uint256((supplyValueDelta < 0) ? -supplyValueDelta : supplyValueDelta);\n }\n\n supplyDelta = (supplyValueDeltaAbs * 1e18) / collateralAssetPrice;\n borrowsDelta = (supplyValueDeltaAbs * 1e18) / borrowedAssetPrice;\n\n if (up) {\n // stables to borrow = c * x\n borrowsDelta = (borrowsDelta * slippageFactor) / 1e18;\n } else {\n // amount to redeem = c * x\n supplyDelta = (supplyDelta * slippageFactor) / 1e18;\n }\n }\n\n /*----------------------------------------------------------------\n Internal Functions\n ----------------------------------------------------------------*/\n\n function _supplyCollateral(IERC20Upgradeable fundingAsset) internal returns (uint256 amountToSupply) {\n // in case the funding is with a different asset\n if (address(collateralAsset) != address(fundingAsset)) {\n // swap for collateral asset\n convertAllTo(fundingAsset, collateralAsset);\n }\n\n // supply the collateral\n amountToSupply = collateralAsset.balanceOf(address(this));\n collateralAsset.approve(address(collateralMarket), amountToSupply);\n uint256 errorCode = collateralMarket.mint(amountToSupply);\n if (errorCode != 0) revert SupplyCollateralFailed(errorCode);\n }\n\n // @dev flash loan the needed amount, then borrow stables and swap them for the amount needed to repay the FL\n function _leverUp(uint256 targetRatio) internal {\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n (uint256 flashLoanCollateralAmount, uint256 stableToBorrow) = _getSupplyAmountDelta(\n true,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n\n collateralMarket.flash(flashLoanCollateralAmount, abi.encode(stableToBorrow));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n\n // all stables are swapped for collateral to repay the FL\n uint256 collateralLeftovers = collateralAsset.balanceOf(address(this));\n if (collateralLeftovers > 0) {\n collateralAsset.approve(address(collateralMarket), collateralLeftovers);\n collateralMarket.mint(collateralLeftovers);\n }\n }\n\n // @dev supply the flash loaned collateral and then borrow stables with it\n function _leverUpPostFL(uint256 stableToBorrow) internal {\n // supply the flash loaned collateral\n _supplyCollateral(collateralAsset);\n\n // borrow stables that will be swapped to repay the FL\n uint256 errorCode = stableMarket.borrow(stableToBorrow);\n if (errorCode != 0) revert BorrowStableFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(stableAsset, collateralAsset);\n }\n\n // @dev redeems the supplied collateral by first repaying the debt with which it was levered\n function _leverDown(uint256 targetRatio) internal {\n uint256 amountToRedeem;\n uint256 borrowsToRepay;\n\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(collateralMarket);\n\n if (targetRatio <= 1e18) {\n // if max levering down, then derive the amount to redeem from the debt to be repaid\n borrowsToRepay = stableMarket.borrowBalanceCurrent(address(this));\n uint256 borrowsToRepayValueScaled = borrowsToRepay * stableAssetPrice;\n // accounting for swaps slippage\n uint256 assumedSlippage = factory.liquidatorsRegistry().getSlippage(collateralAsset, stableAsset);\n uint256 amountToRedeemValueScaled = (borrowsToRepayValueScaled * (10000 + assumedSlippage)) / 10000;\n amountToRedeem = amountToRedeemValueScaled / collateralAssetPrice;\n // round up when dividing in order to redeem enough (otherwise calcs could be exploited)\n if (amountToRedeemValueScaled % collateralAssetPrice > 0) amountToRedeem += 1;\n } else {\n // else derive the debt to be repaid from the amount to redeem\n (amountToRedeem, borrowsToRepay) = _getSupplyAmountDelta(\n false,\n targetRatio,\n collateralAssetPrice,\n stableAssetPrice\n );\n // the slippage is already accounted for in _getSupplyAmountDelta\n }\n\n if (borrowsToRepay > 0) {\n ICErc20(address(stableMarket)).flash(borrowsToRepay, abi.encode(amountToRedeem));\n // the execution will first receive a callback to receiveFlashLoan()\n // then it continues from here\n }\n\n // all the redeemed collateral is swapped for stables to repay the FL\n uint256 stableLeftovers = stableAsset.balanceOf(address(this));\n if (stableLeftovers > 0) {\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n if (borrowBalance > 0) {\n // whatever is smaller\n uint256 amountToRepay = borrowBalance > stableLeftovers ? stableLeftovers : borrowBalance;\n stableAsset.approve(address(stableMarket), amountToRepay);\n stableMarket.repayBorrow(amountToRepay);\n }\n }\n }\n\n function _leverDownPostFL(uint256 _flashLoanedCollateral, uint256 _amountToRedeem) internal {\n // repay the borrows\n uint256 borrowBalance = stableMarket.borrowBalanceCurrent(address(this));\n uint256 repayAmount = _flashLoanedCollateral < borrowBalance ? _flashLoanedCollateral : borrowBalance;\n stableAsset.approve(address(stableMarket), repayAmount);\n uint256 errorCode = stableMarket.repayBorrow(repayAmount);\n if (errorCode != 0) revert RepayBorrowFailed(errorCode);\n\n // redeem the corresponding amount needed to repay the FL\n errorCode = collateralMarket.redeemUnderlying(_amountToRedeem);\n if (errorCode != 0) revert RedeemCollateralFailed(errorCode);\n\n // swap for the FL asset\n convertAllTo(collateralAsset, stableAsset);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n private\n returns (uint256 outputAmount)\n {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = factory\n .getRedemptionStrategies(inputToken, outputToken);\n\n if (redemptionStrategies.length == 0) revert ConvertFundsFailed();\n\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (outputToken, outputAmount) = convertCustomFunds(inputToken, inputAmount, redemptionStrategy, strategyData);\n inputAmount = outputAmount;\n inputToken = outputToken;\n }\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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" + }, + "contracts/ionic/levered/LeveredPositionFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { DiamondBase, DiamondExtension, LibDiamond } from \"../../ionic/DiamondExtension.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactory is LeveredPositionFactoryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /*----------------------------------------------------------------\n Constructor\n ----------------------------------------------------------------*/\n\n constructor(\n IFeeDistributor _feeDistributor,\n ILiquidatorsRegistry _registry,\n uint256 _blocksPerYear\n ) {\n feeDistributor = _feeDistributor;\n liquidatorsRegistry = _registry;\n blocksPerYear = _blocksPerYear;\n }\n\n /*----------------------------------------------------------------\n Admin Functions\n ----------------------------------------------------------------*/\n\n function _setPairWhitelisted(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n bool _whitelisted\n ) external onlyOwner {\n require(_collateralMarket.comptroller() == _stableMarket.comptroller(), \"markets not of the same pool\");\n\n if (_whitelisted) {\n collateralMarkets.add(address(_collateralMarket));\n borrowableMarketsByCollateral[_collateralMarket].add(address(_stableMarket));\n } else {\n borrowableMarketsByCollateral[_collateralMarket].remove(address(_stableMarket));\n if (borrowableMarketsByCollateral[_collateralMarket].length() == 0)\n collateralMarkets.remove(address(_collateralMarket));\n }\n }\n\n function _setLiquidatorsRegistry(ILiquidatorsRegistry _liquidatorsRegistry) external onlyOwner {\n liquidatorsRegistry = _liquidatorsRegistry;\n }\n\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryFirstExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactoryFirstExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactoryFirstExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactoryFirstExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n error NoSuchPosition();\n error PositionNotClosed();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 10;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.removeClosedPosition.selector;\n functionSelectors[--fnsCount] = this.closeAndRemoveUserPosition.selector;\n functionSelectors[--fnsCount] = this.getMinBorrowNative.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getBorrowableMarketsByCollateral.selector;\n functionSelectors[--fnsCount] = this.getWhitelistedCollateralMarkets.selector;\n functionSelectors[--fnsCount] = this.getAccountsWithOpenPositions.selector;\n functionSelectors[--fnsCount] = this.getPositionsByAccount.selector;\n functionSelectors[--fnsCount] = this.getPositionsExtension.selector;\n functionSelectors[--fnsCount] = this._setPositionsExtension.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n // @return true if removed, otherwise false\n function removeClosedPosition(address closedPosition) external returns (bool) {\n return _removeClosedPosition(closedPosition, msg.sender);\n }\n\n function closeAndRemoveUserPosition(LeveredPosition position) external onlyOwner returns (bool) {\n address positionOwner = position.positionOwner();\n position.closePosition(positionOwner);\n return _removeClosedPosition(address(position), positionOwner);\n }\n\n function _removeClosedPosition(address closedPosition, address positionOwner) internal returns (bool removed) {\n EnumerableSet.AddressSet storage userPositions = positionsByAccount[positionOwner];\n if (!userPositions.contains(closedPosition)) revert NoSuchPosition();\n if (!LeveredPosition(closedPosition).isPositionClosed()) revert PositionNotClosed();\n\n removed = userPositions.remove(closedPosition);\n if (userPositions.length() == 0) accountsWithOpenPositions.remove(positionOwner);\n }\n\n function _setPositionsExtension(bytes4 msgSig, address extension) external onlyOwner {\n _positionsExtensions[msgSig] = extension;\n }\n\n /*----------------------------------------------------------------\n View Functions\n ----------------------------------------------------------------*/\n\n function getMinBorrowNative() external view returns (uint256) {\n return feeDistributor.minBorrowEth();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n return liquidatorsRegistry.getRedemptionStrategies(inputToken, outputToken);\n }\n\n function getPositionsByAccount(\n address account\n ) external view returns (address[] memory positions, bool[] memory closed) {\n positions = positionsByAccount[account].values();\n closed = new bool[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n closed[i] = LeveredPosition(positions[i]).isPositionClosed();\n }\n }\n\n function getAccountsWithOpenPositions() external view returns (address[] memory) {\n return accountsWithOpenPositions.values();\n }\n\n function getWhitelistedCollateralMarkets() external view returns (address[] memory) {\n return collateralMarkets.values();\n }\n\n function getBorrowableMarketsByCollateral(ICErc20 _collateralMarket) external view returns (address[] memory) {\n return borrowableMarketsByCollateral[_collateralMarket].values();\n }\n\n function getPositionsExtension(bytes4 msgSig) external view returns (address) {\n return _positionsExtensions[msgSig];\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactorySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport { LeveredPositionFactoryStorage } from \"./LeveredPositionFactoryStorage.sol\";\nimport { ILeveredPositionFactorySecondExtension } from \"./ILeveredPositionFactory.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { IComptroller, IPriceOracle } from \"../../external/compound/IComptroller.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { AuthoritiesRegistry } from \"../AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../PoolRolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract LeveredPositionFactorySecondExtension is\n LeveredPositionFactoryStorage,\n DiamondExtension,\n ILeveredPositionFactorySecondExtension\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n using EnumerableSet for EnumerableSet.AddressSet;\n\n error PairNotWhitelisted();\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 3;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.createPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPosition.selector;\n functionSelectors[--fnsCount] = this.createAndFundPositionAtRatio.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n /*----------------------------------------------------------------\n Mutable Functions\n ----------------------------------------------------------------*/\n\n function createPosition(ICErc20 _collateralMarket, ICErc20 _stableMarket) public returns (LeveredPosition) {\n if (!borrowableMarketsByCollateral[_collateralMarket].contains(address(_stableMarket))) revert PairNotWhitelisted();\n\n LeveredPosition position = new LeveredPosition(msg.sender, _collateralMarket, _stableMarket);\n\n accountsWithOpenPositions.add(msg.sender);\n positionsByAccount[msg.sender].add(address(position));\n\n AuthoritiesRegistry authoritiesRegistry = feeDistributor.authoritiesRegistry();\n address poolAddress = address(_collateralMarket.comptroller());\n PoolRolesAuthority poolAuth = authoritiesRegistry.poolsAuthorities(poolAddress);\n if (address(poolAuth) != address(0)) {\n authoritiesRegistry.setUserRole(poolAddress, address(position), poolAuth.LEVERED_POSITION_ROLE(), true);\n }\n\n return position;\n }\n\n function createAndFundPosition(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount\n ) public returns (LeveredPosition) {\n LeveredPosition position = createPosition(_collateralMarket, _stableMarket);\n _fundingAsset.safeTransferFrom(msg.sender, address(this), _fundingAmount);\n _fundingAsset.approve(address(position), _fundingAmount);\n position.fundPosition(_fundingAsset, _fundingAmount);\n return position;\n }\n\n function createAndFundPositionAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n IERC20Upgradeable _fundingAsset,\n uint256 _fundingAmount,\n uint256 _leverageRatio\n ) external returns (LeveredPosition) {\n LeveredPosition position = createAndFundPosition(_collateralMarket, _stableMarket, _fundingAsset, _fundingAmount);\n if (_leverageRatio > 1e18) {\n position.adjustLeverageRatio(_leverageRatio);\n }\n return position;\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionFactoryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { IFeeDistributor } from \"../../compound/IFeeDistributor.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LeveredPositionFactoryStorage is SafeOwnable {\n EnumerableSet.AddressSet internal accountsWithOpenPositions;\n mapping(address => EnumerableSet.AddressSet) internal positionsByAccount;\n EnumerableSet.AddressSet internal collateralMarkets;\n mapping(ICErc20 => EnumerableSet.AddressSet) internal borrowableMarketsByCollateral;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) private __unused;\n\n IFeeDistributor public feeDistributor;\n ILiquidatorsRegistry public liquidatorsRegistry;\n uint256 public blocksPerYear;\n\n mapping(bytes4 => address) internal _positionsExtensions;\n}\n" + }, + "contracts/ionic/levered/LeveredPositionsLens.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { LeveredPosition } from \"./LeveredPosition.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract LeveredPositionsLens is Initializable {\n ILeveredPositionFactory public factory;\n\n function initialize(ILeveredPositionFactory _factory) external initializer {\n factory = _factory;\n }\n\n function reinitialize(ILeveredPositionFactory _factory) external reinitializer(2) {\n factory = _factory;\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names and symbols of the underlying assets of those collateral markets that are whitelisted\n function getCollateralMarkets()\n external\n view\n returns (\n address[] memory markets,\n IonicComptroller[] memory poolOfMarket,\n address[] memory underlyings,\n uint256[] memory underlyingPrices,\n string[] memory names,\n string[] memory symbols,\n uint8[] memory decimals,\n uint256[] memory totalUnderlyingSupplied,\n uint256[] memory ratesPerBlock\n )\n {\n markets = factory.getWhitelistedCollateralMarkets();\n poolOfMarket = new IonicComptroller[](markets.length);\n underlyings = new address[](markets.length);\n underlyingPrices = new uint256[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n totalUnderlyingSupplied = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n ratesPerBlock = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n poolOfMarket[i] = market.comptroller();\n underlyingPrices[i] = BasePriceOracle(poolOfMarket[i].oracle()).getUnderlyingPrice(market);\n underlyings[i] = market.underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyings[i]);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n decimals[i] = underlying.decimals();\n totalUnderlyingSupplied[i] = market.getTotalUnderlyingSupplied();\n ratesPerBlock[i] = market.supplyRatePerBlock();\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns the Rate for the chosen borrowable at the specified leverage ratio and supply amount\n function getBorrowRateAtRatio(\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _equityAmount,\n uint256 _targetLeverageRatio\n ) external view returns (uint256) {\n IonicComptroller pool = IonicComptroller(_stableMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n uint256 stableAssetPrice = oracle.getUnderlyingPrice(_stableMarket);\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n uint256 borrowAmount = ((_targetLeverageRatio - 1e18) * _equityAmount * collateralAssetPrice) /\n (stableAssetPrice * 1e18);\n return _stableMarket.borrowRatePerBlockAfterBorrow(borrowAmount) * factory.blocksPerYear();\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n /// @dev returns lists of the market addresses, names, symbols and the current Rate for each Borrowable asset\n function getBorrowableMarketsAndRates(ICErc20 _collateralMarket)\n external\n view\n returns (\n address[] memory markets,\n address[] memory underlyings,\n uint256[] memory underlyingsPrices,\n string[] memory names,\n string[] memory symbols,\n uint256[] memory rates,\n uint8[] memory decimals\n )\n {\n markets = factory.getBorrowableMarketsByCollateral(_collateralMarket);\n underlyings = new address[](markets.length);\n names = new string[](markets.length);\n symbols = new string[](markets.length);\n rates = new uint256[](markets.length);\n decimals = new uint8[](markets.length);\n underlyingsPrices = new uint256[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = ICErc20(markets[i]);\n address underlyingAddress = market.underlying();\n underlyings[i] = underlyingAddress;\n ERC20Upgradeable underlying = ERC20Upgradeable(underlyingAddress);\n names[i] = underlying.name();\n symbols[i] = underlying.symbol();\n rates[i] = market.borrowRatePerBlock();\n decimals[i] = underlying.decimals();\n underlyingsPrices[i] = market.comptroller().oracle().getUnderlyingPrice(market);\n }\n }\n\n /// @notice this is a lens fn, it is not intended to be used on-chain\n function getNetAPY(\n uint256 _supplyAPY,\n uint256 _supplyAmount,\n ICErc20 _collateralMarket,\n ICErc20 _stableMarket,\n uint256 _targetLeverageRatio\n ) public view returns (int256 netAPY) {\n if (_supplyAmount == 0 || _targetLeverageRatio <= 1e18) return 0;\n\n IonicComptroller pool = IonicComptroller(_collateralMarket.comptroller());\n BasePriceOracle oracle = pool.oracle();\n // TODO the calcs can be implemented without using collateralAssetPrice\n uint256 collateralAssetPrice = oracle.getUnderlyingPrice(_collateralMarket);\n\n // total collateral = base collateral + levered collateral\n uint256 totalCollateral = (_supplyAmount * _targetLeverageRatio) / 1e18;\n uint256 yieldFromTotalSupplyScaled = _supplyAPY * totalCollateral;\n int256 yieldValueScaled = int256((yieldFromTotalSupplyScaled * collateralAssetPrice) / 1e18);\n\n uint256 borrowedValueScaled = (totalCollateral - _supplyAmount) * collateralAssetPrice;\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n int256 borrowInterestValueScaled = int256((_borrowRate * borrowedValueScaled) / 1e18);\n\n int256 netValueDiffScaled = yieldValueScaled - borrowInterestValueScaled;\n\n netAPY = ((netValueDiffScaled / int256(collateralAssetPrice)) * 1e18) / int256(_supplyAmount);\n }\n\n function getPositionsInfo(LeveredPosition[] calldata positions, uint256[] calldata supplyApys)\n external\n view\n returns (PositionInfo[] memory infos)\n {\n infos = new PositionInfo[](positions.length);\n for (uint256 i = 0; i < positions.length; i++) {\n infos[i] = getPositionInfo(positions[i], supplyApys[i]);\n }\n }\n\n function getLeverageRatioAfterFunding(LeveredPosition pos, uint256 newFunding) public view returns (uint256) {\n uint256 equityAmount = pos.getEquityAmount();\n if (equityAmount == 0 && newFunding == 0) return 0;\n\n uint256 suppliedCollateralCurrent = pos.collateralMarket().balanceOfUnderlying(address(pos));\n return ((suppliedCollateralCurrent + newFunding) * 1e18) / (equityAmount + newFunding);\n }\n\n function getNetApyForPositionAfterFunding(\n LeveredPosition pos,\n uint256 supplyAPY,\n uint256 newFunding\n ) public view returns (int256) {\n return\n getNetAPY(\n supplyAPY,\n pos.getEquityAmount() + newFunding,\n pos.collateralMarket(),\n pos.stableMarket(),\n getLeverageRatioAfterFunding(pos, newFunding)\n );\n }\n\n function getNetApyForPosition(LeveredPosition pos, uint256 supplyAPY) public view returns (int256) {\n return getNetApyForPositionAfterFunding(pos, supplyAPY, 0);\n }\n\n struct PositionInfo {\n uint256 collateralAssetPrice;\n uint256 borrowedAssetPrice;\n uint256 positionSupplyAmount;\n uint256 positionValue;\n uint256 debtAmount;\n uint256 debtValue;\n uint256 equityAmount;\n uint256 equityValue;\n int256 currentApy;\n uint256 debtRatio;\n uint256 liquidationThreshold;\n uint256 safetyBuffer;\n }\n\n function getPositionInfo(LeveredPosition pos, uint256 supplyApy) public view returns (PositionInfo memory info) {\n ICErc20 collateralMarket = pos.collateralMarket();\n IonicComptroller pool = pos.pool();\n info.collateralAssetPrice = pool.oracle().getUnderlyingPrice(collateralMarket);\n {\n info.positionSupplyAmount = collateralMarket.balanceOfUnderlying(address(pos));\n info.positionValue = (info.collateralAssetPrice * info.positionSupplyAmount) / 1e18;\n info.currentApy = getNetApyForPosition(pos, supplyApy);\n }\n\n {\n ICErc20 stableMarket = pos.stableMarket();\n info.borrowedAssetPrice = pool.oracle().getUnderlyingPrice(stableMarket);\n info.debtAmount = stableMarket.borrowBalanceCurrent(address(pos));\n info.debtValue = (info.borrowedAssetPrice * info.debtAmount) / 1e18;\n info.equityValue = info.positionValue - info.debtValue;\n info.debtRatio = info.positionValue == 0 ? 0 : (info.debtValue * 1e18) / info.positionValue;\n info.equityAmount = (info.equityValue * 1e18) / info.collateralAssetPrice;\n }\n\n {\n (, uint256 collateralFactor) = pool.markets(address(collateralMarket));\n info.liquidationThreshold = collateralFactor;\n info.safetyBuffer = collateralFactor - info.debtRatio;\n }\n }\n}\n" + }, + "contracts/ionic/levered/LeveredPositionStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport { ILeveredPositionFactory } from \"./ILeveredPositionFactory.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract LeveredPositionStorage {\n address public immutable positionOwner;\n ILeveredPositionFactory public factory;\n\n ICErc20 public collateralMarket;\n ICErc20 public stableMarket;\n IonicComptroller public pool;\n\n IERC20Upgradeable public collateralAsset;\n IERC20Upgradeable public stableAsset;\n\n constructor(address _positionOwner) {\n positionOwner = _positionOwner;\n }\n}\n" + }, + "contracts/ionic/PoolRolesAuthority.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IonicComptroller, ComptrollerInterface } from \"../compound/ComptrollerInterface.sol\";\nimport { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from \"../compound/CTokenInterfaces.sol\";\n\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\ncontract PoolRolesAuthority is RolesAuthority, Initializable {\n constructor() RolesAuthority(address(0), Authority(address(0))) {\n _disableInitializers();\n }\n\n function initialize(address _owner) public initializer {\n owner = _owner;\n authority = this;\n }\n\n // up to 256 roles\n uint8 public constant REGISTRY_ROLE = 0;\n uint8 public constant SUPPLIER_ROLE = 1;\n uint8 public constant BORROWER_ROLE = 2;\n uint8 public constant LIQUIDATOR_ROLE = 3;\n uint8 public constant LEVERED_POSITION_ROLE = 4;\n\n function configureRegistryCapabilities() external requiresAuth {\n setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolSupplierCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,\n true\n );\n setRoleCapability(\n REGISTRY_ROLE,\n address(this),\n PoolRolesAuthority.configureLeveredPositionCapabilities.selector,\n true\n );\n setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);\n }\n\n function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, true);\n }\n\n function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolSupplierCapabilities(pool, false);\n }\n\n function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {\n setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);\n setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);\n }\n }\n }\n\n function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {\n _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);\n }\n\n function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {\n uint8 fnsCount = 6;\n selectors = new bytes4[](fnsCount);\n selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;\n selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;\n selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;\n\n require(fnsCount == 0, \"use the correct array length\");\n return selectors;\n }\n\n function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {\n setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(role, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n bytes4[] memory selectors = getSupplierMarketSelectors();\n for (uint256 j = 0; j < selectors.length; j++) {\n setRoleCapability(role, address(allMarkets[i]), selectors[j], true);\n }\n }\n }\n\n function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, true);\n }\n\n function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n _setPublicPoolBorrowerCapabilities(pool, false);\n }\n\n function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);\n setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);\n }\n }\n\n function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {\n // borrowers have the SUPPLIER_ROLE capabilities by default\n _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);\n setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n\n function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);\n // TODO this leaves redeeming open for everyone\n setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n }\n }\n\n function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);\n ICErc20[] memory allMarkets = pool.getAllMarkets();\n for (uint256 i = 0; i < allMarkets.length; i++) {\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);\n\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);\n setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);\n }\n }\n}\n" + }, + "contracts/ionic/SafeOwnable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\nabstract contract SafeOwnable is Ownable2Step {\n function renounceOwnership() public override onlyOwner {\n revert(\"renounce ownership not allowed\");\n }\n}\n" + }, + "contracts/ionic/SafeOwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\n/**\n * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.\n * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable\n * that will shift the other.\n */\nabstract contract SafeOwnableUpgradeable is OwnableUpgradeable {\n /**\n * @notice Pending owner of this contract\n */\n address public pendingOwner;\n\n function __SafeOwnable_init(address owner_) internal onlyInitializing {\n __Ownable_init();\n _transferOwnership(owner_);\n }\n\n struct AddressSlot {\n address value;\n }\n\n modifier onlyOwnerOrAdmin() {\n bool isOwner = owner() == _msgSender();\n if (!isOwner) {\n address admin = _getProxyAdmin();\n bool isAdmin = admin == _msgSender();\n require(isAdmin, \"Ownable: caller is neither the owner nor the admin\");\n }\n _;\n }\n\n /**\n * @notice Emitted when pendingOwner is changed\n */\n event NewPendingOwner(address oldPendingOwner, address newPendingOwner);\n\n /**\n * @notice Emitted when pendingOwner is accepted, which means owner is updated\n */\n event NewOwner(address oldOwner, address newOwner);\n\n /**\n * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.\n * @param newPendingOwner New pending owner.\n */\n function _setPendingOwner(address newPendingOwner) public onlyOwner {\n // Save current value, if any, for inclusion in log\n address oldPendingOwner = pendingOwner;\n\n // Store pendingOwner with value newPendingOwner\n pendingOwner = newPendingOwner;\n\n // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)\n emit NewPendingOwner(oldPendingOwner, newPendingOwner);\n }\n\n /**\n * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner\n * @dev Owner function for pending owner to accept role and update owner\n */\n function _acceptOwner() public {\n // Check caller is pendingOwner and pendingOwner ≠ address(0)\n require(msg.sender == pendingOwner, \"not the pending owner\");\n\n // Save current values for inclusion in log\n address oldOwner = owner();\n address oldPendingOwner = pendingOwner;\n\n // Store owner with value pendingOwner\n _transferOwnership(pendingOwner);\n\n // Clear the pending value\n pendingOwner = address(0);\n\n emit NewOwner(oldOwner, pendingOwner);\n emit NewPendingOwner(oldPendingOwner, pendingOwner);\n }\n\n function renounceOwnership() public override onlyOwner {\n // do not remove this overriding fn\n revert(\"not used anymore\");\n }\n\n function transferOwnership(address newOwner) public override onlyOwner {\n emit NewPendingOwner(pendingOwner, newOwner);\n pendingOwner = newOwner;\n }\n\n function _getProxyAdmin() internal view returns (address admin) {\n bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n AddressSlot storage adminSlot;\n assembly {\n adminSlot.slot := _ADMIN_SLOT\n }\n admin = adminSlot.value;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IFlywheelBooster.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/**\n @title Balance Booster Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Booster module is an optional module for virtually boosting or otherwise transforming user balances. \n If a booster is not configured, the strategies ERC-20 balanceOf/totalSupply will be used instead.\n \n Boosting logic can be associated with referrals, vote-escrow, or other strategies.\n\n SECURITY NOTE: similar to how Core needs to be notified any time the strategy user composition changes, the booster would need to be notified of any conditions which change the boosted balances atomically.\n This prevents gaming of the reward calculation function by using manipulated balances when accruing.\n*/\ninterface IFlywheelBooster {\n /**\n @notice calculate the boosted supply of a strategy.\n @param strategy the strategy to calculate boosted supply of\n @return the boosted supply\n */\n function boostedTotalSupply(ERC20 strategy) external view returns (uint256);\n\n /**\n @notice calculate the boosted balance of a user in a given strategy.\n @param strategy the strategy to calculate boosted balance of\n @param user the user to calculate boosted balance of\n @return the boosted balance\n */\n function boostedBalanceOf(ERC20 strategy, address user) external view returns (uint256);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IIonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ninterface IIonicFlywheel {\n function isRewardsDistributor() external returns (bool);\n\n function isFlywheel() external returns (bool);\n\n function flywheelPreSupplierAction(address market, address supplier) external;\n\n function flywheelPreBorrowerAction(address market, address borrower) external;\n\n function flywheelPreTransferAction(address market, address src, address dst) external;\n\n function compAccrued(address user) external view returns (uint256);\n\n function addMarketForRewards(ERC20 strategy) external;\n\n function marketState(ERC20 strategy) external view returns (uint224 index, uint32 lastUpdatedTimestamp);\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheel.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport \"./IIonicFlywheel.sol\";\n\ncontract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {\n bool public constant isRewardsDistributor = true;\n bool public constant isFlywheel = true;\n\n function flywheelPreSupplierAction(address market, address supplier) external {\n accrue(ERC20(market), supplier);\n }\n\n function flywheelPreBorrowerAction(address market, address borrower) external {}\n\n function flywheelPreTransferAction(address market, address src, address dst) external {\n accrue(ERC20(market), src, dst);\n }\n\n function compAccrued(address user) external view returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function addMarketForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n // TODO remove\n function marketState(ERC20 strategy) external view returns (uint224, uint32) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelCore.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\nimport { SafeCastLib } from \"solmate/utils/SafeCastLib.sol\";\n\nimport { IFlywheelRewards } from \"./rewards/IFlywheelRewards.sol\";\nimport { IFlywheelBooster } from \"./IFlywheelBooster.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../../ionic/SafeOwnableUpgradeable.sol\";\n\ncontract IonicFlywheelCore is SafeOwnableUpgradeable {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n /// @notice How much rewardsToken will be send to treasury\n uint256 public performanceFee;\n\n /// @notice Address that gets rewardsToken accrued by performanceFee\n address public feeRecipient;\n\n /// @notice The token to reward\n ERC20 public rewardToken;\n\n /// @notice append-only list of strategies added\n ERC20[] public allStrategies;\n\n /// @notice the rewards contract for managing streams\n IFlywheelRewards public flywheelRewards;\n\n /// @notice optional booster module for calculating virtual balances on strategies\n IFlywheelBooster public flywheelBooster;\n\n /// @notice The accrued but not yet transferred rewards for each user\n mapping(address => uint256) internal _rewardsAccrued;\n\n /// @notice The strategy index and last updated per strategy\n mapping(ERC20 => RewardsState) internal _strategyState;\n\n /// @notice user index per strategy\n mapping(ERC20 => mapping(address => uint224)) internal _userIndex;\n\n constructor() {\n // prevents the misusage of the implementation contract\n _disableInitializers();\n }\n\n function initialize(\n ERC20 _rewardToken,\n IFlywheelRewards _flywheelRewards,\n IFlywheelBooster _flywheelBooster,\n address _owner\n ) public initializer {\n __SafeOwnable_init(msg.sender);\n\n rewardToken = _rewardToken;\n flywheelRewards = _flywheelRewards;\n flywheelBooster = _flywheelBooster;\n\n _transferOwnership(_owner);\n\n performanceFee = 10e16; // 10%\n feeRecipient = _owner;\n }\n\n /*----------------------------------------------------------------\n ACCRUE/CLAIM LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a user's rewards accrue to a given strategy.\n @param strategy the updated rewards strategy\n @param user the user of the rewards\n @param rewardsDelta how many new rewards accrued to the user\n @param rewardsIndex the market index for rewards per token accrued\n */\n event AccrueRewards(ERC20 indexed strategy, address indexed user, uint256 rewardsDelta, uint256 rewardsIndex);\n\n /** \n @notice Emitted when a user claims accrued rewards.\n @param user the user of the rewards\n @param amount the amount of rewards claimed\n */\n event ClaimRewards(address indexed user, uint256 amount);\n\n /** \n @notice accrue rewards for a single user on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the user to be accrued\n @return the cumulative amount of rewards accrued to user (including prior)\n */\n function accrue(ERC20 strategy, address user) public returns (uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return 0;\n\n state = accrueStrategy(strategy, state);\n return accrueUser(strategy, user, state);\n }\n\n /** \n @notice accrue rewards for a two users on a strategy\n @param strategy the strategy to accrue a user's rewards on\n @param user the first user to be accrued\n @param user the second user to be accrued\n @return the cumulative amount of rewards accrued to the first user (including prior)\n @return the cumulative amount of rewards accrued to the second user (including prior)\n */\n function accrue(\n ERC20 strategy,\n address user,\n address secondUser\n ) public returns (uint256, uint256) {\n (uint224 index, uint32 ts) = strategyState(strategy);\n RewardsState memory state = RewardsState(index, ts);\n\n if (state.index == 0) return (0, 0);\n\n state = accrueStrategy(strategy, state);\n return (accrueUser(strategy, user, state), accrueUser(strategy, secondUser, state));\n }\n\n /** \n @notice claim rewards for a given user\n @param user the user claiming rewards\n @dev this function is public, and all rewards transfer to the user\n */\n function claimRewards(address user) external {\n uint256 accrued = rewardsAccrued(user);\n\n if (accrued != 0) {\n _rewardsAccrued[user] = 0;\n\n rewardToken.safeTransferFrom(address(flywheelRewards), user, accrued);\n\n emit ClaimRewards(user, accrued);\n }\n }\n\n /*----------------------------------------------------------------\n ADMIN LOGIC\n ----------------------------------------------------------------*/\n\n /** \n @notice Emitted when a new strategy is added to flywheel by the admin\n @param newStrategy the new added strategy\n */\n event AddStrategy(address indexed newStrategy);\n\n /// @notice initialize a new strategy\n function addStrategyForRewards(ERC20 strategy) external onlyOwner {\n _addStrategyForRewards(strategy);\n }\n\n function _addStrategyForRewards(ERC20 strategy) internal {\n (uint224 index, ) = strategyState(strategy);\n require(index == 0, \"strategy\");\n _strategyState[strategy] = RewardsState({\n index: (10**rewardToken.decimals()).safeCastTo224(),\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n\n allStrategies.push(strategy);\n emit AddStrategy(address(strategy));\n }\n\n function getAllStrategies() external view returns (ERC20[] memory) {\n return allStrategies;\n }\n\n /** \n @notice Emitted when the rewards module changes\n @param newFlywheelRewards the new rewards module\n */\n event FlywheelRewardsUpdate(address indexed newFlywheelRewards);\n\n /// @notice swap out the flywheel rewards contract\n function setFlywheelRewards(IFlywheelRewards newFlywheelRewards) external onlyOwner {\n if (address(flywheelRewards) != address(0)) {\n uint256 oldRewardBalance = rewardToken.balanceOf(address(flywheelRewards));\n if (oldRewardBalance > 0) {\n rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance);\n }\n }\n\n flywheelRewards = newFlywheelRewards;\n\n emit FlywheelRewardsUpdate(address(newFlywheelRewards));\n }\n\n /** \n @notice Emitted when the booster module changes\n @param newBooster the new booster module\n */\n event FlywheelBoosterUpdate(address indexed newBooster);\n\n /// @notice swap out the flywheel booster contract\n function setBooster(IFlywheelBooster newBooster) external onlyOwner {\n flywheelBooster = newBooster;\n\n emit FlywheelBoosterUpdate(address(newBooster));\n }\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n * @dev Claim rewards first from the previous feeRecipient before changing it\n */\n function updateFeeSettings(uint256 _performanceFee, address _feeRecipient) external onlyOwner {\n _updateFeeSettings(_performanceFee, _feeRecipient);\n }\n\n function _updateFeeSettings(uint256 _performanceFee, address _feeRecipient) internal {\n emit UpdatedFeeSettings(performanceFee, _performanceFee, feeRecipient, _feeRecipient);\n\n if (feeRecipient != _feeRecipient) {\n _rewardsAccrued[_feeRecipient] += rewardsAccrued(feeRecipient);\n _rewardsAccrued[feeRecipient] = 0;\n }\n performanceFee = _performanceFee;\n feeRecipient = _feeRecipient;\n }\n\n /*----------------------------------------------------------------\n INTERNAL ACCOUNTING LOGIC\n ----------------------------------------------------------------*/\n\n struct RewardsState {\n /// @notice The strategy's last updated index\n uint224 index;\n /// @notice The timestamp the index was last updated at\n uint32 lastUpdatedTimestamp;\n }\n\n /// @notice accumulate global rewards on a strategy\n function accrueStrategy(ERC20 strategy, RewardsState memory state)\n private\n returns (RewardsState memory rewardsState)\n {\n // calculate accrued rewards through module\n uint256 strategyRewardsAccrued = flywheelRewards.getAccruedRewards(strategy, state.lastUpdatedTimestamp);\n\n rewardsState = state;\n\n if (strategyRewardsAccrued > 0) {\n // use the booster or token supply to calculate reward index denominator\n uint256 supplyTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedTotalSupply(strategy)\n : strategy.totalSupply();\n\n // 100% = 100e16\n uint256 accruedFees = (strategyRewardsAccrued * performanceFee) / uint224(100e16);\n\n _rewardsAccrued[feeRecipient] += accruedFees;\n strategyRewardsAccrued -= accruedFees;\n\n uint224 deltaIndex;\n\n if (supplyTokens != 0)\n deltaIndex = ((strategyRewardsAccrued * (10**strategy.decimals())) / supplyTokens).safeCastTo224();\n\n // accumulate rewards per token onto the index, multiplied by fixed-point factor\n rewardsState = RewardsState({\n index: state.index + deltaIndex,\n lastUpdatedTimestamp: block.timestamp.safeCastTo32()\n });\n _strategyState[strategy] = rewardsState;\n }\n }\n\n /// @notice accumulate rewards on a strategy for a specific user\n function accrueUser(\n ERC20 strategy,\n address user,\n RewardsState memory state\n ) private returns (uint256) {\n // load indices\n uint224 strategyIndex = state.index;\n uint224 supplierIndex = userIndex(strategy, user);\n\n // sync user index to global\n _userIndex[strategy][user] = strategyIndex;\n\n // if user hasn't yet accrued rewards, grant them interest from the strategy beginning if they have a balance\n // zero balances will have no effect other than syncing to global index\n if (supplierIndex == 0) {\n supplierIndex = (10**rewardToken.decimals()).safeCastTo224();\n }\n\n uint224 deltaIndex = strategyIndex - supplierIndex;\n // use the booster or token balance to calculate reward balance multiplier\n uint256 supplierTokens = address(flywheelBooster) != address(0)\n ? flywheelBooster.boostedBalanceOf(strategy, user)\n : strategy.balanceOf(user);\n\n // accumulate rewards by multiplying user tokens by rewardsPerToken index and adding on unclaimed\n uint256 supplierDelta = (deltaIndex * supplierTokens) / (10**strategy.decimals());\n uint256 supplierAccrued = rewardsAccrued(user) + supplierDelta;\n\n _rewardsAccrued[user] = supplierAccrued;\n\n emit AccrueRewards(strategy, user, supplierDelta, strategyIndex);\n\n return supplierAccrued;\n }\n\n function rewardsAccrued(address user) public virtual returns (uint256) {\n return _rewardsAccrued[user];\n }\n\n function userIndex(ERC20 strategy, address user) public virtual returns (uint224) {\n return _userIndex[strategy][user];\n }\n\n function strategyState(ERC20 strategy) public virtual returns (uint224 index, uint32 lastUpdatedTimestamp) {\n return (_strategyState[strategy].index, _strategyState[strategy].lastUpdatedTimestamp);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { IonicFlywheelCore } from \"./IonicFlywheelCore.sol\";\nimport { IonicComptroller } from \"../../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../../compound/CTokenInterfaces.sol\";\nimport { BasePriceOracle } from \"../../../oracles/BasePriceOracle.sol\";\nimport { PoolDirectory } from \"../../../PoolDirectory.sol\";\n\ninterface IPriceOracle_IFLR {\n function getUnderlyingPrice(ERC20 cToken) external view returns (uint256);\n\n function price(address underlying) external view returns (uint256);\n}\n\ncontract IonicFlywheelLensRouter {\n PoolDirectory public fpd;\n\n constructor(PoolDirectory _fpd) {\n fpd = _fpd;\n }\n\n struct MarketRewardsInfo {\n /// @dev comptroller oracle price of market underlying\n uint256 underlyingPrice;\n ICErc20 market;\n RewardsInfo[] rewardsInfo;\n }\n\n struct RewardsInfo {\n /// @dev rewards in `rewardToken` paid per underlying staked token in `market` per second\n uint256 rewardSpeedPerSecondPerToken;\n /// @dev comptroller oracle price of reward token\n uint256 rewardTokenPrice;\n /// @dev APR scaled by 1e18. Calculated as rewardSpeedPerSecondPerToken * rewardTokenPrice * 365.25 days / underlyingPrice * 1e18 / market.exchangeRate\n uint256 formattedAPR;\n address flywheel;\n address rewardToken;\n }\n\n function getPoolMarketRewardsInfo(IonicComptroller comptroller) external returns (MarketRewardsInfo[] memory) {\n ICErc20[] memory markets = comptroller.getAllMarkets();\n return _getMarketRewardsInfo(markets, comptroller);\n }\n\n function getMarketRewardsInfo(ICErc20[] memory markets) external returns (MarketRewardsInfo[] memory) {\n IonicComptroller pool;\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 asMarket = ICErc20(address(markets[i]));\n if (address(pool) == address(0)) pool = asMarket.comptroller();\n else require(asMarket.comptroller() == pool);\n }\n return _getMarketRewardsInfo(markets, pool);\n }\n\n function _getMarketRewardsInfo(ICErc20[] memory markets, IonicComptroller comptroller)\n internal\n returns (MarketRewardsInfo[] memory)\n {\n if (address(comptroller) == address(0) || markets.length == 0) return new MarketRewardsInfo[](0);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n address[] memory rewardTokens = new address[](flywheels.length);\n uint256[] memory rewardTokenPrices = new uint256[](flywheels.length);\n uint256[] memory rewardTokenDecimals = new uint256[](flywheels.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n MarketRewardsInfo[] memory infoList = new MarketRewardsInfo[](markets.length);\n for (uint256 i = 0; i < markets.length; i++) {\n RewardsInfo[] memory rewardsInfo = new RewardsInfo[](flywheels.length);\n\n ICErc20 market = ICErc20(address(markets[i]));\n uint256 price = oracle.price(market.underlying()); // scaled to 1e18\n\n if (i == 0) {\n for (uint256 j = 0; j < flywheels.length; j++) {\n ERC20 rewardToken = IonicFlywheelCore(flywheels[j]).rewardToken();\n rewardTokens[j] = address(rewardToken);\n rewardTokenPrices[j] = oracle.price(address(rewardToken)); // scaled to 1e18\n rewardTokenDecimals[j] = uint256(rewardToken.decimals());\n }\n }\n\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n rewardTokenDecimals[j]\n );\n uint256 apr = getApr(\n rewardSpeedPerSecondPerToken,\n rewardTokenPrices[j],\n price, \n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n rewardsInfo[j] = RewardsInfo({\n rewardSpeedPerSecondPerToken: rewardSpeedPerSecondPerToken, // scaled in 1e18\n rewardTokenPrice: rewardTokenPrices[j],\n formattedAPR: apr, // scaled in 1e18\n flywheel: address(flywheel),\n rewardToken: rewardTokens[j]\n });\n }\n\n infoList[i] = MarketRewardsInfo({ market: market, rewardsInfo: rewardsInfo, underlyingPrice: price });\n }\n\n return infoList;\n }\n\n function scaleIndexDiff(uint256 indexDiff, uint256 decimals) internal pure returns (uint256) {\n return decimals <= 18 ? uint256(indexDiff) * (10**(18 - decimals)) : uint256(indexDiff) / (10**(decimals - 18));\n }\n\n function getRewardSpeedPerSecondPerToken(\n IonicFlywheelCore flywheel,\n ICErc20 market,\n uint256 decimals\n ) internal returns (uint256 rewardSpeedPerSecondPerToken) {\n ERC20 strategy = ERC20(address(market));\n (uint224 indexBefore, uint32 lastUpdatedTimestampBefore) = flywheel.strategyState(strategy);\n flywheel.accrue(strategy, address(0));\n (uint224 indexAfter, uint32 lastUpdatedTimestampAfter) = flywheel.strategyState(strategy);\n if (lastUpdatedTimestampAfter > lastUpdatedTimestampBefore) {\n rewardSpeedPerSecondPerToken =\n scaleIndexDiff((indexAfter - indexBefore), decimals) /\n (lastUpdatedTimestampAfter - lastUpdatedTimestampBefore);\n }\n }\n\n function getApr(\n uint256 rewardSpeedPerSecondPerToken,\n uint256 rewardTokenPrice,\n uint256 underlyingPrice,\n uint256 exchangeRate,\n bool isBorrow\n ) internal pure returns (uint256) {\n if (rewardSpeedPerSecondPerToken == 0) return 0;\n uint256 nativeSpeedPerSecondPerCToken = rewardSpeedPerSecondPerToken * rewardTokenPrice; // scaled to 1e36\n uint256 nativeSpeedPerYearPerCToken = nativeSpeedPerSecondPerCToken * 365.25 days; // scaled to 1e36\n uint256 assetSpeedPerYearPerCToken = nativeSpeedPerYearPerCToken / underlyingPrice; // scaled to 1e18\n uint256 assetSpeedPerYearPerCTokenScaled = assetSpeedPerYearPerCToken * 1e18; // scaled to 1e36\n uint256 apr = assetSpeedPerYearPerCTokenScaled;\n if (!isBorrow) {\n // if not borrowing, use exchange rate to scale\n apr = assetSpeedPerYearPerCTokenScaled / exchangeRate; // scaled to 1e18\n } else {\n apr = assetSpeedPerYearPerCTokenScaled / 1e18; // scaled to 1e18\n }\n return apr;\n }\n\n function getRewardsAprForMarket(ICErc20 market) internal returns (int256 totalMarketRewardsApr) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 underlyingPrice = oracle.getUnderlyingPrice(market);\n\n address[] memory flywheels = comptroller.getAccruingFlywheels();\n for (uint256 j = 0; j < flywheels.length; j++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheels[j]);\n ERC20 rewardToken = flywheel.rewardToken();\n\n uint256 rewardSpeedPerSecondPerToken = getRewardSpeedPerSecondPerToken(\n flywheel,\n market,\n uint256(rewardToken.decimals())\n );\n\n uint256 marketApr = getApr(\n rewardSpeedPerSecondPerToken,\n oracle.price(address(rewardToken)),\n underlyingPrice,\n market.exchangeRateCurrent(),\n address(flywheel.flywheelBooster()) != address(0)\n );\n\n totalMarketRewardsApr += int256(marketApr);\n }\n }\n\n function getUserNetValueDeltaForMarket(\n address user,\n ICErc20 market,\n int256 offchainApr,\n int256 blocksPerYear\n ) internal returns (int256) {\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n int256 netApr = getRewardsAprForMarket(market) +\n getUserInterestAprForMarket(user, market, blocksPerYear) +\n offchainApr;\n return (netApr * int256(market.balanceOfUnderlying(user)) * int256(oracle.getUnderlyingPrice(market))) / 1e36;\n }\n\n function getUserInterestAprForMarket(\n address user,\n ICErc20 market,\n int256 blocksPerYear\n ) internal returns (int256) {\n uint256 borrows = market.borrowBalanceCurrent(user);\n uint256 supplied = market.balanceOfUnderlying(user);\n uint256 supplyRatePerBlock = market.supplyRatePerBlock();\n uint256 borrowRatePerBlock = market.borrowRatePerBlock();\n\n IonicComptroller comptroller = market.comptroller();\n BasePriceOracle oracle = comptroller.oracle();\n uint256 assetPrice = oracle.getUnderlyingPrice(market);\n uint256 collateralValue = (supplied * assetPrice) / 1e18;\n uint256 borrowsValue = (borrows * assetPrice) / 1e18;\n\n uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;\n uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;\n\n if (collateralValue == 0) return 0;\n return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);\n }\n\n struct AdjustedUserNetAprVars {\n int256 userNetAssetsValue;\n int256 userNetValueDelta;\n BasePriceOracle oracle;\n ICErc20[] markets;\n IonicComptroller pool;\n }\n\n function getAdjustedUserNetApr(\n address user,\n int256 blocksPerYear,\n address[] memory offchainRewardsAprMarkets,\n int256[] memory offchainRewardsAprs\n ) public returns (int256) {\n AdjustedUserNetAprVars memory vars;\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n vars.oracle = pool.oracle();\n vars.markets = pool.getAllMarkets();\n for (uint256 j = 0; j < vars.markets.length; j++) {\n int256 offchainRewardsApr = 0;\n for (uint256 k = 0; k < offchainRewardsAprMarkets.length; k++) {\n if (offchainRewardsAprMarkets[k] == address(vars.markets[j])) offchainRewardsApr = offchainRewardsAprs[k];\n }\n vars.userNetAssetsValue +=\n int256(vars.markets[j].balanceOfUnderlying(user) * vars.oracle.getUnderlyingPrice(vars.markets[j])) /\n 1e18;\n vars.userNetValueDelta += getUserNetValueDeltaForMarket(\n user,\n vars.markets[j],\n offchainRewardsApr,\n blocksPerYear\n );\n }\n }\n\n if (vars.userNetAssetsValue == 0) return 0;\n else return (vars.userNetValueDelta * 1e18) / vars.userNetAssetsValue;\n }\n\n function getUserNetApr(address user, int256 blocksPerYear) external returns (int256) {\n address[] memory emptyAddrArray = new address[](0);\n int256[] memory emptyIntArray = new int256[](0);\n return getAdjustedUserNetApr(user, blocksPerYear, emptyAddrArray, emptyIntArray);\n }\n\n function getAllRewardTokens() public view returns (address[] memory uniqueRewardTokens) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n uint256 rewardTokensCounter;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n rewardTokensCounter += fws.length;\n }\n\n address[] memory rewardTokens = new address[](rewardTokensCounter);\n\n uint256 uniqueRewardTokensCounter = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address[] memory fws = pool.getRewardsDistributors();\n\n for (uint256 j = 0; j < fws.length; j++) {\n address rwToken = address(IonicFlywheelCore(fws[j]).rewardToken());\n if (rwToken == address(0)) break;\n\n bool added;\n for (uint256 k = 0; k < rewardTokens.length; k++) {\n if (rwToken == rewardTokens[k]) {\n added = true;\n break;\n }\n }\n if (!added) rewardTokens[uniqueRewardTokensCounter++] = rwToken;\n }\n }\n\n uniqueRewardTokens = new address[](uniqueRewardTokensCounter);\n for (uint256 i = 0; i < uniqueRewardTokensCounter; i++) {\n uniqueRewardTokens[i] = rewardTokens[i];\n }\n }\n\n function claimAllRewardTokens(address user) external returns (address[] memory, uint256[] memory) {\n address[] memory rewardTokens = getAllRewardTokens();\n uint256[] memory rewardsClaimedForToken = new uint256[](rewardTokens.length);\n\n for (uint256 i = 0; i < rewardTokens.length; i++) {\n rewardsClaimedForToken[i] = claimRewardsOfRewardToken(user, rewardTokens[i]);\n }\n\n return (rewardTokens, rewardsClaimedForToken);\n }\n\n function claimRewardsOfRewardToken(address user, address rewardToken) public returns (uint256 rewardsClaimed) {\n uint256 balanceBefore = ERC20(rewardToken).balanceOf(user);\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ERC20[] memory markets;\n {\n ICErc20[] memory cerc20s = pool.getAllMarkets();\n markets = new ERC20[](cerc20s.length);\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n }\n\n address[] memory flywheelAddresses = pool.getAccruingFlywheels();\n for (uint256 k = 0; k < flywheelAddresses.length; k++) {\n IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);\n if (address(flywheel.rewardToken()) == rewardToken) {\n for (uint256 m = 0; m < markets.length; m++) {\n flywheel.accrue(markets[m], user);\n }\n flywheel.claimRewards(user);\n }\n }\n }\n\n uint256 balanceAfter = ERC20(rewardToken).balanceOf(user);\n return balanceAfter - balanceBefore;\n }\n\n function claimRewardsForMarket(\n address user,\n ERC20 market,\n IonicFlywheelCore[] calldata flywheels,\n bool[] calldata accrue\n )\n external\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n uint256 size = flywheels.length;\n rewards = new uint256[](size);\n rewardTokens = new address[](size);\n\n for (uint256 i = 0; i < size; i++) {\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n\n function claimRewardsForPool(address user, IonicComptroller comptroller)\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory,\n uint256[] memory\n )\n {\n ICErc20[] memory cerc20s = comptroller.getAllMarkets();\n ERC20[] memory markets = new ERC20[](cerc20s.length);\n address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();\n IonicFlywheelCore[] memory flywheels = new IonicFlywheelCore[](flywheelAddresses.length);\n bool[] memory accrue = new bool[](flywheelAddresses.length);\n\n for (uint256 j = 0; j < flywheelAddresses.length; j++) {\n flywheels[j] = IonicFlywheelCore(flywheelAddresses[j]);\n accrue[j] = true;\n }\n\n for (uint256 j = 0; j < cerc20s.length; j++) {\n markets[j] = ERC20(address(cerc20s[j]));\n }\n\n return claimRewardsForMarkets(user, markets, flywheels, accrue);\n }\n\n function claimRewardsForMarkets(\n address user,\n ERC20[] memory markets,\n IonicFlywheelCore[] memory flywheels,\n bool[] memory accrue\n )\n public\n returns (\n IonicFlywheelCore[] memory,\n address[] memory rewardTokens,\n uint256[] memory rewards\n )\n {\n rewards = new uint256[](flywheels.length);\n rewardTokens = new address[](flywheels.length);\n\n for (uint256 i = 0; i < flywheels.length; i++) {\n for (uint256 j = 0; j < markets.length; j++) {\n ERC20 market = markets[j];\n\n uint256 newRewards;\n if (accrue[i]) {\n newRewards = flywheels[i].accrue(market, user);\n } else {\n newRewards = flywheels[i].rewardsAccrued(user);\n }\n\n // Take the max, because rewards are cumulative.\n rewards[i] = rewards[i] >= newRewards ? rewards[i] : newRewards;\n }\n\n flywheels[i].claimRewards(user);\n rewardTokens[i] = address(flywheels[i].rewardToken());\n }\n\n return (flywheels, rewardTokens, rewards);\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/BaseFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IFlywheelRewards} from \"./IFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Reward Module\n @notice Determines how many rewards accrue to each strategy globally over a given time period.\n @dev approves the flywheel core for the reward token to allow balances to be managed by the module but claimed from core.\n*/\nabstract contract BaseFlywheelRewards is IFlywheelRewards {\n using SafeTransferLib for ERC20;\n\n /// @notice thrown when caller is not the flywheel\n error FlywheelError();\n\n /// @notice the reward token paid\n ERC20 public immutable override rewardToken;\n\n /// @notice the flywheel core contract\n IonicFlywheelCore public immutable override flywheel;\n\n constructor(IonicFlywheelCore _flywheel) {\n flywheel = _flywheel;\n ERC20 _rewardToken = _flywheel.rewardToken();\n rewardToken = _rewardToken;\n\n _rewardToken.safeApprove(address(_flywheel), type(uint256).max);\n }\n\n modifier onlyFlywheel() {\n if (msg.sender != address(flywheel)) revert FlywheelError();\n _;\n }\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelDynamicRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\nimport {SafeTransferLib, ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {SafeCastLib} from \"solmate/utils/SafeCastLib.sol\";\n\n/** \n @title Flywheel Dynamic Reward Stream\n @notice Determines rewards based on a dynamic reward stream.\n Rewards are transferred linearly over a \"rewards cycle\" to prevent gaming the reward distribution. \n The reward source can be arbitrary logic, but most common is to \"pass through\" rewards from some other source.\n The getNextCycleRewards() hook should also transfer the next cycle's rewards to this contract to ensure proper accounting.\n*/\nabstract contract FlywheelDynamicRewards is BaseFlywheelRewards {\n using SafeTransferLib for ERC20;\n using SafeCastLib for uint256;\n\n event NewRewardsCycle(uint32 indexed start, uint32 indexed end, uint192 reward);\n\n /// @notice the length of a rewards cycle\n uint32 public immutable rewardsCycleLength;\n\n struct RewardsCycle {\n uint32 start;\n uint32 end;\n uint192 reward;\n }\n\n mapping(ERC20 => RewardsCycle) public rewardsCycle;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _rewardsCycleLength) BaseFlywheelRewards(_flywheel) {\n rewardsCycleLength = _rewardsCycleLength;\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsCycle memory cycle = rewardsCycle[strategy];\n\n uint32 timestamp = block.timestamp.safeCastTo32();\n\n uint32 latest = timestamp >= cycle.end ? cycle.end : timestamp;\n uint32 earliest = lastUpdatedTimestamp <= cycle.start ? cycle.start : lastUpdatedTimestamp;\n if (cycle.end != 0) {\n amount = (cycle.reward * (latest - earliest)) / (cycle.end - cycle.start);\n assert(amount <= cycle.reward); // should never happen because latest <= cycle.end and earliest >= cycle.start\n }\n // if cycle has ended, reset cycle and transfer all available\n if (timestamp >= cycle.end) {\n uint32 end = ((timestamp + rewardsCycleLength) / rewardsCycleLength) * rewardsCycleLength;\n uint192 rewards = getNextCycleRewards(strategy);\n\n // reset for next cycle\n rewardsCycle[strategy] = RewardsCycle({start: timestamp, end: end, reward: rewards});\n\n emit NewRewardsCycle(timestamp, end, rewards);\n }\n }\n\n function getNextCycleRewards(ERC20 strategy) internal virtual returns (uint192);\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {Auth, Authority} from \"solmate/auth/Auth.sol\";\nimport {BaseFlywheelRewards} from \"./BaseFlywheelRewards.sol\";\nimport {ERC20} from \"solmate/utils/SafeTransferLib.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/** \n @title Flywheel Static Reward Stream\n @notice Determines rewards per strategy based on a fixed reward rate per second\n*/\ncontract FlywheelStaticRewards is Auth, BaseFlywheelRewards {\n event RewardsInfoUpdate(ERC20 indexed strategy, uint224 rewardsPerSecond, uint32 rewardsEndTimestamp);\n\n struct RewardsInfo {\n /// @notice Rewards per second\n uint224 rewardsPerSecond;\n /// @notice The timestamp the rewards end at\n /// @dev use 0 to specify no end\n uint32 rewardsEndTimestamp;\n }\n\n /// @notice rewards info per strategy\n mapping(ERC20 => RewardsInfo) public rewardsInfo;\n\n constructor(\n IonicFlywheelCore _flywheel,\n address _owner,\n Authority _authority\n ) Auth(_owner, _authority) BaseFlywheelRewards(_flywheel) {}\n\n /**\n @notice set rewards per second and rewards end time for Fei Rewards\n @param strategy the strategy to accrue rewards for\n @param rewards the rewards info for the strategy\n */\n function setRewardsInfo(ERC20 strategy, RewardsInfo calldata rewards) external requiresAuth {\n rewardsInfo[strategy] = rewards;\n emit RewardsInfoUpdate(strategy, rewards.rewardsPerSecond, rewards.rewardsEndTimestamp);\n }\n\n /**\n @notice calculate and transfer accrued rewards to flywheel core\n @param strategy the strategy to accrue rewards for\n @param lastUpdatedTimestamp the last updated time for strategy\n @return amount the amount of tokens accrued and transferred\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp)\n external\n view\n override\n onlyFlywheel\n returns (uint256 amount)\n {\n RewardsInfo memory rewards = rewardsInfo[strategy];\n\n uint256 elapsed;\n if (rewards.rewardsEndTimestamp == 0 || rewards.rewardsEndTimestamp > block.timestamp) {\n elapsed = block.timestamp - lastUpdatedTimestamp;\n } else if (rewards.rewardsEndTimestamp > lastUpdatedTimestamp) {\n elapsed = rewards.rewardsEndTimestamp - lastUpdatedTimestamp;\n }\n\n amount = rewards.rewardsPerSecond * elapsed;\n }\n}" + }, + "contracts/ionic/strategies/flywheel/rewards/IFlywheelRewards.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IonicFlywheelCore} from \"../IonicFlywheelCore.sol\";\n\n/**\n @title Rewards Module for Flywheel\n @notice Flywheel is a general framework for managing token incentives.\n It takes reward streams to various *strategies* such as staking LP tokens and divides them among *users* of those strategies.\n\n The Rewards module is responsible for:\n * determining the ongoing reward amounts to entire strategies (core handles the logic for dividing among users)\n * actually holding rewards that are yet to be claimed\n\n The reward stream can follow arbitrary logic as long as the amount of rewards passed to flywheel core has been sent to this contract.\n\n Different module strategies include:\n * a static reward rate per second\n * a decaying reward rate\n * a dynamic just-in-time reward stream\n * liquid governance reward delegation (Curve Gauge style)\n\n SECURITY NOTE: The rewards strategy should be smooth and continuous, to prevent gaming the reward distribution by frontrunning.\n */\ninterface IFlywheelRewards {\n /**\n @notice calculate the rewards amount accrued to a strategy since the last update.\n @param strategy the strategy to accrue rewards for.\n @param lastUpdatedTimestamp the last time rewards were accrued for the strategy.\n @return rewards the amount of rewards accrued to the market\n */\n function getAccruedRewards(ERC20 strategy, uint32 lastUpdatedTimestamp) external returns (uint256 rewards);\n\n /// @notice return the flywheel core address\n function flywheel() external view returns (IonicFlywheelCore);\n\n /// @notice return the reward token associated with flywheel core.\n function rewardToken() external view returns (ERC20);\n}\n" + }, + "contracts/ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.10;\n\nimport \"./FlywheelDynamicRewards.sol\";\n\ninterface ICERC20 {\n function plugin() external returns (address);\n}\n\ninterface IPlugin_FDR {\n function claimRewards() external;\n}\n\n/** \n @title Ionic Flywheel Dynamic Reward Stream\n @notice Determines rewards based on reward cycle\n Each cycle, claims rewards on the plugin before getting the reward amount\n*/\ncontract IonicFlywheelDynamicRewardsPlugin is FlywheelDynamicRewards {\n using SafeTransferLib for ERC20;\n\n constructor(IonicFlywheelCore _flywheel, uint32 _cycleLength)\n FlywheelDynamicRewards(_flywheel, _cycleLength)\n {}\n\n function getNextCycleRewards(ERC20 strategy)\n internal\n override\n returns (uint192)\n {\n IPlugin_FDR plugin = IPlugin_FDR(ICERC20(address(strategy)).plugin());\n try plugin.claimRewards() {} catch {}\n\n uint256 rewardAmount = rewardToken.balanceOf(address(strategy));\n if (rewardAmount != 0) {\n rewardToken.safeTransferFrom(\n address(strategy),\n address(this),\n rewardAmount\n );\n }\n return uint192(rewardAmount);\n }\n}" + }, + "contracts/ionic/strategies/IonicERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nimport { PausableUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol\";\nimport { ERC4626Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { SafeOwnableUpgradeable } from \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nabstract contract IonicERC4626 is SafeOwnableUpgradeable, PausableUpgradeable, ERC4626Upgradeable {\n using FixedPointMathLib for uint256;\n using SafeERC20Upgradeable for ERC20Upgradeable;\n\n /* ========== STATE VARIABLES ========== */\n\n uint256 public vaultShareHWM;\n uint256 public performanceFee;\n address public feeRecipient;\n\n /* ========== EVENTS ========== */\n\n event UpdatedFeeSettings(\n uint256 oldPerformanceFee,\n uint256 newPerformanceFee,\n address oldFeeRecipient,\n address newFeeRecipient\n );\n\n /* ========== INITIALIZER ========== */\n\n function __IonicER4626_init(ERC20Upgradeable asset_) internal onlyInitializing {\n __SafeOwnable_init(msg.sender);\n __Pausable_init();\n __Context_init();\n __ERC20_init(\n string(abi.encodePacked(\"Ionic \", asset_.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", asset_.symbol()))\n );\n __ERC4626_init(asset_);\n\n vaultShareHWM = 10**asset_.decimals();\n feeRecipient = msg.sender;\n }\n\n function _asset() internal view returns (ERC20Upgradeable) {\n return ERC20Upgradeable(super.asset());\n }\n\n /* ========== DEPOSIT/WITHDRAW FUNCTIONS ========== */\n\n function deposit(uint256 assets, address receiver) public override whenNotPaused returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public override whenNotPaused returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n _asset().safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public override returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public override returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance(owner, msg.sender); // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) _approve(owner, msg.sender, allowed - shares);\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n if (!paused()) {\n uint256 balanceBeforeWithdraw = _asset().balanceOf(address(this));\n\n beforeWithdraw(assets, shares);\n\n assets = _asset().balanceOf(address(this)) - balanceBeforeWithdraw;\n }\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n _asset().safeTransfer(receiver, assets);\n }\n\n /* ========== FEE FUNCTIONS ========== */\n\n /**\n * @notice Take the performance fee that has accrued since last fee harvest.\n * @dev Performance fee is based on a vault share high water mark value. If vault share value has increased above the\n * HWM in a fee period, issue fee shares to the vault equal to the performance fee.\n */\n function takePerformanceFee() external onlyOwner {\n require(feeRecipient != address(0), \"fee recipient not initialized\");\n\n uint256 currentAssets = totalAssets();\n uint256 shareValue = convertToAssets(10**_asset().decimals());\n\n require(shareValue > vaultShareHWM, \"shareValue !> vaultShareHWM\");\n // cache value\n uint256 supply = totalSupply();\n\n uint256 accruedPerformanceFee = (performanceFee * (shareValue - vaultShareHWM) * supply) / 1e36;\n _mint(feeRecipient, accruedPerformanceFee.mulDivDown(supply, (currentAssets - accruedPerformanceFee)));\n\n vaultShareHWM = convertToAssets(10**_asset().decimals());\n }\n\n /**\n * @notice Transfer accrued fees to rewards manager contract. Caller must be a registered keeper.\n * @dev We must make sure that feeRecipient is not address(0) before withdrawing fees\n */\n function withdrawAccruedFees() external onlyOwner {\n redeem(balanceOf(feeRecipient), feeRecipient, feeRecipient);\n }\n\n /**\n * @notice Update performanceFee and/or feeRecipient\n */\n function updateFeeSettings(uint256 newPerformanceFee, address newFeeRecipient) external onlyOwner {\n emit UpdatedFeeSettings(performanceFee, newPerformanceFee, feeRecipient, newFeeRecipient);\n\n performanceFee = newPerformanceFee;\n\n if (newFeeRecipient != feeRecipient) {\n if (feeRecipient != address(0)) {\n uint256 oldFees = balanceOf(feeRecipient);\n\n _burn(feeRecipient, oldFees);\n _approve(feeRecipient, owner(), 0);\n _mint(newFeeRecipient, oldFees);\n }\n\n _approve(newFeeRecipient, owner(), type(uint256).max);\n }\n\n feeRecipient = newFeeRecipient;\n }\n\n /* ========== EMERGENCY FUNCTIONS ========== */\n\n // Should withdraw all funds from the strategy and pause the contract\n function emergencyWithdrawAndPause() external virtual;\n\n function unpause() external virtual;\n\n function shutdown(address market) external onlyOwner whenPaused returns (uint256) {\n ERC20Upgradeable theAsset = _asset();\n uint256 endBalance = theAsset.balanceOf(address(this));\n theAsset.transfer(market, endBalance);\n return endBalance;\n }\n\n /* ========== INTERNAL HOOKS LOGIC ========== */\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual;\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual;\n}\n" + }, + "contracts/ionic/strategies/MockERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { SafeTransferLib } from \"solmate/utils/SafeTransferLib.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626 is ERC4626 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /**\n @notice Creates a new Vault that accepts a specific underlying token.\n @param _asset The ERC20 compliant token the Vault should accept.\n */\n constructor(ERC20 _asset)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {}\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/ionic/strategies/MockERC4626Dynamic.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IonicFlywheelCore } from \"./flywheel/IonicFlywheelCore.sol\";\n\n/**\n * @title Mock ERC4626 Contract\n * @notice ERC4626 wrapper for Tribe Token\n * @author carlomazzaferro\n *\n */\ncontract MockERC4626Dynamic is ERC4626 {\n using FixedPointMathLib for uint256;\n\n /* ========== STATE VARIABLES ========== */\n IonicFlywheelCore public immutable flywheel;\n\n /* ========== INITIALIZER ========== */\n\n /**\n @notice Initializes the Vault.\n @param _asset The ERC20 compliant token the Vault should accept.\n @param _flywheel Flywheel to pull in rewardsToken\n */\n constructor(ERC20 _asset, IonicFlywheelCore _flywheel)\n ERC4626(\n _asset,\n string(abi.encodePacked(\"Midas \", _asset.name(), \" Vault\")),\n string(abi.encodePacked(\"mv\", _asset.symbol()))\n )\n {\n flywheel = _flywheel;\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Calculates the total amount of underlying tokens the Vault holds.\n /// @return The total amount of underlying tokens the Vault holds.\n function totalAssets() public view override returns (uint256) {\n return asset.balanceOf(address(this));\n }\n\n /// @notice Calculates the total amount of underlying tokens the user holds.\n /// @return The total amount of underlying tokens the user holds.\n function balanceOfUnderlying(address account) public view returns (uint256) {\n return convertToAssets(balanceOf[account]);\n }\n\n /* ========== INTERNAL FUNCTIONS ========== */\n\n function afterDeposit(uint256 amount, uint256) internal override {}\n\n function beforeWithdraw(uint256, uint256 shares) internal override {}\n}\n" + }, + "contracts/IonicLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./utils/IW_NATIVE.sol\";\n\nimport \"./external/uniswap/IUniswapV2Router02.sol\";\nimport \"./external/uniswap/IUniswapV2Pair.sol\";\nimport \"./external/uniswap/IUniswapV2Callee.sol\";\nimport \"./external/uniswap/UniswapV2Library.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicLiquidator\n * @author David Lucid (https://github.com/davidlucid)\n * @notice IonicLiquidator safely liquidates unhealthy borrowers (with flashloan support).\n * @dev Do not transfer NATIVE or tokens directly to this address. Only send NATIVE here when using a method, and only approve tokens for transfer to here when using a method. Direct NATIVE transfers will be rejected and direct token transfers will be lost.\n */\ncontract IonicLiquidator is OwnableUpgradeable, ILiquidator, IUniswapV2Callee, IExpressRelayFeeReceiver {\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n\n /**\n * @dev W_NATIVE contract address.\n */\n address public W_NATIVE_ADDRESS;\n\n /**\n * @dev UniswapV2Router02 contract object. (Is interchangable with any UniV2 forks)\n */\n IUniswapV2Router02 public UNISWAP_V2_ROUTER_02;\n\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n mapping(address => bool) public redemptionStrategiesWhitelist;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n /**\n * @dev Percentage of the flash swap fee, measured in basis points.\n */\n uint8 public flashSwapFee;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(\n address _wtoken,\n address _uniswapV2router,\n uint8 _flashSwapFee\n ) external initializer {\n __Ownable_init();\n require(_uniswapV2router != address(0), \"_uniswapV2router not defined.\");\n W_NATIVE_ADDRESS = _wtoken;\n UNISWAP_V2_ROUTER_02 = IUniswapV2Router02(_uniswapV2router);\n flashSwapFee = _flashSwapFee;\n }\n\n function _becomeImplementation(bytes calldata data) external {}\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) private {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @dev Internal function to approve\n */\n function justApprove(\n IERC20Upgradeable token,\n address to,\n uint256 amount\n ) private {\n token.approve(to, amount);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n justApprove(underlying, address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan, confirming that at least `minProfitAmount` in NATIVE profit is seized.\n * @param vars @see LiquidateToTokensWithFlashSwapVars.\n */\n function safeLiquidateToTokensWithFlashLoan(LiquidateToTokensWithFlashSwapVars calldata vars)\n external\n onlyLowHF(vars.borrower, vars.cTokenCollateral)\n returns (uint256)\n {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV2Pair flashSwapPair = IUniswapV2Pair(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPair.token0() == address(fundingToken);\n flashSwapPair.swap(\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n address(this),\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n function uniswapV2Call(\n address,\n uint256,\n uint256,\n bytes calldata data\n ) public override {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars);\n }\n\n /**\n * @dev Callback function for PCS flashloans.\n */\n function pancakeCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n function moraswapCall(\n address sender,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n uniswapV2Call(sender, amount0, amount1, data);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(LiquidateToTokensWithFlashSwapVars memory vars) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n justApprove(IERC20Upgradeable(underlyingBorrow), address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData\n ) private returns (address) {\n // Calculate flashloan return amount\n uint256 flashSwapReturnAmount = (_flashSwapAmount * 10000) / (10000 - flashSwapFee);\n if ((_flashSwapAmount * 10000) % (10000 - flashSwapFee) > 0) flashSwapReturnAmount++; // Round up if division resulted in a remainder\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n IUniswapV2Pair pair = IUniswapV2Pair(msg.sender);\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pair.token0() || address(underlyingCollateral) == pair.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay amount for the borrow side\n collateralRequired = flashSwapReturnAmount;\n } else {\n // repay amount for the non-borrow side\n collateralRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n _flashSwapAmount, //flashSwapReturnAmount,\n array(address(underlyingCollateral), _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n // Repay flashloan\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n require(\n underlyingCollateral.transfer(msg.sender, collateralRequired),\n \"Failed to repay token flashloan on borrow side.\"\n );\n\n return address(underlyingCollateral);\n } else {\n // exchange the collateral to W_NATIVE to repay the borrow side\n uint256 wethRequired;\n if (_flashSwapToken == W_NATIVE_ADDRESS) {\n wethRequired = flashSwapReturnAmount;\n } else {\n // Get W_NATIVE required to repay flashloan\n wethRequired = UniswapV2Library.getAmountsIn(\n UNISWAP_V2_ROUTER_02.factory(),\n flashSwapReturnAmount,\n array(W_NATIVE_ADDRESS, _flashSwapToken),\n flashSwapFee\n )[0];\n }\n\n if (address(underlyingCollateral) != W_NATIVE_ADDRESS) {\n // Approve to Uniswap router\n justApprove(underlyingCollateral, address(UNISWAP_V2_ROUTER_02), underlyingCollateralSeized);\n\n // Swap collateral tokens for W_NATIVE to be repaid via Uniswap router\n UNISWAP_V2_ROUTER_02.swapTokensForExactTokens(\n wethRequired,\n underlyingCollateralSeized,\n array(address(underlyingCollateral), W_NATIVE_ADDRESS),\n address(this),\n block.timestamp\n );\n }\n\n // Repay flashloan\n require(\n wethRequired <= IERC20Upgradeable(W_NATIVE_ADDRESS).balanceOf(address(this)),\n \"Not enough W_NATIVE exchanged from seized collateral to repay flashloan.\"\n );\n require(\n IW_NATIVE(W_NATIVE_ADDRESS).transfer(msg.sender, wethRequired),\n \"Failed to repay Uniswap flashloan with W_NATIVE exchanged from seized collateral.\"\n );\n\n // Return the profited token (underlying collateral if same as exchangeProfitTo; otherwise, W_NATIVE)\n return address(underlyingCollateral);\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(IRedemptionStrategy[] calldata strategies, bool[] calldata whitelisted)\n external\n onlyOwner\n {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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 /**\n * @dev Returns an array containing the parameters supplied.\n */\n function array(address a, address b) private pure returns (address[] memory) {\n address[] memory arr = new address[](2);\n arr[0] = a;\n arr[1] = b;\n return arr;\n }\n}\n" + }, + "contracts/IonicUniV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"./liquidators/IRedemptionStrategy.sol\";\nimport \"./liquidators/IFundsConversionStrategy.sol\";\nimport \"./ILiquidator.sol\";\n\nimport \"./external/uniswap/IUniswapV3FlashCallback.sol\";\nimport \"./external/uniswap/IUniswapV3Pool.sol\";\nimport \"./external/pyth/IExpressRelay.sol\";\nimport \"./external/pyth/IExpressRelayFeeReceiver.sol\";\nimport { IUniswapV3Quoter } from \"./external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IFlashLoanReceiver } from \"./ionic/IFlashLoanReceiver.sol\";\n\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport \"./PoolLens.sol\";\n\n/**\n * @title IonicUniV3Liquidator\n * @author Veliko Minkov (https://github.com/vminkov)\n * @notice IonicUniV3Liquidator liquidates unhealthy borrowers with flashloan support.\n */\ncontract IonicUniV3Liquidator is\n OwnableUpgradeable,\n ILiquidator,\n IUniswapV3FlashCallback,\n IExpressRelayFeeReceiver,\n IFlashLoanReceiver\n{\n using AddressUpgradeable for address payable;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n event VaultReceivedETH(address sender, uint256 amount, bytes permissionKey);\n /**\n * @dev Cached liquidator profit exchange source.\n * ERC20 token address or the zero address for NATIVE.\n * For use in `safeLiquidateToTokensWithFlashLoan` after it is set by `postFlashLoanTokens`.\n */\n address private _liquidatorProfitExchangeSource;\n\n /**\n * @dev Cached flash swap amount.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n uint256 private _flashSwapAmount;\n\n /**\n * @dev Cached flash swap token.\n * For use in `repayTokenFlashLoan` after it is set by `safeLiquidateToTokensWithFlashLoan`.\n */\n address private _flashSwapToken;\n\n address public W_NATIVE_ADDRESS;\n mapping(address => bool) public redemptionStrategiesWhitelist;\n IUniswapV3Quoter public quoter;\n\n /**\n * @dev Addres of Pyth Express Relay for preventing value leakage in liquidations.\n */\n IExpressRelay public expressRelay;\n /**\n * @dev Pool Lens.\n */\n PoolLens public lens;\n /**\n * @dev Health Factor below which PER permissioning is bypassed.\n */\n uint256 public healthFactorThreshold;\n\n modifier onlyLowHF(address borrower, ICErc20 cToken) {\n uint256 currentHealthFactor = lens.getHealthFactor(borrower, cToken.comptroller());\n require(currentHealthFactor < healthFactorThreshold, \"HF not low enough, reserving for PYTH\");\n _;\n }\n\n function initialize(address _wtoken, address _quoter) external initializer {\n __Ownable_init();\n W_NATIVE_ADDRESS = _wtoken;\n quoter = IUniswapV3Quoter(_quoter);\n }\n\n /**\n * @notice Safely liquidate an unhealthy loan (using capital from the sender), confirming that at least `minOutputAmount` in collateral is seized (or outputted by exchange if applicable).\n * @param borrower The borrower's Ethereum address.\n * @param repayAmount The amount to repay to liquidate the unhealthy loan.\n * @param cErc20 The borrowed cErc20 to repay.\n * @param cTokenCollateral The cToken collateral to be liquidated.\n * @param minOutputAmount The minimum amount of collateral to seize (or the minimum exchange output if applicable) required for execution. Reverts if this condition is not met.\n */\n function _safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) internal returns (uint256) {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n IERC20Upgradeable underlying = IERC20Upgradeable(cErc20.underlying());\n underlying.safeTransferFrom(msg.sender, address(this), repayAmount);\n underlying.approve(address(cErc20), repayAmount);\n require(cErc20.liquidateBorrow(borrower, repayAmount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n\n return transferSeizedFunds(address(cTokenCollateral.underlying()), minOutputAmount);\n }\n\n function safeLiquidate(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external onlyLowHF(borrower, cTokenCollateral) returns (uint256) {\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidatePyth(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n uint256 minOutputAmount\n ) external returns (uint256) {\n require(expressRelay.isPermissioned(address(this), abi.encode(borrower)), \"invalid liquidation\");\n return _safeLiquidate(borrower, repayAmount, cErc20, cTokenCollateral, minOutputAmount);\n }\n\n function safeLiquidateWithAggregator(\n address borrower,\n uint256 repayAmount,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData\n ) external {\n // Transfer tokens in, approve to cErc20, and liquidate borrow\n require(repayAmount > 0, \"Repay amount (transaction value) must be greater than 0.\");\n cErc20.flash(\n repayAmount,\n abi.encode(borrower, cErc20, cTokenCollateral, aggregatorTarget, aggregatorData, msg.sender)\n );\n }\n\n function receiveFlashLoan(address _underlyingBorrow, uint256 amount, bytes calldata data) external {\n (\n address borrower,\n ICErc20 cErc20,\n ICErc20 cTokenCollateral,\n address aggregatorTarget,\n bytes memory aggregatorData,\n address liquidator\n ) = abi.decode(data, (address, ICErc20, ICErc20, address, bytes, address));\n IERC20Upgradeable underlyingBorrow = IERC20Upgradeable(_underlyingBorrow);\n underlyingBorrow.approve(address(cErc20), amount);\n require(cErc20.liquidateBorrow(borrower, amount, address(cTokenCollateral)) == 0, \"Liquidation failed.\");\n\n // Redeem seized cTokens for underlying asset\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(cTokenCollateral.underlying());\n {\n uint256 seizedCTokenAmount = cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n uint256 underlyingCollateralRedeemed = underlyingCollateral.balanceOf(address(this));\n\n // Call the aggregator\n underlyingCollateral.approve(aggregatorTarget, underlyingCollateralRedeemed);\n (bool success, ) = aggregatorTarget.call(aggregatorData);\n require(success, \"Aggregator call failed\");\n }\n\n // receive profits\n {\n uint256 receivedAmount = underlyingBorrow.balanceOf(address(this));\n require(receivedAmount >= amount, \"Not received enough collateral after swap.\");\n uint256 profitBorrow = receivedAmount - amount;\n if (profitBorrow > 0) {\n underlyingBorrow.safeTransfer(liquidator, profitBorrow);\n }\n\n uint256 profitCollateral = underlyingCollateral.balanceOf(address(this));\n if (profitCollateral > 0) {\n underlyingCollateral.safeTransfer(liquidator, profitCollateral);\n }\n }\n\n // pay back flashloan\n underlyingBorrow.approve(address(cErc20), amount);\n }\n\n /**\n * @dev Transfers seized funds to the sender.\n * @param erc20Contract The address of the token to transfer.\n * @param minOutputAmount The minimum amount to transfer.\n */\n function transferSeizedFunds(address erc20Contract, uint256 minOutputAmount) internal returns (uint256) {\n IERC20Upgradeable token = IERC20Upgradeable(erc20Contract);\n uint256 seizedOutputAmount = token.balanceOf(address(this));\n require(seizedOutputAmount >= minOutputAmount, \"Minimum token output amount not satified.\");\n if (seizedOutputAmount > 0) token.safeTransfer(msg.sender, seizedOutputAmount);\n\n return seizedOutputAmount;\n }\n\n function safeLiquidateToTokensWithFlashLoan(\n LiquidateToTokensWithFlashSwapVars calldata vars\n ) external onlyLowHF(vars.borrower, vars.cTokenCollateral) returns (uint256) {\n // Input validation\n require(vars.repayAmount > 0, \"Repay amount must be greater than 0.\");\n\n // we want to calculate the needed flashSwapAmount on-chain to\n // avoid errors due to changing market conditions\n // between the time of calculating and including the tx in a block\n uint256 fundingAmount = vars.repayAmount;\n IERC20Upgradeable fundingToken;\n if (vars.debtFundingStrategies.length > 0) {\n require(\n vars.debtFundingStrategies.length == vars.debtFundingStrategiesData.length,\n \"Funding IFundsConversionStrategy contract array and strategy data bytes array must be the same length.\"\n );\n // estimate the initial (flash-swapped token) input from the expected output (debt token)\n for (uint256 i = 0; i < vars.debtFundingStrategies.length; i++) {\n bytes memory strategyData = vars.debtFundingStrategiesData[i];\n IFundsConversionStrategy fcs = vars.debtFundingStrategies[i];\n (fundingToken, fundingAmount) = fcs.estimateInputAmount(fundingAmount, strategyData);\n }\n } else {\n fundingToken = IERC20Upgradeable(ICErc20(address(vars.cErc20)).underlying());\n }\n\n // the last outputs from estimateInputAmount are the ones to be flash-swapped\n _flashSwapAmount = fundingAmount;\n _flashSwapToken = address(fundingToken);\n\n IUniswapV3Pool flashSwapPool = IUniswapV3Pool(vars.flashSwapContract);\n bool token0IsFlashSwapFundingToken = flashSwapPool.token0() == address(fundingToken);\n flashSwapPool.flash(\n address(this),\n token0IsFlashSwapFundingToken ? fundingAmount : 0,\n !token0IsFlashSwapFundingToken ? fundingAmount : 0,\n msg.data\n );\n\n return transferSeizedFunds(_liquidatorProfitExchangeSource, vars.minProfitAmount);\n }\n\n /**\n * @dev Receives NATIVE from liquidations and flashloans.\n * Requires that `msg.sender` is W_NATIVE, a CToken, or a Uniswap V2 Router, or another contract.\n */\n receive() external payable {\n require(payable(msg.sender).isContract(), \"Sender is not a contract.\");\n }\n\n /**\n * @notice receiveAuctionProceedings function - receives native token from the express relay\n * You can use permission key to distribute the received funds to users who got liquidated, LPs, etc...\n */\n function receiveAuctionProceedings(bytes calldata permissionKey) external payable {\n emit VaultReceivedETH(msg.sender, msg.value, permissionKey);\n }\n\n function withdrawAll() external onlyOwner {\n uint256 balance = address(this).balance;\n require(balance > 0, \"No Ether left to withdraw\");\n\n // Transfer all Ether to the owner\n (bool sent, ) = msg.sender.call{ value: balance }(\"\");\n require(sent, \"Failed to send Ether\");\n }\n\n /**\n * @dev Callback function for Uniswap flashloans.\n */\n\n function supV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {\n uniswapV3FlashCallback(fee0, fee1, data);\n }\n\n function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {\n // Liquidate unhealthy borrow, exchange seized collateral, return flashloaned funds, and exchange profit\n // Decode params\n LiquidateToTokensWithFlashSwapVars memory vars = abi.decode(data[4:], (LiquidateToTokensWithFlashSwapVars));\n\n // Post token flashloan\n // Cache liquidation profit token (or the zero address for NATIVE) for use as source for exchange later\n _liquidatorProfitExchangeSource = postFlashLoanTokens(vars, fee0, fee1);\n }\n\n /**\n * @dev Liquidate unhealthy token borrow, exchange seized collateral, return flashloaned funds, and exchange profit.\n */\n function postFlashLoanTokens(\n LiquidateToTokensWithFlashSwapVars memory vars,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IERC20Upgradeable debtRepaymentToken = IERC20Upgradeable(_flashSwapToken);\n uint256 debtRepaymentAmount = _flashSwapAmount;\n\n if (vars.debtFundingStrategies.length > 0) {\n // loop backwards to convert the initial (flash-swapped token) input to the final expected output (debt token)\n for (uint256 i = vars.debtFundingStrategies.length; i > 0; i--) {\n (debtRepaymentToken, debtRepaymentAmount) = convertCustomFunds(\n debtRepaymentToken,\n debtRepaymentAmount,\n vars.debtFundingStrategies[i - 1],\n vars.debtFundingStrategiesData[i - 1]\n );\n }\n }\n\n // Approve the debt repayment transfer, liquidate and redeem the seized collateral\n {\n address underlyingBorrow = vars.cErc20.underlying();\n require(\n address(debtRepaymentToken) == underlyingBorrow,\n \"the debt repayment funds should be converted to the underlying debt token\"\n );\n require(debtRepaymentAmount >= vars.repayAmount, \"debt repayment amount not enough\");\n // Approve repayAmount to cErc20\n IERC20Upgradeable(underlyingBorrow).approve(address(vars.cErc20), vars.repayAmount);\n\n // Liquidate borrow\n require(\n vars.cErc20.liquidateBorrow(vars.borrower, vars.repayAmount, address(vars.cTokenCollateral)) == 0,\n \"Liquidation failed.\"\n );\n\n // Redeem seized cTokens for underlying asset\n uint256 seizedCTokenAmount = vars.cTokenCollateral.balanceOf(address(this));\n require(seizedCTokenAmount > 0, \"No cTokens seized.\");\n uint256 redeemResult = vars.cTokenCollateral.redeem(seizedCTokenAmount);\n require(redeemResult == 0, \"Error calling redeeming seized cToken: error code not equal to 0\");\n }\n\n // Repay flashloan\n return repayTokenFlashLoan(vars.cTokenCollateral, vars.redemptionStrategies, vars.strategyData, fee0, fee1);\n }\n\n /**\n * @dev Repays token flashloans.\n */\n function repayTokenFlashLoan(\n ICErc20 cTokenCollateral,\n IRedemptionStrategy[] memory redemptionStrategies,\n bytes[] memory strategyData,\n uint256 fee0,\n uint256 fee1\n ) private returns (address) {\n IUniswapV3Pool pool = IUniswapV3Pool(msg.sender);\n uint256 flashSwapReturnAmount = _flashSwapAmount;\n if (IUniswapV3Pool(msg.sender).token0() == _flashSwapToken) {\n flashSwapReturnAmount += fee0;\n } else if (IUniswapV3Pool(msg.sender).token1() == _flashSwapToken) {\n flashSwapReturnAmount += fee1;\n } else {\n revert(\"wrong pool or _flashSwapToken\");\n }\n\n // Swap cTokenCollateral for cErc20 via Uniswap\n // Check underlying collateral seized\n IERC20Upgradeable underlyingCollateral = IERC20Upgradeable(ICErc20(address(cTokenCollateral)).underlying());\n uint256 underlyingCollateralSeized = underlyingCollateral.balanceOf(address(this));\n\n // Redeem custom collateral if liquidation strategy is set\n if (redemptionStrategies.length > 0) {\n require(\n redemptionStrategies.length == strategyData.length,\n \"IRedemptionStrategy contract array and strategy data bytes array mnust the the same length.\"\n );\n for (uint256 i = 0; i < redemptionStrategies.length; i++)\n (underlyingCollateral, underlyingCollateralSeized) = redeemCustomCollateral(\n underlyingCollateral,\n underlyingCollateralSeized,\n redemptionStrategies[i],\n strategyData[i]\n );\n }\n\n // Check if we can repay directly one of the sides with collateral\n if (address(underlyingCollateral) == pool.token0() || address(underlyingCollateral) == pool.token1()) {\n // Repay flashloan directly with collateral\n uint256 collateralRequired;\n if (address(underlyingCollateral) == _flashSwapToken) {\n // repay the borrowed asset directly\n collateralRequired = flashSwapReturnAmount;\n\n // Repay flashloan\n IERC20Upgradeable(_flashSwapToken).transfer(address(pool), flashSwapReturnAmount);\n } else {\n // TODO swap within the same pool and then repay the FL to the pool\n bool zeroForOne = address(underlyingCollateral) == pool.token0();\n\n {\n collateralRequired = quoter.quoteExactOutputSingle(\n zeroForOne ? pool.token0() : pool.token1(),\n zeroForOne ? pool.token1() : pool.token0(),\n pool.fee(),\n _flashSwapAmount,\n 0 // sqrtPriceLimitX96\n );\n }\n require(\n collateralRequired <= underlyingCollateralSeized,\n \"Token flashloan return amount greater than seized collateral.\"\n );\n\n // Repay flashloan\n pool.swap(\n address(pool),\n zeroForOne,\n int256(collateralRequired),\n 0, // sqrtPriceLimitX96\n \"\"\n );\n }\n\n return address(underlyingCollateral);\n } else {\n revert(\"the redemptions strategy did not swap to the flash swapped pool assets\");\n }\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategy(IRedemptionStrategy strategy, bool whitelisted) external onlyOwner {\n redemptionStrategiesWhitelist[address(strategy)] = whitelisted;\n }\n\n /**\n * @dev for security reasons only whitelisted redemption strategies may be used.\n * Each whitelisted redemption strategy has to be checked to not be able to\n * call `selfdestruct` with the `delegatecall` call in `redeemCustomCollateral`\n */\n function _whitelistRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n bool[] calldata whitelisted\n ) external onlyOwner {\n require(\n strategies.length > 0 && strategies.length == whitelisted.length,\n \"list of strategies empty or whitelist does not match its length\"\n );\n\n for (uint256 i = 0; i < strategies.length; i++) {\n redemptionStrategiesWhitelist[address(strategies[i])] = whitelisted[i];\n }\n }\n\n function setExpressRelay(address _expressRelay) external onlyOwner {\n expressRelay = IExpressRelay(_expressRelay);\n }\n\n function setPoolLens(address _poolLens) external onlyOwner {\n lens = PoolLens(_poolLens);\n }\n\n function setHealthFactorThreshold(uint256 _healthFactorThreshold) external onlyOwner {\n require(_healthFactorThreshold <= 1e18, \"Invalid Health Factor Threshold\");\n healthFactorThreshold = _healthFactorThreshold;\n }\n\n /**\n * @dev Redeem \"special\" collateral tokens (before swapping the output for borrowed tokens to be repaid via Uniswap).\n * Public visibility because we have to call this function externally if called from a payable IonicLiquidator function (for some reason delegatecall fails when called with msg.value > 0).\n */\n function redeemCustomCollateral(\n IERC20Upgradeable underlyingCollateral,\n uint256 underlyingCollateralSeized,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, underlyingCollateral, underlyingCollateralSeized, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IFundsConversionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n require(redemptionStrategiesWhitelist[address(strategy)], \"only whitelisted redemption strategies can be used\");\n\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.convert.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L37\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.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, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Used by `_functionDelegateCall` to verify the result of a delegate call.\n * Copied from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/contracts/blob/cb4774ace1cb84f2662fa47c573780aab937628b/contracts/utils/MulticallUpgradeable.sol#L45\n */\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) 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" + }, + "contracts/liquidators/AerodromeCLLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { ISwapRouter_Aerodrome } from \"../external/aerodrome/IAerodromeSwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\ncontract AerodromeCLLiquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n ,\n address _outputToken,\n ISwapRouter_Aerodrome swapRouter,\n address _unwrappedInput,\n address _unwrappedOutput,\n int24 _tickSpacing\n ) = abi.decode(strategyData, (address, address, ISwapRouter_Aerodrome, address, address, int24));\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(_outputToken);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n ISwapRouter_Aerodrome.ExactInputSingleParams(\n address(inputToken),\n address(outputToken),\n _tickSpacing,\n address(this),\n block.timestamp,\n inputAmount,\n 0,\n 0\n )\n );\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(_outputToken), outputAmount);\n IERC4626(_outputToken).deposit(outputAmount, address(this));\n outputAmount = IERC4626(_unwrappedOutput).balanceOf(address(this));\n outputToken = IERC20Upgradeable(_outputToken);\n }\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"AerodromeCLLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/AerodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\n\n/**\n * @title AerodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Aerodrome V2 router for use as a step in a liquidation.\n */\ncontract AerodromeV2Liquidator {\n function _swap(IRouter_Aerodrome router, uint256 inputAmount, IRouter_Aerodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"AerodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Aerodrome router, IRouter_Aerodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Aerodrome, IRouter_Aerodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid AerodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/liquidators/AlgebraSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/algebra/ISwapRouter.sol\";\n\n/**\n * @title AlgebraSwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Algebra router for use as a step in a liquidation.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract AlgebraSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address _outputToken, IAlgebraSwapRouter swapRouter) = abi.decode(strategyData, (address, IAlgebraSwapRouter));\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n IAlgebraSwapRouter.ExactInputSingleParams memory params = IAlgebraSwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n address(this),\n block.timestamp,\n inputAmount,\n 0, // amountOutMinimum\n 0 // limitSqrtPrice\n );\n\n outputAmount = swapRouter.exactInputSingle(params);\n }\n\n function name() public pure returns (string memory) {\n return \"AlgebraSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BalancerSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"../external/balancer/IBalancerPool.sol\";\nimport \"../external/balancer/IBalancerVault.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract BalancerSwapLiquidator is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (address outputTokenAddress, IBalancerPool pool) = abi.decode(strategyData, (address, IBalancerPool));\n\n IBalancerVault vault = pool.getVault();\n bytes32 poolId = pool.getPoolId();\n\n SingleSwap memory singleSwap = SingleSwap(\n poolId,\n SwapKind.GIVEN_IN,\n IAsset(address(inputToken)),\n IAsset(address(outputTokenAddress)),\n inputAmount,\n \"\"\n );\n\n FundManagement memory funds = FundManagement(\n address(this),\n false, // fromInternalBalance\n payable(address(this)),\n false // toInternalBalance\n );\n\n inputToken.approve(address(vault), inputAmount);\n vault.swap(singleSwap, funds, 0, block.timestamp + 10);\n outputAmount = IERC20Upgradeable(outputTokenAddress).balanceOf(address(this));\n return (IERC20Upgradeable(outputTokenAddress), outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"BalancerSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/BaseUniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nabstract contract BaseUniswapV2Liquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2 && swapPath[0] == address(inputToken), \"Invalid UniswapLiquidator swap path.\");\n\n // Swap underlying tokens\n inputToken.approve(address(uniswapV2Router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(uniswapV2Router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1]);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal virtual;\n}\n" + }, + "contracts/liquidators/CurveLpTokenLiquidatorNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\nimport { WETH } from \"solmate/tokens/WETH.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title CurveLpTokenLiquidatorNoRegistry\n * @notice Redeems seized Curve LP token collateral for underlying tokens for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveLpTokenLiquidatorNoRegistry is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // TODO get the curvePool from the strategyData instead of the _oracle\n (address outputTokenAddress, address payable wtoken, address _oracle) = abi.decode(\n strategyData,\n (address, address, address)\n );\n // the oracle contains the pool registry\n CurveLpTokenPriceOracleNoRegistry oracle = CurveLpTokenPriceOracleNoRegistry(_oracle);\n\n // Remove liquidity from Curve pool in the form of one coin only (and store output as new collateral)\n ICurvePool curvePool = ICurvePool(oracle.poolOf(address(inputToken)));\n\n uint8 outputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (outputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == outputTokenAddress) outputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n curvePool.remove_liquidity_one_coin(inputAmount, int128(int8(outputIndex)), 1);\n\n // better safe than sorry\n if (outputTokenAddress == address(0) || outputTokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {\n WETH(wtoken).deposit{ value: address(this).balance }();\n outputToken = IERC20Upgradeable(wtoken);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n outputAmount = outputToken.balanceOf(address(this));\n\n return (outputToken, outputAmount);\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenLiquidatorNoRegistry\";\n }\n}\n\ncontract CurveLpTokenWrapper is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (ICurvePool curvePool, address _outputTokenAddress) = abi.decode(strategyData, (ICurvePool, address));\n outputToken = IERC20Upgradeable(_outputTokenAddress);\n\n uint8 inputIndex = type(uint8).max;\n\n uint8 j = 0;\n while (inputIndex == type(uint8).max) {\n try curvePool.coins(uint256(j)) returns (address coin) {\n if (coin == address(inputToken)) inputIndex = j;\n } catch {\n break;\n }\n j++;\n }\n\n inputToken.approve(address(curvePool), inputAmount);\n uint256[2] memory amounts;\n amounts[inputIndex] = inputAmount;\n curvePool.add_liquidity(amounts, 1);\n\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"CurveLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"../external/curve/ICurvePool.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\nimport \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport \"../oracles/default/CurveLpTokenPriceOracleNoRegistry.sol\";\n\n/**\n * @title CurveSwapLiquidator\n * @notice Swaps seized token collateral via Curve as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract CurveSwapLiquidator is IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable, uint256) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address outputTokenAddress,\n address _unwrappedInput,\n address _unwrappedOutput\n ) = abi.decode(strategyData, (CurveV2LpTokenPriceOracleNoRegistry, address, address, address));\n\n if (_unwrappedOutput != address(0)) {\n outputToken = IERC20Upgradeable(_unwrappedOutput);\n } else {\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n if (_unwrappedInput != address(0)) {\n inputToken.approve(address(inputToken), inputAmount);\n inputAmount = IERC4626(address(inputToken)).redeem(inputAmount, address(this), address(this));\n inputToken = IERC20Upgradeable(_unwrappedInput);\n }\n\n address inputTokenAddress = address(inputToken);\n\n ICurvePool curvePool;\n int128 i;\n int128 j;\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, address(outputToken));\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n inputToken.approve(address(curvePool), inputAmount);\n outputAmount = curvePool.exchange(i, j, inputAmount, 0);\n\n if (_unwrappedOutput != address(0)) {\n IERC20Upgradeable(_unwrappedOutput).approve(address(outputTokenAddress), outputAmount);\n IERC4626(outputTokenAddress).deposit(outputAmount, address(this));\n outputToken = IERC20Upgradeable(outputTokenAddress);\n }\n\n outputAmount = outputToken.balanceOf(address(this));\n return (outputToken, outputAmount);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"CurveSwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/CurveSwapLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./CurveSwapLiquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\n\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract CurveSwapLiquidatorFunder is CurveSwapLiquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable, uint256)\n {\n ICurvePool curvePool;\n int128 i;\n int128 j;\n {\n (\n CurveLpTokenPriceOracleNoRegistry curveV1Oracle,\n CurveV2LpTokenPriceOracleNoRegistry curveV2Oracle,\n address inputTokenAddress,\n address outputTokenAddress,\n\n ) = abi.decode(\n strategyData,\n (CurveLpTokenPriceOracleNoRegistry, CurveV2LpTokenPriceOracleNoRegistry, address, address, address)\n );\n\n if (address(curveV2Oracle) != address(0)) {\n (curvePool, i, j) = curveV2Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n if (address(curvePool) == address(0)) {\n (curvePool, i, j) = curveV1Oracle.getPoolForSwap(inputTokenAddress, outputTokenAddress);\n }\n }\n require(address(curvePool) != address(0), \"!curve pool\");\n\n IERC20MetadataUpgradeable inputMetadataToken = IERC20MetadataUpgradeable(curvePool.coins(uint256(int256(i))));\n uint256 inputAmountGuesstimate = guesstimateInputAmount(curvePool, i, j, inputMetadataToken, outputAmount);\n uint256 inputAmount = binSearch(\n curvePool,\n i,\n j,\n (70 * inputAmountGuesstimate) / 100,\n (130 * inputAmountGuesstimate) / 100,\n outputAmount\n );\n\n return (inputMetadataToken, inputAmount);\n }\n\n function guesstimateInputAmount(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n IERC20MetadataUpgradeable inputMetadataToken,\n uint256 outputAmount\n ) internal view returns (uint256) {\n uint256 oneInputToken = 10**inputMetadataToken.decimals();\n uint256 outputTokensForOneInputToken = curvePool.get_dy(i, j, oneInputToken);\n // inputAmount / outputAmount = oneInputToken / outputTokensForOneInputToken\n uint256 inputAmount = (outputAmount * oneInputToken) / outputTokensForOneInputToken;\n return inputAmount;\n }\n\n function binSearch(\n ICurvePool curvePool,\n int128 i,\n int128 j,\n uint256 low,\n uint256 high,\n uint256 value\n ) internal view returns (uint256) {\n if (low >= high) return low;\n\n uint256 mid = (low + high) / 2;\n uint256 outputAmount = curvePool.get_dy(i, j, mid);\n if (outputAmount == 0) revert(\"output amount 0\");\n // output can be up to 10% in excess\n if (outputAmount >= value && outputAmount <= (11 * value) / 10) return mid;\n else if (outputAmount > value) {\n return binSearch(curvePool, i, j, low, mid, value);\n } else {\n return binSearch(curvePool, i, j, mid, high, value);\n }\n }\n\n function name() public pure override(CurveSwapLiquidator, IRedemptionStrategy) returns (string memory) {\n return \"CurveSwapLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/IFundsConversionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./IRedemptionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IFundsConversionStrategy is IRedemptionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount);\n}\n" + }, + "contracts/liquidators/IRedemptionStrategy.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\n/**\n * @title IRedemptionStrategy\n * @notice Redeems seized wrapped token collateral for an underlying token for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface IRedemptionStrategy {\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount);\n\n function name() external view returns (string memory);\n}\n" + }, + "contracts/liquidators/JarvisLiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { IERC20MetadataUpgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { ISynthereumLiquidityPool } from \"../external/jarvis/ISynthereumLiquidityPool.sol\";\n\ncontract JarvisLiquidatorFunder is IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n\n // approve so the pool can pull out the input tokens\n inputToken.approve(address(pool), inputAmount);\n\n IERC20Upgradeable collateralToken = pool.collateralToken();\n IERC20Upgradeable syntheticToken = pool.syntheticToken();\n\n if (inputToken == syntheticToken) {\n outputToken = collateralToken;\n\n uint256 shutdownPrice = 0;\n // TODO figure out why this method was removed and what to use instead\n try pool.emergencyShutdownPrice() returns (uint256 price) {\n shutdownPrice = price;\n } catch {}\n\n if (shutdownPrice > 0) {\n // emergency shutdowns cannot be reverted, so this corner case must be covered\n (, uint256 collateralSettled) = pool.settleEmergencyShutdown();\n outputAmount = collateralSettled;\n // outputToken = collateralToken;\n } else {\n // redeem the underlying BUSD\n // fetch the estimated redeemable collateral in BUSD, less the fee paid\n (uint256 redeemableCollateralAmount, ) = pool.getRedeemTradeInfo(inputAmount);\n\n (uint256 collateralAmountReceived, ) = pool.redeem(\n ISynthereumLiquidityPool.RedeemParams(inputAmount, redeemableCollateralAmount, block.timestamp, address(this))\n );\n\n outputAmount = collateralAmountReceived;\n }\n } else if (inputToken == collateralToken) {\n outputToken = syntheticToken;\n\n // mint jBRL from the supplied bUSD\n (uint256 synthTokensReceived, ) = pool.getMintTradeInfo(inputAmount);\n\n (uint256 syntheticTokensMinted, ) = pool.mint(\n ISynthereumLiquidityPool.MintParams(synthTokensReceived, inputAmount, block.timestamp, address(this))\n );\n\n outputAmount = syntheticTokensMinted;\n } else {\n revert(\"unknown input token\");\n }\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address inputTokenAddress, address poolAddress, ) = abi.decode(strategyData, (address, address, uint256));\n\n inputToken = IERC20Upgradeable(inputTokenAddress);\n\n uint8 decimals = 18;\n try IERC20MetadataUpgradeable(inputTokenAddress).decimals() returns (uint8 dec) {\n decimals = dec;\n } catch {}\n uint256 ONE = 10**decimals;\n\n ISynthereumLiquidityPool pool = ISynthereumLiquidityPool(poolAddress);\n if (inputToken == pool.syntheticToken()) {\n // collateralAmountReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / collateralAmountReceived\n (uint256 collateralAmountReceived, ) = ISynthereumLiquidityPool(poolAddress).getRedeemTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, collateralAmountReceived);\n } else if (inputToken == pool.collateralToken()) {\n // synthTokensReceived / ONE = outputAmount / inputAmount\n // => inputAmount = (ONE * outputAmount) / synthTokensReceived\n (uint256 synthTokensReceived, ) = ISynthereumLiquidityPool(poolAddress).getMintTradeInfo(ONE);\n inputAmount = ONE.mulDivUp(outputAmount, synthTokensReceived);\n } else {\n revert(\"unknown input token\");\n }\n }\n\n function name() public pure returns (string memory) {\n return \"JarvisLiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/KimUniV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\ncontract KimUniV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(\n inputAmount,\n 0,\n swapPath,\n address(this),\n address(0), // referrer\n block.timestamp\n );\n }\n\n function name() public pure virtual returns (string memory) {\n return \"KimUniV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/registry/ILiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ILiquidatorsRegistryStorage {\n function redemptionStrategiesByName(string memory name) external view returns (IRedemptionStrategy);\n\n function redemptionStrategiesByTokens(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy);\n\n function defaultOutputToken(IERC20Upgradeable inputToken) external view returns (IERC20Upgradeable);\n\n function owner() external view returns (address);\n\n function uniswapV3Fees(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external view returns (uint24);\n\n function customUniV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (address);\n}\n\ninterface ILiquidatorsRegistryExtension {\n function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory);\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData);\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IRedemptionStrategy strategy, bytes memory strategyData);\n\n function getAllRedemptionStrategies() external view returns (address[] memory);\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage);\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256);\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage);\n}\n\ninterface ILiquidatorsRegistrySecondExtension {\n function getAllPairsStrategies()\n external\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n );\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool);\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool);\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool);\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external;\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external;\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external;\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external;\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external;\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external;\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external;\n\n function optimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (IERC20Upgradeable[] memory);\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external;\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address);\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external;\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24);\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external;\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool);\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external;\n}\n\ninterface ILiquidatorsRegistry is\n ILiquidatorsRegistryExtension,\n ILiquidatorsRegistrySecondExtension,\n ILiquidatorsRegistryStorage\n{}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistry.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../../ionic/DiamondExtension.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\nimport \"./LiquidatorsRegistryExtension.sol\";\n\ncontract LiquidatorsRegistry is LiquidatorsRegistryStorage, DiamondBase {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n constructor(AddressesProvider _ap) SafeOwnable() {\n ap = _ap;\n }\n\n /**\n * @dev register a logic extension\n * @param extensionToAdd the extension whose functions are to be added\n * @param extensionToReplace the extension whose functions are to be removed/replaced\n */\n function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace)\n public\n override\n onlyOwner\n {\n LibDiamond.registerExtension(extensionToAdd, extensionToReplace);\n }\n\n function asExtension() public view returns (LiquidatorsRegistryExtension) {\n return LiquidatorsRegistryExtension(address(this));\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../IRedemptionStrategy.sol\";\nimport \"../../ionic/DiamondExtension.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\n\nimport { IRouter_Aerodrome as IAerodromeV2Router } from \"../../external/aerodrome/IAerodromeRouter.sol\";\nimport { IRouter_Velodrome as IVelodromeV2Router } from \"../../external/velodrome/IVelodromeRouter.sol\";\nimport { IRouter } from \"../../external/solidly/IRouter.sol\";\nimport { IPair } from \"../../external/solidly/IPair.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ncontract LiquidatorsRegistryExtension is LiquidatorsRegistryStorage, DiamondExtension, ILiquidatorsRegistryExtension {\n using EnumerableSet for EnumerableSet.AddressSet;\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n error NoRedemptionPath();\n error OutputTokenMismatch();\n\n event SlippageUpdated(\n IERC20Upgradeable indexed from,\n IERC20Upgradeable indexed to,\n uint256 prevValue,\n uint256 newValue\n );\n\n // @notice maximum slippage in swaps, in bps\n uint256 public constant MAX_SLIPPAGE = 900; // 9%\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 7;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.getRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this.getInputTokensByOutputToken.selector;\n functionSelectors[--fnsCount] = this.swap.selector;\n functionSelectors[--fnsCount] = this.getAllRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.amountOutAndSlippageOfSwap.selector;\n functionSelectors[--fnsCount] = this.getSlippage.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function getSlippage(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) external view returns (uint256 slippage) {\n slippage = conversionSlippage[inputToken][outputToken];\n // TODO slippage == 0 should be allowed\n if (slippage == 0) return MAX_SLIPPAGE;\n }\n\n function getAllRedemptionStrategies() public view returns (address[] memory) {\n return redemptionStrategies.values();\n }\n\n function amountOutAndSlippageOfSwap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) external returns (uint256 outputAmount, uint256 slippage) {\n if (inputAmount == 0) return (0, 0);\n\n outputAmount = swap(inputToken, inputAmount, outputToken);\n if (outputAmount == 0) return (0, 0);\n\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n uint256 inputTokenPrice = mpo.price(address(inputToken));\n uint256 outputTokenPrice = mpo.price(address(outputToken));\n\n uint256 inputTokensValue = inputAmount * toScaledPrice(inputTokenPrice, inputToken);\n uint256 outputTokensValue = outputAmount * toScaledPrice(outputTokenPrice, outputToken);\n\n if (outputTokensValue < inputTokensValue) {\n slippage = ((inputTokensValue - outputTokensValue) * 10000) / inputTokensValue;\n }\n // min slippage should be non-zero\n // just in case of rounding errors\n slippage += 1;\n\n // cache the slippage\n uint256 prevValue = conversionSlippage[inputToken][outputToken];\n if (prevValue == 0 || block.timestamp - conversionSlippageUpdated[inputToken][outputToken] > 5000) {\n emit SlippageUpdated(inputToken, outputToken, prevValue, slippage);\n\n conversionSlippage[inputToken][outputToken] = slippage;\n conversionSlippageUpdated[inputToken][outputToken] = block.timestamp;\n }\n }\n\n /// @dev returns price scaled to 1e36 - decimals\n function toScaledPrice(uint256 unscaledPrice, IERC20Upgradeable token) internal view returns (uint256) {\n uint256 tokenDecimals = uint256(ERC20Upgradeable(address(token)).decimals());\n return\n tokenDecimals <= 18\n ? uint256(unscaledPrice) * (10 ** (18 - tokenDecimals))\n : uint256(unscaledPrice) / (10 ** (tokenDecimals - 18));\n }\n\n function swap(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IERC20Upgradeable outputToken\n ) public returns (uint256 outputAmount) {\n inputToken.safeTransferFrom(msg.sender, address(this), inputAmount);\n outputAmount = convertAllTo(inputToken, outputToken);\n outputToken.safeTransfer(msg.sender, outputAmount);\n }\n\n function convertAllTo(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) private returns (uint256) {\n uint256 inputAmount = inputToken.balanceOf(address(this));\n (IRedemptionStrategy[] memory redemptionStrategies, bytes[] memory strategiesData) = getRedemptionStrategies(\n inputToken,\n outputToken\n );\n\n if (redemptionStrategies.length == 0) revert NoRedemptionPath();\n\n IERC20Upgradeable swapInputToken = inputToken;\n uint256 swapInputAmount = inputAmount;\n for (uint256 i = 0; i < redemptionStrategies.length; i++) {\n IRedemptionStrategy redemptionStrategy = redemptionStrategies[i];\n bytes memory strategyData = strategiesData[i];\n (IERC20Upgradeable swapOutputToken, uint256 swapOutputAmount) = convertCustomFunds(\n swapInputToken,\n swapInputAmount,\n redemptionStrategy,\n strategyData\n );\n swapInputAmount = swapOutputAmount;\n swapInputToken = swapOutputToken;\n }\n\n if (swapInputToken != outputToken) revert OutputTokenMismatch();\n return outputToken.balanceOf(address(this));\n }\n\n function convertCustomFunds(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n IRedemptionStrategy strategy,\n bytes memory strategyData\n ) private returns (IERC20Upgradeable, uint256) {\n bytes memory returndata = _functionDelegateCall(\n address(strategy),\n abi.encodeWithSelector(strategy.redeem.selector, inputToken, inputAmount, strategyData)\n );\n return abi.decode(returndata, (IERC20Upgradeable, uint256));\n }\n\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n function _verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) private pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n if (returndata.length > 0) {\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 function getInputTokensByOutputToken(IERC20Upgradeable outputToken) external view returns (address[] memory) {\n return inputTokensByOutputToken[outputToken].values();\n }\n\n function getRedemptionStrategies(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) {\n IERC20Upgradeable tokenToRedeem = inputToken;\n IERC20Upgradeable targetOutputToken = outputToken;\n IRedemptionStrategy[] memory strategiesTemp = new IRedemptionStrategy[](10);\n bytes[] memory strategiesDataTemp = new bytes[](10);\n IERC20Upgradeable[] memory tokenPath = new IERC20Upgradeable[](10);\n IERC20Upgradeable[] memory optimalPath = new IERC20Upgradeable[](0);\n uint256 optimalPathIterator = 0;\n\n uint256 k = 0;\n while (tokenToRedeem != targetOutputToken) {\n IERC20Upgradeable nextRedeemedToken;\n IRedemptionStrategy directStrategy = redemptionStrategiesByTokens[tokenToRedeem][targetOutputToken];\n if (address(directStrategy) != address(0)) {\n nextRedeemedToken = targetOutputToken;\n } else {\n // check if an optimal path is preconfigured\n if (optimalPath.length == 0 && _optimalSwapPath[tokenToRedeem][targetOutputToken].length != 0) {\n optimalPath = _optimalSwapPath[tokenToRedeem][targetOutputToken];\n }\n if (optimalPath.length != 0 && optimalPathIterator < optimalPath.length) {\n nextRedeemedToken = optimalPath[optimalPathIterator++];\n } else {\n // else if no optimal path is available, use the default\n nextRedeemedToken = defaultOutputToken[tokenToRedeem];\n }\n }\n\n // check if going in an endless loop\n for (uint256 i = 0; i < tokenPath.length; i++) {\n if (nextRedeemedToken == tokenPath[i]) break;\n }\n\n (IRedemptionStrategy strategy, bytes memory strategyData) = getRedemptionStrategy(\n tokenToRedeem,\n nextRedeemedToken\n );\n if (address(strategy) == address(0)) break;\n\n strategiesTemp[k] = strategy;\n strategiesDataTemp[k] = strategyData;\n tokenPath[k] = nextRedeemedToken;\n tokenToRedeem = nextRedeemedToken;\n\n k++;\n if (k == 10) break;\n }\n\n strategies = new IRedemptionStrategy[](k);\n strategiesData = new bytes[](k);\n\n for (uint8 i = 0; i < k; i++) {\n strategies[i] = strategiesTemp[i];\n strategiesData[i] = strategiesDataTemp[i];\n }\n }\n\n function getRedemptionStrategy(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public view returns (IRedemptionStrategy strategy, bytes memory strategyData) {\n strategy = redemptionStrategiesByTokens[inputToken][outputToken];\n\n if (isStrategy(strategy, \"UniswapV2LiquidatorFunder\") || isStrategy(strategy, \"KimUniV2Liquidator\")) {\n strategyData = uniswapV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"UniswapV3LiquidatorFunder\")) {\n strategyData = uniswapV3LiquidatorFunderData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AlgebraSwapLiquidator\")) {\n strategyData = algebraSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeV2Liquidator\")) {\n strategyData = aerodromeV2LiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"AerodromeCLLiquidator\")) {\n strategyData = aerodromeCLLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"CurveSwapLiquidator\")) {\n strategyData = curveSwapLiquidatorData(inputToken, outputToken);\n } else if (isStrategy(strategy, \"VelodromeV2Liquidator\")) {\n strategyData = velodromeV2LiquidatorData(inputToken, outputToken);\n } else {\n revert(\"no strategy data\");\n }\n }\n\n function isStrategy(IRedemptionStrategy strategy, string memory name) internal view returns (bool) {\n return address(strategy) != address(0) && address(strategy) == address(redemptionStrategiesByName[name]);\n }\n\n function pickPreferredToken(address[] memory tokens, address strategyOutputToken) internal view returns (address) {\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == strategyOutputToken) return strategyOutputToken;\n }\n address wnative = ap.getAddress(\"wtoken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wnative) return wnative;\n }\n address stableToken = ap.getAddress(\"stableToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == stableToken) return stableToken;\n }\n address wbtc = ap.getAddress(\"wBTCToken\");\n for (uint256 i = 0; i < tokens.length; i++) {\n if (tokens[i] == wbtc) return wbtc;\n }\n return tokens[0];\n }\n\n function getUniswapV3Router(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (address) {\n address customRouter = customUniV3Router[inputToken][outputToken];\n if (customRouter == address(0)) {\n customRouter = customUniV3Router[outputToken][inputToken];\n }\n\n if (customRouter != address(0)) {\n return customRouter;\n } else {\n // get asset specific router or default\n return ap.getAddress(\"UNISWAP_V3_ROUTER\");\n }\n }\n\n function getUniswapV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"IUniswapV2Router02\");\n }\n\n function getAerodromeV2Router(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_V2_ROUTER\");\n }\n\n function getAerodromeCLRouter(IERC20Upgradeable inputToken) internal view returns (address) {\n // get asset specific router or default\n return ap.getAddress(\"AERODROME_CL_ROUTER\");\n }\n\n function uniswapV3LiquidatorFunderData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n uint24 fee = uniswapV3Fees[inputToken][outputToken];\n if (fee == 0) fee = uniswapV3Fees[outputToken][inputToken];\n if (fee == 0) fee = 500;\n\n address router = getUniswapV3Router(inputToken, outputToken);\n strategyData = abi.encode(inputToken, outputToken, fee, router, ap.getAddress(\"Quoter\"));\n }\n\n function getWrappedToUnwrapped4626(IERC20Upgradeable inputToken) internal view returns (address) {\n return _wrappedToUnwrapped4626[address(inputToken)];\n }\n\n function getAeroCLTickSpacing(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (int24) {\n int24 tickSpacing = _aeroCLTickSpacings[address(inputToken)][address(outputToken)];\n if (tickSpacing == 0) {\n tickSpacing = 1;\n }\n return tickSpacing;\n }\n\n function aeroV2IsStable(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) internal view returns (bool) {\n return _aeroV2IsStable[address(inputToken)][address(outputToken)];\n }\n\n function uniswapV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IERC20Upgradeable[] memory swapPath = new IERC20Upgradeable[](2);\n swapPath[0] = inputToken;\n swapPath[1] = outputToken;\n strategyData = abi.encode(getUniswapV2Router(inputToken), swapPath);\n }\n\n function aerodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IAerodromeV2Router.Route[] memory swapPath = new IAerodromeV2Router.Route[](1);\n swapPath[0] = IAerodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken),\n factory: ap.getAddress(\"AERODROME_V2_FACTORY\")\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n\n function aerodromeCLLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n inputToken,\n outputToken,\n getAerodromeCLRouter(inputToken),\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken),\n getAeroCLTickSpacing(inputToken, outputToken)\n );\n }\n\n function algebraSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(outputToken, ap.getAddress(\"ALGEBRA_SWAP_ROUTER\"));\n }\n\n function curveSwapLiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n strategyData = abi.encode(\n ap.getAddress(\"CURVE_V2_ORACLE_NO_REGISTRY\"),\n outputToken,\n getWrappedToUnwrapped4626(inputToken),\n getWrappedToUnwrapped4626(outputToken)\n );\n }\n\n function velodromeV2LiquidatorData(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) internal view returns (bytes memory strategyData) {\n IVelodromeV2Router.Route[] memory swapPath = new IVelodromeV2Router.Route[](1);\n swapPath[0] = IVelodromeV2Router.Route({\n from: address(inputToken),\n to: address(outputToken),\n stable: aeroV2IsStable(inputToken, outputToken)\n });\n strategyData = abi.encode(getAerodromeV2Router(inputToken), swapPath);\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistrySecondExtension.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"./ILiquidatorsRegistry.sol\";\nimport \"./LiquidatorsRegistryStorage.sol\";\n\nimport \"../../ionic/DiamondExtension.sol\";\n\ncontract LiquidatorsRegistrySecondExtension is\n LiquidatorsRegistryStorage,\n DiamondExtension,\n ILiquidatorsRegistrySecondExtension\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n function _getExtensionFunctions() external pure override returns (bytes4[] memory) {\n uint8 fnsCount = 20;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getAllPairsStrategies.selector;\n functionSelectors[--fnsCount] = this.pairsStrategiesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsFeesMatch.selector;\n functionSelectors[--fnsCount] = this.uniswapPairsRoutersMatch.selector;\n functionSelectors[--fnsCount] = this._setSlippages.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Fees.selector;\n functionSelectors[--fnsCount] = this._setUniswapV3Routers.selector;\n functionSelectors[--fnsCount] = this._setDefaultOutputToken.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._setRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this._removeRedemptionStrategy.selector;\n functionSelectors[--fnsCount] = this._resetRedemptionStrategies.selector;\n functionSelectors[--fnsCount] = this.optimalSwapPath.selector;\n functionSelectors[--fnsCount] = this._setOptimalSwapPath.selector;\n functionSelectors[--fnsCount] = this.wrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this.aeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this.aeroV2IsStable.selector;\n functionSelectors[--fnsCount] = this._setWrappedToUnwrapped4626.selector;\n functionSelectors[--fnsCount] = this._setAeroCLTickSpacings.selector;\n functionSelectors[--fnsCount] = this._setAeroV2IsStable.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n\n function _setSlippages(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint256[] calldata slippages\n ) external onlyOwner {\n require(slippages.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < slippages.length; i++) {\n conversionSlippage[inputTokens[i]][outputTokens[i]] = slippages[i];\n }\n }\n\n function _setUniswapV3Fees(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n uint24[] calldata fees\n ) external onlyOwner {\n require(fees.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < fees.length; i++) {\n uniswapV3Fees[inputTokens[i]][outputTokens[i]] = fees[i];\n }\n }\n\n function _setUniswapV3Routers(\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens,\n address[] calldata routers\n ) external onlyOwner {\n require(routers.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n for (uint256 i = 0; i < routers.length; i++) {\n customUniV3Router[inputTokens[i]][outputTokens[i]] = routers[i];\n }\n }\n\n function _setDefaultOutputToken(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken) external onlyOwner {\n defaultOutputToken[inputToken] = outputToken;\n }\n\n function _setRedemptionStrategy(\n IRedemptionStrategy strategy,\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken\n ) public onlyOwner {\n string memory name = strategy.name();\n IRedemptionStrategy oldStrategy = redemptionStrategiesByName[name];\n\n redemptionStrategiesByTokens[inputToken][outputToken] = strategy;\n redemptionStrategiesByName[name] = strategy;\n\n redemptionStrategies.remove(address(oldStrategy));\n redemptionStrategies.add(address(strategy));\n\n if (defaultOutputToken[inputToken] == IERC20Upgradeable(address(0))) {\n defaultOutputToken[inputToken] = outputToken;\n }\n inputTokensByOutputToken[outputToken].add(address(inputToken));\n outputTokensSet.add(address(outputToken));\n }\n\n function _setRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _resetRedemptionStrategies(\n IRedemptionStrategy[] calldata strategies,\n IERC20Upgradeable[] calldata inputTokens,\n IERC20Upgradeable[] calldata outputTokens\n ) external onlyOwner {\n require(strategies.length == inputTokens.length && inputTokens.length == outputTokens.length, \"!arrays len\");\n\n // empty the input/output token mappings/sets\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n outputTokensSet.remove(_outputTokens[i]);\n }\n\n // empty the strategies mappings/sets\n address[] memory _currentStrategies = redemptionStrategies.values();\n for (uint256 i = 0; i < _currentStrategies.length; i++) {\n IRedemptionStrategy _currentStrategy = IRedemptionStrategy(_currentStrategies[i]);\n string memory _name = _currentStrategy.name();\n redemptionStrategiesByName[_name] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(_currentStrategies[i]);\n }\n\n // write the new strategies and their tokens configs\n for (uint256 i = 0; i < strategies.length; i++) {\n _setRedemptionStrategy(strategies[i], inputTokens[i], outputTokens[i]);\n }\n }\n\n function _removeRedemptionStrategy(IRedemptionStrategy strategyToRemove) external onlyOwner {\n // check all the input/output tokens if they match the strategy to remove\n address[] memory _outputTokens = outputTokensSet.values();\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n IRedemptionStrategy _currentStrategy = redemptionStrategiesByTokens[_inputToken][_outputToken];\n\n // only nullify the input/output tokens config if the strategy matches\n if (_currentStrategy == strategyToRemove) {\n redemptionStrategiesByTokens[_inputToken][_outputToken] = IRedemptionStrategy(address(0));\n inputTokensByOutputToken[_outputToken].remove(_inputTokens[j]);\n if (defaultOutputToken[_inputToken] == _outputToken) {\n defaultOutputToken[_inputToken] = IERC20Upgradeable(address(0));\n }\n }\n }\n if (inputTokensByOutputToken[_outputToken].length() == 0) {\n outputTokensSet.remove(address(_outputToken));\n }\n }\n\n redemptionStrategiesByName[strategyToRemove.name()] = IRedemptionStrategy(address(0));\n redemptionStrategies.remove(address(strategyToRemove));\n }\n\n function uniswapPairsFeesMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n uint256[] calldata configFees\n ) external view returns (bool) {\n // find a match for each config fee\n for (uint256 i = 0; i < configFees.length; i++) {\n if (uniswapV3Fees[configInputTokens[i]][configOutputTokens[i]] != configFees[i]) return false;\n }\n\n return true;\n }\n\n function uniswapPairsRoutersMatch(\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens,\n address[] calldata configRouters\n ) external view returns (bool) {\n // find a match for each config router\n for (uint256 i = 0; i < configRouters.length; i++) {\n if (customUniV3Router[configInputTokens[i]][configOutputTokens[i]] != configRouters[i]) return false;\n }\n\n return true;\n }\n\n function pairsStrategiesMatch(\n IRedemptionStrategy[] calldata configStrategies,\n IERC20Upgradeable[] calldata configInputTokens,\n IERC20Upgradeable[] calldata configOutputTokens\n ) external view returns (bool) {\n (\n IRedemptionStrategy[] memory onChainStrategies,\n IERC20Upgradeable[] memory onChainInputTokens,\n IERC20Upgradeable[] memory onChainOutputTokens\n ) = getAllPairsStrategies();\n // find a match for each config strategy\n for (uint256 i = 0; i < configStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < onChainStrategies.length; j++) {\n if (\n onChainStrategies[j] == configStrategies[i] &&\n onChainInputTokens[j] == configInputTokens[i] &&\n onChainOutputTokens[j] == configOutputTokens[i]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n // find a match for each on-chain strategy\n for (uint256 i = 0; i < onChainStrategies.length; i++) {\n bool foundMatch = false;\n for (uint256 j = 0; j < configStrategies.length; j++) {\n if (\n onChainStrategies[i] == configStrategies[j] &&\n onChainInputTokens[i] == configInputTokens[j] &&\n onChainOutputTokens[i] == configOutputTokens[j]\n ) {\n foundMatch = true;\n break;\n }\n }\n if (!foundMatch) return false;\n }\n\n return true;\n }\n\n function getAllPairsStrategies()\n public\n view\n returns (\n IRedemptionStrategy[] memory strategies,\n IERC20Upgradeable[] memory inputTokens,\n IERC20Upgradeable[] memory outputTokens\n )\n {\n address[] memory _outputTokens = outputTokensSet.values();\n uint256 pairsCounter = 0;\n\n {\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n pairsCounter += _inputTokens.length;\n }\n\n strategies = new IRedemptionStrategy[](pairsCounter);\n inputTokens = new IERC20Upgradeable[](pairsCounter);\n outputTokens = new IERC20Upgradeable[](pairsCounter);\n }\n\n pairsCounter = 0;\n for (uint256 i = 0; i < _outputTokens.length; i++) {\n IERC20Upgradeable _outputToken = IERC20Upgradeable(_outputTokens[i]);\n address[] memory _inputTokens = inputTokensByOutputToken[_outputToken].values();\n for (uint256 j = 0; j < _inputTokens.length; j++) {\n IERC20Upgradeable _inputToken = IERC20Upgradeable(_inputTokens[j]);\n strategies[pairsCounter] = redemptionStrategiesByTokens[_inputToken][_outputToken];\n inputTokens[pairsCounter] = _inputToken;\n outputTokens[pairsCounter] = _outputToken;\n pairsCounter++;\n }\n }\n }\n\n function optimalSwapPath(IERC20Upgradeable inputToken, IERC20Upgradeable outputToken)\n external\n view\n returns (IERC20Upgradeable[] memory)\n {\n return _optimalSwapPath[inputToken][outputToken];\n }\n\n function _setOptimalSwapPath(\n IERC20Upgradeable inputToken,\n IERC20Upgradeable outputToken,\n IERC20Upgradeable[] calldata optimalPath\n ) external onlyOwner {\n _optimalSwapPath[inputToken][outputToken] = optimalPath;\n }\n\n function wrappedToUnwrapped4626(address wrapped) external view returns (address) {\n return _wrappedToUnwrapped4626[wrapped];\n }\n\n function aeroCLTickSpacings(address inputToken, address outputToken) external view returns (int24) {\n return _aeroCLTickSpacings[inputToken][outputToken];\n }\n\n function aeroV2IsStable(address inputToken, address outputToken) external view returns (bool) {\n return _aeroV2IsStable[inputToken][outputToken];\n }\n\n function _setWrappedToUnwrapped4626(address wrapped, address unwrapped) external onlyOwner {\n _wrappedToUnwrapped4626[wrapped] = unwrapped;\n }\n\n function _setAeroCLTickSpacings(address inputToken, address outputToken, int24 tickSpacing) external onlyOwner {\n _aeroCLTickSpacings[inputToken][outputToken] = tickSpacing;\n }\n\n function _setAeroV2IsStable(address inputToken, address outputToken, bool isStable) external onlyOwner {\n _aeroV2IsStable[inputToken][outputToken] = isStable;\n }\n}\n" + }, + "contracts/liquidators/registry/LiquidatorsRegistryStorage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.10;\n\nimport \"../IRedemptionStrategy.sol\";\nimport { SafeOwnable } from \"../../ionic/SafeOwnable.sol\";\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nabstract contract LiquidatorsRegistryStorage is SafeOwnable {\n AddressesProvider public ap;\n\n EnumerableSet.AddressSet internal redemptionStrategies;\n mapping(string => IRedemptionStrategy) public redemptionStrategiesByName;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IRedemptionStrategy)) public redemptionStrategiesByTokens;\n mapping(IERC20Upgradeable => IERC20Upgradeable) public defaultOutputToken;\n mapping(IERC20Upgradeable => EnumerableSet.AddressSet) internal inputTokensByOutputToken;\n EnumerableSet.AddressSet internal outputTokensSet;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippage;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint256)) internal conversionSlippageUpdated;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => uint24)) public uniswapV3Fees;\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => address)) public customUniV3Router;\n\n mapping(IERC20Upgradeable => mapping(IERC20Upgradeable => IERC20Upgradeable[])) internal _optimalSwapPath;\n mapping(address => address) internal _wrappedToUnwrapped4626;\n mapping(address => mapping(address => int24)) internal _aeroCLTickSpacings;\n mapping(address => mapping(address => bool)) internal _aeroV2IsStable;\n}\n" + }, + "contracts/liquidators/SolidlyLpTokenLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport \"../external/solidly/IRouter.sol\";\nimport \"../external/solidly/IPair.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlyLpTokenLiquidator\n * @notice Exchanges seized Solidly LP token collateral for underlying tokens for use as a step in a liquidation.\n */\ncontract SolidlyLpTokenLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @dev Internal function to approve unlimited tokens of `erc20Contract` to `to`.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address to,\n uint256 minAmount\n ) internal {\n uint256 allowance = token.allowance(address(this), to);\n\n if (allowance < minAmount) {\n if (allowance > 0) token.safeApprove(to, 0);\n token.safeApprove(to, type(uint256).max);\n }\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Exit Uniswap pool\n IPair pair = IPair(address(inputToken));\n bool stable = pair.stable();\n\n address token0 = pair.token0();\n address token1 = pair.token1();\n pair.transfer(address(pair), inputAmount);\n (uint256 amount0, uint256 amount1) = pair.burn(address(this));\n\n // Swap underlying tokens\n (IRouter solidlyRouter, address tokenTo) = abi.decode(strategyData, (IRouter, address));\n\n if (tokenTo != token0) {\n safeApprove(IERC20Upgradeable(token0), address(solidlyRouter), amount0);\n solidlyRouter.swapExactTokensForTokensSimple(amount0, 0, token0, tokenTo, stable, address(this), block.timestamp);\n } else {\n safeApprove(IERC20Upgradeable(token1), address(solidlyRouter), amount1);\n solidlyRouter.swapExactTokensForTokensSimple(amount1, 0, token1, tokenTo, stable, address(this), block.timestamp);\n }\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenLiquidator\";\n }\n}\n\ncontract SolidlyLpTokenWrapper is IRedemptionStrategy {\n struct WrapSolidlyLpTokenVars {\n uint256 amountToSwapOfToken0ForToken1;\n uint256 amountToSwapOfToken1ForToken0;\n IRouter solidlyRouter;\n IERC20Upgradeable token0;\n IERC20Upgradeable token1;\n bool stable;\n IPair pair;\n IRouter.Route[] swapPath0;\n IRouter.Route[] swapPath1;\n uint256 ratio;\n }\n\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n WrapSolidlyLpTokenVars memory vars;\n (vars.solidlyRouter, vars.pair, vars.swapPath0, vars.swapPath1) = abi.decode(\n strategyData,\n (IRouter, IPair, IRouter.Route[], IRouter.Route[])\n );\n vars.token0 = IERC20Upgradeable(vars.pair.token0());\n vars.token1 = IERC20Upgradeable(vars.pair.token1());\n vars.stable = vars.pair.stable();\n\n // calculate the amount for token0 or token1 that needs to be swapped for the other\n {\n vars.amountToSwapOfToken1ForToken0 = inputAmount / 2;\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n if (vars.token0 == inputToken) {\n uint256 out1 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken0ForToken1, vars.swapPath0)[\n vars.swapPath0.length\n ];\n // price1For0 is scaled to 18 + token1.decimals - token0.decimals\n uint256 price1For0 = (out1 * 1e18) / vars.amountToSwapOfToken0ForToken1;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n vars.amountToSwapOfToken1ForToken0,\n out1\n );\n\n vars.ratio = (amount1 * 1e36) / (amount0 * price1For0);\n }\n\n if (vars.token1 == inputToken) {\n uint256 out0 = vars.solidlyRouter.getAmountsOut(vars.amountToSwapOfToken1ForToken0, vars.swapPath1)[\n vars.swapPath1.length\n ];\n // price0For1 is scaled to 18 + token0.decimals - token1.decimals\n uint256 price0For1 = (out0 * 1e18) / vars.amountToSwapOfToken1ForToken0;\n // use the quoted input amounts to check what is the actual required ratio of inputs\n (uint256 amount0, uint256 amount1, ) = vars.solidlyRouter.quoteAddLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n out0,\n vars.amountToSwapOfToken0ForToken1\n );\n\n vars.ratio = (amount1 * price0For1) / amount0;\n }\n\n // recalculate the amounts to swap based on the ratio of the value of the required input amounts\n vars.amountToSwapOfToken1ForToken0 = (inputAmount * 1e18) / (vars.ratio + 1e18);\n vars.amountToSwapOfToken0ForToken1 = inputAmount - vars.amountToSwapOfToken1ForToken0;\n }\n\n // swap a part of the input token amount for the other token\n if (vars.token0 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken0ForToken1);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken0ForToken1,\n 0,\n vars.swapPath0,\n address(this),\n block.timestamp\n );\n }\n if (vars.token1 == inputToken) {\n inputToken.approve(address(vars.solidlyRouter), vars.amountToSwapOfToken1ForToken0);\n vars.solidlyRouter.swapExactTokensForTokens(\n vars.amountToSwapOfToken1ForToken0,\n 0,\n vars.swapPath1,\n address(this),\n block.timestamp\n );\n }\n\n // provide the liquidity\n uint256 token0Balance = vars.token0.balanceOf(address(this));\n uint256 token1Balance = vars.token1.balanceOf(address(this));\n\n vars.token0.approve(address(vars.solidlyRouter), token0Balance);\n vars.token1.approve(address(vars.solidlyRouter), token1Balance);\n vars.solidlyRouter.addLiquidity(\n address(vars.token0),\n address(vars.token1),\n vars.stable,\n token0Balance,\n token1Balance,\n 1,\n 1,\n address(this),\n block.timestamp\n );\n\n outputToken = IERC20Upgradeable(address(vars.pair));\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlyLpTokenWrapper\";\n }\n}\n" + }, + "contracts/liquidators/SolidlySwapLiquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport { IRouter } from \"../external/solidly/IRouter.sol\";\n\nimport \"./IRedemptionStrategy.sol\";\n\n/**\n * @title SolidlySwapLiquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Solidly router for use as a step in a liquidation.\n */\ncontract SolidlySwapLiquidator is IRedemptionStrategy {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Solidly router and path\n (IRouter solidlyRouter, address tokenTo, bool stable) = abi.decode(strategyData, (IRouter, address, bool));\n\n // Swap underlying tokens\n inputToken.approve(address(solidlyRouter), inputAmount);\n solidlyRouter.swapExactTokensForTokensSimple(\n inputAmount,\n 0,\n address(inputToken),\n tokenTo,\n stable,\n address(this),\n block.timestamp\n );\n\n // Get new collateral\n outputToken = IERC20Upgradeable(tokenTo);\n outputAmount = outputToken.balanceOf(address(this));\n }\n\n function name() public pure returns (string memory) {\n return \"SolidlySwapLiquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./BaseUniswapV2Liquidator.sol\";\n\n/**\n * @title UniswapV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Uniswap V2 router for use as a step in a liquidation.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract UniswapV2Liquidator is BaseUniswapV2Liquidator {\n function _swap(\n IUniswapV2Router02 uniswapV2Router,\n uint256 inputAmount,\n address[] memory swapPath\n ) internal override {\n uniswapV2Router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"UniswapV2Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV2LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { UniswapV2Liquidator } from \"./UniswapV2Liquidator.sol\";\nimport \"./IFundsConversionStrategy.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"../external/uniswap/IUniswapV2Router02.sol\";\n\ncontract UniswapV2LiquidatorFunder is UniswapV2Liquidator, IFundsConversionStrategy {\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (IUniswapV2Router02 uniswapV2Router, address[] memory swapPath) = abi.decode(\n strategyData,\n (IUniswapV2Router02, address[])\n );\n require(swapPath.length >= 2, \"Invalid UniswapLiquidator swap path.\");\n\n uint256[] memory amounts = uniswapV2Router.getAmountsIn(outputAmount, swapPath);\n\n inputAmount = amounts[0];\n inputToken = IERC20Upgradeable(swapPath[0]);\n }\n\n function name() public pure override(UniswapV2Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV2LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport { IV3SwapRouter } from \"../external/uniswap/IV3SwapRouter.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract UniswapV3Liquidator is IRedemptionStrategy {\n /**\n * @dev Redeems `inputToken` for `outputToken` where `inputAmount` < `outputAmount`\n * @param inputToken Address of the token\n * @param inputAmount input amount\n * @param strategyData context specific data like input token, pool address and tx expiratio period\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n (, address _outputToken, uint24 fee, IV3SwapRouter swapRouter, ) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, address)\n );\n outputToken = IERC20Upgradeable(_outputToken);\n\n inputToken.approve(address(swapRouter), inputAmount);\n\n outputAmount = swapRouter.exactInputSingle(\n IV3SwapRouter.ExactInputSingleParams(\n address(inputToken),\n _outputToken,\n fee,\n address(this),\n inputAmount,\n 0,\n 0\n )\n );\n }\n\n function name() public pure virtual override returns (string memory) {\n return \"UniswapV3Liquidator\";\n }\n}\n" + }, + "contracts/liquidators/UniswapV3LiquidatorFunder.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\nimport { IFundsConversionStrategy } from \"./IFundsConversionStrategy.sol\";\nimport { IRedemptionStrategy } from \"./IRedemptionStrategy.sol\";\nimport \"./UniswapV3Liquidator.sol\";\n\nimport { Quoter } from \"../external/uniswap/quoter/Quoter.sol\";\n\ncontract UniswapV3LiquidatorFunder is UniswapV3Liquidator, IFundsConversionStrategy {\n using FixedPointMathLib for uint256;\n\n function convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external override returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n /**\n * @dev Estimates the needed input amount of the input token for the conversion to return the desired output amount.\n * @param outputAmount the desired output amount\n * @param strategyData the input token\n */\n function estimateInputAmount(uint256 outputAmount, bytes memory strategyData)\n external\n view\n returns (IERC20Upgradeable inputToken, uint256 inputAmount)\n {\n (address _inputToken, address _outputToken, uint24 fee, , Quoter quoter) = abi.decode(\n strategyData,\n (address, address, uint24, IV3SwapRouter, Quoter)\n );\n\n inputAmount = quoter.estimateMinSwapUniswapV3(_inputToken, _outputToken, outputAmount, fee);\n inputToken = IERC20Upgradeable(_inputToken);\n }\n\n function name() public pure override(UniswapV3Liquidator, IRedemptionStrategy) returns (string memory) {\n return \"UniswapV3LiquidatorFunder\";\n }\n}\n" + }, + "contracts/liquidators/VelodromeV2Liquidator.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\n\n/**\n * @title VelodromeV2Liquidator\n * @notice Exchanges seized token collateral for underlying tokens via a Velodrome V2 router for use as a step in a liquidation.\n */\ncontract VelodromeV2Liquidator {\n function _swap(IRouter_Velodrome router, uint256 inputAmount, IRouter_Velodrome.Route[] memory swapPath) internal {\n router.swapExactTokensForTokens(inputAmount, 0, swapPath, address(this), block.timestamp);\n }\n\n function name() public pure virtual returns (string memory) {\n return \"VelodromeV2Liquidator\";\n }\n\n /**\n * @notice Redeems custom collateral `token` for an underlying token.\n * @param inputToken The input wrapped token to be redeemed for an underlying token.\n * @param inputAmount The amount of the input wrapped token to be redeemed for an underlying token.\n * @param strategyData The ABI-encoded data to be used in the redemption strategy logic.\n * @return outputToken The underlying ERC20 token outputted.\n * @return outputAmount The quantity of underlying tokens outputted.\n */\n function redeem(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) external returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n return _convert(inputToken, inputAmount, strategyData);\n }\n\n function _convert(\n IERC20Upgradeable inputToken,\n uint256 inputAmount,\n bytes memory strategyData\n ) internal returns (IERC20Upgradeable outputToken, uint256 outputAmount) {\n // Get Uniswap router and path\n (IRouter_Velodrome router, IRouter_Velodrome.Route[] memory swapPath) = abi.decode(\n strategyData,\n (IRouter_Velodrome, IRouter_Velodrome.Route[])\n );\n require(\n swapPath.length >= 1 && swapPath[0].from == address(inputToken),\n \"Invalid VelodromeV2Liquidator swap path.\"\n );\n\n // Swap underlying tokens\n inputToken.approve(address(router), inputAmount);\n\n // call the relevant fn depending on the uni v2 fork specifics\n _swap(router, inputAmount, swapPath);\n\n // Get new collateral\n outputToken = IERC20Upgradeable(swapPath[swapPath.length - 1].to);\n outputAmount = outputToken.balanceOf(address(this));\n }\n}\n" + }, + "contracts/oracles/1337/MockPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/chainlink/AggregatorV3Interface.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title MockPriceOracle\n * @notice Returns mocked prices from a Chainlink-like oracle. Used for local dev only\n * @dev Implements `PriceOracle`.\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n */\ncontract MockPriceOracle is BasePriceOracle {\n /**\n * @notice The maximum number of seconds elapsed since the round was last updated before the price is considered stale. If set to 0, no limit is enforced.\n */\n uint256 public maxSecondsBeforePriceIsStale;\n\n /**\n * @dev Constructor to set `maxSecondsBeforePriceIsStale` as well as all Chainlink price feeds.\n */\n constructor(uint256 _maxSecondsBeforePriceIsStale) {\n // Set maxSecondsBeforePriceIsStale\n maxSecondsBeforePriceIsStale = _maxSecondsBeforePriceIsStale;\n }\n\n /**\n * @dev Returns a boolean indicating if a price feed exists for the underlying asset.\n */\n\n function hasPriceFeed(address underlying) external pure returns (bool) {\n return true;\n }\n\n /**\n * @dev Internal function returning the price in ETH of `underlying`.\n */\n\n function random() private view returns (uint256) {\n uint256 r = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 99;\n r = r + 1;\n return r;\n }\n\n function _price(address underlying) internal view returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) return 1e18;\n\n int256 tokenEthPrice = 1;\n uint256 r = random();\n\n return ((uint256(tokenEthPrice) * 1e18) / r) / 1e18;\n }\n\n /**\n * @dev Returns the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n return 1e18;\n }\n}\n" + }, + "contracts/oracles/BasePriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"../compound/CTokenInterfaces.sol\";\n\n/**\n * @title BasePriceOracle\n * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.\n * @dev Implements the `PriceOracle` interface.\n * @author David Lucid (https://github.com/davidlucid)\n */\ninterface BasePriceOracle {\n /**\n * @notice Get the price of an underlying asset.\n * @param underlying The underlying asset to get the price of.\n * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function price(address underlying) external view returns (uint256);\n\n /**\n * @notice Get the underlying price of a cToken asset\n * @param cToken The cToken to get the underlying price of\n * @return The underlying asset price mantissa (scaled by 1e18).\n * Zero means the price is unavailable.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);\n}\n" + }, + "contracts/oracles/default/CurveLpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\n\nimport \"../../external/curve/ICurvePool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracleNoRegistry\n * @author David Lucid (https://github.com/davidlucid)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Ionic pools (and Compound v2).\n */\ncontract CurveLpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n /**\n * @dev Maps Curve LP token addresses to underlying token addresses.\n */\n mapping(address => address[]) public underlyingTokens;\n\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n * @param _poolUnderlyings The underlying token addresses of a pool\n */\n function initialize(\n address[] memory _lpTokens,\n address[] memory _pools,\n address[][] memory _poolUnderlyings\n ) public initializer {\n require(\n _lpTokens.length == _pools.length && _lpTokens.length == _poolUnderlyings.length,\n \"No LP tokens supplied or array lengths not equal.\"\n );\n\n __SafeOwnable_init(msg.sender);\n for (uint256 i = 0; i < _lpTokens.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n underlyingTokens[_lpTokens[i]] = _poolUnderlyings[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), 0, 0);\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token/ETH price from Curve, with 18 decimals of precision.\n * Source: https://github.com/AlphaFinanceLab/homora-v2/blob/master/contracts/oracle/CurveOracle.sol\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(pool != address(0), \"LP token is not registered.\");\n address[] memory tokens = underlyingTokens[lpToken];\n uint256 minPx = type(uint256).max;\n uint256 n = tokens.length;\n\n for (uint256 i = 0; i < n; i++) {\n address ulToken = tokens[i];\n uint256 tokenPx = BasePriceOracle(msg.sender).price(ulToken);\n if (tokenPx < minPx) minPx = tokenPx;\n }\n\n require(minPx != type(uint256).max, \"No minimum underlying token price found.\");\n return (minPx * ICurvePool(pool).get_virtual_price()) / 1e18; // Use min underlying token prices\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n * @param _underlyings Underlying addresses.\n */\n function registerPool(\n address _lpToken,\n address _pool,\n address[] memory _underlyings\n ) external onlyOwner {\n poolOf[_lpToken] = _pool;\n underlyingTokens[_lpToken] = _underlyings;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n\n /**\n * @dev getter for the underlying tokens\n * @param lpToken the LP token address.\n * @return _underlyings Underlying addresses.\n */\n function getUnderlyingTokens(address lpToken) public view returns (address[] memory) {\n return underlyingTokens[lpToken];\n }\n}\n" + }, + "contracts/oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { EIP20Interface } from \"../../compound/EIP20Interface.sol\";\nimport { MasterPriceOracle } from \"../MasterPriceOracle.sol\";\n\nimport \"../../external/curve/ICurveV2Pool.sol\";\nimport \"../../ionic/SafeOwnableUpgradeable.sol\";\n\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title CurveLpTokenPriceOracle\n * @author Carlo Mazzaferro (https://github.com/carlomazzaferro)\n * @notice CurveLpTokenPriceOracleNoRegistry is a price oracle for Curve V2 LP tokens (using the sender as a root oracle).\n * @dev Implements the `PriceOracle` interface used by Midas pools (and Compound v2).\n */\ncontract CurveV2LpTokenPriceOracleNoRegistry is SafeOwnableUpgradeable, BasePriceOracle {\n address public usdToken;\n MasterPriceOracle public masterPriceOracle;\n /**\n * @dev Maps Curve LP token addresses to pool addresses.\n */\n mapping(address => address) public poolOf;\n\n address[] public lpTokens;\n\n /**\n * @dev Initializes an array of LP tokens and pools if desired.\n * @param _lpTokens Array of LP token addresses.\n * @param _pools Array of pool addresses.\n */\n function initialize(address[] memory _lpTokens, address[] memory _pools) public initializer {\n require(_lpTokens.length == _pools.length, \"No LP tokens supplied or array lengths not equal.\");\n __SafeOwnable_init(msg.sender);\n\n for (uint256 i = 0; i < _pools.length; i++) {\n poolOf[_lpTokens[i]] = _pools[i];\n }\n }\n\n function getAllLPTokens() public view returns (address[] memory) {\n return lpTokens;\n }\n\n function getPoolForSwap(address inputToken, address outputToken)\n public\n view\n returns (\n ICurvePool,\n int128,\n int128\n )\n {\n for (uint256 i = 0; i < lpTokens.length; i++) {\n ICurvePool pool = ICurvePool(poolOf[lpTokens[i]]);\n int128 inputIndex = -1;\n int128 outputIndex = -1;\n int128 j = 0;\n while (true) {\n try pool.coins(uint256(uint128(j))) returns (address coin) {\n if (coin == inputToken) inputIndex = j;\n else if (coin == outputToken) outputIndex = j;\n j++;\n } catch {\n break;\n }\n\n if (outputIndex > -1 && inputIndex > -1) {\n return (pool, inputIndex, outputIndex);\n }\n }\n }\n\n return (ICurvePool(address(0)), int128(0), int128(0));\n }\n\n /**\n * @notice Get the LP token price price for an underlying token address.\n * @param underlying The underlying token address for which to get the price (set to zero address for ETH).\n * @return Price denominated in ETH (scaled by 1e18).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n address underlying = cToken.underlying();\n // Comptroller needs prices to be scaled by 1e(36 - decimals)\n // Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)\n return (_price(underlying) * 1e18) / (10**uint256(EIP20Interface(underlying).decimals()));\n }\n\n /**\n * @dev Fetches the fair LP token price from Curve, with 18 decimals of precision.\n * @param lpToken The LP token contract address for price retrieval.\n */\n function _price(address lpToken) internal view returns (uint256) {\n address pool = poolOf[lpToken];\n require(address(pool) != address(0), \"LP token is not registered.\");\n\n address baseToken = ICurvePool(pool).coins(0);\n uint256 lpPrice = ICurveV2Pool(pool).lp_price();\n uint256 baseTokenPrice = BasePriceOracle(msg.sender).price(baseToken);\n return (lpPrice * baseTokenPrice) / 10**18;\n }\n\n /**\n * @dev Register the pool given LP token address and set the pool info.\n * @param _lpToken LP token to find the corresponding pool.\n * @param _pool Pool address.\n */\n function registerPool(address _lpToken, address _pool) external onlyOwner {\n address pool = poolOf[_lpToken];\n require(pool == address(0), \"This LP token is already registered.\");\n poolOf[_lpToken] = _pool;\n\n bool skip = false;\n for (uint256 j = 0; j < lpTokens.length; j++) {\n if (lpTokens[j] == _lpToken) {\n skip = true;\n break;\n }\n }\n if (!skip) lpTokens.push(_lpToken);\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracle is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWeETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWeETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A) {\n underlying = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/default/RedstoneAdapterPriceOracleWrsETH.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport \"../../external/redstone/IRedstoneOracle.sol\";\nimport \"../BasePriceOracle.sol\";\n\n/**\n * @title RedstoneAdapterPriceOracle\n * @notice Returns prices from Redstone.\n * @dev Implements `BasePriceOracle`.\n * @author Veliko Minkov (https://github.com/vminkov)\n */\ncontract RedstoneAdapterPriceOracleWrsETH is BasePriceOracle {\n /**\n * @notice The Redstone oracle contract\n */\n IRedstoneOracle public REDSTONE_ORACLE;\n\n /**\n * @dev Constructor to set admin, wtoken address and native token USD price feed address\n * @param redstoneOracle The Redstone oracle contract address\n */\n constructor(address redstoneOracle) {\n REDSTONE_ORACLE = IRedstoneOracle(redstoneOracle);\n }\n\n /**\n * @notice Internal function returning the price in of `underlying`.\n * @dev will return a price denominated in the native token\n */\n function _price(address underlying) internal view returns (uint256) {\n // special case for wrsETH\n // if input is wrsETH, we need to get the price of rsETH\n if (underlying == 0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd) {\n underlying = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n }\n uint256 priceInUsd = REDSTONE_ORACLE.priceOf(underlying);\n uint256 priceOfNativeInUsd = REDSTONE_ORACLE.priceOfETH();\n return (priceInUsd * 1e18) / priceOfNativeInUsd;\n }\n\n /**\n * @notice Returns the price in of `underlying` either in the\n * native token (implements `BasePriceOracle`).\n */\n function price(address underlying) external view override returns (uint256) {\n return _price(underlying);\n }\n\n /**\n * @notice Returns the price in WNATIVE of the token underlying `cToken`.\n * @dev Implements the `BasePriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in WNATIVE of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying token address\n address underlying = cToken.underlying();\n\n uint256 oraclePrice = _price(underlying);\n\n uint256 underlyingDecimals = uint256(ERC20Upgradeable(underlying).decimals());\n return\n underlyingDecimals <= 18\n ? uint256(oraclePrice) * (10**(18 - underlyingDecimals))\n : uint256(oraclePrice) / (10**(underlyingDecimals - 18));\n }\n}\n" + }, + "contracts/oracles/MasterPriceOracle.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BasePriceOracle } from \"./BasePriceOracle.sol\";\n\n/**\n * @title MasterPriceOracle\n * @notice Use a combination of price oracles.\n * @dev Implements `PriceOracle`.\n * @author David Lucid (https://github.com/davidlucid)\n */\ncontract MasterPriceOracle is Initializable, BasePriceOracle {\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public oracles;\n\n /**\n * @dev Default/fallback `PriceOracle`.\n */\n BasePriceOracle public defaultOracle;\n\n /**\n * @dev The administrator of this `MasterPriceOracle`.\n */\n address public admin;\n\n /**\n * @dev Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n bool internal noAdminOverwrite;\n\n /**\n * @dev The Wrapped native asset address.\n */\n address public wtoken;\n\n /**\n * @dev Maps underlying token addresses to `PriceOracle` contracts (can be `BasePriceOracle` contracts too).\n */\n mapping(address => BasePriceOracle) public fallbackOracles;\n\n /**\n * @dev Returns a boolean indicating if `admin` can overwrite existing assignments of oracles to underlying tokens.\n */\n function canAdminOverwrite() external view returns (bool) {\n return !noAdminOverwrite;\n }\n\n /**\n * @dev Event emitted when `admin` is changed.\n */\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /**\n * @dev Event emitted when the default oracle is changed.\n */\n event NewDefaultOracle(address oldOracle, address newOracle);\n\n /**\n * @dev Event emitted when an underlying token's oracle is changed.\n */\n event NewOracle(address underlying, address oldOracle, address newOracle);\n\n /**\n * @dev Initialize state variables.\n * @param underlyings The underlying ERC20 token addresses to link to `_oracles`.\n * @param _oracles The `PriceOracle` contracts to be assigned to `underlyings`.\n * @param _defaultOracle The default `PriceOracle` contract to use.\n * @param _admin The admin who can assign oracles to underlying tokens.\n * @param _canAdminOverwrite Controls if `admin` can overwrite existing assignments of oracles to underlying tokens.\n * @param _wtoken The Wrapped native asset address\n */\n function initialize(\n address[] memory underlyings,\n BasePriceOracle[] memory _oracles,\n BasePriceOracle _defaultOracle,\n address _admin,\n bool _canAdminOverwrite,\n address _wtoken\n ) external initializer {\n // Input validation\n require(underlyings.length == _oracles.length, \"Lengths of both arrays must be equal.\");\n\n // Initialize state variables\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, address(0), address(newOracle));\n }\n\n defaultOracle = _defaultOracle;\n admin = _admin;\n noAdminOverwrite = !_canAdminOverwrite;\n wtoken = _wtoken;\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function add(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(oracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n oracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Sets `_oracles` for `underlyings`.\n */\n function addFallbacks(address[] calldata underlyings, BasePriceOracle[] calldata _oracles) external onlyAdmin {\n // Input validation\n require(\n underlyings.length > 0 && underlyings.length == _oracles.length,\n \"Lengths of both arrays must be equal and greater than 0.\"\n );\n\n // Assign oracles to underlying tokens\n for (uint256 i = 0; i < underlyings.length; i++) {\n address underlying = underlyings[i];\n address oldOracle = address(fallbackOracles[underlying]);\n if (noAdminOverwrite)\n require(\n oldOracle == address(0),\n \"Admin cannot overwrite existing assignments of oracles to underlying tokens.\"\n );\n BasePriceOracle newOracle = _oracles[i];\n fallbackOracles[underlying] = newOracle;\n emit NewOracle(underlying, oldOracle, address(newOracle));\n }\n }\n\n /**\n * @dev Changes the default price oracle\n */\n function setDefaultOracle(BasePriceOracle newOracle) external onlyAdmin {\n BasePriceOracle oldOracle = defaultOracle;\n defaultOracle = newOracle;\n emit NewDefaultOracle(address(oldOracle), address(newOracle));\n }\n\n /**\n * @dev Changes the admin and emits an event.\n */\n function changeAdmin(address newAdmin) external onlyAdmin {\n address oldAdmin = admin;\n admin = newAdmin;\n emit NewAdmin(oldAdmin, newAdmin);\n }\n\n /**\n * @dev Modifier that checks if `msg.sender == admin`.\n */\n modifier onlyAdmin() {\n require(msg.sender == admin, \"Sender is not the admin.\");\n _;\n }\n\n /**\n * @notice Returns the price in ETH of the token underlying `cToken`.\n * @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).\n * @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.\n */\n function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {\n // Get underlying ERC20 token address\n address underlying = address(ICErc20(address(cToken)).underlying());\n\n if (underlying == wtoken) return 1e18;\n\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.getUnderlyingPrice(cToken) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.getUnderlyingPrice(cToken);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n\n /**\n * @dev Attempts to return the price in ETH of `underlying` (implements `BasePriceOracle`).\n */\n function price(address underlying) public view override returns (uint256) {\n // Return 1e18 for WETH\n if (underlying == wtoken) return 1e18;\n\n // Get underlying price from assigned oracle\n BasePriceOracle oracle = oracles[underlying];\n BasePriceOracle fallbackOracle = fallbackOracles[underlying];\n\n if (address(oracle) != address(0)) {\n try oracle.price(underlying) returns (uint256 underlyingPrice) {\n if (underlyingPrice == 0) {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n } else {\n return underlyingPrice;\n }\n } catch {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n } else {\n if (address(fallbackOracle) != address(0)) return fallbackOracle.price(underlying);\n }\n revert(\"Price oracle not found for this underlying token address.\");\n }\n}\n" + }, + "contracts/PoolDirectory.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { Unitroller } from \"./compound/Unitroller.sol\";\nimport \"./ionic/SafeOwnableUpgradeable.sol\";\nimport \"./ionic/DiamondExtension.sol\";\n\n/**\n * @title PoolDirectory\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolDirectory is a directory for Ionic interest rate pools.\n */\ncontract PoolDirectory is SafeOwnableUpgradeable {\n /**\n * @dev Initializes a deployer whitelist if desired.\n * @param _enforceDeployerWhitelist Boolean indicating if the deployer whitelist is to be enforced.\n * @param _deployerWhitelist Array of Ethereum accounts to be whitelisted.\n */\n function initialize(bool _enforceDeployerWhitelist, address[] memory _deployerWhitelist) public initializer {\n __SafeOwnable_init(msg.sender);\n enforceDeployerWhitelist = _enforceDeployerWhitelist;\n for (uint256 i = 0; i < _deployerWhitelist.length; i++) deployerWhitelist[_deployerWhitelist[i]] = true;\n }\n\n /**\n * @dev Struct for a Ionic interest rate pool.\n */\n struct Pool {\n string name;\n address creator;\n address comptroller;\n uint256 blockPosted;\n uint256 timestampPosted;\n }\n\n /**\n * @dev Array of Ionic interest rate pools.\n */\n Pool[] public pools;\n\n /**\n * @dev Maps Ethereum accounts to arrays of Ionic pool indexes.\n */\n mapping(address => uint256[]) private _poolsByAccount;\n\n /**\n * @dev Maps Ionic pool Comptroller addresses to bools indicating if they have been registered via the directory.\n */\n mapping(address => bool) public poolExists;\n\n /**\n * @dev Emitted when a new Ionic pool is added to the directory.\n */\n event PoolRegistered(uint256 index, Pool pool);\n\n /**\n * @dev Booleans indicating if the deployer whitelist is enforced.\n */\n bool public enforceDeployerWhitelist;\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are allowed to deploy pools.\n */\n mapping(address => bool) public deployerWhitelist;\n\n /**\n * @dev Controls if the deployer whitelist is to be enforced.\n * @param enforce Boolean indicating if the deployer whitelist is to be enforced.\n */\n function _setDeployerWhitelistEnforcement(bool enforce) external onlyOwner {\n enforceDeployerWhitelist = enforce;\n }\n\n /**\n * @dev Adds/removes Ethereum accounts to the deployer whitelist.\n * @param deployers Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editDeployerWhitelist(address[] calldata deployers, bool status) external onlyOwner {\n require(deployers.length > 0, \"No deployers supplied.\");\n for (uint256 i = 0; i < deployers.length; i++) deployerWhitelist[deployers[i]] = status;\n }\n\n /**\n * @dev Adds a new Ionic pool to the directory (without checking msg.sender).\n * @param name The name of the pool.\n * @param comptroller The pool's Comptroller proxy contract address.\n * @return The index of the registered Ionic pool.\n */\n function _registerPool(string memory name, address comptroller) internal returns (uint256) {\n require(!poolExists[comptroller], \"Pool already exists in the directory.\");\n require(!enforceDeployerWhitelist || deployerWhitelist[msg.sender], \"Sender is not on deployer whitelist.\");\n require(bytes(name).length <= 100, \"No pool name supplied.\");\n Pool memory pool = Pool(name, msg.sender, comptroller, block.number, block.timestamp);\n pools.push(pool);\n _poolsByAccount[msg.sender].push(pools.length - 1);\n poolExists[comptroller] = true;\n emit PoolRegistered(pools.length - 1, pool);\n return pools.length - 1;\n }\n\n function _deprecatePool(address comptroller) external onlyOwner {\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller == comptroller) {\n _deprecatePool(i);\n break;\n }\n }\n }\n\n function _deprecatePool(uint256 index) public onlyOwner {\n Pool storage ionicPool = pools[index];\n\n require(ionicPool.comptroller != address(0), \"pool already deprecated\");\n\n // swap with the last pool of the creator and delete\n uint256[] storage creatorPools = _poolsByAccount[ionicPool.creator];\n for (uint256 i = 0; i < creatorPools.length; i++) {\n if (creatorPools[i] == index) {\n creatorPools[i] = creatorPools[creatorPools.length - 1];\n creatorPools.pop();\n break;\n }\n }\n\n // leave it to true to deny the re-registering of the same pool\n poolExists[ionicPool.comptroller] = true;\n\n // nullify the storage\n ionicPool.comptroller = address(0);\n ionicPool.creator = address(0);\n ionicPool.name = \"\";\n ionicPool.blockPosted = 0;\n ionicPool.timestampPosted = 0;\n }\n\n /**\n * @dev Deploys a new Ionic pool and adds to the directory.\n * @param name The name of the pool.\n * @param implementation The Comptroller implementation contract address.\n * @param constructorData Encoded construction data for `Unitroller constructor()`\n * @param enforceWhitelist Boolean indicating if the pool's supplier/borrower whitelist is to be enforced.\n * @param closeFactor The pool's close factor (scaled by 1e18).\n * @param liquidationIncentive The pool's liquidation incentive (scaled by 1e18).\n * @param priceOracle The pool's PriceOracle contract address.\n * @return Index of the registered Ionic pool and the Unitroller proxy address.\n */\n function deployPool(\n string memory name,\n address implementation,\n bytes calldata constructorData,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive,\n address priceOracle\n ) external returns (uint256, address) {\n // Input validation\n require(implementation != address(0), \"No Comptroller implementation contract address specified.\");\n require(priceOracle != address(0), \"No PriceOracle contract address specified.\");\n\n // Deploy Unitroller using msg.sender, name, and block.number as a salt\n bytes memory unitrollerCreationCode = abi.encodePacked(type(Unitroller).creationCode, constructorData);\n address proxy = Create2Upgradeable.deploy(\n 0,\n keccak256(abi.encodePacked(msg.sender, name, ++poolsCounter)),\n unitrollerCreationCode\n );\n\n // Setup the pool\n IonicComptroller comptrollerProxy = IonicComptroller(proxy);\n // Set up the extensions\n comptrollerProxy._upgrade();\n\n // Set pool parameters\n require(comptrollerProxy._setCloseFactor(closeFactor) == 0, \"Failed to set pool close factor.\");\n require(\n comptrollerProxy._setLiquidationIncentive(liquidationIncentive) == 0,\n \"Failed to set pool liquidation incentive.\"\n );\n require(comptrollerProxy._setPriceOracle(BasePriceOracle(priceOracle)) == 0, \"Failed to set pool price oracle.\");\n\n // Whitelist\n if (enforceWhitelist)\n require(comptrollerProxy._setWhitelistEnforcement(true) == 0, \"Failed to enforce supplier/borrower whitelist.\");\n\n // Make msg.sender the admin\n require(comptrollerProxy._setPendingAdmin(msg.sender) == 0, \"Failed to set pending admin on Unitroller.\");\n\n // Register the pool with this PoolDirectory\n return (_registerPool(name, proxy), proxy);\n }\n\n /**\n * @notice Returns `ids` and directory information of all non-deprecated Ionic pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getActivePools() public view returns (uint256[] memory, Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory activePools = new Pool[](count);\n uint256[] memory poolIds = new uint256[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n poolIds[index] = i;\n activePools[index] = pools[i];\n index++;\n }\n }\n\n return (poolIds, activePools);\n }\n\n /**\n * @notice Returns arrays of all Ionic pools' data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getAllPools() public view returns (Pool[] memory) {\n uint256 count = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) count++;\n }\n\n Pool[] memory result = new Pool[](count);\n\n uint256 index = 0;\n for (uint256 i = 0; i < pools.length; i++) {\n if (pools[i].comptroller != address(0)) {\n result[index++] = pools[i];\n }\n }\n\n return result;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPools() external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).enforceWhitelist() returns (bool enforceWhitelist) {\n if (enforceWhitelist) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes and data.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolsOfUser(address user) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory poolsOfUser = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n try IonicComptroller(activePools[i].comptroller).isUserOfPool(user) returns (bool isUsing) {\n if (!isUsing) continue;\n } catch {}\n\n indexes[index] = i;\n poolsOfUser[index] = activePools[i];\n index++;\n }\n\n return (indexes, poolsOfUser);\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data created by `account`.\n */\n function getPoolsByAccount(address account) external view returns (uint256[] memory, Pool[] memory) {\n uint256[] memory indexes = new uint256[](_poolsByAccount[account].length);\n Pool[] memory accountPools = new Pool[](_poolsByAccount[account].length);\n (, Pool[] memory activePools) = getActivePools();\n\n for (uint256 i = 0; i < _poolsByAccount[account].length; i++) {\n indexes[i] = _poolsByAccount[account][i];\n accountPools[i] = activePools[_poolsByAccount[account][i]];\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Modify existing Ionic pool name.\n */\n function setPoolName(uint256 index, string calldata name) external {\n IonicComptroller _comptroller = IonicComptroller(pools[index].comptroller);\n require(\n (msg.sender == _comptroller.admin() && _comptroller.adminHasRights()) || msg.sender == owner(),\n \"!permission\"\n );\n pools[index].name = name;\n }\n\n /**\n * @dev Maps Ethereum accounts to booleans indicating if they are a whitelisted admin.\n */\n mapping(address => bool) public adminWhitelist;\n\n /**\n * @dev used as salt for the creation of new pools\n */\n uint256 public poolsCounter;\n\n /**\n * @dev Event emitted when the admin whitelist is updated.\n */\n event AdminWhitelistUpdated(address[] admins, bool status);\n\n /**\n * @dev Adds/removes Ethereum accounts to the admin whitelist.\n * @param admins Array of Ethereum accounts to be whitelisted.\n * @param status Whether to add or remove the accounts.\n */\n function _editAdminWhitelist(address[] calldata admins, bool status) external onlyOwner {\n require(admins.length > 0, \"No admins supplied.\");\n for (uint256 i = 0; i < admins.length; i++) adminWhitelist[admins[i]] = status;\n emit AdminWhitelistUpdated(admins, status);\n }\n\n /**\n * @notice Returns arrays of all Ionic pool indexes and data with whitelisted admins.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPublicPoolsByVerification(bool whitelistedAdmin) external view returns (uint256[] memory, Pool[] memory) {\n uint256 arrayLength = 0;\n\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory publicPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.admin() returns (address admin) {\n if (whitelistedAdmin != adminWhitelist[admin]) continue;\n } catch {}\n\n indexes[index] = i;\n publicPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, publicPools);\n }\n\n /**\n * @notice Returns arrays of all verified Ionic pool indexes and data for which the account is whitelisted\n * @param account who is whitelisted in the returned verified whitelist-enabled pools.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getVerifiedPoolsOfWhitelistedAccount(address account)\n external\n view\n returns (uint256[] memory, Pool[] memory)\n {\n uint256 arrayLength = 0;\n (, Pool[] memory activePools) = getActivePools();\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n Pool[] memory accountWhitelistedPools = new Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < activePools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(activePools[i].comptroller);\n try comptroller.enforceWhitelist() returns (bool enforceWhitelist) {\n if (!enforceWhitelist || !comptroller.whitelist(account)) continue;\n } catch {}\n\n indexes[index] = i;\n accountWhitelistedPools[index] = activePools[i];\n index++;\n }\n\n return (indexes, accountWhitelistedPools);\n }\n}\n" + }, + "contracts/PoolLens.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { BasePriceOracle } from \"./oracles/BasePriceOracle.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"./oracles/MasterPriceOracle.sol\";\n\n/**\n * @title PoolLens\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLens returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLens is Initializable {\n error ComptrollerError(uint256 errCode);\n\n /**\n * @notice Initialize the `PoolDirectory` contract object.\n * @param _directory The PoolDirectory\n * @param _name Name for the nativeToken\n * @param _symbol Symbol for the nativeToken\n * @param _hardcodedAddresses Underlying token addresses for a token like maker which are DSToken and/or use bytes32 for `symbol`\n * @param _hardcodedNames Harcoded name for these tokens\n * @param _hardcodedSymbols Harcoded symbol for these tokens\n * @param _uniswapLPTokenNames Harcoded names for underlying uniswap LpToken\n * @param _uniswapLPTokenSymbols Harcoded symbols for underlying uniswap LpToken\n * @param _uniswapLPTokenDisplayNames Harcoded display names for underlying uniswap LpToken\n */\n function initialize(\n PoolDirectory _directory,\n string memory _name,\n string memory _symbol,\n address[] memory _hardcodedAddresses,\n string[] memory _hardcodedNames,\n string[] memory _hardcodedSymbols,\n string[] memory _uniswapLPTokenNames,\n string[] memory _uniswapLPTokenSymbols,\n string[] memory _uniswapLPTokenDisplayNames\n ) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n require(\n _hardcodedAddresses.length == _hardcodedNames.length && _hardcodedAddresses.length == _hardcodedSymbols.length,\n \"Hardcoded addresses lengths not equal.\"\n );\n require(\n _uniswapLPTokenNames.length == _uniswapLPTokenSymbols.length &&\n _uniswapLPTokenNames.length == _uniswapLPTokenDisplayNames.length,\n \"Uniswap LP token names lengths not equal.\"\n );\n\n directory = _directory;\n name = _name;\n symbol = _symbol;\n for (uint256 i = 0; i < _hardcodedAddresses.length; i++) {\n hardcoded[_hardcodedAddresses[i]] = TokenData({ name: _hardcodedNames[i], symbol: _hardcodedSymbols[i] });\n }\n\n for (uint256 i = 0; i < _uniswapLPTokenNames.length; i++) {\n uniswapData.push(\n UniswapData({\n name: _uniswapLPTokenNames[i],\n symbol: _uniswapLPTokenSymbols[i],\n displayName: _uniswapLPTokenDisplayNames[i]\n })\n );\n }\n }\n\n string public name;\n string public symbol;\n\n struct TokenData {\n string name;\n string symbol;\n }\n mapping(address => TokenData) hardcoded;\n\n struct UniswapData {\n string name; // ie \"Uniswap V2\" or \"SushiSwap LP Token\"\n string symbol; // ie \"UNI-V2\" or \"SLP\"\n string displayName; // ie \"SushiSwap\" or \"Uniswap\"\n }\n UniswapData[] uniswapData;\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @dev Struct for Ionic pool summary data.\n */\n struct IonicPoolData {\n uint256 totalSupply;\n uint256 totalBorrow;\n address[] underlyingTokens;\n string[] underlyingSymbols;\n bool whitelistedAdmin;\n }\n\n /**\n * @notice Returns arrays of all public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsWithData()\n external\n returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory)\n {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPools();\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of all whitelisted public Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPublicPoolsByVerificationWithData(\n bool whitelistedAdmin\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory publicPools) = directory.getPublicPoolsByVerification(\n whitelistedAdmin\n );\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(publicPools);\n return (indexes, publicPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools created by `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = directory.getPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools used by `user`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsOIonicrWithData(\n address user\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory userPools) = directory.getPoolsOfUser(user);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(userPools);\n return (indexes, userPools, data, errored);\n }\n\n /**\n * @notice Internal function returning arrays of requested Ionic pool indexes, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolsData(PoolDirectory.Pool[] memory pools) internal returns (IonicPoolData[] memory, bool[] memory) {\n IonicPoolData[] memory data = new IonicPoolData[](pools.length);\n bool[] memory errored = new bool[](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n try this.getPoolSummary(IonicComptroller(pools[i].comptroller)) returns (\n uint256 _totalSupply,\n uint256 _totalBorrow,\n address[] memory _underlyingTokens,\n string[] memory _underlyingSymbols,\n bool _whitelistedAdmin\n ) {\n data[i] = IonicPoolData(_totalSupply, _totalBorrow, _underlyingTokens, _underlyingSymbols, _whitelistedAdmin);\n } catch {\n errored[i] = true;\n }\n }\n\n return (data, errored);\n }\n\n /**\n * @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.\n */\n function getPoolSummary(\n IonicComptroller comptroller\n ) external returns (uint256, uint256, address[] memory, string[] memory, bool) {\n uint256 totalBorrow = 0;\n uint256 totalSupply = 0;\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n address[] memory underlyingTokens = new address[](cTokens.length);\n string[] memory underlyingSymbols = new string[](cTokens.length);\n BasePriceOracle oracle = comptroller.oracle();\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n cToken.accrueInterest();\n uint256 assetTotalBorrow = cToken.totalBorrowsCurrent();\n uint256 assetTotalSupply = cToken.getCash() +\n assetTotalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n uint256 underlyingPrice = oracle.getUnderlyingPrice(cToken);\n totalBorrow = totalBorrow + (assetTotalBorrow * underlyingPrice) / 1e18;\n totalSupply = totalSupply + (assetTotalSupply * underlyingPrice) / 1e18;\n\n underlyingTokens[i] = ICErc20(address(cToken)).underlying();\n (, underlyingSymbols[i]) = getTokenNameAndSymbol(underlyingTokens[i]);\n }\n\n bool whitelistedAdmin = directory.adminWhitelist(comptroller.admin());\n return (totalSupply, totalBorrow, underlyingTokens, underlyingSymbols, whitelistedAdmin);\n }\n\n /**\n * @dev Struct for a Ionic pool asset.\n */\n struct PoolAsset {\n address cToken;\n address underlyingToken;\n string underlyingName;\n string underlyingSymbol;\n uint256 underlyingDecimals;\n uint256 underlyingBalance;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 totalSupply;\n uint256 totalBorrow;\n uint256 supplyBalance;\n uint256 borrowBalance;\n uint256 liquidity;\n bool membership;\n uint256 exchangeRate; // Price of cTokens in terms of underlying tokens\n uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)\n address oracle;\n uint256 collateralFactor;\n uint256 reserveFactor;\n uint256 adminFee;\n uint256 ionicFee;\n bool borrowGuardianPaused;\n bool mintGuardianPaused;\n }\n\n /**\n * @notice Returns data on the specified assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract address of the Ionic pool.\n * @param cTokens The cToken contract addresses of the assets to query.\n * @param user The user for which to get account data.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(\n IonicComptroller comptroller,\n ICErc20[] memory cTokens,\n address user\n ) internal returns (PoolAsset[] memory) {\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n (bool isListed, ) = comptroller.markets(address(cTokens[i]));\n if (isListed) arrayLength++;\n }\n\n PoolAsset[] memory detailedAssets = new PoolAsset[](arrayLength);\n uint256 index = 0;\n BasePriceOracle oracle = BasePriceOracle(address(comptroller.oracle()));\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n // Check if market is listed and get collateral factor\n (bool isListed, uint256 collateralFactorMantissa) = comptroller.markets(address(cTokens[i]));\n if (!isListed) continue;\n\n // Start adding data to PoolAsset\n PoolAsset memory asset;\n ICErc20 cToken = cTokens[i];\n asset.cToken = address(cToken);\n\n cToken.accrueInterest();\n\n // Get underlying asset data\n asset.underlyingToken = ICErc20(address(cToken)).underlying();\n ERC20Upgradeable underlying = ERC20Upgradeable(asset.underlyingToken);\n (asset.underlyingName, asset.underlyingSymbol) = getTokenNameAndSymbol(asset.underlyingToken);\n asset.underlyingDecimals = underlying.decimals();\n asset.underlyingBalance = underlying.balanceOf(user);\n\n // Get cToken data\n asset.supplyRatePerBlock = cToken.supplyRatePerBlock();\n asset.borrowRatePerBlock = cToken.borrowRatePerBlock();\n asset.liquidity = cToken.getCash();\n asset.totalBorrow = cToken.totalBorrowsCurrent();\n asset.totalSupply =\n asset.liquidity +\n asset.totalBorrow -\n (cToken.totalReserves() + cToken.totalAdminFees() + cToken.totalIonicFees());\n asset.supplyBalance = cToken.balanceOfUnderlying(user);\n asset.borrowBalance = cToken.borrowBalanceCurrent(user);\n asset.membership = comptroller.checkMembership(user, cToken);\n asset.exchangeRate = cToken.exchangeRateCurrent(); // We would use exchangeRateCurrent but we already accrue interest above\n asset.underlyingPrice = oracle.price(asset.underlyingToken);\n\n // Get oracle for this cToken\n asset.oracle = address(oracle);\n\n try MasterPriceOracle(asset.oracle).oracles(asset.underlyingToken) returns (BasePriceOracle _oracle) {\n asset.oracle = address(_oracle);\n } catch {}\n\n // More cToken data\n asset.collateralFactor = collateralFactorMantissa;\n asset.reserveFactor = cToken.reserveFactorMantissa();\n asset.adminFee = cToken.adminFeeMantissa();\n asset.ionicFee = cToken.ionicFeeMantissa();\n asset.borrowGuardianPaused = comptroller.borrowGuardianPaused(address(cToken));\n asset.mintGuardianPaused = comptroller.mintGuardianPaused(address(cToken));\n\n // Add to assets array and increment index\n detailedAssets[index] = asset;\n index++;\n }\n\n return (detailedAssets);\n }\n\n function getBorrowCapsPerCollateral(\n ICErc20 borrowedAsset,\n IonicComptroller comptroller\n )\n internal\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsAgainstCollateral,\n bool[] memory borrowingBlacklistedAgainstCollateral\n )\n {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n collateral = new address[](poolMarkets.length);\n borrowCapsAgainstCollateral = new uint256[](poolMarkets.length);\n borrowingBlacklistedAgainstCollateral = new bool[](poolMarkets.length);\n\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n address collateralAddress = address(poolMarkets[i]);\n if (collateralAddress != address(borrowedAsset)) {\n collateral[i] = collateralAddress;\n borrowCapsAgainstCollateral[i] = comptroller.borrowCapForCollateral(address(borrowedAsset), collateralAddress);\n borrowingBlacklistedAgainstCollateral[i] = comptroller.borrowingAgainstCollateralBlacklist(\n address(borrowedAsset),\n collateralAddress\n );\n }\n }\n }\n\n /**\n * @notice Returns the `name` and `symbol` of `token`.\n * Supports Uniswap V2 and SushiSwap LP tokens as well as MKR.\n * @param token An ERC20 token contract object.\n * @return The `name` and `symbol`.\n */\n function getTokenNameAndSymbol(address token) internal view returns (string memory, string memory) {\n // i.e. MKR is a DSToken and uses bytes32\n if (bytes(hardcoded[token].symbol).length != 0) {\n return (hardcoded[token].name, hardcoded[token].symbol);\n }\n\n // Get name and symbol from token contract\n ERC20Upgradeable tokenContract = ERC20Upgradeable(token);\n string memory _name = tokenContract.name();\n string memory _symbol = tokenContract.symbol();\n\n return (_name, _symbol);\n }\n\n /**\n * @notice Returns the assets of the specified Ionic pool.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n * @param comptroller The Comptroller proxy contract of the Ionic pool.\n * @return An array of Ionic pool assets.\n */\n function getPoolAssetsWithData(IonicComptroller comptroller) external returns (PoolAsset[] memory) {\n return getPoolAssetsWithData(comptroller, comptroller.getAllMarkets(), msg.sender);\n }\n\n /**\n * @dev Struct for a Ionic pool user.\n */\n struct IonicPoolUser {\n address account;\n uint256 totalBorrow;\n uint256 totalCollateral;\n uint256 health;\n }\n\n /**\n * @notice Returns arrays of PoolAsset for a specific user\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getPoolAssetsByUser(IonicComptroller comptroller, address user) public returns (PoolAsset[] memory) {\n PoolAsset[] memory assets = getPoolAssetsWithData(comptroller, comptroller.getAssetsIn(user), user);\n return assets;\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsForPool(IonicComptroller comptroller) public view returns (address[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n }\n\n return (assets, supplyCapsPerAsset);\n }\n\n /**\n * @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getSupplyCapsDataForPool(\n IonicComptroller comptroller\n ) public view returns (address[] memory, uint256[] memory, uint256[] memory) {\n ICErc20[] memory poolMarkets = comptroller.getAllMarkets();\n\n address[] memory assets = new address[](poolMarkets.length);\n uint256[] memory supplyCapsPerAsset = new uint256[](poolMarkets.length);\n uint256[] memory nonWhitelistedTotalSupply = new uint256[](poolMarkets.length);\n for (uint256 i = 0; i < poolMarkets.length; i++) {\n assets[i] = address(poolMarkets[i]);\n supplyCapsPerAsset[i] = comptroller.effectiveSupplyCaps(assets[i]);\n uint256 assetTotalSupplied = poolMarkets[i].getTotalUnderlyingSupplied();\n uint256 whitelistedSuppliersSupply = comptroller.getWhitelistedSuppliersSupply(assets[i]);\n if (whitelistedSuppliersSupply >= assetTotalSupplied) nonWhitelistedTotalSupply[i] = 0;\n else nonWhitelistedTotalSupply[i] = assetTotalSupplied - whitelistedSuppliersSupply;\n }\n\n return (assets, supplyCapsPerAsset, nonWhitelistedTotalSupply);\n }\n\n /**\n * @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n }\n\n /**\n * @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getBorrowCapsDataForAsset(\n ICErc20 asset\n )\n public\n view\n returns (\n address[] memory collateral,\n uint256[] memory borrowCapsPerCollateral,\n bool[] memory collateralBlacklisted,\n uint256 totalBorrowCap,\n uint256 nonWhitelistedTotalBorrows\n )\n {\n IonicComptroller comptroller = IonicComptroller(asset.comptroller());\n (collateral, borrowCapsPerCollateral, collateralBlacklisted) = getBorrowCapsPerCollateral(asset, comptroller);\n totalBorrowCap = comptroller.effectiveBorrowCaps(address(asset));\n uint256 totalBorrows = asset.totalBorrowsCurrent();\n uint256 whitelistedBorrowersBorrows = comptroller.getWhitelistedBorrowersBorrows(address(asset));\n if (whitelistedBorrowersBorrows >= totalBorrows) nonWhitelistedTotalBorrows = 0;\n else nonWhitelistedTotalBorrows = totalBorrows - whitelistedBorrowersBorrows;\n }\n\n /**\n * @notice Returns arrays of Ionic pool indexes and data with a whitelist containing `account`.\n * Note that the whitelist does not have to be enforced.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getWhitelistedPoolsByAccount(\n address account\n ) public view returns (uint256[] memory, PoolDirectory.Pool[] memory) {\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) arrayLength++;\n }\n\n uint256[] memory indexes = new uint256[](arrayLength);\n PoolDirectory.Pool[] memory accountPools = new PoolDirectory.Pool[](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n if (comptroller.whitelist(account)) {\n indexes[index] = i;\n accountPools[index] = pools[i];\n index++;\n break;\n }\n }\n\n return (indexes, accountPools);\n }\n\n /**\n * @notice Returns arrays of the indexes of Ionic pools with a whitelist containing `account`, data, total supply balances (in ETH), total borrow balances (in ETH), arrays of underlying token addresses, arrays of underlying asset symbols, and booleans indicating if retrieving each pool's data failed.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getWhitelistedPoolsByAccountWithData(\n address account\n ) external returns (uint256[] memory, PoolDirectory.Pool[] memory, IonicPoolData[] memory, bool[] memory) {\n (uint256[] memory indexes, PoolDirectory.Pool[] memory accountPools) = getWhitelistedPoolsByAccount(account);\n (IonicPoolData[] memory data, bool[] memory errored) = getPoolsData(accountPools);\n return (indexes, accountPools, data, errored);\n }\n\n function getHealthFactor(address user, IonicComptroller pool) external view returns (uint256) {\n return getHealthFactorHypothetical(pool, user, address(0), 0, 0, 0);\n }\n\n function getHealthFactorHypothetical(\n IonicComptroller pool,\n address account,\n address cTokenModify,\n uint256 redeemTokens,\n uint256 borrowAmount,\n uint256 repayAmount\n ) public view returns (uint256) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getHypotheticalAccountLiquidity(\n account,\n cTokenModify,\n redeemTokens,\n borrowAmount,\n repayAmount\n );\n\n if (err != 0) revert ComptrollerError(err);\n\n if (shortfall > 0) {\n // HF < 1.0\n return (collateralValue * 1e18) / (collateralValue + shortfall);\n } else {\n // HF >= 1.0\n if (collateralValue <= liquidity) return type(uint256).max;\n else return (collateralValue * 1e18) / (collateralValue - liquidity);\n }\n }\n}\n" + }, + "contracts/PoolLensSecondary.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\n\nimport { IonicComptroller } from \"./compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"./compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"./external/uniswap/IUniswapV2Pair.sol\";\n\nimport { PoolDirectory } from \"./PoolDirectory.sol\";\n\ninterface IRewardsDistributor_PLS {\n function rewardToken() external view returns (address);\n\n function compSupplySpeeds(address) external view returns (uint256);\n\n function compBorrowSpeeds(address) external view returns (uint256);\n\n function compAccrued(address) external view returns (uint256);\n\n function flywheelPreSupplierAction(address cToken, address supplier) external;\n\n function flywheelPreBorrowerAction(address cToken, address borrower) external;\n\n function getAllMarkets() external view returns (ICErc20[] memory);\n}\n\n/**\n * @title PoolLensSecondary\n * @author David Lucid (https://github.com/davidlucid)\n * @notice PoolLensSecondary returns data on Ionic interest rate pools in mass for viewing by dApps, bots, etc.\n */\ncontract PoolLensSecondary is Initializable {\n /**\n * @notice Constructor to set the `PoolDirectory` contract object.\n */\n function initialize(PoolDirectory _directory) public initializer {\n require(address(_directory) != address(0), \"PoolDirectory instance cannot be the zero address.\");\n directory = _directory;\n }\n\n /**\n * @notice `PoolDirectory` contract object.\n */\n PoolDirectory public directory;\n\n /**\n * @notice Struct for ownership over a CToken.\n */\n struct CTokenOwnership {\n address cToken;\n address admin;\n bool adminHasRights;\n bool ionicAdminHasRights;\n }\n\n /**\n * @notice Returns the admin, admin rights, Ionic admin (constant), Ionic admin rights, and an array of cTokens with differing properties.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n * Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.\n */\n function getPoolOwnership(IonicComptroller comptroller)\n external\n view\n returns (\n address,\n bool,\n bool,\n CTokenOwnership[] memory\n )\n {\n // Get pool ownership\n address comptrollerAdmin = comptroller.admin();\n bool comptrollerAdminHasRights = comptroller.adminHasRights();\n bool comptrollerIonicAdminHasRights = comptroller.ionicAdminHasRights();\n\n // Get cToken ownership\n ICErc20[] memory cTokens = comptroller.getAllMarkets();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) arrayLength++;\n }\n\n CTokenOwnership[] memory outliers = new CTokenOwnership[](arrayLength);\n uint256 arrayIndex = 0;\n\n for (uint256 i = 0; i < cTokens.length; i++) {\n ICErc20 cToken = cTokens[i];\n (bool isListed, ) = comptroller.markets(address(cToken));\n if (!isListed) continue;\n\n address cTokenAdmin;\n try cToken.admin() returns (address _cTokenAdmin) {\n cTokenAdmin = _cTokenAdmin;\n } catch {\n continue;\n }\n bool cTokenAdminHasRights = cToken.adminHasRights();\n bool cTokenIonicAdminHasRights = cToken.ionicAdminHasRights();\n\n // If outlier, push to array and increment array index\n if (\n cTokenAdmin != comptrollerAdmin ||\n cTokenAdminHasRights != comptrollerAdminHasRights ||\n cTokenIonicAdminHasRights != comptrollerIonicAdminHasRights\n ) {\n outliers[arrayIndex] = CTokenOwnership(\n address(cToken),\n cTokenAdmin,\n cTokenAdminHasRights,\n cTokenIonicAdminHasRights\n );\n arrayIndex++;\n }\n }\n\n return (comptrollerAdmin, comptrollerAdminHasRights, comptrollerIonicAdminHasRights, outliers);\n }\n\n /**\n * @notice Determine the maximum redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum redeem amount.\n */\n function getMaxRedeem(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, false);\n }\n\n /**\n * @notice Determine the maximum borrow amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow amount.\n */\n function getMaxBorrow(address account, ICErc20 cTokenModify) external returns (uint256) {\n return getMaxRedeemOrBorrow(account, cTokenModify, true);\n }\n\n /**\n * @dev Internal function to determine the maximum borrow/redeem amount of a cToken.\n * @param cTokenModify The market to hypothetically borrow/redeem in.\n * @param account The account to determine liquidity for.\n * @return Maximum borrow/redeem amount.\n */\n function getMaxRedeemOrBorrow(\n address account,\n ICErc20 cTokenModify,\n bool isBorrow\n ) internal returns (uint256) {\n IonicComptroller comptroller = IonicComptroller(cTokenModify.comptroller());\n return comptroller.getMaxRedeemOrBorrow(account, cTokenModify, isBorrow);\n }\n\n /**\n * @notice Returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptroller The Ionic pool Comptroller to check.\n */\n function getRewardSpeedsByPool(IonicComptroller comptroller)\n public\n view\n returns (\n ICErc20[] memory,\n address[] memory,\n address[] memory,\n uint256[][] memory,\n uint256[][] memory\n )\n {\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n address[] memory distributors;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors = _distributors;\n } catch {\n distributors = new address[](0);\n }\n\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[][] memory supplySpeeds = new uint256[][](allMarkets.length);\n uint256[][] memory borrowSpeeds = new uint256[][](allMarkets.length);\n\n // Get reward tokens for each distributor\n for (uint256 i = 0; i < distributors.length; i++) {\n rewardTokens[i] = IRewardsDistributor_PLS(distributors[i]).rewardToken();\n }\n\n // Get reward speeds for each market for each distributor\n for (uint256 i = 0; i < allMarkets.length; i++) {\n address cToken = address(allMarkets[i]);\n supplySpeeds[i] = new uint256[](distributors.length);\n borrowSpeeds[i] = new uint256[](distributors.length);\n\n for (uint256 j = 0; j < distributors.length; j++) {\n IRewardsDistributor_PLS distributor = IRewardsDistributor_PLS(distributors[j]);\n supplySpeeds[i][j] = distributor.compSupplySpeeds(cToken);\n borrowSpeeds[i][j] = distributor.compBorrowSpeeds(cToken);\n }\n }\n\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice For each `Comptroller`, returns an array of all markets, an array of all `RewardsDistributor` contracts, an array of reward token addresses for each `RewardsDistributor`, an array of supply speeds for each distributor for each, and their borrow speeds.\n * @param comptrollers The Ionic pool Comptrollers to check.\n */\n function getRewardSpeedsByPools(IonicComptroller[] memory comptrollers)\n external\n view\n returns (\n ICErc20[][] memory,\n address[][] memory,\n address[][] memory,\n uint256[][][] memory,\n uint256[][][] memory\n )\n {\n ICErc20[][] memory allMarkets = new ICErc20[][](comptrollers.length);\n address[][] memory distributors = new address[][](comptrollers.length);\n address[][] memory rewardTokens = new address[][](comptrollers.length);\n uint256[][][] memory supplySpeeds = new uint256[][][](comptrollers.length);\n uint256[][][] memory borrowSpeeds = new uint256[][][](comptrollers.length);\n for (uint256 i = 0; i < comptrollers.length; i++)\n (allMarkets[i], distributors[i], rewardTokens[i], supplySpeeds[i], borrowSpeeds[i]) = getRewardSpeedsByPool(\n comptrollers[i]\n );\n return (allMarkets, distributors, rewardTokens, supplySpeeds, borrowSpeeds);\n }\n\n /**\n * @notice Returns unaccrued rewards by `holder` from `cToken` on `distributor`.\n * @param holder The address to check.\n * @param distributor The RewardsDistributor to check.\n * @param cToken The CToken to check.\n * @return Unaccrued (unclaimed) supply-side rewards and unaccrued (unclaimed) borrow-side rewards.\n */\n function getUnaccruedRewards(\n address holder,\n IRewardsDistributor_PLS distributor,\n ICErc20 cToken\n ) internal returns (uint256, uint256) {\n // Get unaccrued supply rewards\n uint256 compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreSupplierAction(address(cToken), holder);\n uint256 supplyRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Get unaccrued borrow rewards\n compAccruedPrior = distributor.compAccrued(holder);\n distributor.flywheelPreBorrowerAction(address(cToken), holder);\n uint256 borrowRewardsUnaccrued = distributor.compAccrued(holder) - compAccruedPrior;\n\n // Return both\n return (supplyRewardsUnaccrued, borrowRewardsUnaccrued);\n }\n\n /**\n * @notice Returns all unclaimed rewards accrued by the `holder` on `distributors`.\n * @param holder The address to check.\n * @param distributors The `RewardsDistributor` contracts to check.\n * @return For each of `distributors`: total quantity of unclaimed rewards, array of cTokens, array of unaccrued (unclaimed) supply-side and borrow-side rewards per cToken, and quantity of funds available in the distributor.\n */\n function getUnclaimedRewardsByDistributors(address holder, IRewardsDistributor_PLS[] memory distributors)\n external\n returns (\n address[] memory,\n uint256[] memory,\n ICErc20[][] memory,\n uint256[2][][] memory,\n uint256[] memory\n )\n {\n address[] memory rewardTokens = new address[](distributors.length);\n uint256[] memory compUnclaimedTotal = new uint256[](distributors.length);\n ICErc20[][] memory allMarkets = new ICErc20[][](distributors.length);\n uint256[2][][] memory rewardsUnaccrued = new uint256[2][][](distributors.length);\n uint256[] memory distributorFunds = new uint256[](distributors.length);\n\n for (uint256 i = 0; i < distributors.length; i++) {\n IRewardsDistributor_PLS distributor = distributors[i];\n rewardTokens[i] = distributor.rewardToken();\n allMarkets[i] = distributor.getAllMarkets();\n rewardsUnaccrued[i] = new uint256[2][](allMarkets[i].length);\n for (uint256 j = 0; j < allMarkets[i].length; j++)\n (rewardsUnaccrued[i][j][0], rewardsUnaccrued[i][j][1]) = getUnaccruedRewards(\n holder,\n distributor,\n allMarkets[i][j]\n );\n compUnclaimedTotal[i] = distributor.compAccrued(holder);\n distributorFunds[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(distributor));\n }\n\n return (rewardTokens, compUnclaimedTotal, allMarkets, rewardsUnaccrued, distributorFunds);\n }\n\n /**\n * @notice Returns arrays of indexes, `Comptroller` proxy contracts, and `RewardsDistributor` contracts for Ionic pools supplied to by `account`.\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getRewardsDistributorsBySupplier(address supplier)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n // Get array length\n (, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n uint256 arrayLength = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n try IonicComptroller(pools[i].comptroller).suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) arrayLength++;\n } catch {}\n }\n\n // Build array\n uint256[] memory indexes = new uint256[](arrayLength);\n IonicComptroller[] memory comptrollers = new IonicComptroller[](arrayLength);\n address[][] memory distributors = new address[][](arrayLength);\n uint256 index = 0;\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n\n try comptroller.suppliers(supplier) returns (bool isSupplier) {\n if (isSupplier) {\n indexes[index] = i;\n comptrollers[index] = comptroller;\n\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n distributors[index] = _distributors;\n } catch {}\n\n index++;\n }\n } catch {}\n }\n\n // Return distributors\n return (indexes, comptrollers, distributors);\n }\n\n /**\n * @notice The returned list of flywheels contains address(0) for flywheels for which the user has no rewards to claim\n * @dev This function is not designed to be called in a transaction: it is too gas-intensive.\n */\n function getFlywheelsToClaim(address user)\n external\n view\n returns (\n uint256[] memory,\n IonicComptroller[] memory,\n address[][] memory\n )\n {\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = directory.getActivePools();\n\n IonicComptroller[] memory comptrollers = new IonicComptroller[](pools.length);\n address[][] memory distributors = new address[][](pools.length);\n\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);\n try comptroller.getRewardsDistributors() returns (address[] memory _distributors) {\n comptrollers[i] = comptroller;\n distributors[i] = flywheelsWithRewardsForPoolUser(user, _distributors);\n } catch {}\n }\n\n return (poolIds, comptrollers, distributors);\n }\n\n function flywheelsWithRewardsForPoolUser(address user, address[] memory _distributors)\n internal\n view\n returns (address[] memory)\n {\n address[] memory distributors = new address[](_distributors.length);\n for (uint256 j = 0; j < _distributors.length; j++) {\n if (IRewardsDistributor_PLS(_distributors[j]).compAccrued(user) > 0) {\n distributors[j] = _distributors[j];\n }\n }\n\n return distributors;\n }\n}\n" + }, + "contracts/security/OracleRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\nimport { Ownable2Step } from \"@openzeppelin/contracts/access/Ownable2Step.sol\";\n\ncontract OracleRegistry is Ownable2Step {\n bytes32 private constant HYPERNATIVE_ORACLE_STORAGE_SLOT =\n bytes32(uint256(keccak256(\"eip1967.hypernative.oracle\")) - 1);\n bytes32 private constant HYPERNATIVE_MODE_STORAGE_SLOT =\n bytes32(uint256(keccak256(\"eip1967.hypernative.is_strict_mode\")) - 1);\n\n event OracleAdminChanged(address indexed previousAdmin, address indexed newAdmin);\n event OracleAddressChanged(address indexed previousOracle, address indexed newOracle);\n\n constructor() Ownable2Step() {}\n\n function oracleRegister(address _account) public {\n address oracleAddress = hypernativeOracle();\n bool isStrictMode = hypernativeOracleIsStrictMode();\n IHypernativeOracle oracle = IHypernativeOracle(oracleAddress);\n oracle.register(_account, isStrictMode);\n }\n\n function setOracle(address _oracle) public onlyOwner {\n _setOracle(_oracle);\n }\n\n function setIsStrictMode(bool _mode) public onlyOwner {\n _setIsStrictMode(_mode);\n }\n\n function hypernativeOracleIsStrictMode() public view returns (bool) {\n return _getValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT) == 1;\n }\n\n function hypernativeOracle() public view returns (address) {\n return _getAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT);\n }\n\n /**\n * @dev Admin only function, sets new oracle admin. set to address(0) to revoke oracle\n */\n function _setOracle(address _oracle) internal {\n address oldOracle = hypernativeOracle();\n _setAddressBySlot(HYPERNATIVE_ORACLE_STORAGE_SLOT, _oracle);\n emit OracleAddressChanged(oldOracle, _oracle);\n }\n\n function _setIsStrictMode(bool _mode) internal {\n _setValueBySlot(HYPERNATIVE_MODE_STORAGE_SLOT, _mode ? 1 : 0);\n }\n\n function _setAddressBySlot(bytes32 slot, address newAddress) internal {\n assembly {\n sstore(slot, newAddress)\n }\n }\n\n function _setValueBySlot(bytes32 _slot, uint256 _value) internal {\n assembly {\n sstore(_slot, _value)\n }\n }\n\n function _getAddressBySlot(bytes32 slot) internal view returns (address addr) {\n assembly {\n addr := sload(slot)\n }\n }\n\n function _getValueBySlot(bytes32 _slot) internal view returns (uint256 _value) {\n assembly {\n _value := sload(_slot)\n }\n }\n}\n" + }, + "contracts/test/abstracts/AbstractAssetTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { AbstractERC4626Test } from \"./AbstractERC4626Test.sol\";\nimport { ITestConfigStorage } from \"./ITestConfigStorage.sol\";\n\ncontract AbstractAssetTest is BaseTest {\n AbstractERC4626Test public test;\n ITestConfigStorage public testConfigStorage;\n\n function setUpTestContract(bytes calldata testConfig) public virtual {\n // test._setUp(MockERC20(address(IBeefyVault(testConfig.beefyVault).want())).symbol(), testConfig);\n }\n\n function runTest(function() external testFn) public {\n if (shouldRunForChain(block.chainid)) {\n for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n this.setUpTestContract(testConfigStorage.getTestConfig(i));\n testFn();\n }\n }\n }\n\n function testInitializedValues() public virtual {\n // for (uint8 i; i < testConfigStorage.getTestConfigLength(); i++) {\n // this.setUpTestContract(testConfigs[i]);\n // test.testInitializedValues(asset.name(), asset.symbol());\n // }\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n this.runTest(test.testPreviewDepositAndMintReturnTheSameValue);\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n this.runTest(test.testPreviewWithdrawAndRedeemReturnTheSameValue);\n }\n\n function testDeposit() public {\n this.runTest(test.testDeposit);\n }\n\n function testDepositWithIncreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithIncreasedVaultValue);\n }\n\n function testDepositWithDecreasedVaultValue() public virtual {\n this.runTest(test.testDepositWithDecreasedVaultValue);\n }\n\n function testMultipleDeposit() public {\n this.runTest(test.testMultipleDeposit);\n }\n\n function testMint() public {\n this.runTest(test.testMint);\n }\n\n function testMultipleMint() public {\n this.runTest(test.testMultipleMint);\n }\n\n function testWithdraw() public {\n this.runTest(test.testWithdraw);\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithIncreasedVaultValue);\n }\n\n function testWithdrawWithDecreasedVaultValue() public virtual {\n this.runTest(test.testWithdrawWithDecreasedVaultValue);\n }\n\n function testMultipleWithdraw() public {\n this.runTest(test.testMultipleWithdraw);\n }\n\n function testRedeem() public {\n this.runTest(test.testRedeem);\n }\n\n function testMultipleRedeem() public {\n this.runTest(test.testMultipleRedeem);\n }\n\n function testPauseContract() public {\n this.runTest(test.testPauseContract);\n }\n\n function testEmergencyWithdrawAndPause() public {\n this.runTest(test.testEmergencyWithdrawAndPause);\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n this.runTest(test.testEmergencyWithdrawAndRedeem);\n }\n}\n" + }, + "contracts/test/abstracts/AbstractERC4626Test.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../helpers/WithPool.sol\";\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { IonicERC4626 } from \"../../ionic/strategies/IonicERC4626.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Authority } from \"solmate/auth/Auth.sol\";\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nabstract contract AbstractERC4626Test is WithPool {\n using FixedPointMathLib for uint256;\n\n IonicERC4626 plugin;\n\n string testPreFix;\n\n uint256 public depositAmount = 100e18;\n uint256 BPS_DENOMINATOR = 10_000;\n\n uint256 initialStrategyBalance;\n uint256 initialStrategySupply;\n\n constructor() {\n _forkAtBlock(uint128(block.chainid), block.number);\n }\n\n function _setUp(string memory _testPreFix, bytes calldata data) public virtual;\n\n function deposit(address _owner, uint256 amount) public {\n vm.startPrank(_owner);\n underlyingToken.approve(address(plugin), amount);\n plugin.deposit(amount, _owner);\n vm.stopPrank();\n }\n\n function sendUnderlyingToken(uint256 amount, address recipient) public {\n deal(address(underlyingToken), recipient, amount);\n }\n\n function increaseAssetsInVault() public virtual {}\n\n function decreaseAssetsInVault() public virtual {}\n\n function getDepositShares() public view virtual returns (uint256);\n\n function getStrategyBalance() public view virtual returns (uint256);\n\n function getExpectedDepositShares() public view virtual returns (uint256);\n\n function testInitializedValues(string memory assetName, string memory assetSymbol) public virtual {\n assertEq(\n plugin.name(),\n string(abi.encodePacked(\"Midas \", assetName, \" Vault\")),\n string(abi.encodePacked(\"!name \", testPreFix))\n );\n assertEq(\n plugin.symbol(),\n string(abi.encodePacked(\"mv\", assetSymbol)),\n string(abi.encodePacked(\"!symbol \", testPreFix))\n );\n assertEq(address(plugin.asset()), address(underlyingToken), string(abi.encodePacked(\"!asset \", testPreFix)));\n // assertEq(\n // address(BeefyERC4626(address(plugin)).beefyVault()),\n // address(beefyVault),\n // string(abi.encodePacked(\"!beefyVault \", testPreFix))\n // );\n }\n\n function testPreviewDepositAndMintReturnTheSameValue() public {\n uint256 returnedShares = plugin.previewDeposit(depositAmount);\n assertApproxEqAbs(\n plugin.previewMint(returnedShares),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewMint \", testPreFix))\n );\n }\n\n function testPreviewWithdrawAndRedeemReturnTheSameValue() public {\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 reqShares = plugin.previewWithdraw(withdrawalAmount);\n assertApproxEqAbs(\n plugin.previewRedeem(reqShares),\n withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!previewRedeem \", testPreFix))\n );\n }\n\n function testDeposit() public virtual {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShares \", testPreFix))\n );\n }\n\n function testDepositWithIncreasedVaultValue() public {\n // lpDepositor just mints the exact amount of depositShares as the user deposits in assets\n uint256 oldExpectedDepositShare = this.getExpectedDepositShares();\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n oldExpected4626Shares + previewErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == oldExpectedShares \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n previewErc4626Shares,\n oldExpected4626Shares,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n assertApproxEqAbs(\n previewErc4626Shares,\n expected4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!previewShares == expectedShares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n oldExpectedDepositShare + expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares \", testPreFix))\n );\n }\n\n function testDepositWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n uint256 oldExpecteDepositShares = depositAmount;\n uint256 oldExpected4626Shares = plugin.previewDeposit(depositAmount);\n deposit(address(this), depositAmount);\n // Decrease the share price\n decreaseAssetsInVault();\n uint256 expectedDepositShare = depositAmount;\n uint256 previewErc4626Shares = plugin.previewDeposit(depositAmount);\n uint256 expected4626Shares = depositAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n sendUnderlyingToken(depositAmount, address(this));\n deposit(address(this), depositAmount);\n // Test that we minted the correct amount of token\n assertApproxEqAbs(plugin.balanceOf(address(this)), oldExpected4626Shares + previewErc4626Shares);\n // Test that we got less shares on the second mint after assets in the vault increased\n assertGt(previewErc4626Shares, oldExpected4626Shares, \"!new shares > old Shares\");\n assertApproxEqAbs(previewErc4626Shares, expected4626Shares, \"!previewShares == expectedShares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(this.getDepositShares(), oldExpecteDepositShares + expectedDepositShare);\n */\n }\n\n function testMultipleDeposit() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 expectedErc4626Shares = plugin.previewDeposit(depositAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount * 2,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount * 2,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"Total Assets should be same as sum of deposited amounts \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"Underlying token balance should be same as deposited amount \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(this) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n expectedErc4626Shares,\n uint256(10),\n string(abi.encodePacked(\"!expectedShares address(1) \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n expectedErc4626Shares * 2,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n // DotDot ERC4626 should not have underlyingToken after deposit\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testMultipleMint() public {\n uint256 expectedDepositShare = this.getExpectedDepositShares();\n uint256 mintAmount = plugin.previewDeposit(depositAmount);\n\n underlyingToken.approve(address(plugin), depositAmount);\n plugin.mint(mintAmount, address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n plugin.totalAssets(),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.convertToAssets(plugin.balanceOf(address(this))),\n depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare,\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n vm.startPrank(address(1));\n underlyingToken.approve(address(plugin), depositAmount);\n sendUnderlyingToken(depositAmount, address(1));\n plugin.mint(mintAmount, address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n this.getStrategyBalance(),\n initialStrategyBalance + depositAmount + depositAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.transfer \", testPreFix))\n );\n\n // Test that the balance view calls work\n assertApproxEqAbs(\n depositAmount + depositAmount,\n plugin.totalAssets(),\n uint256(10),\n string(abi.encodePacked(\"!2.totalAssets \", testPreFix))\n );\n assertApproxEqAbs(\n depositAmount,\n plugin.convertToAssets(plugin.balanceOf(address(1))),\n uint256(10),\n string(abi.encodePacked(\"!2.balOfUnderlying \", testPreFix))\n );\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.mint \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalSupply(),\n mintAmount + mintAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n expectedDepositShare * 2,\n uint256(10),\n string(abi.encodePacked(\"!2.depositShare \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n uint256(2),\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n vm.stopPrank();\n }\n\n function testWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n assertTrue(underlyingToken.balanceOf(address(plugin)) <= 1, string(abi.encodePacked(\"!0 \", testPreFix)));\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testWithdrawWithIncreasedVaultValue() public virtual {\n uint256 depositShareBal = this.getExpectedDepositShares();\n\n deposit(address(this), depositAmount);\n\n uint256 withdrawalAmount = 10e18;\n\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Increase the share price\n increaseAssetsInVault();\n\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!mint \", testPreFix))\n );\n\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(\n expectedErc4626SharesNeeded,\n oldExpectedErc4626SharesNeeded,\n string(abi.encodePacked(\"!new shares < old Shares \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + ExpectedDepositSharesNeeded),\n uint256(10),\n string(abi.encodePacked(\"!depositShare \", testPreFix))\n );\n }\n\n function testWithdrawWithDecreasedVaultValue() public {\n // THIS TEST WILL ALWAYS FAIL\n // A transfer out of the lpStaker will always fail.\n // There also doesnt seem another way to reduce the balance of lpStaker so we cant test this scenario\n /* =============== ACTUAL TEST =============== */\n /*\n sendUnderlyingToken(depositAmount, address(this));\n uint256 depositShares = this.getExpectedDepositShares();\n deposit(address(this), depositAmount);\n uint256 withdrawalAmount = 10e18;\n uint256 oldExpectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 oldExpectedDepositSharesNeeded = oldExpectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Increase the share price\n decreaseAssetsInVault();\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n plugin.withdraw(withdrawalAmount, address(this), address(this));\n // Test that we minted the correct amount of token\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - (oldExpectedErc4626SharesNeeded + expectedErc4626SharesNeeded)\n );\n // Test that we got less shares on the second mint after assets in the vault increased\n assertLe(expectedErc4626SharesNeeded, oldExpectedErc4626SharesNeeded, \"!new shares < old Shares\");\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShareBal - (oldExpectedDepositSharesNeeded + expectedDepositSharesNeeded)\n );\n */\n }\n\n function testMultipleWithdraw() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n uint256 ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(\n this.getDepositShares(),\n plugin.totalSupply()\n );\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal\", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n depositAmount * 2 - expectedErc4626SharesNeeded,\n plugin.totalSupply(),\n 10,\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 1,\n 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - expectedErc4626SharesNeeded;\n depositShares = depositShares - ExpectedDepositSharesNeeded;\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n expectedErc4626SharesNeeded = plugin.previewWithdraw(withdrawalAmount);\n ExpectedDepositSharesNeeded = expectedErc4626SharesNeeded.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - expectedErc4626SharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n 2,\n 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares();\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!dotDot share balance \", testPreFix))\n );\n }\n\n function testMultipleRedeem() public virtual {\n uint256 depositShares = this.getExpectedDepositShares() * 2;\n\n uint256 withdrawalAmount = 10e18;\n uint256 redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n\n deposit(address(this), depositAmount);\n\n sendUnderlyingToken(depositAmount, address(1));\n deposit(address(1), depositAmount);\n\n uint256 assetBalBefore = underlyingToken.balanceOf(address(this));\n uint256 erc4626BalBefore = plugin.balanceOf(address(this));\n uint256 ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n\n plugin.withdraw(10e18, address(this), address(this));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n depositAmount * 2 - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!1.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!1.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 1,\n string(abi.encodePacked(\"1.DotDot erc4626 locked amount checking \", testPreFix))\n );\n\n uint256 totalSupplyBefore = depositAmount * 2 - redeemAmount;\n depositShares -= ExpectedDepositSharesNeeded;\n redeemAmount = plugin.previewWithdraw(withdrawalAmount);\n assetBalBefore = underlyingToken.balanceOf(address(1));\n erc4626BalBefore = plugin.balanceOf(address(1));\n ExpectedDepositSharesNeeded = redeemAmount.mulDivUp(this.getDepositShares(), plugin.totalSupply());\n vm.prank(address(1));\n plugin.withdraw(10e18, address(1), address(1));\n\n // Test that the actual transfers worked\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(1)),\n assetBalBefore + withdrawalAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.user asset bal \", testPreFix))\n );\n\n // Test that the balance view calls work\n // I just couldnt not calculate this properly. i was for some reason always ~ 1 BPS off\n // uint256 expectedAssetsAfter = depositAmount - (ExpectedDepositSharesNeeded + (ExpectedDepositSharesNeeded / 1000));\n //assertApproxEqAbs(plugin.totalAssets(), expectedAssetsAfter, \"!erc4626 asset bal\");\n assertApproxEqAbs(\n plugin.totalSupply(),\n totalSupplyBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.totalSupply \", testPreFix))\n );\n\n // Test that we burned the right amount of shares\n assertApproxEqAbs(\n plugin.balanceOf(address(1)),\n erc4626BalBefore - redeemAmount,\n uint256(10),\n string(abi.encodePacked(\"!2.erc4626 supply \", testPreFix))\n );\n\n // Test that the ERC4626 holds the expected amount of dotDot shares\n assertApproxEqAbs(\n this.getDepositShares(),\n depositShares - ExpectedDepositSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!2.dotDot share balance \", testPreFix))\n );\n assertTrue(\n underlyingToken.balanceOf(address(plugin)) <= 2,\n string(abi.encodePacked(\"2.DotDot erc4626 locked amount checking \", testPreFix))\n );\n }\n\n function testPauseContract() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n underlyingToken.approve(address(plugin), depositAmount);\n vm.expectRevert(\"Pausable: paused\");\n plugin.deposit(depositAmount, address(this));\n\n vm.expectRevert(\"Pausable: paused\");\n plugin.mint(depositAmount, address(this));\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndPause() public virtual {\n deposit(address(this), depositAmount);\n\n uint256 expectedBal = plugin.previewRedeem(depositAmount);\n assertEq(underlyingToken.balanceOf(address(plugin)), 0, string(abi.encodePacked(\"!init 0 \", testPreFix)));\n\n plugin.emergencyWithdrawAndPause();\n\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(plugin)),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!withdraws underlying \", testPreFix))\n );\n assertApproxEqAbs(\n plugin.totalAssets(),\n expectedBal,\n uint256(10),\n string(abi.encodePacked(\"!totalAssets == expectedBal \", testPreFix))\n );\n }\n\n function testEmergencyWithdrawAndRedeem() public {\n uint256 withdrawAmount = 1e18;\n\n deposit(address(this), depositAmount);\n\n vm.warp(block.timestamp + 10);\n\n plugin.emergencyWithdrawAndPause();\n\n uint256 expectedSharesNeeded = withdrawAmount.mulDivDown(plugin.totalSupply(), plugin.totalAssets());\n plugin.withdraw(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!withdraw share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount,\n uint256(10),\n string(abi.encodePacked(\"!withdraw asset bal \", testPreFix))\n );\n\n uint256 expectedAssets = withdrawAmount.mulDivUp(plugin.totalAssets(), plugin.totalSupply());\n plugin.redeem(withdrawAmount, address(this), address(this));\n\n assertApproxEqAbs(\n plugin.balanceOf(address(this)),\n depositAmount - withdrawAmount - expectedSharesNeeded,\n uint256(10),\n string(abi.encodePacked(\"!redeem share bal \", testPreFix))\n );\n assertApproxEqAbs(\n underlyingToken.balanceOf(address(this)),\n withdrawAmount + expectedAssets,\n uint256(10),\n string(abi.encodePacked(\"!redeem asset bal \", testPreFix))\n );\n }\n}\n" + }, + "contracts/test/abstracts/ITestConfigStorage.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface ITestConfigStorage {\n function getTestConfig(uint256 i) external view returns (bytes memory);\n\n function getTestConfigLength() external view returns (uint256);\n}\n" + }, + "contracts/test/AccountLiquidityTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract AccountLiquidityTest is UpgradesBaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n } else {\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testUserMaxWithdraw() public debuggingOnly forkAtBlock(MODE_MAINNET, 5890823) {\n address user = 0xBf891E7eFCC98A8239385D3172bA10AD593c7886;\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n _upgradePoolWithExtension(asUnitroller);\n\n {\n _testAccountLiquidity(user);\n\n uint256 maxRedeem = lens2.getMaxRedeem(user, wethMarket);\n emit log_named_uint(\"maxRedeem\", maxRedeem);\n\n bool isMember = pool.checkMembership(user, wethMarket);\n emit log(isMember ? \"is member\" : \"NOT A MEMBER\");\n }\n //vm.rollFork(5891795);\n // redeemed before liquidation at 5890822\n\n // before withdraw call at block 5890821\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 156238264982770748812\n // liquidity: 16428491404549045373\n // maxRedeem: 23469273435070064818\n // is member\n\n // user calls withdraw with max(uint256) at block 5890822\n // user: 0xBf891E7eFCC98A8239385D3172bA10AD593c7886\n // collateralValue: 139809773853485792955\n // SHORTFALL: 257892668904\n // maxRedeem: 0\n // is member\n\n // liquidated at 5890902\n // https://explorer.mode.network/tx/0x424fd0504e7afb00382c6dcd25a2efdefd96c005c2333112be450fc7bd98cc88\n }\n}\n" + }, + "contracts/test/AccrueInterestTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\n\nstruct AccrualDiff {\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalIonicFees;\n uint256 totalAdminFees;\n}\n\ncontract AccrueInterestTest is UpgradesBaseTest {\n // fork before the accrue interest refactoring\n function testAccrueInterest() public debuggingOnly forkAtBlock(BSC_MAINNET, 26032460) {\n address busdMarketAddress = 0xa7213deB44f570646Ea955771Cc7f39B58841363;\n address wbnbMarketAddress = 0x57a64a77f8E4cFbFDcd22D5551F52D675cc5A956;\n\n _testAccrueInterest(wbnbMarketAddress);\n }\n\n function _testAccrueInterest(address marketAddress) internal {\n //CErc20Delegate market = CErc20Delegate(marketAddress);\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(marketAddress);\n ICErc20 market = ICErc20(marketAddress);\n\n uint256 adminFeeMantissa = market.adminFeeMantissa();\n uint256 ionicFeeMantissa = market.ionicFeeMantissa();\n uint256 reserveFactorMantissa = market.reserveFactorMantissa();\n\n // test with the logic before the refactoring\n\n AccrualDiff memory diffBefore;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index old impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows old impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves old impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees old impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees old impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply old impl\");\n\n diffBefore.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffBefore.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffBefore.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffBefore.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffBefore.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n // test with the logic after the refactoring\n vm.rollFork(26032460);\n afterForkSetUp();\n _upgradeMarketWithExtension(market);\n\n AccrualDiff memory diffAfter;\n // accrue at the latest block in order to have an equal/comparable accrual period\n marketAsExt.accrueInterest();\n {\n CTokenFirstExtension.InterestAccrual memory accrualDataBefore;\n CTokenFirstExtension.InterestAccrual memory accrualDataAfter;\n\n accrualDataBefore.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataBefore.borrowIndex = marketAsExt.borrowIndex();\n accrualDataBefore.totalBorrows = marketAsExt.totalBorrows();\n accrualDataBefore.totalReserves = marketAsExt.totalReserves();\n accrualDataBefore.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataBefore.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataBefore.totalSupply = marketAsExt.totalSupply();\n\n vm.roll(block.number + 1e6); // move 1M blocks forward\n marketAsExt.accrueInterest();\n\n accrualDataAfter.accrualBlockNumber = marketAsExt.accrualBlockNumber();\n accrualDataAfter.borrowIndex = marketAsExt.borrowIndex();\n accrualDataAfter.totalBorrows = marketAsExt.totalBorrows();\n accrualDataAfter.totalReserves = marketAsExt.totalReserves();\n accrualDataAfter.totalIonicFees = marketAsExt.totalIonicFees();\n accrualDataAfter.totalAdminFees = marketAsExt.totalAdminFees();\n accrualDataAfter.totalSupply = marketAsExt.totalSupply();\n\n assertEq(\n accrualDataBefore.accrualBlockNumber,\n accrualDataAfter.accrualBlockNumber - 1e6,\n \"!total supply old impl\"\n );\n assertLt(accrualDataBefore.borrowIndex, accrualDataAfter.borrowIndex, \"!borrow index new impl\");\n assertLt(accrualDataBefore.totalBorrows, accrualDataAfter.totalBorrows, \"!total borrows new impl\");\n if (reserveFactorMantissa > 0) {\n assertLt(accrualDataBefore.totalReserves, accrualDataAfter.totalReserves, \"!total reserves new impl\");\n }\n if (ionicFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalIonicFees, accrualDataAfter.totalIonicFees, \"!total ionic fees new impl\");\n }\n if (adminFeeMantissa > 0) {\n assertLt(accrualDataBefore.totalAdminFees, accrualDataAfter.totalAdminFees, \"!total admin fees new impl\");\n }\n assertEq(accrualDataBefore.totalSupply, accrualDataAfter.totalSupply, \"!total supply new impl\");\n\n diffAfter.borrowIndex = accrualDataAfter.borrowIndex - accrualDataBefore.borrowIndex;\n diffAfter.totalBorrows = accrualDataAfter.totalBorrows - accrualDataBefore.totalBorrows;\n diffAfter.totalReserves = accrualDataAfter.totalReserves - accrualDataBefore.totalReserves;\n diffAfter.totalIonicFees = accrualDataAfter.totalIonicFees - accrualDataBefore.totalIonicFees;\n diffAfter.totalAdminFees = accrualDataAfter.totalAdminFees - accrualDataBefore.totalAdminFees;\n }\n\n assertEq(diffBefore.borrowIndex, diffAfter.borrowIndex, \"!borrowIndexDiff\");\n assertEq(diffBefore.totalBorrows, diffAfter.totalBorrows, \"!totalBorrowsDiff\");\n assertEq(diffBefore.totalReserves, diffAfter.totalReserves, \"!totalReservesDiff\");\n assertEq(diffBefore.totalIonicFees, diffAfter.totalIonicFees, \"!totalIonicFeesDiff\");\n assertEq(diffBefore.totalAdminFees, diffAfter.totalAdminFees, \"!totalAdminFeesDiff\");\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testMintGated() public fork(POLYGON_MAINNET) {\n address newMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address assetWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n // approve spending\n vm.startPrank(assetWhale);\n IERC20Upgradeable(CErc20Delegate(newMarket).underlying()).approve(newMarket, 1e6);\n require(CErc20Delegate(newMarket).mint(1e6) == 0, \"!mint failed\");\n vm.stopPrank();\n }\n\n function testDeployCToken() public debuggingOnly fork(POLYGON_MAINNET) {\n CErc20Delegate cErc20Delegate = new CErc20Delegate();\n IonicComptroller pool = IonicComptroller(0x69617fE545804BcDfE853626B4C8EF23475Ac54B);\n emit log_named_address(\"admin\", pool.admin());\n pool.adminHasRights();\n vm.startPrank(0x9308dddeC9B5cCd8a2685A46E913C892FE31C826);\n pool._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(0xb5DFABd7fF7F83BAB83995E72A52B97ABb7bcf63),\n 0x69617fE545804BcDfE853626B4C8EF23475Ac54B,\n payable(address(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c)),\n InterestRateModel(address(0xA433B7d3a8A87D8fd40dA68A424007Dd8a21Ce41)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(0),\n uint256(0)\n ),\n \"\",\n 0.72e18\n );\n vm.stopPrank();\n // _functionCall(0xC40119C7269A5FA813d878BF83d14E3462fC8Fde, hex\"8f93bfba\", \"raw liquidation failed\");\n }\n\n function testDeployNeonPool() public debuggingOnly fork(NEON_MAINNET) {\n PoolDirectory poolDirectory = PoolDirectory(0x297a15F615aCdf87580af1Fc497EE57424975Dae);\n FeeDistributor ionicAdmin = FeeDistributor(payable(0x62E27eA8d0389390039277CFfD83Ca18ce9B2D9c));\n Comptroller tempComptroller = new Comptroller();\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n vm.prank(ionicAdmin.owner());\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))), // FD\n false,\n 0.1e18,\n 1.1e18,\n 0xBAAb9986A7002ad67cb5a9C1761210C2Cdd98BFa // MPO\n );\n }\n}\n" + }, + "contracts/test/AuthoritiesRegistryTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport \"../ionic/AuthoritiesRegistry.sol\";\nimport \"./helpers/WithPool.sol\";\nimport { RolesAuthority, Authority } from \"solmate/auth/authorities/RolesAuthority.sol\";\n\ncontract AuthoritiesRegistryTest is WithPool {\n AuthoritiesRegistry registry;\n\n function afterForkSetUp() internal override {\n registry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n if (address(registry) == address(0)) {\n address proxyAdmin = address(999);\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), proxyAdmin, \"\");\n registry = AuthoritiesRegistry(address(proxy));\n registry.initialize(address(1023));\n }\n\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n setUpPool(\"auth-reg-test\", false, 0.1e18, 1.1e18);\n }\n\n function testRegistry() public fork(POLYGON_MAINNET) {\n PoolRolesAuthority auth;\n\n vm.prank(address(555));\n vm.expectRevert(\"Ownable: caller is not the owner\");\n auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n auth = registry.createPoolAuthority(address(comptroller));\n\n assertEq(auth.owner(), registry.owner(), \"!same owner\");\n }\n\n function testAuthReconfigurePermissions() public fork(POLYGON_MAINNET) {\n vm.prank(registry.owner());\n PoolRolesAuthority auth = registry.createPoolAuthority(address(comptroller));\n\n vm.prank(address(8283));\n vm.expectRevert(\"not owner or pool\");\n registry.reconfigureAuthority(address(comptroller));\n\n vm.prank(registry.owner());\n registry.reconfigureAuthority(address(comptroller));\n }\n\n function upgradeRegistry() internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(registry)));\n AuthoritiesRegistry newImpl = new AuthoritiesRegistry();\n vm.startPrank(dpa.owner());\n dpa.upgradeAndCall(\n proxy,\n address(newImpl),\n abi.encodeWithSelector(AuthoritiesRegistry.reinitialize.selector, registry.leveredPositionsFactory())\n );\n vm.stopPrank();\n }\n\n function upgradeAuth(PoolRolesAuthority auth) internal {\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n PoolRolesAuthority newImpl = new PoolRolesAuthority();\n vm.prank(dpa.owner());\n dpa.upgrade(proxy, address(newImpl));\n }\n\n function testAuthPermissions() public debuggingOnly fork(BSC_CHAPEL) {\n address pool = 0xa4bc2fCF2F9d87EB349f74f8729024F92A030330;\n registry = AuthoritiesRegistry(0xa5E190Fa38F325617381e835da8b2DB2D12cE5eb);\n //upgradeRegistry();\n\n PoolRolesAuthority auth = PoolRolesAuthority(0xFe5AfFFC8b55A2d139cb2ef76699C8B58c1EA299);\n //upgradeAuth(auth);\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(auth)));\n\n vm.prank(address(dpa));\n emit log_named_address(\"proxy.implementation\", proxy.implementation());\n\n emit log_named_address(\"registry.poolAuthLogic\", address(registry.poolAuthLogic()));\n //vm.prank(registry.owner());\n //registry.reconfigureAuthority(pool);\n\n bool isReg = auth.doesUserHaveRole(address(registry), auth.REGISTRY_ROLE());\n assertEq(isReg, true, \"!not registry role\");\n\n bool canCall = auth.canCall(address(registry), address(auth), RolesAuthority.setUserRole.selector);\n assertEq(canCall, true, \"!cannot call setUserRol\");\n }\n}\n" + }, + "contracts/test/caps/AdrastiaPrudentiaCapsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { ComptrollerPrudentiaCapsExt, DiamondExtension } from \"../../compound/ComptrollerPrudentiaCapsExt.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { ComptrollerV4Storage } from \"../../compound/ComptrollerStorage.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\nimport { PrudentiaLib } from \"../../adrastia/PrudentiaLib.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MockPriceOracle } from \"../../oracles/1337/MockPriceOracle.sol\";\n\nimport \"adrastia-periphery/rates/IHistoricalRates.sol\";\n\nabstract contract HistoricalRates is IHistoricalRates {\n struct BufferMetadata {\n uint8 start;\n uint8 end;\n uint8 size;\n uint8 maxSize;\n bool pauseUpdates; // Note: this is left for extentions, but is not used in this contract.\n }\n\n /// @notice Event emitted when a rate buffer's capacity is increased past the initial capacity.\n /// @dev Buffer initialization does not emit an event.\n /// @param token The token for which the rate buffer's capacity was increased.\n /// @param oldCapacity The previous capacity of the rate buffer.\n /// @param newCapacity The new capacity of the rate buffer.\n event RatesCapacityIncreased(address indexed token, uint256 oldCapacity, uint256 newCapacity);\n\n /// @notice Event emitted when a rate buffer's capacity is initialized.\n /// @param token The token for which the rate buffer's capacity was initialized.\n /// @param capacity The capacity of the rate buffer.\n event RatesCapacityInitialized(address indexed token, uint256 capacity);\n\n /// @notice Event emitted when a new rate is pushed to the rate buffer.\n /// @param token The token for which the rate was pushed.\n /// @param target The target rate.\n /// @param current The current rate, which may be different from the target rate if the rate change is capped.\n /// @param timestamp The timestamp at which the rate was pushed.\n event RateUpdated(address indexed token, uint256 target, uint256 current, uint256 timestamp);\n\n /// @notice An error that is thrown if we try to initialize a rate buffer that has already been initialized.\n /// @param token The token for which we tried to initialize the rate buffer.\n error BufferAlreadyInitialized(address token);\n\n /// @notice An error that is thrown if we try to retrieve a rate at an invalid index.\n /// @param token The token for which we tried to retrieve the rate.\n /// @param index The index of the rate that we tried to retrieve.\n /// @param size The size of the rate buffer.\n error InvalidIndex(address token, uint256 index, uint256 size);\n\n /// @notice An error that is thrown if we try to decrease the capacity of a rate buffer.\n /// @param token The token for which we tried to decrease the capacity of the rate buffer.\n /// @param amount The capacity that we tried to decrease the rate buffer to.\n /// @param currentCapacity The current capacity of the rate buffer.\n error CapacityCannotBeDecreased(address token, uint256 amount, uint256 currentCapacity);\n\n /// @notice An error that is thrown if we try to increase the capacity of a rate buffer past the maximum capacity.\n /// @param token The token for which we tried to increase the capacity of the rate buffer.\n /// @param amount The capacity that we tried to increase the rate buffer to.\n /// @param maxCapacity The maximum capacity of the rate buffer.\n error CapacityTooLarge(address token, uint256 amount, uint256 maxCapacity);\n\n /// @notice An error that is thrown if we try to retrieve more rates than are available in the rate buffer.\n /// @param token The token for which we tried to retrieve the rates.\n /// @param size The size of the rate buffer.\n /// @param minSizeRequired The minimum size of the rate buffer that we require.\n error InsufficientData(address token, uint256 size, uint256 minSizeRequired);\n\n /// @notice The initial capacity of the rate buffer.\n uint8 internal immutable initialBufferCardinality;\n\n /// @notice Maps a token to its metadata.\n mapping(address => BufferMetadata) internal rateBufferMetadata;\n\n /// @notice Maps a token to a buffer of rates.\n mapping(address => RateLibrary.Rate[]) internal rateBuffers;\n\n /**\n * @notice Constructs the HistoricalRates contract with a specified initial buffer capacity.\n * @param initialBufferCardinality_ The initial capacity of the rate buffer.\n */\n constructor(uint8 initialBufferCardinality_) {\n initialBufferCardinality = initialBufferCardinality_;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRateAt(address token, uint256 index) external view virtual override returns (RateLibrary.Rate memory) {\n BufferMetadata memory meta = rateBufferMetadata[token];\n\n if (index >= meta.size) {\n revert InvalidIndex(token, index, meta.size);\n }\n\n uint256 bufferIndex = meta.end < index ? meta.end + meta.size - index : meta.end - index;\n\n return rateBuffers[token][bufferIndex];\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(address token, uint256 amount) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, 0, 1);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) external view virtual override returns (RateLibrary.Rate[] memory) {\n return _getRates(token, amount, offset, increment);\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCount(address token) external view override returns (uint256) {\n return rateBufferMetadata[token].size;\n }\n\n /// @inheritdoc IHistoricalRates\n function getRatesCapacity(address token) external view virtual override returns (uint256) {\n uint256 maxSize = rateBufferMetadata[token].maxSize;\n if (maxSize == 0) return initialBufferCardinality;\n\n return maxSize;\n }\n\n /// @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n /// less than 256.\n /// @inheritdoc IHistoricalRates\n function setRatesCapacity(address token, uint256 amount) external virtual {\n _setRatesCapacity(token, amount);\n }\n\n /**\n * @dev Internal function to set the capacity of the rate buffer for a token.\n * @param token The token for which to set the new capacity.\n * @param amount The new capacity of rates for the token. Must be greater than the current capacity, but\n * less than 256.\n */\n function _setRatesCapacity(address token, uint256 amount) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (amount < meta.maxSize) revert CapacityCannotBeDecreased(token, amount, meta.maxSize);\n if (amount > type(uint8).max) revert CapacityTooLarge(token, amount, type(uint8).max);\n\n RateLibrary.Rate[] storage rateBuffer = rateBuffers[token];\n\n // Add new slots to the buffer\n uint256 capacityToAdd = amount - meta.maxSize;\n for (uint256 i = 0; i < capacityToAdd; ++i) {\n // Push a dummy rate with non-zero values to put most of the gas cost on the caller\n rateBuffer.push(RateLibrary.Rate({ target: 1, current: 1, timestamp: 1 }));\n }\n\n if (meta.maxSize != amount) {\n emit RatesCapacityIncreased(token, meta.maxSize, amount);\n\n // Update the metadata\n meta.maxSize = uint8(amount);\n }\n }\n\n /**\n * @dev Internal function to get historical rates with specified amount, offset, and increment.\n * @param token The token for which to retrieve the rates.\n * @param amount The number of historical rates to retrieve.\n * @param offset The number of rates to skip before starting to collect the rates.\n * @param increment The step size between the rates to collect.\n * @return observations An array of Rate structs containing the retrieved historical rates.\n */\n function _getRates(\n address token,\n uint256 amount,\n uint256 offset,\n uint256 increment\n ) internal view virtual returns (RateLibrary.Rate[] memory) {\n if (amount == 0) return new RateLibrary.Rate[](0);\n\n BufferMetadata memory meta = rateBufferMetadata[token];\n if (meta.size <= (amount - 1) * increment + offset)\n revert InsufficientData(token, meta.size, (amount - 1) * increment + offset + 1);\n\n RateLibrary.Rate[] memory observations = new RateLibrary.Rate[](amount);\n\n uint256 count = 0;\n\n for (\n uint256 i = meta.end < offset ? meta.end + meta.size - offset : meta.end - offset;\n count < amount;\n i = (i < increment) ? (i + meta.size) - increment : i - increment\n ) {\n observations[count++] = rateBuffers[token][i];\n }\n\n return observations;\n }\n\n /**\n * @dev Internal function to initialize rate buffers for a token.\n * @param token The token for which to initialize the rate buffer.\n */\n function initializeBuffers(address token) internal virtual {\n if (rateBuffers[token].length != 0) {\n revert BufferAlreadyInitialized(token);\n }\n\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n // Initialize the buffers\n RateLibrary.Rate[] storage observationBuffer = rateBuffers[token];\n\n for (uint256 i = 0; i < initialBufferCardinality; ++i) {\n observationBuffer.push();\n }\n\n // Initialize the metadata\n meta.start = 0;\n meta.end = 0;\n meta.size = 0;\n meta.maxSize = initialBufferCardinality;\n meta.pauseUpdates = false;\n\n emit RatesCapacityInitialized(token, meta.maxSize);\n }\n\n /**\n * @dev Internal function to push a new rate data into the rate buffer and update metadata accordingly.\n * @param token The token for which to push the new rate data.\n * @param rate The Rate struct containing target rate, current rate, and timestamp data to be pushed.\n */\n function push(address token, RateLibrary.Rate memory rate) internal virtual {\n BufferMetadata storage meta = rateBufferMetadata[token];\n\n if (meta.size == 0) {\n if (meta.maxSize == 0) {\n // Initialize the buffers\n initializeBuffers(token);\n }\n } else {\n meta.end = (meta.end + 1) % meta.maxSize;\n }\n\n rateBuffers[token][meta.end] = rate;\n\n emit RateUpdated(token, rate.target, rate.current, block.timestamp);\n\n if (meta.size < meta.maxSize && meta.end == meta.size) {\n // We are at the end of the array and we have not yet filled it\n meta.size++;\n } else {\n // start was just overwritten\n meta.start = (meta.start + 1) % meta.size;\n }\n }\n}\n\ncontract PrudentiaStub is HistoricalRates {\n constructor() HistoricalRates(2) {}\n\n function stubPush(address underlyingToken, uint64 rate) public {\n push(underlyingToken, RateLibrary.Rate({ target: rate, current: rate, timestamp: uint32(block.timestamp) }));\n }\n}\n\ncontract AdrastiaPrudentiaCapsTest is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicComptroller comptroller;\n\n InterestRateModel interestModel;\n MockPriceOracle priceOracle;\n\n MockERC20 underlyingToken1;\n ICErc20 cToken1;\n\n MockERC20 underlyingToken2;\n ICErc20 cToken2;\n\n MockERC20 underlyingToken3;\n ICErc20 cToken3;\n\n CErc20Delegate cErc20Delegate;\n\n PrudentiaStub prudentia;\n\n function setUp() public {\n // Deploy admin contracts\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n // Deploy comptroller logic\n Comptroller comptrollerLogic = new Comptroller();\n\n // Deploy underlying tokens\n underlyingToken1 = new MockERC20(\"UnderlyingToken1\", \"UT1\", 18);\n underlyingToken1.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken2 = new MockERC20(\"UnderlyingToken2\", \"UT2\", 18);\n underlyingToken2.mint(address(this), 1000000e18); // 1M tokens\n underlyingToken3 = new MockERC20(\"UnderlyingToken3\", \"UT3\", 6);\n underlyingToken3.mint(address(this), 1000000e6); // 1M tokens\n\n // Deploy cToken delegates\n cErc20Delegate = new CErc20Delegate();\n\n // Deploy price oracle\n priceOracle = new MockPriceOracle(10);\n\n // Deploy IRM\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n\n // Deploy comptroller\n address[] memory unitroller = new address[](1);\n unitroller[0] = address(comptrollerLogic);\n address[] memory addressZero = new address[](1);\n addressZero[0] = address(0);\n bool[] memory boolTrue = new bool[](1);\n boolTrue[0] = true;\n bool[] memory boolFalse = new bool[](1);\n boolFalse[0] = false;\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(comptrollerLogic));\n DiamondExtension[] memory extensions = new DiamondExtension[](3);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = new ComptrollerPrudentiaCapsExt();\n extensions[2] = comptrollerLogic;\n ionicAdmin._setComptrollerExtensions(address(comptrollerLogic), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\", // name\n address(comptrollerLogic), // implementation address\n abi.encode(payable(address(ionicAdmin))), // constructor args\n false, // whitelist enforcement\n 0.1e18, // close factor = 10%\n 1.1e18, // liquidation incentive = 110%\n address(priceOracle) // price oracle\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n\n // Setup CErc20Delegate whitelist\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](1);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n address[] memory oldCErc20Implementations = new address[](1);\n oldCErc20Implementations[0] = address(0);\n address[] memory newCErc20Implementations = new address[](1);\n newCErc20Implementations[0] = address(cErc20Delegate);\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n // Deploy cToken1\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken1), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 1\", // cToken name\n \"CT1\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken2\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken2), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 2\", // cToken name\n \"CT2\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Deploy cToken3\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken3), // underlying token\n comptroller, // comptroller\n payable(address(ionicAdmin)), // admin\n InterestRateModel(address(interestModel)), // interest rate model\n \"cToken 3\", // cToken name\n \"CT3\", // cToken symbol\n uint256(1), // reserve factor\n uint256(0) // admin fee\n ),\n \"\",\n 0.9e18 // collateral factor = 90%\n );\n\n // Store the cToken addresses\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n assertEq(allMarkets.length, 3);\n cToken1 = allMarkets[0];\n cToken2 = allMarkets[1];\n cToken3 = allMarkets[2];\n\n // Deploy Prudentia\n prudentia = new PrudentiaStub();\n }\n\n function test_NativeCaps_UnrestrictedSupply() public {\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), 0); // No supply cap set (unrestricted)\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n }\n\n function test_NativeCaps_RestrictedSupply() public {\n uint256 cap = 9999e18; // supply cap of 9,999\n uint256 mintAmount = 10000e18; // mint of 10,000\n\n // Set a native supply cap for cToken1\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = cap;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cTokens[0])), supplyCaps[0]);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_NativeCaps_UnrestrictedBorrow() public {\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // No borrow cap set (unrestricted)\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n cToken2.borrow(1000e18); // Borrow 1,000 cToken2\n }\n\n function test_NativeCaps_RestrictedBorrow() public {\n uint256 cap = 999e18; // borrow cap of 999\n uint256 borrowAmount = 1000e18; // borrow of 1,000\n\n // Set a native borrow cap for cToken2\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = cap;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cTokens[0])), borrowCaps[0]);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0\n */\n\n function test_Prudentia_Supply_Unrestricted() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Supply cap\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken2\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted supply cap for cToken2\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken2)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_WithRateConfiguredForAnotherCToken() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken1\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted borrow cap for cToken1\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken1)), 0); // Unrestricted\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftPos1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e19);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e19);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and a decimal shift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_DecShiftNeg1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e17);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e17);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n * Prudentia caps tests with an offset of 0 and using a cToken with the underlying token having 6 decimals\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e6);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 10000 / 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftPos1() public {\n uint64 cap = 1000 / 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: 1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e7);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 0, using a cToken with the underlying token having 6 decimals,\n * and a decimalShift of -1\n */\n\n function test_Prudentia_Supply_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), cap); // Unrestricted\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 9999e6; // mint of 9,999\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(mintAmount); // Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), mintAmount);\n }\n\n function test_Prudentia_Supply_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 10000 * 10; // supply cap of 10,000\n uint256 mintAmount = 10001e6; // mint of 10,001\n\n // Set a native supply cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia supply cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Mint\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken3.mint(mintAmount); // FAIL: Mint\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 0);\n }\n\n function test_Prudentia_Borrow_LessThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_Unrestricted_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e6; // borrow of 999\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), cap); // Unrestricted\n\n // Borrow\n cToken3.borrow(borrowAmount); // Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6 - borrowAmount);\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_6UnderlyingDecimals_DecShiftNeg1() public {\n uint64 cap = 1000 * 10; // borrow cap of 1,000\n uint256 borrowAmount = 1001e6; // borrow of 1,001\n\n // Set a native borrow cap for cToken3\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken3;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken3\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken3.approve(address(cToken3), type(uint256).max); // Approve max\n cToken3.mint(10000e6); // Mint 10,000 cToken3\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 0, decimalShift: -1 })\n );\n\n // Set Prudentia borrow cap for cToken3\n prudentia.stubPush(address(underlyingToken3), cap);\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken3)), uint256(cap) * 1e5);\n\n // Borrow\n vm.expectRevert();\n cToken3.borrow(borrowAmount); // FAIL: Borrow\n\n assertEq(underlyingToken3.balanceOf(address(cToken3)), 10000e6);\n }\n\n /*\n * Prudentia caps tests with an offset of 1\n */\n\n function test_Prudentia_Supply_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted supply cap\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // Unrestricted cap at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), cap); // Unrestricted\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_MissingRate_Offset1() public {\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a supply cap for cToken1 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveSupplyCaps(address(cToken1)); // FAIL: Missing rate\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Supply_LessThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 9999e18; // mint of 9,999\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(mintAmount); // Mint\n }\n\n function test_Prudentia_Supply_GreaterThanCap_Offset1() public {\n uint64 cap = 10000; // supply cap of 10,000\n uint256 mintAmount = 10001e18; // mint of 10,001\n\n // Set a native supply cap for cToken1\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken1;\n uint256[] memory supplyCaps = new uint256[](1);\n supplyCaps[0] = 1;\n comptroller._setMarketSupplyCaps(cTokens, supplyCaps);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia supply cap for cToken1\n prudentia.stubPush(address(underlyingToken1), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken1), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveSupplyCaps(address(cToken1)), uint256(cap) * 1e18);\n\n // Mint\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n vm.expectRevert();\n cToken1.mint(mintAmount); // FAIL: Mint\n }\n\n function test_Prudentia_Borrow_LessThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_Unrestricted_Offset1() public {\n uint64 cap = 0; // Unrestricted borrow cap\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 1); // Highly restrictive cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), cap); // Unrestricted\n\n // Borrow\n cToken2.borrow(borrowAmount); // Borrow\n }\n\n function test_Prudentia_Borrow_MissingRate_Offset1() public {\n uint256 borrowAmount = 999e18; // borrow of 999\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Note: Prudentia doesn't have a borrow cap for cToken2 at index 1 (the offset)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n vm.expectRevert();\n comptroller.effectiveBorrowCaps(address(cToken2)); // FAIL: Missing rate\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n function test_Prudentia_Borrow_GreaterThanCap_Offset1() public {\n uint64 cap = 1000; // borrow cap of 1,000\n uint256 borrowAmount = 1001e18; // borrow of 1,001\n\n // Set a native borrow cap for cToken2\n // This should be ignored since we're using Prudentia\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = cToken2;\n uint256[] memory borrowCaps = new uint256[](1);\n borrowCaps[0] = 1;\n comptroller._setMarketBorrowCaps(cTokens, borrowCaps);\n\n // Mint cToken1 and cToken2\n underlyingToken1.approve(address(cToken1), type(uint256).max); // Approve max\n cToken1.mint(10000e18); // Mint 10,000 cToken1\n underlyingToken2.approve(address(cToken2), type(uint256).max); // Approve max\n cToken2.mint(10000e18); // Mint 10,000 cToken2\n\n // Use cToken1 as collateral\n address[] memory enterMarkets = new address[](1);\n enterMarkets[0] = address(cToken1);\n comptroller.enterMarkets(enterMarkets);\n\n // Enable Prudentia\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(\n PrudentiaLib.PrudentiaConfig({ controller: address(prudentia), offset: 1, decimalShift: 0 })\n );\n\n // Set Prudentia borrow cap for cToken2\n prudentia.stubPush(address(underlyingToken2), cap); // The cap we're using at index 1 (this should be used)\n prudentia.stubPush(address(underlyingToken2), 0); // Unrestricted cap at index 0. If this cap is used, the test should fail.\n\n assertEq(comptroller.effectiveBorrowCaps(address(cToken2)), uint256(cap) * 1e18);\n\n // Borrow\n vm.expectRevert();\n cToken2.borrow(borrowAmount); // FAIL: Borrow\n }\n\n /*\n Additional ComptrollerPrudentiaCapsExt tests\n */\n\n event NewBorrowCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n event NewSupplyCapConfig(PrudentiaLib.PrudentiaConfig oldConfig, PrudentiaLib.PrudentiaConfig newConfig);\n\n function test_Prudentia_SupplyCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewSupplyCapConfig(oldConfig, newConfig);\n\n // Set supply cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n\n // Get the supply cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getSupplyCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_BorrowCapConfig() public {\n PrudentiaLib.PrudentiaConfig memory oldConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(0),\n offset: 0,\n decimalShift: 0\n });\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Setup expectation of the following event\n vm.expectEmit(false, false, false, true);\n emit NewBorrowCapConfig(oldConfig, newConfig);\n\n // Set borrow cap config\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n\n // Get the borrow cap config\n PrudentiaLib.PrudentiaConfig memory current = ComptrollerPrudentiaCapsExt(address(comptroller))\n .getBorrowCapConfig();\n\n assertEq(newConfig.controller, current.controller, \"controller\");\n assertEq(newConfig.offset, current.offset, \"offset\");\n }\n\n function test_Prudentia_SetSupplyCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setSupplyCapConfig(newConfig);\n }\n\n function test_Prudentia_SetBorrowCapConfig_OnlyAdmin() public {\n PrudentiaLib.PrudentiaConfig memory newConfig = PrudentiaLib.PrudentiaConfig({\n controller: address(prudentia),\n offset: 0,\n decimalShift: 0\n });\n\n // Set supply cap config\n vm.prank(address(7));\n vm.expectRevert(\"!admin\");\n ComptrollerPrudentiaCapsExt(address(comptroller))._setBorrowCapConfig(newConfig);\n }\n}\n" + }, + "contracts/test/CollateralSwapTest.t.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CollateralSwap } from \"../ionic/CollateralSwap.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\n\ncontract CollateralSwapTest is UpgradesBaseTest {\n ICErc20 wethMarket = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3);\n ICErc20 usdcMarket = ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0);\n ICErc20 ezETHMarket = ICErc20(0x079f84161642D81aaFb67966123C9949F9284bf5);\n ICErc20 cbETHMarket = ICErc20(0x9c201024A62466F9157b2dAaDda9326207ADDd29);\n PoolLens lens = PoolLens(0x6ec80f9aCd960b568932696C0F0bE06FBfCd175a);\n CollateralSwap swap;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n _upgradeMarketWithExtension(wethMarket);\n _upgradeMarketWithExtension(ezETHMarket);\n _upgradeMarketWithExtension(cbETHMarket);\n _upgradeMarketWithExtension(usdcMarket);\n swap = new CollateralSwap(0, msg.sender, address(wethMarket.comptroller()), new address[](0));\n emit log_named_address(\"swap address: \", address(swap));\n }\n\n function test_collateralSwap_works_noBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20754244) {\n address ionwethWhale = 0x753E909D68921388b8fB4E471D155ff73c735ebC;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n uint256 healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n bytes memory swapData = abi.encodePacked(\n hex\"5fd9ae2ea41bd686f6e5326450d10ac2dc733b837ae20fb0aaf871e87b4a9227171918ab00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a0cb889707d426a7a386870a03bc70d1b0697598000000000000000000000000000000000000000000000000000000001d42cce300000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000005696f6e6963000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000000a6d96e7f4d7b96cfe42185df61e64d255c12dff0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000002d02dd2e34e182400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000084eedd56e100000000000000000000000042000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000b85da6a0970f0000000000000000000000000000000000000000000000000001ccea209179a9000000000000000000000000d5ee82d18f63f0b82df91a6ae73b74cfda57144e000000000000000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000002cda88b1c1c076b00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae00000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000000000000000000000000000000000001d42cce3000000000000000000000000000000000000000000000000000000001d68714c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004d69971ccd4a636c403a3c1b00c85e99bb9b5606000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000002cda88b1c1c076b000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e4200000000000000000000000000000000000006000064b79dd08ea68a908a97220c76d19a6aa9cbde437600002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000b79dd08ea68a908a97220c76d19a6aa9cbde437600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000000c1a09d5d0445047da3ab4994262b22404288a3b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002eb79dd08ea68a908a97220c76d19a6aa9cbde4376000001833589fcd6edb6e08f4c7c32d4f71b54bda029130000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e85000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a0000000000000000000000000000000000000000000000000000000001d68714c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f865422000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f99000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n vm.startPrank(ionwethWhale);\n wethMarket.approve(address(swap), 1e18);\n swap.swapCollateral(1e18, wethMarket, usdcMarket, swapTarget, swapData);\n vm.stopPrank();\n healthFactor = lens.getHealthFactor(0x753E909D68921388b8fB4E471D155ff73c735ebC, wethMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n }\n\n function test_collateralSwap_worksWithBorrows() public debuggingOnly forkAtBlock(BASE_MAINNET, 20874971) {\n address ionezEthWhale = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address swapTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE;\n swap.setAllowedSwapTarget(swapTarget, true);\n bytes memory swapData = abi.encodePacked(\n hex\"4666fc80a7f78b3a1e00f74ab91e766714a7b7390c173e43f2f65d7c74bda18ff1e067dd00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000d6bbde9174b1cdaa358d2cf4d57d1a9f7178fbff000000000000000000000000000000000000000000000000003625685b773877000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000006352a56caadc4f1e25cd6c75970fa768a3304e640000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000000000000000000000000000000039afc19de8c3ba00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000aa490411a32000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a99000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000002416092f143378750bb29b79ed961ab195cceea50000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a990000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000000000000000000000000000003625685b77387700000000000000000000000000000000000000000000000000366b101e2d34e40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000933a06c631ed8b5e4f3848c91a1cfc45e5c7eab3000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb0000000000000000000000004c98e9c2439c0d4621c62fee2fed6d042fa8c57000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000039afc19de8c3ba000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e2416092f143378750bb29b79ed961ab195cceea5000064420000000000000000000000000000000000000600000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002449f865422000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000104e5b07cdb000000000000000000000000257fcbae4ac6b26a02e4fc5e1a11e4174b5ce39500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dec876911cbe9428265af0d12132c52ee8642a9900000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002e42000000000000000000000000000000000000060000642ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000648a6a1e850000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22000000000000000000000000353c1f0bc78fbbc245b3c93ef77b1dcc5b77d2a000000000000000000000000000000000000000000000000000366b101e2d34e400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a49f8654220000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec2200000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d1660f990000000000000000000000002ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec220000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n );\n\n (uint256 error, uint256 balance, uint256 borrowBalance, uint256 exchangeRateMantissa) = ezETHMarket\n .getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n vm.startPrank(ionezEthWhale);\n ezETHMarket.approve(address(swap), type(uint256).max);\n uint256 healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor before: \", healthFactor);\n swap.swapCollateral(16237319785333690, ezETHMarket, cbETHMarket, swapTarget, swapData);\n healthFactor = lens.getHealthFactor(ionezEthWhale, ezETHMarket.comptroller());\n emit log_named_uint(\"health factor after: \", healthFactor);\n vm.stopPrank();\n\n (error, balance, borrowBalance, exchangeRateMantissa) = ezETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"ezETH error: \", error);\n emit log_named_uint(\"ezETH balance: \", balance);\n emit log_named_uint(\"ezETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"ezETH exchangeRateMantissa: \", exchangeRateMantissa);\n\n (error, balance, borrowBalance, exchangeRateMantissa) = cbETHMarket.getAccountSnapshot(ionezEthWhale);\n emit log_named_uint(\"cbETH error: \", error);\n emit log_named_uint(\"cbETH balance: \", balance);\n emit log_named_uint(\"cbETH borrowBalance: \", borrowBalance);\n emit log_named_uint(\"cbETH exchangeRateMantissa: \", exchangeRateMantissa);\n }\n}\n" + }, + "contracts/test/ComptrollerTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ComptrollerErrorReporter } from \"../compound/ErrorReporter.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract ComptrollerTest is BaseTest {\n IonicComptroller internal comptroller;\n IonicFlywheel internal flywheel;\n address internal nonOwner = address(0x2222);\n\n event Failure(uint256 error, uint256 info, uint256 detail);\n\n function setUp() public {\n {\n Unitroller proxy = new Unitroller(payable(address(this)));\n proxy._registerExtension(new Comptroller(), DiamondExtension(address(0)));\n comptroller = IonicComptroller(address(proxy));\n }\n {\n ERC20 rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, IFlywheelRewards(address(2)), IFlywheelBooster(address(3)), address(this));\n }\n }\n\n function test__setFlywheel() external {\n vm.prank(comptroller.admin());\n comptroller._addRewardsDistributor(address(flywheel));\n assertEq(comptroller.rewardsDistributors(0), address(flywheel));\n }\n\n function test__setFlywheelRevertsIfNonOwner() external {\n vm.startPrank(nonOwner);\n vm.expectRevert(\"!admin\");\n comptroller._addRewardsDistributor(address(flywheel));\n }\n\n function testBscInflationProtection() public debuggingOnly fork(BSC_MAINNET) {\n _testInflationProtection();\n }\n\n function testPolygonInflationProtection() public debuggingOnly fork(POLYGON_MAINNET) {\n _testInflationProtection();\n }\n\n function testModeInflationProtection() public debuggingOnly fork(MODE_MAINNET) {\n _testInflationProtection();\n }\n\n function _testInflationProtection() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n PoolDirectory.Pool[] memory pools = fpd.getAllPools();\n for (uint256 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n uint256 totalSupply = market.totalSupply();\n if (totalSupply > 0) {\n if (totalSupply < 1000) {\n emit log_named_address(\"low ts market\", address(markets[j]));\n emit log_named_uint(\"ts\", totalSupply);\n } else {\n assertEq(\n pool.redeemAllowed(address(markets[j]), address(0), totalSupply - 980),\n uint256(ComptrollerErrorReporter.Error.REJECTION),\n \"low ts not rejected\"\n );\n }\n }\n }\n }\n }\n}\n" + }, + "contracts/test/config/BaseTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\nimport \"forge-std/Test.sol\";\nimport \"forge-std/console.sol\";\n\nimport { AddressesProvider } from \"../../ionic/AddressesProvider.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n\nabstract contract BaseTest is Test {\n uint128 constant ETHEREUM_MAINNET = 1;\n uint128 constant BSC_MAINNET = 56;\n uint128 constant POLYGON_MAINNET = 137;\n uint128 constant ARBITRUM_ONE = 42161;\n\n uint128 constant BSC_CHAPEL = 97;\n uint128 constant NEON_MAINNET = 245022934;\n uint128 constant LINEA_MAINNET = 59144;\n uint128 constant ZKEVM_MAINNET = 1101;\n uint128 constant MODE_MAINNET = 34443;\n uint128 constant BASE_MAINNET = 8453;\n\n // taken from ERC1967Upgrade\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n AddressesProvider public ap;\n ProxyAdmin public dpa;\n\n mapping(uint128 => uint256) private forkIds;\n\n constructor() {\n configureAddressesProvider(0);\n }\n\n uint256 constant CRITICAL = 100;\n uint256 constant NORMAL = 90;\n uint256 constant LOW = 80;\n\n modifier importance(uint256 testImportance) {\n uint256 runLevel = NORMAL;\n\n try vm.envUint(\"TEST_RUN_LEVEL\") returns (uint256 level) {\n runLevel = level;\n } catch {\n emit log(\"failed to get env param TEST_RUN_LEVEL\");\n }\n\n if (testImportance >= runLevel) {\n _;\n } else {\n emit log(\"not running the test\");\n }\n }\n\n modifier debuggingOnly() {\n try vm.envBool(\"LOCAL_FORGE_ENV\") returns (bool run) {\n if (run) _;\n } catch {\n emit log(\"skipping this test in the CI/CD - add LOCAL_FORGE_ENV=true to your .env file to run locally\");\n }\n }\n\n modifier fork(uint128 chainid) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, 0);\n _;\n }\n }\n\n modifier forkAtBlock(uint128 chainid, uint256 blockNumber) {\n if (shouldRunForChain(chainid)) {\n _forkAtBlock(chainid, blockNumber);\n _;\n }\n }\n\n modifier whenForking() {\n try vm.activeFork() returns (uint256) {\n _;\n } catch {}\n }\n\n function shouldRunForChain(uint256 chainid) internal returns (bool) {\n bool run = true;\n try vm.envUint(\"TEST_RUN_CHAINID\") returns (uint256 envChainId) {\n run = envChainId == chainid;\n } catch {\n emit log(\"failed to get env param TEST_RUN_CHAINID\");\n }\n return run;\n }\n\n function _forkAtBlock(uint128 chainid, uint256 blockNumber) internal {\n if (block.chainid != chainid) {\n if (blockNumber != 0) {\n vm.selectFork(getArchiveForkId(chainid));\n vm.rollFork(blockNumber);\n } else {\n vm.selectFork(getForkId(chainid));\n }\n }\n configureAddressesProvider(chainid);\n afterForkSetUp();\n }\n\n function getForkId(uint128 chainid, bool archive) private returns (uint256) {\n return archive ? getForkId(chainid) : getArchiveForkId(chainid);\n }\n\n function getForkId(uint128 chainid) private returns (uint256) {\n if (forkIds[chainid] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"bsc_chapel\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"polygon\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"neon\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"arbitrum\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"ethereum\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"linea\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"zkevm\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"mode\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainid] = vm.createFork(vm.rpcUrl(\"base\")) + 100;\n }\n }\n\n return forkIds[chainid] - 100;\n }\n\n function getArchiveForkId(uint128 chainid) private returns (uint256) {\n // store the archive rpc urls in the forkIds mapping at an offset\n uint128 chainidWithOffset = chainid + type(uint64).max;\n if (forkIds[chainidWithOffset] == 0) {\n if (chainid == BSC_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_archive\")) + 100;\n } else if (chainid == BSC_CHAPEL) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"bsc_chapel_archive\")) + 100;\n } else if (chainid == POLYGON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"polygon_archive\")) + 100;\n } else if (chainid == NEON_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"neon_archive\")) + 100;\n } else if (chainid == ARBITRUM_ONE) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"arbitrum_archive\")) + 100;\n } else if (chainid == ETHEREUM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"ethereum_archive\")) + 100;\n } else if (chainid == LINEA_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"linea_archive\")) + 100;\n } else if (chainid == ZKEVM_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"zkevm_archive\")) + 100;\n } else if (chainid == MODE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"mode_archive\")) + 100;\n } else if (chainid == BASE_MAINNET) {\n forkIds[chainidWithOffset] = vm.createFork(vm.rpcUrl(\"base_archive\")) + 100;\n }\n }\n return forkIds[chainidWithOffset] - 100;\n }\n\n function afterForkSetUp() internal virtual {}\n\n function configureAddressesProvider(uint128 chainid) private {\n if (chainid == BSC_MAINNET) {\n ap = AddressesProvider(address(0));\n } else if (chainid == BSC_CHAPEL) {\n ap = AddressesProvider(0x3dc8CE9f581e49B9E5304CF580940ad341F64c3f);\n } else if (block.chainid == POLYGON_MAINNET) {\n ap = AddressesProvider(0xE31baC0B582AA248c0017F87F24087cEa7A55E26);\n } else if (chainid == NEON_MAINNET) {\n ap = AddressesProvider(0xF4C60F6ac6b3AF54044757a1a54D76EEe28244CE);\n } else if (chainid == ARBITRUM_ONE) {\n ap = AddressesProvider(0x3B12BA992259Fb3855C4E1D452a754dCa2E276fC);\n } else if (chainid == LINEA_MAINNET) {\n ap = AddressesProvider(0x914694DA0bED80e74ef1a28029f016119782C0f1);\n } else if (chainid == ZKEVM_MAINNET) {\n ap = AddressesProvider(0x27aA55A3D55959261e119d75256aadAB79aE897C);\n } else if (chainid == MODE_MAINNET) {\n ap = AddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n } else if (chainid == BASE_MAINNET) {\n ap = AddressesProvider(0xcD4D7c8e2bA627684a9B18F7fe88239341D3ba5c);\n } else {\n dpa = new ProxyAdmin();\n AddressesProvider logic = new AddressesProvider();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(\n address(logic),\n address(dpa),\n abi.encodeWithSelector(ap.initialize.selector, address(this))\n );\n ap = AddressesProvider(address(proxy));\n ap.setAddress(\"DefaultProxyAdmin\", address(dpa));\n }\n dpa = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n if (ap.owner() == address(0)) {\n ap.initialize(address(this));\n }\n if (ap.getAddress(\"deployer\") == address(0)) {\n vm.prank(ap.owner());\n ap.setAddress(\"deployer\", 0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n }\n\n function diff(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n } else {\n return b - a;\n }\n }\n\n function compareStrings(string memory a, string memory b) public pure returns (bool) {\n return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));\n }\n\n function asArray(address value) public pure returns (address[] memory) {\n address[] memory array = new address[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(address value0, address value1) public pure returns (address[] memory) {\n address[] memory array = new address[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n address value0,\n address value1,\n address value2\n ) public pure returns (address[] memory) {\n address[] memory array = new address[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function asArray(bool value) public pure returns (bool[] memory) {\n bool[] memory array = new bool[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(uint256 value0, uint256 value1) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(uint256 value) public pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](1);\n array[0] = value;\n return array;\n }\n\n function asArray(bytes memory value0, bytes memory value1) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](2);\n array[0] = value0;\n array[1] = value1;\n return array;\n }\n\n function asArray(\n bytes memory value0,\n bytes memory value1,\n bytes memory value2\n ) public pure returns (bytes[] memory) {\n bytes[] memory array = new bytes[](3);\n array[0] = value0;\n array[1] = value1;\n array[2] = value2;\n return array;\n }\n\n function sqrt(uint256 x) public pure returns (uint256) {\n if (x == 0) return 0;\n uint256 xx = x;\n uint256 r = 1;\n\n if (xx >= 0x100000000000000000000000000000000) {\n xx >>= 128;\n r <<= 64;\n }\n if (xx >= 0x10000000000000000) {\n xx >>= 64;\n r <<= 32;\n }\n if (xx >= 0x100000000) {\n xx >>= 32;\n r <<= 16;\n }\n if (xx >= 0x10000) {\n xx >>= 16;\n r <<= 8;\n }\n if (xx >= 0x100) {\n xx >>= 8;\n r <<= 4;\n }\n if (xx >= 0x10) {\n xx >>= 4;\n r <<= 2;\n }\n if (xx >= 0x8) {\n r <<= 1;\n }\n\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return (r < r1 ? r : r1);\n }\n}\n" + }, + "contracts/test/config/MarketsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { BaseTest } from \"./BaseTest.t.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../../compound/CErc20RewardsDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { DiamondExtension } from \"../../ionic/DiamondExtension.sol\";\nimport { CTokenFirstExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MarketsTest is BaseTest {\n FeeDistributor internal ffd;\n\n CErc20Delegate internal cErc20Delegate;\n CErc20PluginDelegate internal cErc20PluginDelegate;\n CErc20RewardsDelegate internal cErc20RewardsDelegate;\n CErc20PluginRewardsDelegate internal cErc20PluginRewardsDelegate;\n CTokenFirstExtension internal newCTokenExtension;\n\n address payable internal latestComptrollerImplementation;\n ComptrollerFirstExtension internal comptrollerExtension;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n upgradeFfd();\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20RewardsDelegate = new CErc20RewardsDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n newCTokenExtension = new CTokenFirstExtension();\n\n comptrollerExtension = new ComptrollerFirstExtension();\n Comptroller newComptrollerImplementation = new Comptroller();\n latestComptrollerImplementation = payable(address(newComptrollerImplementation));\n }\n\n function upgradeFfd() internal {\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffd)));\n bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n if (address(ffd.authoritiesRegistry()) == address(0)) {\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n vm.prank(ffd.owner());\n ffd.reinitialize(newAr);\n }\n }\n\n function _prepareCTokenUpgrade(ICErc20 market) internal returns (address) {\n address implBefore = market.implementation();\n //emit log(\"implementation before\");\n //emit log_address(implBefore);\n\n CErc20Delegate newImpl;\n if (market.delegateType() == 1) {\n newImpl = cErc20Delegate;\n } else if (market.delegateType() == 2) {\n newImpl = cErc20PluginDelegate;\n } else if (market.delegateType() == 3) {\n newImpl = cErc20RewardsDelegate;\n } else {\n newImpl = cErc20PluginRewardsDelegate;\n }\n\n // set the new ctoken delegate as the latest\n uint8 delegateType = market.delegateType();\n vm.prank(ffd.owner());\n ffd._setLatestCErc20Delegate(delegateType, address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = DiamondExtension(newImpl);\n cErc20DelegateExtensions[1] = newCTokenExtension;\n vm.prank(ffd.owner());\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n\n return address(newImpl);\n }\n\n function _upgradeMarket(ICErc20 market) internal {\n address newDelegate = _prepareCTokenUpgrade(market);\n\n bytes memory becomeImplData = (address(newDelegate) == address(cErc20Delegate))\n ? bytes(\"\")\n : abi.encode(address(0));\n vm.prank(market.ionicAdmin());\n market._setImplementationSafe(newDelegate, becomeImplData);\n }\n\n function _prepareComptrollerUpgrade(address oldCompImpl) internal {\n vm.startPrank(ffd.owner());\n ffd._setLatestComptrollerImplementation(oldCompImpl, latestComptrollerImplementation);\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = comptrollerExtension;\n extensions[1] = Comptroller(latestComptrollerImplementation);\n ffd._setComptrollerExtensions(latestComptrollerImplementation, extensions);\n vm.stopPrank();\n }\n\n function _upgradeExistingPool(address poolAddress) internal {\n Unitroller asUnitroller = Unitroller(payable(poolAddress));\n // change the implementation to the new that can add extensions\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n _prepareComptrollerUpgrade(oldComptrollerImplementation);\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n}\n" + }, + "contracts/test/ContractsUpgradesTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ComptrollerFirstExtension, DiamondExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract ContractsUpgradesTest is BaseTest {\n function testPoolDirectoryUpgrade() public fork(BSC_MAINNET) {\n address contractToTest = ap.getAddress(\"PoolDirectory\"); // PoolDirectory proxy\n\n // before upgrade\n PoolDirectory fpdBefore = PoolDirectory(contractToTest);\n PoolDirectory.Pool[] memory poolsBefore = fpdBefore.getAllPools();\n address ownerBefore = fpdBefore.owner();\n emit log_address(ownerBefore);\n\n uint256 lenBefore = poolsBefore.length;\n emit log_uint(lenBefore);\n\n // upgrade\n {\n PoolDirectory newImpl = new PoolDirectory();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(contractToTest));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n PoolDirectory fpd = PoolDirectory(contractToTest);\n address ownerAfter = fpd.owner();\n emit log_address(ownerAfter);\n\n (, PoolDirectory.Pool[] memory poolsAfter) = fpd.getActivePools();\n uint256 lenAfter = poolsAfter.length;\n emit log_uint(poolsAfter.length);\n\n assertEq(lenBefore, lenAfter, \"pools count does not match\");\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testFeeDistributorUpgrade() public fork(BSC_MAINNET) {\n // TODO use an already deployed market\n CErc20Delegate oldCercDelegate = new CErc20Delegate();\n\n // before upgrade\n FeeDistributor ffdProxy = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n uint256 marketsCounterBefore = ffdProxy.marketsCounter();\n address ownerBefore = ffdProxy.owner();\n\n (address latestCErc20DelegateBefore, ) = ffdProxy.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterBefore);\n emit log_address(ownerBefore);\n\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ffdProxy)));\n bytes32 bytesAtSlot = vm.load(address(proxy), _ADMIN_SLOT);\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n\n // after upgrade\n FeeDistributor ffd = FeeDistributor(payable(address(ffdProxy)));\n\n uint256 marketsCounterAfter = ffd.marketsCounter();\n address ownerAfter = ffd.owner();\n (address latestCErc20DelegateAfter, ) = ffd.latestCErc20Delegate(oldCercDelegate.delegateType());\n\n emit log_uint(marketsCounterAfter);\n emit log_address(ownerAfter);\n\n assertEq(latestCErc20DelegateBefore, latestCErc20DelegateAfter, \"latest delegates do not match\");\n assertEq(marketsCounterBefore, marketsCounterAfter, \"markets counter does not match\");\n\n assertEq(ownerBefore, ownerAfter, \"owner mismatch\");\n }\n\n function testMarketsLatestImplementationsChapel() public fork(BSC_CHAPEL) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsBsc() public fork(BSC_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsPolygon() public fork(POLYGON_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsArbitrum() public fork(ARBITRUM_ONE) {\n _testMarketsLatestImplementations();\n }\n\n function testMarketsLatestImplementationsEth() public fork(ETHEREUM_MAINNET) {\n _testMarketsLatestImplementations();\n }\n\n function _testMarketsLatestImplementations() internal {\n FeeDistributor ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n if (address(fpd) != address(0)) {\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n ICErc20[] memory markets = pool.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n\n uint8 currentDelegateType = market.delegateType();\n (address upgradeToImpl, ) = ffd.latestCErc20Delegate(currentDelegateType);\n\n address currentImpl = market.implementation();\n if (currentImpl != upgradeToImpl) emit log_address(address(market));\n assertEq(currentImpl, upgradeToImpl, \"market needs to be upgraded\");\n\n DiamondBase asBase = DiamondBase(address(markets[j]));\n try asBase._listExtensions() returns (address[] memory extensions) {\n assertEq(extensions.length, 2, \"market is missing an extension\");\n } catch {\n emit log(\"market that is not yet upgraded to the extensions upgrade\");\n emit log_address(address(market));\n emit log(\"implementation\");\n emit log_address(currentImpl);\n emit log(\"pool\");\n emit log_address(pools[i].comptroller);\n emit log(\"\");\n }\n }\n }\n }\n }\n\n function testPauseGuardiansBsc() public debuggingOnly fork(BSC_MAINNET) {\n _testPauseGuardians();\n }\n\n // TODO redeploy to polygon to fix\n function testPauseGuardiansPolygon() public debuggingOnly fork(POLYGON_MAINNET) {\n _testPauseGuardians();\n }\n\n function _testPauseGuardians() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n address deployer = ap.getAddress(\"deployer\");\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller pool = IonicComptroller(pools[i].comptroller);\n address pauseGuardian = pool.pauseGuardian();\n if (pauseGuardian != address(0) && pauseGuardian != deployer) {\n emit log_named_address(\"pool\", address(pool));\n emit log_named_address(\"unknown pause guardian\", pauseGuardian);\n emit log(\"\");\n }\n }\n }\n}\n" + }, + "contracts/test/DeployMarkets.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Test.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { IonicFlywheelDynamicRewardsPlugin } from \"../ionic/strategies/flywheel/rewards/IonicFlywheelDynamicRewardsPlugin.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20, ICErc20Plugin, ICErc20PluginRewards } from \"../compound/CTokenInterfaces.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { MockERC4626 } from \"../ionic/strategies/MockERC4626.sol\";\nimport { MockERC4626Dynamic } from \"../ionic/strategies/MockERC4626Dynamic.sol\";\n\ncontract DeployMarketsTest is Test {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n MockERC4626 mockERC4626;\n MockERC4626Dynamic mockERC4626Dynamic;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheelDynamicRewardsPlugin rewards;\n\n address[] markets;\n bool[] t;\n bool[] f;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts() public {\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", 18);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", 18);\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n }\n\n function setUpExtensions() public {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = cErc20Delegate;\n cErc20DelegateExtensions[1] = new CTokenFirstExtension();\n ionicAdmin._setCErc20DelegateExtensions(address(0), cErc20DelegateExtensions);\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n\n cErc20DelegateExtensions[0] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n }\n\n function setUpPool() public {\n underlyingToken.mint(address(this), 100e36);\n\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n newAr.setUserRole(comptrollerAddress, address(ionicAdmin), poolAuth.SUPPLIER_ROLE(), true);\n }\n\n function setUp() public {\n setUpBaseContracts();\n setUpPool();\n setUpExtensions();\n vm.roll(1);\n }\n\n function testDeployCErc20Delegate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n require(cToken.mint(10e18) == 0, \"mint failed\");\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(underlyingToken.balanceOf(address(cToken)), 10e18);\n }\n\n function testDeployCErc20PluginDelegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10e18);\n assertEq(cToken.totalSupply(), 10e18 * 5);\n assertEq(mockERC4626.balanceOf(address(cToken)), 10e18);\n assertEq(underlyingToken.balanceOf(address(mockERC4626)), 10e18);\n }\n\n function testDeployCErc20PluginRewardsDelegate() public {\n IonicFlywheelCore impl = new IonicFlywheelCore();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n IonicFlywheelCore flywheel = IonicFlywheelCore(address(proxy));\n flywheel.initialize(underlyingToken, IFlywheelRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n IonicFlywheelCore asFlywheelCore = IonicFlywheelCore(address(flywheel));\n rewards = new IonicFlywheelDynamicRewardsPlugin(asFlywheelCore, 1);\n flywheel.setFlywheelRewards(rewards);\n\n mockERC4626Dynamic = new MockERC4626Dynamic(ERC20(address(underlyingToken)), asFlywheelCore);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(address(mockERC4626Dynamic), address(flywheel), address(underlyingToken)),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20PluginRewards cToken = ICErc20PluginRewards(address(allMarkets[allMarkets.length - 1]));\n\n flywheel.addStrategyForRewards(ERC20(address(cToken)));\n\n assertEq(address(cToken.plugin()), address(mockERC4626Dynamic), \"!plugin == erc4626\");\n assertEq(underlyingToken.allowance(address(cToken), address(mockERC4626Dynamic)), type(uint256).max);\n assertEq(underlyingToken.allowance(address(cToken), address(flywheel)), 0);\n\n cToken.approve(address(rewardToken), address(flywheel));\n assertEq(rewardToken.allowance(address(cToken), address(flywheel)), type(uint256).max);\n\n underlyingToken.approve(address(cToken), 1e36);\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n cToken.mint(10000000);\n assertEq(cToken.totalSupply(), 10000000 * 5);\n assertEq(mockERC4626Dynamic.balanceOf(address(cToken)), 10000000);\n assertEq(underlyingToken.balanceOf(address(mockERC4626Dynamic)), 10000000);\n }\n\n function testAutoImplementationCErc20Delegate() public {\n mockERC4626 = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(mockERC4626),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(mockERC4626), \"!plugin == erc4626\");\n\n address implBefore = cToken.implementation();\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n cToken.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address implAfter = cToken.implementation();\n\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testAutoImplementationPlugin() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n ionicAdmin._upgradePluginToLatestImplementation(address(cToken));\n address pluginImplAfter = address(cToken.plugin());\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n }\n\n function testAutoImplementationCErc20PluginDelegate() public {\n MockERC4626 pluginA = new MockERC4626(ERC20(address(underlyingToken)));\n MockERC4626 pluginB = new MockERC4626(ERC20(address(underlyingToken)));\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(pluginA),\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20Plugin cToken = ICErc20Plugin(address(allMarkets[allMarkets.length - 1]));\n\n assertEq(address(cToken.plugin()), address(pluginA), \"!plugin == erc4626\");\n\n address pluginImplBefore = address(cToken.plugin());\n address implBefore = cToken.implementation();\n uint8 delegateType = cToken.delegateType();\n\n // just testing to replace the plugin delegate with the plugin rewards delegate\n ionicAdmin._setLatestCErc20Delegate(\n delegateType,\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0)) // should trigger use of latest implementation\n );\n ionicAdmin._setLatestPluginImplementation(address(pluginA), address(pluginB));\n\n // run the upgrade\n vm.prank(ionicAdmin.owner());\n ionicAdmin.autoUpgradePool(comptroller);\n\n address pluginImplAfter = address(cToken.plugin());\n address implAfter = cToken.implementation();\n\n assertEq(pluginImplBefore, address(pluginA), \"the old impl should be the A plugin\");\n assertEq(pluginImplAfter, address(pluginB), \"the new impl should be the B plugin\");\n assertEq(implBefore, address(cErc20PluginDelegate), \"the old impl should be the plugin delegate\");\n assertEq(implAfter, address(cErc20PluginRewardsDelegate), \"the new impl should be the plugin rewards delegate\");\n }\n\n function testInflateExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint just 2 wei\n underlyingToken.approve(address(cToken), 1e36);\n cToken.mint(2);\n assertEq(cToken.totalSupply(), 10);\n assertEq(underlyingToken.balanceOf(address(cToken)), 2, \"!total supply 2\");\n\n uint256 exchRateBefore = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate\", exchRateBefore);\n assertEq(exchRateBefore, 2e17, \"!default exch rate\");\n\n // donate\n underlyingToken.transfer(address(cToken), 1e36);\n\n uint256 exchRateAfter = cToken.exchangeRateCurrent();\n emit log_named_uint(\"exch rate after\", exchRateAfter);\n assertGt(exchRateAfter, 1e30, \"!inflated exch rate\");\n\n // the market should own 1e36 + 2 underlying assets\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e36 + 2, \"!total underlying\");\n\n // 50% + 1\n uint256 errCode = cToken.redeemUnderlying(0.5e36 + 2);\n assertEq(errCode, 0, \"!redeem underlying\");\n\n assertEq(cToken.totalSupply(), 0, \"!should have redeemed all ctokens for 50% + 1 of the underlying\");\n }\n\n function testSupplyCapInflatedExchangeRate() public {\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n ICErc20 cToken = allMarkets[allMarkets.length - 1];\n assertEq(cToken.name(), \"cUnderlyingToken\");\n address[] memory cTokens = new address[](1);\n cTokens[0] = address(cToken);\n comptroller.enterMarkets(cTokens);\n vm.roll(1);\n\n // mint 1e18\n underlyingToken.approve(address(cToken), 1e18);\n cToken.mint(1e18);\n assertEq(cToken.totalSupply(), 5 * 1e18, \"!total supply 5\");\n assertEq(underlyingToken.balanceOf(address(cToken)), 1e18, \"!market underlying balance 1\");\n\n (, , uint256 liqBefore, uint256 sfBefore) = comptroller.getAccountLiquidity(address(this));\n\n uint256[] memory caps = new uint256[](1);\n caps[0] = 25e18;\n ICErc20[] memory marketArray = new ICErc20[](1);\n marketArray[0] = cToken;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(marketArray, caps);\n\n // donate 100e18\n underlyingToken.transfer(address(cToken), 100e18);\n assertEq(underlyingToken.balanceOf(address(cToken)), 101e18, \"!market balance 101\");\n assertEq(cToken.balanceOfUnderlying(address(this)), 101e18, \"!user balance 101\");\n\n (, , uint256 liqAfter, uint256 sfAfter) = comptroller.getAccountLiquidity(address(this));\n emit log_named_uint(\"liqBefore\", liqBefore);\n emit log_named_uint(\"liqAfter\", liqAfter);\n\n assertEq(liqAfter / liqBefore, 25, \"liquidity should increase only 25x\");\n }\n}\n" + }, + "contracts/test/DevTesting.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport \"./config/BaseTest.t.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { ISwapRouter } from \"../external/uniswap/ISwapRouter.sol\";\nimport { RedstoneAdapterPriceOracle } from \"../oracles/default/RedstoneAdapterPriceOracle.sol\";\nimport { RedstoneAdapterPriceOracleWrsETH } from \"../oracles/default/RedstoneAdapterPriceOracleWrsETH.sol\";\nimport { RedstoneAdapterPriceOracleWeETH } from \"../oracles/default/RedstoneAdapterPriceOracleWeETH.sol\";\nimport { MasterPriceOracle, BasePriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { LeveredPositionFactory } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { LeveredPositionStorage } from \"../ionic/levered/LeveredPositionStorage.sol\";\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle_IFLR } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { CurveSwapLiquidator } from \"../liquidators/CurveSwapLiquidator.sol\";\nimport { CurveV2LpTokenPriceOracleNoRegistry } from \"../oracles/default/CurveV2LpTokenPriceOracleNoRegistry.sol\";\nimport { IRouter_Aerodrome } from \"../external/aerodrome/IAerodromeRouter.sol\";\nimport { VelodromeV2Liquidator } from \"../liquidators/VelodromeV2Liquidator.sol\";\nimport { IRouter_Velodrome } from \"../external/velodrome/IVelodromeRouter.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport \"forge-std/console.sol\";\n\nstruct HealthFactorVars {\n uint256 usdcSupplied;\n uint256 wethSupplied;\n uint256 ezEthSuppled;\n uint256 stoneSupplied;\n uint256 wbtcSupplied;\n uint256 weEthSupplied;\n uint256 merlinBTCSupplied;\n uint256 usdcBorrowed;\n uint256 wethBorrowed;\n uint256 ezEthBorrowed;\n uint256 stoneBorrowed;\n uint256 wbtcBorrowed;\n uint256 weEthBorrowed;\n uint256 merlinBTCBorrowed;\n ICErc20 testCToken;\n address testUnderlying;\n uint256 amountBorrow;\n}\n\ncontract DevTesting is BaseTest {\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n PoolLensSecondary lens2 = PoolLensSecondary(0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154);\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n LeveredPositionsLens levPosLens;\n\n address deployer = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;\n\n ICErc20 wethMarket;\n ICErc20 usdcMarket;\n ICErc20 usdtMarket;\n ICErc20 wbtcMarket;\n ICErc20 ezEthMarket;\n ICErc20 stoneMarket;\n ICErc20 weEthMarket;\n ICErc20 merlinBTCMarket;\n\n // mode mainnet assets\n address WETH = 0x4200000000000000000000000000000000000006;\n address USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address USDT = 0xf0F161fDA2712DB8b566946122a5af183995e2eD;\n address WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;\n address UNI = 0x3e7eF8f50246f725885102E8238CBba33F276747;\n address SNX = 0x9e5AAC1Ba1a2e6aEd6b32689DFcF62A509Ca96f3;\n address LINK = 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb;\n address DAI = 0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea;\n address BAL = 0xD08a2917653d4E460893203471f0000826fb4034;\n address AAVE = 0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2;\n address weETH = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n address merlinBTC = 0x59889b7021243dB5B1e065385F918316cD90D46c;\n IERC20Upgradeable wsuperOETH = IERC20Upgradeable(0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6);\n IERC20Upgradeable superOETH = IERC20Upgradeable(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == MODE_MAINNET) {\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdcMarket = ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n wbtcMarket = ICErc20(0xd70254C3baD29504789714A7c69d60Ec1127375C);\n ezEthMarket = ICErc20(0x59e710215d45F584f44c0FEe83DA6d43D762D857);\n stoneMarket = ICErc20(0x959FA710CCBb22c7Ce1e59Da82A247e686629310);\n weEthMarket = ICErc20(0xA0D844742B4abbbc43d8931a6Edb00C56325aA18);\n merlinBTCMarket = ICErc20(0x19F245782b1258cf3e11Eda25784A378cC18c108);\n ICErc20[] memory markets = pool.getAllMarkets();\n wethMarket = markets[0];\n usdcMarket = markets[1];\n } else {}\n levPosLens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testModePoolBorrowers() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_array(\"borrowers\", pool.getAllBorrowers());\n }\n\n function testModeLiquidationShortfall() public debuggingOnly fork(MODE_MAINNET) {\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(\n 0xa75F9C8246f7269279bE4c969e7Bc6Eb619cC204\n );\n\n emit log_named_uint(\"err\", err);\n emit log_named_uint(\"collateralValue\", collateralValue);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n }\n\n function testModeHealthFactor() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n\n uint256 wethSupplied = wethMarket.balanceOfUnderlying(rahul);\n uint256 usdcSupplied = usdcMarket.balanceOfUnderlying(rahul);\n uint256 usdtSupplied = usdtMarket.balanceOfUnderlying(rahul);\n uint256 wbtcSupplied = wbtcMarket.balanceOfUnderlying(rahul);\n // emit log_named_uint(\"wethSupplied\", wethSupplied);\n emit log_named_uint(\"usdcSupplied\", usdcSupplied);\n emit log_named_uint(\"usdtSupplied\", usdtSupplied);\n emit log_named_uint(\"wbtcSupplied\", wbtcSupplied);\n emit log_named_uint(\"value of wethSupplied\", wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n emit log_named_uint(\"value of usdcSupplied\", usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n emit log_named_uint(\"value of usdtSupplied\", usdtSupplied * pool.oracle().getUnderlyingPrice(usdtMarket));\n emit log_named_uint(\"value of wbtcSupplied\", wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n PoolLens newImpl = new PoolLens();\n // TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(lens)));\n // vm.prank(dpa.owner());\n // proxy.upgradeTo(address(newImpl));\n\n uint256 hf = newImpl.getHealthFactor(rahul, pool);\n\n emit log_named_uint(\"hf\", hf);\n }\n\n function testNetAprMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 8479829) {\n address user = 0x30D5047e839f079bDE1Ab16b34668f57391DacB3;\n int256 blocks = 30 * 24 * 365 * 60;\n IonicFlywheelLensRouter lensRouter = new IonicFlywheelLensRouter(\n PoolDirectory(0x39C353Cf9041CcF467A04d0e78B63d961E81458a)\n );\n int256 apr = lensRouter.getUserNetApr(user, blocks);\n\n emit log_named_int(\"apr\", apr);\n }\n\n function testModeUsdcBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdcMarket);\n }\n\n function testHypotheticalPosition() public debuggingOnly forkAtBlock(MODE_MAINNET, 8028296) {\n HealthFactorVars memory vars;\n\n address wolfy = 0x7d922bf0975424b3371074f54cC784AF738Dac0D;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n address wbtcWhale = 0xBD8CCf3ebE4CC2D57962cdC2756B143ce0135a6B;\n address wethWhale = 0xD746A2a6048C5D3AFF5766a8c4A0C8cFD2311745;\n\n address whale = wbtcWhale;\n vars.testCToken = wethMarket;\n vars.testUnderlying = WETH;\n vars.amountBorrow = 1e18 / 2;\n\n address[] memory cTokens = new address[](1);\n\n vm.startPrank(usdcWhale);\n ERC20(USDC).transfer(wolfy, ERC20(USDC).balanceOf(usdcWhale));\n vm.stopPrank();\n\n vm.startPrank(wbtcWhale);\n ERC20(WBTC).transfer(wolfy, ERC20(WBTC).balanceOf(wbtcWhale));\n vm.stopPrank();\n\n vm.startPrank(wethWhale);\n ERC20(WETH).transfer(wolfy, ERC20(WETH).balanceOf(wethWhale));\n vm.stopPrank();\n\n // emit log_named_uint(\"USDC balance\", ERC20(USDC).balanceOf(wolfy));\n // emit log_named_uint(\"WBTC balance\", ERC20(WBTC).balanceOf(wolfy));\n // emit log_named_uint(\"WETH balance\", ERC20(WETH).balanceOf(wolfy));\n\n vm.startPrank(wolfy);\n\n ERC20(USDC).approve(address(usdcMarket), ERC20(USDC).balanceOf(wolfy));\n usdcMarket.mint(ERC20(USDC).balanceOf(wolfy));\n cTokens[0] = address(usdcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WBTC).approve(address(wbtcMarket), ERC20(WBTC).balanceOf(wolfy));\n wbtcMarket.mint(ERC20(WBTC).balanceOf(wolfy));\n cTokens[0] = address(wbtcMarket);\n pool.enterMarkets(cTokens);\n\n ERC20(WETH).approve(address(wethMarket), ERC20(WETH).balanceOf(wolfy));\n wethMarket.mint(ERC20(WETH).balanceOf(wolfy));\n cTokens[0] = address(wethMarket);\n pool.enterMarkets(cTokens);\n\n wethMarket.borrow(1e18);\n\n vm.stopPrank();\n\n vars.usdcSupplied = usdcMarket.balanceOfUnderlying(wolfy);\n vars.wethSupplied = wethMarket.balanceOfUnderlying(wolfy);\n vars.ezEthSuppled = ezEthMarket.balanceOfUnderlying(wolfy);\n vars.stoneSupplied = stoneMarket.balanceOfUnderlying(wolfy);\n vars.wbtcSupplied = wbtcMarket.balanceOfUnderlying(wolfy);\n vars.weEthSupplied = weEthMarket.balanceOfUnderlying(wolfy);\n vars.merlinBTCSupplied = merlinBTCMarket.balanceOfUnderlying(wolfy);\n\n vars.usdcBorrowed = usdcMarket.borrowBalanceCurrent(wolfy);\n vars.wethBorrowed = wethMarket.borrowBalanceCurrent(wolfy);\n vars.ezEthBorrowed = ezEthMarket.borrowBalanceCurrent(wolfy);\n vars.stoneBorrowed = stoneMarket.borrowBalanceCurrent(wolfy);\n vars.wbtcBorrowed = wbtcMarket.borrowBalanceCurrent(wolfy);\n vars.weEthBorrowed = weEthMarket.borrowBalanceCurrent(wolfy);\n vars.merlinBTCBorrowed = merlinBTCMarket.borrowBalanceCurrent(wolfy);\n\n emit log_named_uint(\"usdcSupplied\", vars.usdcSupplied);\n emit log_named_uint(\"wethSupplied\", vars.wethSupplied);\n emit log_named_uint(\"ezEthSupplied\", vars.ezEthSuppled);\n emit log_named_uint(\"stoneSupplied\", vars.stoneSupplied);\n emit log_named_uint(\"wbtcSupplied\", vars.wbtcSupplied);\n emit log_named_uint(\"weEthSupplied\", vars.weEthSupplied);\n emit log_named_uint(\"merlinBTCSupplied\", vars.merlinBTCSupplied);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"usdcBorrowed\", vars.usdcBorrowed);\n emit log_named_uint(\"wethBorrowed\", vars.wethBorrowed);\n emit log_named_uint(\"ezEthBorrowed\", vars.ezEthBorrowed);\n emit log_named_uint(\"stoneBorrowed\", vars.stoneBorrowed);\n emit log_named_uint(\"wbtcBorrowed\", vars.wbtcBorrowed);\n emit log_named_uint(\"weEthBorrowed\", vars.weEthBorrowed);\n emit log_named_uint(\"merlinBTCBorrowed\", vars.merlinBTCBorrowed);\n\n // emit log_named_uint(\"value of usdcSupplied\", vars.usdcSupplied * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethSupplied\", vars.wethSupplied * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthSupplied\", vars.ezEthSuppled * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneSupplied\", vars.stoneSupplied * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcSupplied\", vars.wbtcSupplied * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n // emit log_named_uint(\"value of usdcBorrowed\", vars.usdcBorrowed * pool.oracle().getUnderlyingPrice(usdcMarket));\n // emit log_named_uint(\"value of wethBorrowed\", vars.wethBorrowed * pool.oracle().getUnderlyingPrice(wethMarket));\n // emit log_named_uint(\"value of ezEthBorrowed\", vars.ezEthBorrowed * pool.oracle().getUnderlyingPrice(ezEthMarket));\n // emit log_named_uint(\"value of stoneBorrowed\", vars.stoneBorrowed * pool.oracle().getUnderlyingPrice(stoneMarket));\n // emit log_named_uint(\"value of wbtcBorrowed\", vars.wbtcBorrowed * pool.oracle().getUnderlyingPrice(wbtcMarket));\n\n vm.startPrank(whale);\n ERC20(vars.testUnderlying).transfer(wolfy, ERC20(vars.testUnderlying).balanceOf(whale));\n vm.stopPrank();\n\n uint256 hf = lens.getHealthFactor(wolfy, pool);\n uint256 hypothetical = lens.getHealthFactorHypothetical(\n pool,\n wolfy,\n address(vars.testCToken),\n 0,\n 0,\n vars.amountBorrow\n );\n\n (uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value Before\", collateralValue);\n emit log_named_uint(\"Liquidity Before\", liquidity);\n emit log_named_uint(\"hf before\", hf);\n emit log_named_uint(\"hypothetical hf\", hypothetical);\n\n vm.startPrank(wolfy);\n ERC20(vars.testUnderlying).approve(address(vars.testCToken), vars.amountBorrow);\n vars.testCToken.repayBorrow(vars.amountBorrow);\n vm.stopPrank();\n\n uint256 hfAfter = lens.getHealthFactor(wolfy, pool);\n (err, collateralValue, liquidity, shortfall) = pool.getAccountLiquidity(wolfy);\n\n emit log_named_uint(\"-------------------------------------------------\", 0);\n emit log_named_uint(\"Collateral Value After\", collateralValue);\n emit log_named_uint(\"Liquidity After\", liquidity);\n emit log_named_uint(\"hf after\", hfAfter);\n emit log_named_uint(\"user balance after\", ERC20(vars.testUnderlying).balanceOf(wolfy));\n emit log_named_uint(\"new borrow balance after repay\", vars.testCToken.borrowBalanceCurrent(wolfy));\n }\n\n function testModeUsdtBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(usdtMarket);\n }\n\n function testModeWethBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {\n _testModeBorrowCaps(wethMarket);\n wethMarket.accrueInterest();\n _testModeBorrowCaps(wethMarket);\n }\n\n function _testModeBorrowCaps(ICErc20 market) internal {\n uint256 borrowCapUsdc = pool.borrowCaps(address(market));\n uint256 totalBorrowsCurrent = market.totalBorrowsCurrent();\n\n uint256 wethBorrowAmount = 154753148031252;\n console.log(\"borrowCapUsdc %e\", borrowCapUsdc);\n console.log(\"totalBorrowsCurrent %e\", totalBorrowsCurrent);\n console.log(\"new totalBorrowsCurrent %e\", totalBorrowsCurrent + wethBorrowAmount);\n }\n\n function testMarketMember() public debuggingOnly fork(MODE_MAINNET) {\n address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint256 i = 0; i < markets.length; i++) {\n if (pool.checkMembership(rahul, markets[i])) {\n emit log(\"is a member\");\n } else {\n emit log(\"NOT a member\");\n }\n }\n }\n\n function testGetCashError() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20 market = ICErc20(0x49950319aBE7CE5c3A6C90698381b45989C99b46);\n market.getCash();\n }\n\n function testWrsEthBalanceOfError() public debuggingOnly fork(MODE_MAINNET) {\n address wrsEthMarketAddress = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ERC20 wrsEth = ERC20(0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd);\n wrsEth.balanceOf(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n }\n\n function testModeRepay() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0x1A3C4E9B49e4fc595fB7e5f723159bA73a9426e7;\n ICErc20 market = usdcMarket;\n ERC20 asset = ERC20(market.underlying());\n\n uint256 borrowBalance = market.borrowBalanceCurrent(user);\n emit log_named_uint(\"borrowBalance\", borrowBalance);\n\n vm.startPrank(user);\n asset.approve(address(market), borrowBalance);\n uint256 err = market.repayBorrow(borrowBalance / 2);\n\n emit log_named_uint(\"error\", err);\n }\n\n function testAssetsPrices() public debuggingOnly fork(MODE_MAINNET) {\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n emit log_named_uint(\"WETH price\", mpo.price(WETH));\n emit log_named_uint(\"USDC price\", mpo.price(USDC));\n emit log_named_uint(\"USDT price\", mpo.price(USDT));\n emit log_named_uint(\"UNI price\", mpo.price(UNI));\n emit log_named_uint(\"SNX price\", mpo.price(SNX));\n emit log_named_uint(\"LINK price\", mpo.price(LINK));\n emit log_named_uint(\"DAI price\", mpo.price(DAI));\n emit log_named_uint(\"BAL price\", mpo.price(BAL));\n emit log_named_uint(\"AAVE price\", mpo.price(AAVE));\n emit log_named_uint(\"WBTC price\", mpo.price(WBTC));\n }\n\n function testDeployedMarkets() public debuggingOnly fork(MODE_MAINNET) {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n emit log_named_address(\"market\", address(markets[i]));\n emit log(markets[i].symbol());\n emit log(markets[i].name());\n }\n }\n\n function testDisableCollateralUsdc() public debuggingOnly fork(MODE_MAINNET) {\n address user = 0xF70CBE91fB1b1AfdeB3C45Fb8CDD2E1249b5b75E;\n address usdcMarketAddr = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n\n vm.startPrank(user);\n\n uint256 borrowed = ICErc20(usdcMarketAddr).borrowBalanceCurrent(user);\n\n emit log_named_uint(\"borrowed\", borrowed);\n\n pool.exitMarket(usdcMarketAddr);\n }\n\n function testBorrowRateAtRatio() public debuggingOnly fork(MODE_MAINNET) {\n uint256 rate = levPosLens.getBorrowRateAtRatio(wethMarket, ezEthMarket, 9988992945501686, 2e18);\n emit log_named_uint(\"borrow rate at ratio\", rate);\n }\n\n function testAssetAsCollateralCap() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;\n address ezEthWhale = 0x2344F131B07E6AFd943b0901C55898573F0d1561;\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_EZETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Renzo Restaked ETH\",\n \"ionezETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 ezEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(ezEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(ezEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(ezEthWhale);\n ERC20(MODE_EZETH).approve(address(ezEthMarket), 1e36);\n errCode = ezEthMarket.mint(1e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testNewStoneMarketCapped() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_STONE = 0x80137510979822322193FC997d400D5A6C747bf7;\n address stoneWhale = 0x76486cbED5216C82d26Ee60113E48E06C189541A;\n\n address redstoneOracleAddress = 0x63A1531a06F0Ac597a0DfA5A516a37073c3E1e0a;\n RedstoneAdapterPriceOracle oracle = RedstoneAdapterPriceOracle(redstoneOracleAddress);\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(mpo.admin());\n mpo.add(asArray(MODE_STONE), oracles);\n\n vm.startPrank(multisig);\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_STONE,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic StakeStone Ether\",\n \"ionSTONE\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 stoneMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(stoneMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(stoneMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(stoneWhale);\n ERC20(MODE_STONE).approve(address(stoneMarket), 1e36);\n vm.expectRevert(\"not authorized\");\n errCode = stoneMarket.mint(1e18);\n //require(errCode != 0, \"should be unable to supply\");\n }\n\n function testRegisterSFS() public debuggingOnly fork(MODE_MAINNET) {\n emit log_named_address(\"pool admin\", pool.admin());\n\n vm.startPrank(multisig);\n pool.registerInSFS();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n for (uint8 i = 0; i < markets.length; i++) {\n markets[i].registerInSFS();\n }\n }\n\n function upgradePool() internal {\n ComptrollerFirstExtension newComptrollerExtension = new ComptrollerFirstExtension();\n\n Unitroller asUnitroller = Unitroller(payable(address(pool)));\n\n // upgrade to the new comptroller extension\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(newComptrollerExtension, DiamondExtension(asUnitroller._listExtensions()[1]));\n\n //asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function testModeBorrowRate() public fork(MODE_MAINNET) {\n //ICErc20[] memory markets = pool.getAllMarkets();\n\n IonicComptroller pool = ezEthMarket.comptroller();\n vm.prank(pool.admin());\n ezEthMarket._setInterestRateModel(JumpRateModel(0x413aD59b80b1632988d478115a466bdF9B26743a));\n\n JumpRateModel discRateModel = JumpRateModel(ezEthMarket.interestRateModel());\n\n uint256 borrows = 200e18;\n uint256 cash = 5000e18 - borrows;\n uint256 reserves = 1e18;\n uint256 rate = discRateModel.getBorrowRate(cash, borrows, reserves);\n\n emit log_named_uint(\"rate per year %e\", rate * discRateModel.blocksPerYear());\n }\n\n function testModeFetchBorrowers() public fork(MODE_MAINNET) {\n // address[] memory borrowers = pool.getAllBorrowers();\n // emit log_named_uint(\"borrowers.len\", borrowers.length);\n\n //upgradePool();\n\n (uint256 totalPages, address[] memory borrowersPage) = pool.getPaginatedBorrowers(1, 0);\n\n emit log_named_uint(\"total pages with 300 size (default)\", totalPages);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(totalPages - 1, 50);\n emit log_named_array(\"last page of 300 borrowers\", borrowersPage);\n\n (totalPages, borrowersPage) = pool.getPaginatedBorrowers(1, 50);\n emit log_named_uint(\"total pages with 50 size\", totalPages);\n emit log_named_array(\"page of 50 borrowers\", borrowersPage);\n\n // for (uint256 i = 0; i < borrowers.length; i++) {\n // (\n // uint256 error,\n // uint256 collateralValue,\n // uint256 liquidity,\n // uint256 shortfall\n // ) = pool.getAccountLiquidity(borrowers[i]);\n //\n // emit log(\"\");\n // emit log_named_address(\"user\", borrowers[i]);\n // emit log_named_uint(\"collateralValue\", collateralValue);\n // if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n // if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n // }\n }\n\n function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {\n _testAccountLiquidity(0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763);\n }\n\n function _testAccountLiquidity(address borrower) internal {\n (uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);\n\n emit log(\"\");\n emit log_named_address(\"user\", borrower);\n emit log_named_uint(\"collateralValue\", collateralValue);\n if (liquidity > 0) emit log_named_uint(\"liquidity\", liquidity);\n if (shortfall > 0) emit log_named_uint(\"SHORTFALL\", shortfall);\n }\n\n function testModeDeployMarket() public debuggingOnly fork(MODE_MAINNET) {\n address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;\n address weEthWhale = 0x6e55a90772B92f17f87Be04F9562f3faafd0cc38;\n\n vm.startPrank(pool.admin());\n uint256 errCode = pool._deployMarket(\n 1, //delegateType\n abi.encode(\n MODE_WEETH,\n address(pool),\n ap.getAddress(\"FeeDistributor\"),\n 0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode\n \"Ionic Wrapped eETH\",\n \"ionweETH\",\n 0.10e18,\n 0.10e18\n ),\n \"\",\n 0.70e18\n );\n vm.stopPrank();\n require(errCode == 0, \"error deploying market\");\n\n ICErc20[] memory markets = pool.getAllMarkets();\n ICErc20 weEthMarket = markets[markets.length - 1];\n\n // uint256 cap = pool.getAssetAsCollateralValueCap(weEthMarket, usdcMarket, false, deployer);\n uint256 cap = pool.supplyCaps(address(weEthMarket));\n require(cap == 0, \"non-zero cap\");\n\n vm.startPrank(weEthWhale);\n ERC20(MODE_WEETH).approve(address(weEthMarket), 1e36);\n errCode = weEthMarket.mint(0.01e18);\n require(errCode == 0, \"should be unable to supply\");\n }\n\n function testModeWrsETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6635923) {\n address wrsEth = 0x4186BFC76E2E237523CBC30FD220FE055156b41F;\n RedstoneAdapterPriceOracleWrsETH oracle = new RedstoneAdapterPriceOracleWrsETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(wrsEth), oracles);\n\n uint256 price = mpo.price(wrsEth);\n emit log_named_uint(\"price of wrsEth\", price);\n }\n\n function testModeWeETH() public debuggingOnly forkAtBlock(MODE_MAINNET, 6861468) {\n address weEth = 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A;\n RedstoneAdapterPriceOracleWeETH oracle = new RedstoneAdapterPriceOracleWeETH(\n 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256\n );\n MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\"));\n\n BasePriceOracle[] memory oracles = new BasePriceOracle[](1);\n oracles[0] = oracle;\n vm.prank(multisig);\n mpo.add(asArray(weEth), oracles);\n\n uint256 price = mpo.price(weEth);\n emit log_named_uint(\"price of weEth\", price);\n assertEq(price, 1036212437077011599);\n }\n\n function testPERLiquidation() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n vm.prank(0x5Cc070844E98F4ceC5f2fBE1592fB1ed73aB7b48);\n _functionCall(\n 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A,\n hex\"20b72325000000000000000000000000f28570694a6c9cd0494955966ae75af61abf5a0700000000000000000000000000000000000000000000000001bc1214ed792fbb0000000000000000000000004341620757bee7eb4553912fafc963e59c949147000000000000000000000000c53edeafb6d502daec5a7015d67936cea0cd0f520000000000000000000000000000000000000000000000000000000000000000\",\n \"error in call\"\n );\n }\n\n function testCtokenUpgrade() public debuggingOnly forkAtBlock(MODE_MAINNET, 10255413) {\n CErc20PluginRewardsDelegate newImpl = new CErc20PluginRewardsDelegate();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(wethMarket)));\n\n (uint256[] memory poolIds, PoolDirectory.Pool[] memory pools) = PoolDirectory(\n 0x39C353Cf9041CcF467A04d0e78B63d961E81458a\n ).getActivePools();\n\n emit log_named_uint(\"First Pool ID\", poolIds[0]);\n emit log_named_uint(\"First Pool ID\", poolIds[1]);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_string(\"First Pool Address\", pools[0].name);\n emit log_named_address(\"First Pool Address\", pools[0].creator);\n emit log_named_address(\"First Pool Address\", pools[1].creator);\n emit log_named_address(\"First Pool Address\", pools[0].comptroller);\n emit log_named_address(\"First Pool Address\", pools[1].comptroller);\n //bytes32 bytesAtSlot = vm.load(address(proxy), 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103);\n //address admin = address(uint160(uint256(bytesAtSlot)));\n //vm.prank(admin);\n //proxy.upgradeTo(address(newImpl));\n\n //vm.prank(dpa.owner());\n //proxy.upgradeTo(address(newImpl));\n }\n\n function testAerodromeV2Liquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeV2Liquidator liquidator = new AerodromeV2Liquidator();\n IERC20Upgradeable hyUSD = IERC20Upgradeable(0xCc7FF230365bD730eE4B352cC2492CEdAC49383e);\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n IERC20Upgradeable usdc = IERC20Upgradeable(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);\n address hyusdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0xaac391f166f33CdaEfaa4AfA6616A3BEA66B694d;\n address eusdWhale = 0xEE8Bd6594E046d72D592ac0e278E3CA179b8f189;\n address aerodromeV2Router = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;\n\n vm.startPrank(eusdWhale);\n eUSD.transfer(address(liquidator), 1000 ether);\n IRouter_Aerodrome.Route[] memory path = new IRouter_Aerodrome.Route[](1);\n path[0] = IRouter_Aerodrome.Route({\n from: address(eUSD),\n to: address(usdc),\n stable: true,\n factory: 0x420DD381b31aEf6683db6B902084cB0FFECe40Da\n });\n liquidator.redeem(eUSD, 1000 ether, abi.encode(aerodromeV2Router, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidator() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address superOETHWhale = 0xF1010eE787Ee588766b441d7cC397b40DdFB17a3;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n vm.startPrank(superOETHWhale);\n superOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(superOETH, 1 ether, abi.encode(address(superOETH), address(weth), int24(1), aerodromeCLRouter));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorWrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 20203998) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wethWhale = 0x751b77C43643a63362Ab024d466fcC1d75354295;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = AerodromeCLLiquidator(0xb50De36105F6053006306553AB54e77224818B9B);\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n weth,\n 1 ether,\n abi.encode(address(weth), address(wsuperOETH), aerodromeCLRouter, address(0), address(superOETH), 1)\n );\n emit log_named_uint(\"wsuperOETH received\", wsuperOETH.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testAerodromeCLLiquidatorUnwrap() public debuggingOnly forkAtBlock(BASE_MAINNET, 19968360) {\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address wsuperOethWhale = 0x0EEaCD4c475040463389d15EAd034d1291b008b1;\n address aerodromeCLRouter = 0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5;\n\n AerodromeCLLiquidator liquidator = new AerodromeCLLiquidator();\n\n vm.startPrank(wsuperOethWhale);\n wsuperOETH.transfer(address(liquidator), 1 ether);\n liquidator.redeem(\n wsuperOETH,\n 1 ether,\n abi.encode(address(wsuperOETH), address(weth), aerodromeCLRouter, address(superOETH), address(0), 1)\n );\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testCurveSwapLiquidatorUSDCtowUSDM() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address usdcWhale = 0x134575ff75F9882ca905EE1D78C9340C091d6056;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n vm.prank(usdcWhale);\n IERC20Upgradeable(usdc).transfer(address(liquidator), 100e6);\n liquidator.redeem(IERC20Upgradeable(usdc), 100e6, abi.encode(oracle, wUSDM, address(0), usdm));\n emit log_named_uint(\"wUSDM received\", IERC20Upgradeable(wUSDM).balanceOf(address(liquidator)));\n }\n\n function testCurveSwapLiquidatorwUSDMtoUSDC() public debuggingOnly forkAtBlock(BASE_MAINNET, 20237792) {\n address _pool = 0x63Eb7846642630456707C3efBb50A03c79B89D81;\n address usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;\n address usdm = 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C;\n address wUSDM = 0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812;\n address wusdmWhale = 0x9b8b04B6f82cD5e1dae58cA3614d445F93DeFc5c;\n CurveV2LpTokenPriceOracleNoRegistry oracle = new CurveV2LpTokenPriceOracleNoRegistry();\n CurveSwapLiquidator liquidator = new CurveSwapLiquidator();\n vm.prank(oracle.owner());\n oracle.registerPool(_pool, _pool);\n\n vm.startPrank(wusdmWhale);\n IERC20Upgradeable(wUSDM).transfer(address(liquidator), 30 ether);\n liquidator.redeem(IERC20Upgradeable(wUSDM), 30 ether, abi.encode(oracle, usdc, usdm, address(0)));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testKimLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 13579406) {\n address weth = 0x4200000000000000000000000000000000000006;\n address usdc = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n address kimRouter = 0xAc48FcF1049668B285f3dC72483DF5Ae2162f7e8;\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n AlgebraSwapLiquidator liquidator = AlgebraSwapLiquidator(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vm.startPrank(wethWhale);\n IERC20Upgradeable(weth).transfer(address(liquidator), 2018770577362160);\n liquidator.redeem(IERC20Upgradeable(weth), 2018770577362160, abi.encode(usdc, kimRouter));\n emit log_named_uint(\"usdc received\", IERC20Upgradeable(usdc).balanceOf(address(liquidator)));\n }\n\n function testVelodromeV2Liquidator_mode_usdcToWeth() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n address usdcWhale = 0xFd1D36995d76c0F75bbe4637C84C06E4A68bBB3a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(usdcWhale);\n usdc.transfer(address(liquidator), 1000 * 10e6);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(usdc), to: address(weth), stable: false });\n liquidator.redeem(usdc, 1000 * 10e6, abi.encode(veloRouter, path));\n emit log_named_uint(\"weth received\", weth.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function testVelodromeV2Liquidator_mode_wethToUSDC() public debuggingOnly forkAtBlock(MODE_MAINNET, 13881743) {\n VelodromeV2Liquidator liquidator = new VelodromeV2Liquidator();\n IERC20Upgradeable weth = IERC20Upgradeable(0x4200000000000000000000000000000000000006);\n IERC20Upgradeable usdc = IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f);\n address wethWhale = 0xe9b14a1Be94E70900EDdF1E22A4cB8c56aC9e10a;\n\n address veloRouter = 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45;\n\n vm.startPrank(wethWhale);\n weth.transfer(address(liquidator), 1 ether);\n IRouter_Velodrome.Route[] memory path = new IRouter_Velodrome.Route[](1);\n path[0] = IRouter_Velodrome.Route({ from: address(weth), to: address(usdc), stable: false });\n\n liquidator.redeem(weth, 1 ether, abi.encode(veloRouter, path));\n emit log_named_uint(\"usdc received\", usdc.balanceOf(address(liquidator)));\n vm.stopPrank();\n }\n\n function test_claimRewardFromLeveredPosition() public debuggingOnly fork(BASE_MAINNET) {\n LeveredPosition position = LeveredPosition(\n 0x3a0eA2C577b0e0f2CAaEcC2b8fF8fF1850267ba2 // 20 days old\n );\n ILeveredPositionFactory factory = position.factory();\n\n vm.prank(address(factory));\n LeveredPosition dummy = new LeveredPosition(\n msg.sender,\n ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3),\n ICErc20(0xa900A17a49Bc4D442bA7F72c39FA2108865671f0)\n );\n emit log_named_address(\"dummy\", address(dummy));\n\n vm.startPrank(factory.owner());\n DiamondBase(address(factory))._registerExtension(\n new LeveredPositionFactoryFirstExtension(),\n DiamondExtension(0x115455f15ef67e298F012F225B606D3c4Daa1d60)\n );\n factory._setPositionsExtension(LeveredPosition.claimRewardsFromRouter.selector, address(dummy));\n vm.stopPrank();\n\n {\n // mock the usdz call\n vm.mockCall(\n 0x04D5ddf5f3a8939889F11E97f8c4BB48317F1938,\n abi.encodeWithSelector(IERC20Upgradeable.balanceOf.selector),\n abi.encode(53307671999615298341926)\n );\n }\n\n vm.startPrank(0xC13110d04f22ed464Cb72A620fF8163585358Ff9);\n (address[] memory rewardTokens, uint256[] memory rewards) = position.claimRewardsFromRouter(\n 0xB1402333b12fc066C3D7F55d37944D5e281a3e8B\n );\n emit log_named_uint(\"reward tokens\", rewardTokens.length);\n emit log_named_uint(\"rewards\", rewards.length);\n vm.stopPrank();\n }\n\n function test_liquidateWithAggregator() public debuggingOnly forkAtBlock(MODE_MAINNET, 15435970) {\n IonicUniV3Liquidator liquidator = IonicUniV3Liquidator(payable(0x50F13EC4B68c9522260d3ccd4F19826679B3Ce5C));\n emit log_named_address(\"liquidator\", address(liquidator));\n address cErc20 = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18; // weEth\n address cTokenCollateral = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038; // usdc\n uint256 repayAmount = 843900759317990;\n address borrower = 0x1Bec4f239F1Ec11FD8DC7B31A8fea7A5bA5a9Aa4;\n address aggregatorTarget = 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE; // lifi\n // 0xd988097fb8612cc24eeC14542bC03424c656005f usdc\n // 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A weeth\n bytes memory aggregatorData = vm.parseBytes(\n \"0x4666fc800d27477c9a16fe2929353656c1222839791dbe26e815e7533f731ea9a6b919bb00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000050f13ec4b68c9522260d3ccd4f19826679b3ce5c0000000000000000000000000000000000000000000000000002ff85fb26dbe8000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000086c6966692d617069000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307830303030303030303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c7848740000000000000000000000007e15eb462cdc67cf92af1f7102465a8f8c784874000000000000000000000000d988097fb8612cc24eec14542bc03424c656005f00000000000000000000000004c0599ae5a44757c0af6f9ec3b93da8976c150a000000000000000000000000000000000000000000000000000000000027891800000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000f283bd37f90001d988097fb8612cc24eec14542bc03424c656005f000104c0599ae5a44757c0af6f9ec3b93da8976c150a0327891807030361590977620147ae00019b57dca972db5d8866c630554acdbdfe58b2659c000000011231deb6f5749ef6ce6943a275a1d3e7486f4eae59725ade04010205000601020203000205000100010400ff0000000000000000000000000053e85d00f2c6578a1205b842255ab9df9d05374425ba258e510faca5ab7ff941a1584bdd2174c94dd988097fb8612cc24eec14542bc03424c656005f4200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000\"\n );\n\n emit log_named_uint(\n \"before collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"before borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidator.safeLiquidateWithAggregator(\n borrower,\n repayAmount,\n ICErc20(cErc20),\n ICErc20(cTokenCollateral),\n aggregatorTarget,\n aggregatorData\n );\n vm.stopPrank();\n\n emit log_named_uint(\n \"profit collateral\",\n IERC20Upgradeable(ICErc20(cTokenCollateral).underlying()).balanceOf(address(this))\n );\n emit log_named_uint(\"profit borrow\", IERC20Upgradeable(ICErc20(cErc20).underlying()).balanceOf(address(this)));\n }\n\n function _functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.call(data);\n\n if (!success) {\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 return returndata;\n }\n\n function testRawCall() public debuggingOnly forkAtBlock(BASE_MAINNET, 20569373) {\n address caller = 0xC13110d04f22ed464Cb72A620fF8163585358Ff9;\n address target = 0x180272dDf5767C771b3a8d37A2DC6cA507aaa1d9;\n\n ILeveredPositionFactory factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n\n IERC20Upgradeable inputToken = IERC20Upgradeable(WETH);\n IERC20Upgradeable outputToken = wsuperOETH;\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(aerodomeClLiquidator, inputToken, outputToken);\n registry._setRedemptionStrategy(aerodomeClLiquidator, outputToken, inputToken);\n vm.stopPrank();\n\n bytes memory data = hex\"c393d0e3\";\n vm.prank(caller);\n _functionCall(target, data, \"raw call failed\");\n\n uint256 superOETHBalance = superOETH.balanceOf(target);\n emit log_named_uint(\"balance of levered position\", superOETHBalance);\n }\n}\n" + }, + "contracts/test/ExtensionsTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\ncontract MockComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFirstMarketSymbol() public view returns (string memory) {\n return allMarkets[0].symbol();\n }\n\n function _setTransferPaused(bool) public returns (bool) {\n return false;\n }\n\n function _setSeizePaused(bool) public returns (bool) {\n return false;\n }\n\n // a dummy fn to test if the replacement of extension fns works\n function getSecondMarketSymbol() public view returns (string memory) {\n return allMarkets[1].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 4;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this._setTransferPaused.selector;\n functionSelectors[--fnsCount] = this._setSeizePaused.selector;\n functionSelectors[--fnsCount] = this.getFirstMarketSymbol.selector;\n functionSelectors[--fnsCount] = this.getSecondMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockSecondComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getThirdMarketSymbol() public view returns (string memory) {\n return allMarkets[2].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getThirdMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract MockThirdComptrollerExtension is DiamondExtension, ComptrollerV3Storage {\n function getFourthMarketSymbol() public view returns (string memory) {\n return allMarkets[3].symbol();\n }\n\n function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) {\n uint8 fnsCount = 1;\n bytes4[] memory functionSelectors = new bytes4[](fnsCount);\n functionSelectors[--fnsCount] = this.getFourthMarketSymbol.selector;\n require(fnsCount == 0, \"use the correct array length\");\n return functionSelectors;\n }\n}\n\ncontract ExtensionsTest is MarketsTest {\n MockComptrollerExtension internal mockExtension;\n MockSecondComptrollerExtension internal second;\n MockThirdComptrollerExtension internal third;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n mockExtension = new MockComptrollerExtension();\n second = new MockSecondComptrollerExtension();\n third = new MockThirdComptrollerExtension();\n }\n\n function testExtensionReplace() public debuggingOnly fork(BSC_MAINNET) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n _upgradeExistingPool(jFiatPoolAddress);\n\n // replace the first extension with the mock\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, mockExtension, comptrollerExtension);\n\n // assert that the replacement worked\n MockComptrollerExtension asMockExtension = MockComptrollerExtension(jFiatPoolAddress);\n emit log(asMockExtension.getSecondMarketSymbol());\n assertEq(asMockExtension.getSecondMarketSymbol(), \"fETH-1\", \"market symbol does not match\");\n\n // add a second mock extension\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, second, DiamondExtension(address(0)));\n\n // add again the third, removing the second\n vm.prank(ffd.owner());\n ffd._registerComptrollerExtension(jFiatPoolAddress, third, second);\n\n // assert that it worked\n DiamondBase asBase = DiamondBase(jFiatPoolAddress);\n address[] memory currentExtensions = asBase._listExtensions();\n assertEq(currentExtensions.length, 2, \"extensions count does not match\");\n assertEq(currentExtensions[0], address(mockExtension), \"!first\");\n assertEq(currentExtensions[1], address(third), \"!second\");\n }\n\n function testNewPoolExtensions() public fork(BSC_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n _prepareComptrollerUpgrade(address(0));\n\n // deploy a pool that will have an extension registered automatically\n {\n (, address poolAddress) = fpd.deployPool(\n \"just-a-test2\",\n latestComptrollerImplementation,\n abi.encode(payable(address(ffd))),\n false,\n 0.1e18,\n 1.1e18,\n ap.getAddress(\"MasterPriceOracle\")\n );\n\n address[] memory initExtensionsAfter = DiamondBase(payable(poolAddress))._listExtensions();\n assertEq(initExtensionsAfter.length, 1, \"remove this if the ffd config is set up\");\n assertEq(initExtensionsAfter[0], address(comptrollerExtension), \"first extension is not the CFE\");\n }\n }\n\n function testMulticallMarket() public fork(BSC_MAINNET) {\n uint8 random = uint8(block.timestamp % 256);\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(pools[random % pools.length].comptroller);\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n ICErc20 someMarket = markets[random % markets.length];\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n vm.roll(block.number + 1);\n\n bytes memory blockNumberBeforeCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes memory accrueInterestCall = abi.encodeWithSelector(someMarket.accrueInterest.selector);\n bytes memory blockNumberAfterCall = abi.encodeWithSelector(someMarket.accrualBlockNumber.selector);\n bytes[] memory results = someMarket.multicall(\n asArray(blockNumberBeforeCall, accrueInterestCall, blockNumberAfterCall)\n );\n uint256 blockNumberBefore = abi.decode(results[0], (uint256));\n uint256 blockNumberAfter = abi.decode(results[2], (uint256));\n\n assertGt(blockNumberAfter, blockNumberBefore, \"did not accrue?\");\n }\n\n function testBscExistingCTokenExtensionUpgrade() public fork(BSC_MAINNET) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function testArbitrumExistingCTokenExtensionUpgrade() public fork(ARBITRUM_ONE) {\n _testAllPoolsAllMarketsCTokenExtensionUpgrade();\n }\n\n function _testAllPoolsAllMarketsCTokenExtensionUpgrade() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n for (uint256 i = 0; i < pools.length; i++) {\n _testPoolAllMarketsExtensionUpgrade(pools[i].comptroller);\n }\n }\n\n function _testPoolAllMarketsExtensionUpgrade(address poolAddress) internal {\n ComptrollerFirstExtension somePool = ComptrollerFirstExtension(poolAddress);\n\n ICErc20[] memory markets = somePool.getAllMarkets();\n\n if (markets.length == 0) return;\n\n for (uint256 j = 0; j < markets.length; j++) {\n ICErc20 someMarket = markets[j];\n CErc20Delegator asDelegator = CErc20Delegator(address(someMarket));\n\n emit log(\"pool\");\n emit log_address(address(somePool));\n emit log(\"market\");\n emit log_address(address(someMarket));\n\n try this._testExistingCTokenExtensionUpgrade(asDelegator) {} catch Error(string memory reason) {\n address plugin = address(CErc20PluginDelegate(address(asDelegator)).plugin());\n emit log(\"plugin\");\n emit log_address(plugin);\n\n address latestPlugin = ffd.latestPluginImplementation(plugin);\n emit log(\"latest plugin impl\");\n emit log_address(latestPlugin);\n\n revert(reason);\n }\n }\n }\n\n function _testExistingCTokenExtensionUpgrade(CErc20Delegator asDelegator) public {\n uint256 totalSupplyBefore = asDelegator.totalSupply();\n if (totalSupplyBefore == 0) return; // total supply should be non-zero\n\n // TODO\n _upgradeMarket(ICErc20(address(asDelegator)));\n\n // check if the extension was added\n address[] memory extensions = asDelegator._listExtensions();\n assertEq(extensions.length, 1, \"the first extension should be added\");\n assertEq(extensions[0], address(newCTokenExtension), \"the first extension should be the only extension\");\n\n // check if the storage is read from the same place\n uint256 totalSupplyAfter = asDelegator.totalSupply();\n assertGt(totalSupplyAfter, 0, \"total supply should be non-zero\");\n assertEq(totalSupplyAfter, totalSupplyBefore, \"total supply should be the same\");\n }\n\n function testBscComptrollerExtensions() public debuggingOnly fork(BSC_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testPolygonComptrollerExtensions() public debuggingOnly fork(POLYGON_MAINNET) {\n _testComptrollersExtensions();\n }\n\n function testChapelComptrollerExtensions() public debuggingOnly fork(BSC_CHAPEL) {\n _testComptrollersExtensions();\n }\n\n function testArbitrumComptrollerExtensions() public debuggingOnly fork(ARBITRUM_ONE) {\n _testComptrollersExtensions();\n }\n\n function _testComptrollersExtensions() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n address payable asPayable = payable(pools[i].comptroller);\n DiamondBase asBase = DiamondBase(asPayable);\n address[] memory extensions = asBase._listExtensions();\n assertEq(extensions.length, 1, \"each pool should have the first extension\");\n }\n }\n\n function testBulkAutoUpgrade() public debuggingOnly fork(POLYGON_MAINNET) {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n vm.prank(ffd.owner());\n ffd.autoUpgradePool(IonicComptroller(pools[i].comptroller));\n }\n }\n\n function testPolygonTotalUnderlyingSupplied() public debuggingOnly fork(POLYGON_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function testBscTotalUnderlyingSupplied() public debuggingOnly fork(BSC_MAINNET) {\n _testTotalUnderlyingSupplied();\n }\n\n function _testTotalUnderlyingSupplied() internal {\n PoolDirectory fpd = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n\n (, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n // if (pools[i].comptroller == 0x5373C052Df65b317e48D6CAD8Bb8AC50995e9459) continue;\n // if (pools[i].comptroller == 0xD265ff7e5487E9DD556a4BB900ccA6D087Eb3AD2) continue;\n ComptrollerFirstExtension poolExt = ComptrollerFirstExtension(pools[i].comptroller);\n\n ICErc20[] memory markets = poolExt.getAllMarkets();\n for (uint8 k = 0; k < markets.length; k++) {\n CErc20Delegate market = CErc20Delegate(address(markets[k]));\n // emit log(market.contractType());\n // emit log_named_address(\"impl\", market.implementation());\n CTokenFirstExtension marketAsExt = CTokenFirstExtension(address(markets[k]));\n marketAsExt.getTotalUnderlyingSupplied();\n }\n }\n }\n\n function testDelegateType() public debuggingOnly fork(POLYGON_MAINNET) {\n emit log(CErc20Delegate(0x587906620D627fe75C4d1288C6A584089780959c).contractType());\n }\n}\n" + }, + "contracts/test/helpers/WithPool.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.4.23;\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\n\nimport { JumpRateModel } from \"../../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { Comptroller } from \"../../compound/Comptroller.sol\";\nimport { CErc20PluginDelegate } from \"../../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20Delegate } from \"../../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { InterestRateModel } from \"../../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../../PoolDirectory.sol\";\nimport { MasterPriceOracle } from \"../../oracles/MasterPriceOracle.sol\";\nimport { ERC4626 } from \"solmate/mixins/ERC4626.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\nimport { ERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../../compound/ComptrollerFirstExtension.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\n\ncontract WithPool is BaseTest {\n ERC20Upgradeable public underlyingToken;\n CErc20Delegate cErc20Delegate;\n CErc20PluginDelegate cErc20PluginDelegate;\n CErc20PluginRewardsDelegate cErc20PluginRewardsDelegate;\n\n IonicComptroller comptroller;\n Comptroller newComptroller;\n JumpRateModel interestModel;\n\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n MasterPriceOracle priceOracle;\n PoolLens poolLens;\n\n address[] markets;\n bool[] t;\n bool[] f;\n address[] newImplementation;\n address[] hardcodedAddresses;\n string[] hardcodedNames;\n\n function setUpWithPool(MasterPriceOracle _masterPriceOracle, ERC20Upgradeable _underlyingToken) public {\n priceOracle = _masterPriceOracle;\n underlyingToken = _underlyingToken;\n\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n if (address(ionicAdmin) != address(0)) {\n // upgrade\n {\n FeeDistributor newImpl = new FeeDistributor();\n TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(address(ionicAdmin)));\n bytes32 bytesAtSlot = vm.load(\n address(proxy),\n 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n );\n address admin = address(uint160(uint256(bytesAtSlot)));\n vm.prank(admin);\n proxy.upgradeTo(address(newImpl));\n }\n } else {\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1e16);\n }\n\n {\n vm.prank(ionicAdmin.owner());\n ionicAdmin._setPendingOwner(address(this));\n ionicAdmin._acceptOwner();\n }\n setUpBaseContracts();\n setUpExtensions();\n }\n\n function setUpExtensions() internal {\n cErc20Delegate = new CErc20Delegate();\n cErc20PluginDelegate = new CErc20PluginDelegate();\n cErc20PluginRewardsDelegate = new CErc20PluginRewardsDelegate();\n\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), \"\");\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginDelegate.delegateType(),\n address(cErc20PluginDelegate),\n abi.encode(address(0))\n );\n ionicAdmin._setLatestCErc20Delegate(\n cErc20PluginRewardsDelegate.delegateType(),\n address(cErc20PluginRewardsDelegate),\n abi.encode(address(0))\n );\n\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginDelegate), cErc20DelegateExtensions);\n cErc20DelegateExtensions[1] = cErc20PluginRewardsDelegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20PluginRewardsDelegate), cErc20DelegateExtensions);\n }\n\n function setUpBaseContracts() internal {\n interestModel = new JumpRateModel(2343665, 1e18, 1e18, 4e18, 0.8e18);\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n\n poolLens = new PoolLens();\n poolLens.initialize(\n poolDirectory,\n \"Pool\",\n \"lens\",\n hardcodedAddresses,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames,\n hardcodedNames\n );\n }\n\n function setUpPool(\n string memory name,\n bool enforceWhitelist,\n uint256 closeFactor,\n uint256 liquidationIncentive\n ) public {\n Comptroller newComptrollerImplementation = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(newComptrollerImplementation));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = newComptrollerImplementation;\n ionicAdmin._setComptrollerExtensions(address(newComptrollerImplementation), extensions);\n\n (, address comptrollerAddress) = poolDirectory.deployPool(\n name,\n address(newComptrollerImplementation),\n abi.encode(payable(address(ionicAdmin))),\n enforceWhitelist,\n closeFactor,\n liquidationIncentive,\n address(priceOracle)\n );\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, address(this), poolAuth.BORROWER_ROLE(), true);\n }\n\n function upgradePool(address pool) internal {\n Comptroller newComptrollerImplementation = new Comptroller();\n\n Unitroller asUnitroller = Unitroller(payable(pool));\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n newComptrollerImplementation,\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function deployCErc20Delegate(\n address _underlyingToken,\n bytes memory name,\n bytes memory symbol,\n uint256 _collateralFactorMantissa\n ) public {\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n _underlyingToken,\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n name,\n symbol,\n uint256(1),\n uint256(0)\n ),\n \"\",\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginDelegate(address _erc4626, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_erc4626),\n _collateralFactorMantissa\n );\n }\n\n function deployCErc20PluginRewardsDelegate(address _mockERC4626Dynamic, uint256 _collateralFactorMantissa) public {\n comptroller._deployMarket(\n cErc20PluginRewardsDelegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"cUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n abi.encode(_mockERC4626Dynamic),\n _collateralFactorMantissa\n );\n }\n}\n" + }, + "contracts/test/LatestImplementationWhitelisted.t.sol": { + "content": "pragma solidity ^0.8.0;\n\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IERC4626 } from \"../compound/IERC4626.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LatestImplementationWhitelisted is BaseTest {\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n address[] poolsImplementationsSet;\n address[] marketsImplementationsSet;\n address[] pluginsSet;\n\n function testBscImplementations() public fork(BSC_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function testPolygonImplementations() public fork(POLYGON_MAINNET) {\n testPoolImplementations();\n testMarketImplementations();\n testPluginImplementations();\n }\n\n function afterForkSetUp() internal override {\n poolDirectory = PoolDirectory(ap.getAddress(\"PoolDirectory\"));\n ionicAdmin = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testPoolImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n address implementation = comptroller.comptrollerImplementation();\n\n bool added = false;\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n if (poolsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) poolsImplementationsSet.push(implementation);\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < poolsImplementationsSet.length; k++) {\n emit log_address(poolsImplementationsSet[k]);\n\n address latestImpl = ionicAdmin.latestComptrollerImplementation(poolsImplementationsSet[k]);\n assertTrue(poolsImplementationsSet[k] == latestImpl, \"some pool is not upgraded the latest impl\");\n }\n }\n\n function testMarketImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n ICErc20 market = markets[j];\n address implementation = market.implementation();\n\n bool added = false;\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n if (marketsImplementationsSet[k] == implementation) {\n added = true;\n }\n }\n\n if (!added) marketsImplementationsSet.push(implementation);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < marketsImplementationsSet.length; k++) {\n emit log_address(marketsImplementationsSet[k]);\n (address latestCErc20Delegate, bytes memory becomeImplementationData) = ionicAdmin.latestCErc20Delegate(\n CErc20Delegate(marketsImplementationsSet[k]).delegateType()\n );\n\n assertTrue(marketsImplementationsSet[k] == latestCErc20Delegate, \"some markets need to be upgraded\");\n }\n }\n\n function testPluginImplementations() internal {\n (, PoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();\n\n for (uint8 i = 0; i < pools.length; i++) {\n IonicComptroller comptroller = IonicComptroller(payable(pools[i].comptroller));\n ICErc20[] memory markets = comptroller.getAllMarkets();\n for (uint8 j = 0; j < markets.length; j++) {\n CErc20PluginDelegate delegate = CErc20PluginDelegate(address(markets[j]));\n\n address plugin;\n try delegate.plugin() returns (IERC4626 _plugin) {\n plugin = address(_plugin);\n } catch {\n continue;\n }\n\n bool added = false;\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n if (pluginsSet[k] == plugin) {\n added = true;\n }\n }\n\n if (!added) pluginsSet.push(plugin);\n }\n }\n\n emit log(\"listing the set\");\n for (uint8 k = 0; k < pluginsSet.length; k++) {\n address latestPluginImpl = ionicAdmin.latestPluginImplementation(pluginsSet[k]);\n\n emit log_address(pluginsSet[k]);\n\n assertTrue(pluginsSet[k] == latestPluginImpl, \"some plugin is not upgraded to the latest impl\");\n }\n }\n}\n" + }, + "contracts/test/LeveredPositionTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest, BaseTest } from \"./config/MarketsTest.t.sol\";\nimport { DiamondBase, DiamondExtension } from \"../ionic/DiamondExtension.sol\";\n\nimport { LeveredPosition } from \"../ionic/levered/LeveredPosition.sol\";\nimport { LeveredPositionFactory, IFeeDistributor } from \"../ionic/levered/LeveredPositionFactory.sol\";\nimport { JarvisLiquidatorFunder } from \"../liquidators/JarvisLiquidatorFunder.sol\";\nimport { BalancerSwapLiquidator } from \"../liquidators/BalancerSwapLiquidator.sol\";\nimport { AlgebraSwapLiquidator } from \"../liquidators/AlgebraSwapLiquidator.sol\";\nimport { SolidlyLpTokenLiquidator, SolidlyLpTokenWrapper } from \"../liquidators/SolidlyLpTokenLiquidator.sol\";\nimport { SolidlySwapLiquidator } from \"../liquidators/SolidlySwapLiquidator.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { AerodromeCLLiquidator } from \"../liquidators/AerodromeCLLiquidator.sol\";\nimport { AerodromeV2Liquidator } from \"../liquidators/AerodromeV2Liquidator.sol\";\n\nimport { CurveLpTokenLiquidatorNoRegistry } from \"../liquidators/CurveLpTokenLiquidatorNoRegistry.sol\";\nimport { LeveredPositionFactoryFirstExtension } from \"../ionic/levered/LeveredPositionFactoryFirstExtension.sol\";\nimport { LeveredPositionFactorySecondExtension } from \"../ionic/levered/LeveredPositionFactorySecondExtension.sol\";\nimport { ILeveredPositionFactory } from \"../ionic/levered/ILeveredPositionFactory.sol\";\nimport { LeveredPositionsLens } from \"../ionic/levered/LeveredPositionsLens.sol\";\nimport { LiquidatorsRegistry } from \"../liquidators/registry/LiquidatorsRegistry.sol\";\nimport { LiquidatorsRegistryExtension } from \"../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport { ILiquidatorsRegistry } from \"../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { SafeOwnable } from \"../ionic/SafeOwnable.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\n\ncontract LeveredPositionLensTest is BaseTest {\n LeveredPositionsLens lens;\n ILeveredPositionFactory factory;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n emit log_named_address(\"factory\", address(factory));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n // lens = new LeveredPositionsLens();\n // lens.initialize(factory);\n }\n\n function testLPLens() public debuggingOnly fork(BSC_CHAPEL) {\n _testLPLens();\n }\n\n function _testLPLens() internal {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(0xb6c11605e971ab46B9BE4fDC48C9650A257075db);\n\n // address[] memory accounts = factory.getAccountsWithOpenPositions();\n // for (uint256 i = 0; i < accounts.length; i++) {\n // (positions, closed) = factory.getPositionsByAccount(accounts[i]);\n // if (positions.length > 0) break;\n // }\n\n uint256[] memory apys = new uint256[](positions.length);\n LeveredPosition[] memory pos = new LeveredPosition[](positions.length);\n for (uint256 j = 0; j < positions.length; j++) {\n apys[j] = 1e17;\n\n if (address(0) == positions[j]) revert(\"zero pos address\");\n pos[j] = LeveredPosition(positions[j]);\n }\n\n LeveredPositionsLens.PositionInfo[] memory infos = lens.getPositionsInfo(pos, apys);\n\n for (uint256 k = 0; k < infos.length; k++) {\n emit log_named_address(\"address\", address(pos[k]));\n emit log_named_uint(\"positionSupplyAmount\", infos[k].positionSupplyAmount);\n emit log_named_uint(\"positionValue\", infos[k].positionValue);\n emit log_named_uint(\"debtAmount\", infos[k].debtAmount);\n emit log_named_uint(\"debtValue\", infos[k].debtValue);\n emit log_named_uint(\"equityValue\", infos[k].equityValue);\n emit log_named_uint(\"equityAmount\", infos[k].equityAmount);\n emit log_named_int(\"currentApy\", infos[k].currentApy);\n emit log_named_uint(\"debtRatio\", infos[k].debtRatio);\n emit log_named_uint(\"liquidationThreshold\", infos[k].liquidationThreshold);\n emit log_named_uint(\"safetyBuffer\", infos[k].safetyBuffer);\n\n emit log(\"\");\n }\n }\n\n function testPrintLeveredPositions() public debuggingOnly fork(POLYGON_MAINNET) {\n address[] memory accounts = factory.getAccountsWithOpenPositions();\n\n emit log_named_array(\"accounts\", accounts);\n\n for (uint256 j = 0; j < accounts.length; j++) {\n address[] memory positions;\n bool[] memory closed;\n (positions, closed) = factory.getPositionsByAccount(accounts[j]);\n emit log_named_array(\"positions\", positions);\n //emit log_named_array(\"closed\", closed);\n }\n }\n\n function testScenarioLeverageFailed() public debuggingOnly forkAtBlock(MODE_MAINNET, 10672173) {\n address USER = 0x95Ce459B20586cf44ee6d295C4f28e1a134CF529;\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006).approve(\n // address(factory),\n // 100000 ether\n // );\n vm.prank(ap.owner());\n ap.setAddress(\"IUniswapV2Router02\", 0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45);\n vm.startPrank(USER);\n LeveredPosition position = factory.createAndFundPositionAtRatio(\n ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n IERC20Upgradeable(0x4200000000000000000000000000000000000006),\n 16754252276537996590,\n 3000000000000000000\n );\n emit log_named_address(\"position\", address(position));\n\n // vm.stopPrank();\n // ILiquidatorsRegistry registry = factory.liquidatorsRegistry();\n // vm.startPrank(registry.owner());\n // registry._setRedemptionStrategy(\n // new UniswapV3LiquidatorFunder(),\n // IERC20Upgradeable(0xd988097fb8612cc24eeC14542bC03424c656005f),\n // IERC20Upgradeable(0x4200000000000000000000000000000000000006)\n // );\n // vm.stopPrank();\n // vm.startPrank(USER);\n\n vm.roll(10673509);\n position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(10852409);\n // position.adjustLeverageRatio(3000000000000000000);\n\n // vm.roll(11268772);\n // position.adjustLeverageRatio(3000000000000000000);\n vm.stopPrank();\n }\n}\n\ncontract LeveredPositionFactoryTest is BaseTest {\n ILeveredPositionFactory factory;\n LeveredPositionsLens lens;\n\n function afterForkSetUp() internal override {\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function testChapelNetApy() public debuggingOnly fork(BSC_CHAPEL) {\n ICErc20 _stableMarket = ICErc20(address(1)); // DAI\n\n uint256 borrowRate = 5.2e16; // 5.2%\n vm.mockCall(\n address(_stableMarket),\n abi.encodeWithSelector(_stableMarket.borrowRatePerBlock.selector),\n abi.encode(borrowRate / factory.blocksPerYear())\n );\n\n uint256 _borrowRate = _stableMarket.borrowRatePerBlock() * factory.blocksPerYear();\n emit log_named_uint(\"_borrowRate\", _borrowRate);\n\n int256 netApy = lens.getNetAPY(\n 2.7e16, // 2.7%\n 1e18, // supply amount\n ICErc20(address(0)), // BOMB\n _stableMarket,\n 2e18 // ratio\n );\n\n emit log_named_int(\"net apy\", netApy);\n\n // boosted APY = 2x 2.7% = 5.4 % of the equity\n // borrow APR = 5.2%\n // diff = 5.4 - 5.2 = 0.2%\n assertApproxEqRel(netApy, 0.2e16, 1e12, \"!net apy\");\n }\n}\n\nabstract contract LeveredPositionTest is MarketsTest {\n ICErc20 collateralMarket;\n ICErc20 stableMarket;\n ILeveredPositionFactory factory;\n ILiquidatorsRegistry registry;\n LeveredPosition position;\n LeveredPositionsLens lens;\n\n uint256 minLevRatio;\n uint256 maxLevRatio;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n factory = ILeveredPositionFactory(ap.getAddress(\"LeveredPositionFactory\"));\n registry = factory.liquidatorsRegistry();\n {\n // upgrade the registry\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n\n vm.startPrank(registry.owner());\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory oldExts = asBase._listExtensions();\n\n if (oldExts.length == 1) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(address(0)));\n } else if (oldExts.length == 2) {\n asBase._registerExtension(newExt1, DiamondExtension(oldExts[0]));\n asBase._registerExtension(newExt2, DiamondExtension(oldExts[1]));\n }\n vm.stopPrank();\n }\n\n lens = LeveredPositionsLens(ap.getAddress(\"LeveredPositionsLens\"));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(registry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(registry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function upgradePoolAndMarkets() internal {\n _upgradeExistingPool(address(collateralMarket.comptroller()));\n _upgradeMarket(collateralMarket);\n _upgradeMarket(stableMarket);\n }\n\n function _unpauseMarkets(address collat, address stable) internal {\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(address(ICErc20(stable).comptroller()));\n vm.startPrank(asExtension.admin());\n asExtension._setMintPaused(ICErc20(collat), false);\n asExtension._setMintPaused(ICErc20(stable), false);\n asExtension._setBorrowPaused(ICErc20(stable), false);\n vm.stopPrank();\n }\n\n function _configurePairAndLiquidator(address _collat, address _stable, IRedemptionStrategy _liquidator) internal {\n _configurePair(_collat, _stable);\n _configureTwoWayLiquidator(_collat, _stable, _liquidator);\n }\n\n function _configurePair(address _collat, address _stable) internal {\n collateralMarket = ICErc20(_collat);\n stableMarket = ICErc20(_stable);\n\n //upgradePoolAndMarkets();\n //_unpauseMarkets(_collat, _stable);\n vm.prank(factory.owner());\n factory._setPairWhitelisted(collateralMarket, stableMarket, true);\n }\n\n function _whitelistTestUser(address user) internal {\n address pool = address(collateralMarket.comptroller());\n PoolRolesAuthority pra = ffd.authoritiesRegistry().poolsAuthorities(pool);\n\n vm.startPrank(pra.owner());\n pra.setUserRole(user, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n }\n\n function _configureTwoWayLiquidator(\n address inputMarket,\n address outputMarket,\n IRedemptionStrategy strategy\n ) internal {\n IERC20Upgradeable inputToken = underlying(inputMarket);\n IERC20Upgradeable outputToken = underlying(outputMarket);\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategy(strategy, inputToken, outputToken);\n registry._setRedemptionStrategy(strategy, outputToken, inputToken);\n vm.stopPrank();\n }\n\n function underlying(address market) internal view returns (IERC20Upgradeable) {\n return IERC20Upgradeable(ICErc20(market).underlying());\n }\n\n struct Liquidator {\n IERC20Upgradeable inputToken;\n IERC20Upgradeable outputToken;\n IRedemptionStrategy strategy;\n }\n\n function _configureMultipleLiquidators(Liquidator[] memory liquidators) internal {\n IRedemptionStrategy[] memory strategies = new IRedemptionStrategy[](liquidators.length);\n IERC20Upgradeable[] memory inputTokens = new IERC20Upgradeable[](liquidators.length);\n IERC20Upgradeable[] memory outputTokens = new IERC20Upgradeable[](liquidators.length);\n for (uint256 i = 0; i < liquidators.length; i++) {\n strategies[i] = liquidators[i].strategy;\n inputTokens[i] = liquidators[i].inputToken;\n outputTokens[i] = liquidators[i].outputToken;\n }\n vm.startPrank(registry.owner());\n registry._setRedemptionStrategies(strategies, inputTokens, outputTokens);\n vm.stopPrank();\n }\n\n function _fundMarketAndSelf(ICErc20 market, address whale) internal {\n IERC20Upgradeable token = IERC20Upgradeable(market.underlying());\n\n if (whale == address(0)) {\n whale = address(911);\n //vm.deal(address(token), whale, 100e18);\n }\n\n uint256 allTokens = token.balanceOf(whale);\n vm.prank(whale);\n token.transfer(address(this), allTokens / 20);\n\n if (market.getCash() < allTokens / 2) {\n _whitelistTestUser(whale);\n vm.startPrank(whale);\n token.approve(address(market), allTokens / 2);\n market.mint(allTokens / 2);\n vm.stopPrank();\n }\n }\n\n function _openLeveredPosition(\n address _positionOwner,\n uint256 _depositAmount\n ) internal returns (LeveredPosition _position, uint256 _maxRatio, uint256 _minRatio) {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(_positionOwner, _depositAmount);\n\n vm.startPrank(_positionOwner);\n collateralToken.approve(address(factory), _depositAmount);\n _position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, _depositAmount);\n vm.stopPrank();\n\n _maxRatio = _position.getMaxLeverageRatio();\n emit log_named_uint(\"max ratio\", _maxRatio);\n _minRatio = _position.getMinLeverageRatio();\n emit log_named_uint(\"min ratio\", _minRatio);\n\n assertGt(_maxRatio, _minRatio, \"max ratio <= min ratio\");\n }\n\n function testOpenLeveredPosition() public virtual whenForking {\n assertApproxEqRel(position.getCurrentLeverageRatio(), 1e18, 4e16, \"initial leverage ratio should be 1.0 (1e18)\");\n }\n\n function testAnyLeverageRatio(uint64 ratioDiff) public debuggingOnly whenForking {\n // ratioDiff is between 0 and 2^64 ~= 18.446e18\n uint256 targetLeverageRatio = 1e18 + uint256(ratioDiff);\n emit log_named_uint(\"fuzz max ratio\", maxLevRatio);\n emit log_named_uint(\"fuzz min ratio\", minLevRatio);\n emit log_named_uint(\"target ratio\", targetLeverageRatio);\n vm.assume(targetLeverageRatio < maxLevRatio);\n vm.assume(minLevRatio < targetLeverageRatio);\n\n uint256 borrowedAssetPrice = stableMarket.comptroller().oracle().getUnderlyingPrice(stableMarket);\n (uint256 sd, uint256 bd) = position.getSupplyAmountDelta(targetLeverageRatio);\n emit log_named_uint(\"borrows delta val\", (bd * borrowedAssetPrice) / 1e18);\n emit log_named_uint(\"min borrow value\", ffd.getMinBorrowEth(stableMarket));\n\n uint256 equityAmount = position.getEquityAmount();\n emit log_named_uint(\"equity amount\", equityAmount);\n\n uint256 currentLeverageRatio = position.getCurrentLeverageRatio();\n emit log_named_uint(\"current ratio\", currentLeverageRatio);\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(targetLeverageRatio);\n emit log_named_uint(\"equity amount\", position.getEquityAmount());\n assertApproxEqRel(leverageRatioRealized, targetLeverageRatio, 4e16, \"target ratio not matching\");\n }\n\n function testMinMaxLeverageRatio() public whenForking {\n assertGt(maxLevRatio, minLevRatio, \"max ratio <= min ratio\");\n\n // attempting to adjust to minLevRatio - 0.01 should fail\n vm.expectRevert(abi.encodeWithSelector(LeveredPosition.BorrowStableFailed.selector, 0x3fa));\n position.adjustLeverageRatio((minLevRatio + 1e18) / 2);\n // just testing\n position.adjustLeverageRatio(maxLevRatio);\n // but adjusting to the minLevRatio + 0.01 should succeed\n position.adjustLeverageRatio(minLevRatio + 0.01e18);\n }\n\n function testMaxLeverageRatio() public whenForking {\n uint256 _equityAmount = position.getEquityAmount();\n uint256 rate = lens.getBorrowRateAtRatio(collateralMarket, stableMarket, _equityAmount, maxLevRatio);\n emit log_named_uint(\"borrow rate at max ratio\", rate);\n\n position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(position.getCurrentLeverageRatio(), maxLevRatio, 4e16, \"target max ratio not matching\");\n }\n\n function testRewardsAccruedClaimed() public whenForking {\n address[] memory flywheels = position.pool().getRewardsDistributors();\n if (flywheels.length > 0) {\n vm.warp(block.timestamp + 60 * 60 * 24);\n vm.roll(block.number + 10000);\n\n (ERC20[] memory rewardTokens, uint256[] memory amounts) = position.getAccruedRewards();\n\n ERC20 rewardToken;\n bool atLeastOneAccrued = false;\n for (uint256 i = 0; i < amounts.length; i++) {\n atLeastOneAccrued = amounts[i] > 0;\n if (atLeastOneAccrued) {\n rewardToken = rewardTokens[i];\n emit log_named_address(\"accrued from reward token\", address(rewardTokens[i]));\n break;\n }\n }\n\n assertEq(atLeastOneAccrued, true, \"!should have accrued at least one reward token\");\n\n if (atLeastOneAccrued) {\n uint256 rewardsBalanceBefore = rewardToken.balanceOf(address(this));\n position.claimRewards();\n uint256 rewardsBalanceAfter = rewardToken.balanceOf(address(this));\n assertGt(rewardsBalanceAfter - rewardsBalanceBefore, 0, \"should have claimed some rewards\");\n }\n } else {\n emit log(\"no flywheels/rewards for the pair pool\");\n }\n }\n\n function testLeverMaxDown() public whenForking {\n IERC20Upgradeable stableAsset = IERC20Upgradeable(stableMarket.underlying());\n IERC20Upgradeable collateralAsset = IERC20Upgradeable(collateralMarket.underlying());\n uint256 startingEquity = position.getEquityAmount();\n\n uint256 leverageRatioRealized = position.adjustLeverageRatio(maxLevRatio);\n assertApproxEqRel(leverageRatioRealized, maxLevRatio, 4e16, \"target ratio not matching\");\n\n // decrease the ratio in 10 equal steps\n uint256 ratioDiffStep = (maxLevRatio - 1e18) / 9;\n while (leverageRatioRealized > 1e18) {\n uint256 targetLeverDownRatio = leverageRatioRealized - ratioDiffStep;\n if (targetLeverDownRatio < minLevRatio) targetLeverDownRatio = 1e18;\n leverageRatioRealized = position.adjustLeverageRatio(targetLeverDownRatio);\n assertApproxEqRel(leverageRatioRealized, targetLeverDownRatio, 3e16, \"target lever down ratio not matching\");\n }\n\n uint256 withdrawAmount = position.closePosition();\n emit log_named_uint(\"withdraw amount\", withdrawAmount);\n assertApproxEqRel(startingEquity, withdrawAmount, 5e16, \"!withdraw amount\");\n\n assertEq(position.getEquityAmount(), 0, \"!nonzero equity amount\");\n assertEq(position.getCurrentLeverageRatio(), 0, \"!nonzero leverage ratio\");\n }\n}\n\ncontract WmaticMaticXLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 500e18;\n\n address wmaticMarket = 0xCb8D7c2690536d3444Da3d207f62A939483c8A93;\n address maticxMarket = 0x6ebdbEe1a509247B4A3ac3b73a43bd434C52C7c2;\n address wmaticWhale = 0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97;\n address maticxWhale = 0x72f0275444F2aF8dBf13F78D54A8D3aD7b6E68db;\n\n _configurePair(wmaticMarket, maticxMarket);\n _fundMarketAndSelf(ICErc20(wmaticMarket), wmaticWhale);\n _fundMarketAndSelf(ICErc20(maticxMarket), maticxWhale);\n\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n\n vm.startPrank(wmaticWhale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 100e18, stableToken);\n vm.stopPrank();\n vm.startPrank(maticxWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 100e18, collateralToken);\n vm.stopPrank();\n\n emit log_named_uint(\"slippage coll->stable\", registry.getSlippage(collateralToken, stableToken));\n emit log_named_uint(\"slippage stable->coll\", registry.getSlippage(stableToken, collateralToken));\n }\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract StkBnbWBnbLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 2e18;\n\n address stkBnbMarket = 0xAcfbf93d8fD1A9869bAb2328669dDba33296a421;\n address wbnbMarket = 0x3Af258d24EBdC03127ED6cEb8e58cA90835fbca5;\n address stkBnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n address wbnbWhale = 0x84b78452A97C5afDa1400943333F691448069A29; // algebra pool\n\n AlgebraSwapLiquidator liquidator = new AlgebraSwapLiquidator();\n _configurePairAndLiquidator(stkBnbMarket, wbnbMarket, liquidator);\n _fundMarketAndSelf(ICErc20(stkBnbMarket), stkBnbWhale);\n _fundMarketAndSelf(ICErc20(wbnbMarket), wbnbWhale);\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n collateralToken.transfer(address(this), depositAmount);\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPosition(collateralMarket, stableMarket, collateralToken, depositAmount);\n }\n}\n\ninterface TwoBrl {\n function minter() external view returns (address);\n\n function mint(address payable _to, uint256 _value) external returns (bool);\n}\n\ncontract Jbrl2BrlLeveredPositionTest is LeveredPositionTest {\n IonicComptroller pool;\n ComptrollerFirstExtension asExtension;\n\n function setUp() public fork(BSC_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1000e18;\n\n address twoBrlMarket = 0xf0a2852958aD041a9Fb35c312605482Ca3Ec17ba; // 2brl as collateral\n address jBrlMarket = 0x82A3103bc306293227B756f7554AfAeE82F8ab7a; // jbrl as borrowable\n address payable twoBrlWhale = payable(address(177)); // empty account\n address jBrlWhale = 0xA0695f78AF837F570bcc50f53e58Cda300798B65; // solidly pair BRZ-JBRL\n\n TwoBrl twoBrl = TwoBrl(ICErc20(twoBrlMarket).underlying());\n vm.prank(twoBrl.minter());\n twoBrl.mint(twoBrlWhale, depositAmount * 100);\n\n _configurePair(twoBrlMarket, jBrlMarket);\n _fundMarketAndSelf(ICErc20(twoBrlMarket), twoBrlWhale);\n _fundMarketAndSelf(ICErc20(jBrlMarket), jBrlWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract BombWbnbLeveredPositionTest is LeveredPositionTest {\n uint256 depositAmount = 100e18;\n address whale = 0xe7B7dF67C1fe053f1C6B965826d3bFF19603c482;\n address wbnbWhale = 0x57E30beb8054B248CE301FeabfD0c74677Fa40f0;\n uint256 ratioOnCreation = 1.0e18;\n uint256 minBorrowNative = 1e17;\n\n function setUp() public fork(BSC_CHAPEL) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n vm.mockCall(\n address(ffd),\n abi.encodeWithSelector(IFeeDistributor.minBorrowEth.selector),\n abi.encode(minBorrowNative)\n );\n\n address xMarket = 0x9B6E1039103812E0dcC1100a158e4a68014b2571; // BOMB\n address yMarket = 0x9dD00920f5B74A31177cbaB834AB0904703c31B1; // WBNB\n\n collateralMarket = ICErc20(xMarket);\n stableMarket = ICErc20(yMarket);\n\n //upgradePoolAndMarkets();\n\n IERC20Upgradeable collateralToken = IERC20Upgradeable(collateralMarket.underlying());\n IERC20Upgradeable stableToken = IERC20Upgradeable(stableMarket.underlying());\n // call amountOutAndSlippageOfSwap to cache the slippage\n {\n vm.startPrank(whale);\n collateralToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(collateralToken, 1e18, stableToken);\n collateralToken.transfer(address(this), depositAmount);\n vm.stopPrank();\n\n vm.startPrank(wbnbWhale);\n stableToken.approve(address(registry), 1e36);\n registry.amountOutAndSlippageOfSwap(stableToken, 1e18, collateralToken);\n vm.stopPrank();\n }\n\n vm.prank(whale);\n collateralToken.transfer(address(this), depositAmount);\n\n collateralToken.approve(address(factory), depositAmount);\n position = factory.createAndFundPositionAtRatio(\n collateralMarket,\n stableMarket,\n collateralToken,\n depositAmount,\n ratioOnCreation\n );\n\n maxLevRatio = position.getMaxLeverageRatio();\n minLevRatio = position.getMinLeverageRatio();\n\n vm.label(address(position), \"Levered Position\");\n }\n}\n\ncontract PearlWUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address wusdrMarket = 0x26EA46e975778662f98dAa0E7a12858dA9139262;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address wUsdrWhale = 0x8711a1a52c34EDe8E61eF40496ab2618a8F6EA4B;\n\n _configurePair(lpTokenMarket, wusdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wusdrMarket), wUsdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWUsdrUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 0.000002e18;\n\n address lpTokenMarket = 0x06F61E22ef144f1cC4550D40ffbF681CB1C3aCAF;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x03Fa7A2628D63985bDFe07B95d4026663ED96065;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdrLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 800e9;\n\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n IRedemptionStrategy liquidator = new SolidlySwapLiquidator();\n _configurePairAndLiquidator(usdrMarket, usdcMarket, liquidator);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdcUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdcMarket = 0x71A7037a42D0fB9F905a76B7D16846b2EACC59Aa;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrUsdcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 10e9;\n\n // LP token underlying 0xD17cb0f162f133e339C0BbFc18c36c357E681D6b\n address lpTokenMarket = 0x83DF24fE1B1eBF38048B91ffc4a8De0bAa88b891;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x97Bd59A8202F8263C2eC39cf6cF6B438D0B45876; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrDaiUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 2e18;\n\n // LP token underlying 0xBD02973b441Aa83c8EecEA158b98B5984bb1036E\n address lpTokenMarket = 0xBcE30B4D78cEb9a75A1Aa62156529c3592b3F08b;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x85Fa2331040933A02b154579fAbE6A6a5A765279; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrTngblUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.02e18;\n\n // LP token underlying 0x0Edc235693C20943780b76D79DD763236E94C751\n address lpTokenMarket = 0x2E870Aeee3D9d1eA29Ec93d2c0A99A4e0D5EB697;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdaeF32cA8D699015fcFB2884F6902fFCebE51c5b; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWbtcUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.000000071325342755e18;\n\n // LP token underlying 0xb95E1C22dd965FafE926b2A793e9D6757b6613F4\n address lpTokenMarket = 0xffc8c8d747E52fAfbf973c64Bab10d38A6902c46;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x39976f6328ebA2a3C860b7DE5cF2c1bB41581FB8; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrWethUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.004081e18;\n\n // LP token underlying 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127\n address lpTokenMarket = 0x343D9a8D2Bc6A62390aEc764bb5b900C4B039127;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0x7D02A8b758791A03319102f81bF61E220F73e43D; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract PearlUsdrMaticUsdrLpLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 0.05e18;\n\n // LP token underlying vAMM-WMATIC/USDR\n address lpTokenMarket = 0xfacEdA4f9731797102f040380aD5e234c92d1942;\n address usdrMarket = 0x1F11940B239D129dE0e5D30A3E59089af5Ecd6ed;\n address lpTokenWhale = 0xdA0AfBeEEBef6dA2F060237D35cab759b99B13B6; // Thena Gauge\n address usdrWhale = 0x00e8c0E92eB3Ad88189E7125Ec8825eDc03Ab265; // wUSDR contract\n\n _configurePair(lpTokenMarket, usdrMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdrMarket), usdrWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n upgradeRegistry();\n\n uint256 depositAmount = 300e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcCashLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 700e18;\n\n // LP token underlying xCASH-USDC\n address lpTokenMarket = 0x1D2A7078a404ab970f951d5A6dbECD9e24838FB6;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x35a499c15b4dDCf7e98628D415346B9795CCa80d;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroUsdcAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(lpTokenMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashUsdcLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 300e18;\n\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address usdcMarket = 0x38EbA94210bCEf3F9231E1764EE230abC14D1cbc;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(cashMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroCashAUsdcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xUSDC-WETH05\n address lpTokenMarket = 0xC7cA03A0bE1dBAc350E5BfE5050fC5af6406490E;\n address cashMarket = 0xf69207CFDe6228A1e15A34F2b0c4fDe0845D9eBa;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address cashWhale = 0x88C522E526E5Eea8d636fd6805cA7fEB488780D0;\n\n _configurePair(lpTokenMarket, cashMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(cashMarket), cashWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract RetroWethAWbtcWethLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n // LP token underlying xWBTC-WETH05\n address lpTokenMarket = 0xCB1a06eff3459078c26516ae3a1dB44A61D2DbCA;\n address wethMarket = 0x2469B23354cb7cA50b798663Ec5812Bf28d15e9e;\n address lpTokenWhale = 0x38e481367E0c50f4166AD2A1C9fde0E3c662CFBa;\n address wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n\n _configurePair(lpTokenMarket, wethMarket);\n _fundMarketAndSelf(ICErc20(lpTokenMarket), lpTokenWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract DavosUsdcDusdLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(POLYGON_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 500e18;\n\n address dusdMarket = 0xE70d09dA78900A0429ee70b35200F70A30d7d2B9;\n address usdcMarket = 0x14787e50578d8c606C3d57bDbA53dD65Fd665449;\n address dusdWhale = 0xE69a1876bdACfa7A7a4F6D531BE2FDE843D2165C;\n address usdcWhale = 0x5a52E96BAcdaBb82fd05763E25335261B270Efcb;\n\n _configurePair(dusdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(dusdMarket), dusdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e17;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wethWhale = 0x7380511493DD4c2f1dD75E9CCe5bD52C787D4B51;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wethMarket, USDCMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDCMarket), USDCWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wethWhale = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n\n _configurePair(wethMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDCMarket = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n address wbtcWhale = 0x3f3429D28438Cc14133966820b8A9Ea61Cf1D4F0;\n address USDCWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDCMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n IERC20Upgradeable token = IERC20Upgradeable(ICErc20(wbtcMarket).underlying());\n\n _configurePair(wbtcMarket, USDCMarket);\n\n uint256 allTokens = token.balanceOf(wbtcWhale);\n\n vm.prank(wbtcWhale);\n token.transfer(address(this), allTokens);\n vm.stopPrank();\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract ModeWbtcUSDTLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(MODE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e6;\n\n address wbtcMarket = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n address wbtcWhale = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n address USDTWhale = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(USDTMarket);\n\n uint256[] memory newBorrowCaps = new uint256[](1);\n newBorrowCaps[0] = 1e36;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wbtcMarket).comptroller());\n\n vm.prank(comptroller.admin());\n comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);\n vm.stopPrank();\n\n _configurePair(wbtcMarket, USDTMarket);\n _fundMarketAndSelf(ICErc20(wbtcMarket), wbtcWhale);\n _fundMarketAndSelf(ICErc20(USDTMarket), USDTWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDUSDCLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address usdcMarket = 0xa900A17a49Bc4D442bA7F72c39FA2108865671f0;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address usdcWhale = 0x70FF197c32E922700d3ff2483D250c645979855d;\n\n {\n IERC20Upgradeable x = IERC20Upgradeable(ICErc20(hyUsdMarket).underlying());\n IERC20Upgradeable y = IERC20Upgradeable(ICErc20(usdcMarket).underlying());\n IERC20Upgradeable[] memory xToYPath = new IERC20Upgradeable[](2);\n IERC20Upgradeable[] memory yToXPath = new IERC20Upgradeable[](2);\n\n IERC20Upgradeable eUSD = IERC20Upgradeable(0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4);\n xToYPath[0] = eUSD;\n yToXPath[0] = eUSD;\n xToYPath[1] = y;\n yToXPath[1] = x;\n\n vm.startPrank(registry.owner());\n registry._setOptimalSwapPath(IERC20Upgradeable(x), IERC20Upgradeable(y), xToYPath);\n registry._setOptimalSwapPath(IERC20Upgradeable(y), IERC20Upgradeable(x), yToXPath);\n vm.stopPrank();\n }\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePair(hyUsdMarket, usdcMarket);\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(usdcMarket), usdcWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract HyUSDeUSDLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n upgradeRegistry();\n\n uint256 depositAmount = 20e18;\n\n address hyUsdMarket = 0x751911bDa88eFcF412326ABE649B7A3b28c4dEDe;\n address eUsdMarket = 0x9c2A4f9c5471fd36bE3BBd8437A33935107215A1;\n address hyUsdWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address eUsdWhale = 0xa9E0588E82E9Ee1440f7e5375970a429D09646c1;\n AerodromeV2Liquidator aerodomeV2Liquidator = AerodromeV2Liquidator(0xD46b85409C43571145206B11D370A62AaeB22475);\n\n // IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(hyUsdMarket, eUsdMarket, IRedemptionStrategy(address(aerodomeV2Liquidator)));\n _fundMarketAndSelf(ICErc20(hyUsdMarket), hyUsdWhale);\n _fundMarketAndSelf(ICErc20(eUsdMarket), eUsdWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\ncontract WSuperOETHWETHLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(BASE_MAINNET) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n address wsuperOeth = 0x7FcD174E80f264448ebeE8c88a7C4476AAF58Ea6;\n address weth = 0x4200000000000000000000000000000000000006;\n\n uint256 depositAmount = 1e18;\n\n address wsuperOethMarket = 0xC462eb5587062e2f2391990b8609D2428d8Cf598;\n address wethMarket = 0x49420311B518f3d0c94e897592014de53831cfA3;\n address wsuperOethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n address wethWhale = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;\n\n IonicComptroller comptroller = IonicComptroller(ICErc20(wethMarket).comptroller());\n ICErc20[] memory cTokens = new ICErc20[](1);\n cTokens[0] = ICErc20(wethMarket);\n\n uint256[] memory newSupplyCaps = new uint256[](1);\n newSupplyCaps[0] = 1e36;\n vm.prank(comptroller.admin());\n comptroller._setMarketSupplyCaps(cTokens, newSupplyCaps);\n\n AerodromeCLLiquidator aerodomeClLiquidator = new AerodromeCLLiquidator();\n vm.prank(registry.owner());\n registry._setWrappedToUnwrapped4626(address(wsuperOeth), address(0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3));\n // vm.prank(aerodomeClLiquidator.owner());\n // emit log_named_address(\"wsuperOeth\", address(wsuperOeth));\n // aerodomeClLiquidator.setWrappedToUnwrapped(\n // address(wsuperOeth),\n // 0xDBFeFD2e8460a6Ee4955A68582F85708BAEA60A3\n // );\n _configurePairAndLiquidator(wsuperOethMarket, wethMarket, IRedemptionStrategy(address(aerodomeClLiquidator)));\n _fundMarketAndSelf(ICErc20(wsuperOethMarket), wsuperOethWhale);\n _fundMarketAndSelf(ICErc20(wethMarket), wethWhale);\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n\n/*\ncontract XYLeveredPositionTest is LeveredPositionTest {\n function setUp() public fork(X_CHAIN_ID) {}\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n uint256 depositAmount = 1e18;\n\n address xMarket = 0x...1;\n address yMarket = 0x...2;\n address xWhale = 0x...3;\n address yWhale = 0x...4;\n\n IRedemptionStrategy liquidator = new IRedemptionStrategy();\n _configurePairAndLiquidator(xMarket, yMarket, liquidator);\n _fundMarketAndSelf(ICErc20(xMarket), xWhale);\n _fundMarketAndSelf(ICErc20(yMarket), yWhale);\n\n (position, maxLevRatio, minLevRatio) = _openLeveredPosition(address(this), depositAmount);\n }\n}\n*/\n" + }, + "contracts/test/liquidators/IonicLiquidatorTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\nimport \"openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol\";\n\nimport { IonicLiquidator, ILiquidator } from \"../../IonicLiquidator.sol\";\nimport { IonicUniV3Liquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport { ICurvePool } from \"../../external/curve/ICurvePool.sol\";\nimport { CurveSwapLiquidatorFunder } from \"../../liquidators/CurveSwapLiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IUniswapV2Pair } from \"../../external/uniswap/IUniswapV2Pair.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { LiquidatorsRegistrySecondExtension } from \"../../liquidators/registry/LiquidatorsRegistrySecondExtension.sol\";\nimport \"../../liquidators/registry/LiquidatorsRegistryExtension.sol\";\nimport { Unitroller } from \"../../compound/Unitroller.sol\";\nimport { BasePriceOracle } from \"../../oracles/BasePriceOracle.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport { UpgradesBaseTest } from \"../UpgradesBaseTest.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { ProxyAdmin } from \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\nimport { PoolLens } from \"../../PoolLens.sol\";\n\ncontract MockRedemptionStrategy is IRedemptionStrategy {\n function redeem(\n IERC20Upgradeable,\n uint256,\n bytes memory\n ) external returns (IERC20Upgradeable, uint256) {\n return (IERC20Upgradeable(address(0)), 1);\n }\n\n function name() public pure returns (string memory) {\n return \"MockRedemptionStrategy\";\n }\n}\n\ncontract IonicLiquidatorTest is UpgradesBaseTest {\n ILiquidator liquidator;\n address uniswapRouter;\n address swapRouter;\n IUniswapV3Quoter quoter;\n address usdcWhale;\n address wethWhale;\n address poolAddress;\n address uniV3PooForFlash;\n uint256 usdcMarketIndex;\n uint256 wethMarketIndex;\n\n AuthoritiesRegistry authRegistry;\n ILiquidatorsRegistry liquidatorsRegistry;\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n if (block.chainid == BSC_MAINNET) {\n uniswapRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E;\n } else if (block.chainid == POLYGON_MAINNET) {\n uniswapRouter = 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff;\n swapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n quoter = IUniswapV3Quoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);\n usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD; // aave reserve\n wethWhale = 0x1eED63EfBA5f81D95bfe37d82C8E736b974F477b;\n poolAddress = 0x22A705DEC988410A959B8b17C8c23E33c121580b; // Retro stables pool\n uniV3PooForFlash = 0xA374094527e1673A86dE625aa59517c5dE346d32; // usdc-wmatic\n usdcMarketIndex = 3;\n wethMarketIndex = 5;\n } else if (block.chainid == MODE_MAINNET) {\n uniswapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n // uniswapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n // swapRouter = 0xC9Adff795f46105E53be9bbf14221b1C9919EE25; // sup router\n swapRouter = 0x5D61c537393cf21893BE619E36fC94cd73C77DD3; // kim router\n //quoter = IUniswapV3Quoter(0x7Fd569b2021850fbA53887dd07736010aCBFc787); // other sup quoter?\n quoter = IUniswapV3Quoter(0x5E6AEbab1AD525f5336Bd12E6847b851531F72ba); // sup quoter\n usdcWhale = 0x34b83A3759ba4c9F99c339604181bf6bBdED4C79; // vault\n wethWhale = 0xF4C85269240C1D447309fA602A90ac23F1CB0Dc0;\n poolAddress = 0xFB3323E24743Caf4ADD0fDCCFB268565c0685556;\n //uniV3PooForFlash = 0x293f2B2c17f8cEa4db346D87Ef5712C9dd0491EF; // kim weth-usdc pool\n uniV3PooForFlash = 0x047CF4b081ee80d2928cb2ce3F3C4964e26eB0B9; // kim usdt-usdc pool\n // uniV3PooForFlash = 0xf2e9C024F1C0B7a2a4ea11243C2D86A7b38DD72f; // sup univ2 0x34a1E3Db82f669f8cF88135422AfD80e4f70701A\n usdcMarketIndex = 1;\n wethMarketIndex = 0;\n // weth 0x4200000000000000000000000000000000000006\n // usdc 0xd988097fb8612cc24eeC14542bC03424c656005f\n }\n\n // vm.prank(ap.owner());\n // ap.setAddress(\"IUniswapV2Router02\", uniswapRouter);\n vm.prank(ap.owner());\n ap.setAddress(\"UNISWAP_V3_ROUTER\", uniswapRouter);\n\n authRegistry = AuthoritiesRegistry(ap.getAddress(\"AuthoritiesRegistry\"));\n liquidatorsRegistry = ILiquidatorsRegistry(ap.getAddress(\"LiquidatorsRegistry\"));\n liquidator = IonicLiquidator(payable(ap.getAddress(\"IonicLiquidator\")));\n }\n\n function upgradeRegistry() internal {\n DiamondBase asBase = DiamondBase(address(liquidatorsRegistry));\n address[] memory exts = asBase._listExtensions();\n LiquidatorsRegistryExtension newExt1 = new LiquidatorsRegistryExtension();\n LiquidatorsRegistrySecondExtension newExt2 = new LiquidatorsRegistrySecondExtension();\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt1, DiamondExtension(exts[0]));\n vm.prank(SafeOwnable(address(liquidatorsRegistry)).owner());\n asBase._registerExtension(newExt2, DiamondExtension(exts[1]));\n }\n\n function testBsc() public fork(BSC_MAINNET) {\n testUpgrade();\n }\n\n function testPolygon() public fork(POLYGON_MAINNET) {\n testUpgrade();\n }\n\n function testUpgrade() internal {\n // in case these slots start to get used, please redeploy the FSL\n // with a larger storage gap to protect the owner variable of OwnableUpgradeable\n // from being overwritten by the IonicLiquidator storage\n for (uint256 i = 40; i < 51; i++) {\n address atSloti = address(uint160(uint256(vm.load(address(liquidator), bytes32(i)))));\n assertEq(\n atSloti,\n address(0),\n \"replace the FSL proxy/storage contract with a new one before the owner variable is overwritten\"\n );\n }\n }\n\n function testSpecificLiquidation() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0x5834a3AAFA83A53822B313994Bb554d8E8c215dF;\n address debtMarketAddr = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n address collateralMarketAddr = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n\n liquidator = ILiquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars;\n vars.borrower = borrower;\n vars.cErc20 = ICErc20(debtMarketAddr);\n vars.cTokenCollateral = ICErc20(collateralMarketAddr);\n vars.repayAmount = 0x408c7a4d7c4092;\n vars.flashSwapContract = 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc;\n vars.minProfitAmount = 0;\n vars.redemptionStrategies = new IRedemptionStrategy[](1);\n vars.strategyData = new bytes[](1);\n vars.debtFundingStrategies = new IFundsConversionStrategy[](0);\n vars.debtFundingStrategiesData = new bytes[](0);\n\n vars.redemptionStrategies[0] = IFundsConversionStrategy(0x5cA3fd2c285C4138185Ef1BdA7573D415020F3C8);\n vars.strategyData[\n 0\n ] = hex\"0000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ac48fcf1049668b285f3dc72483df5ae2162f7e8\";\n\n liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n }\n\n function testWithdrawalLiquidator() public debuggingOnly fork(MODE_MAINNET) {\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.prank(0x4200000000000000000000000000000000000016);\n (bool success, ) = address(liquidatorV3).call{ value: 1 ether }(\"\");\n require(success, \"transfer of funds failed\");\n\n uint256 beforeBalance = liquidatorV3.owner().balance;\n\n vm.prank(liquidatorV3.owner());\n liquidatorV3.withdrawAll();\n\n emit log_named_uint(\"balance of liquidator\", liquidatorV3.owner().balance);\n\n assertEq(liquidatorV3.owner().balance, beforeBalance + 1 ether);\n assertEq(address(liquidatorV3).balance, 0);\n }\n\n function testLiquidateAfterUpgradeLiquidator() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(1e18);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: 0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n function testLiquidateAfterUpgradeLiquidatorExpressRelay() public debuggingOnly forkAtBlock(MODE_MAINNET, 9382006) {\n // upgrade IonicLiquidator\n TransparentUpgradeableProxy proxyV3 = TransparentUpgradeableProxy(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n IonicUniV3Liquidator implV3 = new IonicUniV3Liquidator();\n IonicUniV3Liquidator liquidatorV3 = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n PoolLens lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n address expressRelay = makeAddr(\"expressRelay\");\n\n ProxyAdmin proxyAdmin = ProxyAdmin(ap.getAddress(\"DefaultProxyAdmin\"));\n\n vm.startPrank(proxyAdmin.owner());\n proxyAdmin.upgrade(proxyV3, address(implV3));\n vm.stopPrank();\n\n vm.startPrank(0x1155b614971f16758C92c4890eD338C9e3ede6b7);\n liquidatorV3.setPoolLens(address(lens));\n liquidatorV3.setHealthFactorThreshold(95e16);\n liquidatorV3.setExpressRelay(expressRelay);\n vm.stopPrank();\n\n IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n (, , uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n emit log_named_uint(\"liquidity\", liquidity);\n emit log_named_uint(\"shortfall\", shortfall);\n\n uint256 healthFactor = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf before\", healthFactor);\n\n address borrower = address(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d);\n\n ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: borrower,\n repayAmount: 1134537086250983,\n cErc20: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n cTokenCollateral: ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2),\n flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n minProfitAmount: 0,\n redemptionStrategies: new IRedemptionStrategy[](0),\n strategyData: new bytes[](0),\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n });\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(false) \n );\n vm.expectRevert(\"invalid liquidation\");\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n vm.mockCall(\n expressRelay, \n abi.encodeWithSelector(bytes4(keccak256(\"isPermissioned(address,bytes)\")), address(liquidatorV3), abi.encode(borrower)),\n abi.encode(true) \n );\n liquidatorV3.safeLiquidateToTokensWithFlashLoan(vars);\n\n uint256 healthFactorAfter = lens.getHealthFactor(0x92eA6902C5023CC632e3Fd84dE7CcA6b98FE853d, pool);\n emit log_named_uint(\"hf after\", healthFactorAfter);\n }\n\n // TODO test with marginal shortfall for liquidation penalty errors\n function _testLiquidatorLiquidate(address contractForFlashSwap) internal {\n IonicComptroller pool = IonicComptroller(poolAddress);\n // _upgradePoolWithExtension(Unitroller(payable(poolAddress)));\n //upgradeRegistry();\n\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.prank(pool.admin());\n pool._setBorrowCapForCollateral(address(usdcMarket), address(wethMarket), 1e36);\n }\n\n {\n vm.prank(pool.admin());\n pool._borrowCapWhitelist(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038, address(this), true);\n }\n\n {\n vm.prank(wethWhale);\n weth.transfer(address(this), 0.1e18);\n\n weth.approve(address(wethMarket), 1e36);\n require(wethMarket.mint(0.1e18) == 0, \"mint weth failed\");\n pool.enterMarkets(asArray(address(usdcMarket), address(wethMarket)));\n }\n\n {\n vm.startPrank(usdcWhale);\n usdc.approve(address(usdcMarket), 2e36);\n require(usdcMarket.mint(70e6) == 0, \"mint usdc failed\");\n vm.stopPrank();\n }\n\n {\n require(usdcMarket.borrow(50e6) == 0, \"borrow usdc failed\");\n\n // the collateral prices change\n BasePriceOracle mpo = pool.oracle();\n uint256 priceCollateral = mpo.getUnderlyingPrice(wethMarket);\n vm.mockCall(\n address(mpo),\n abi.encodeWithSelector(mpo.getUnderlyingPrice.selector, wethMarket),\n abi.encode(priceCollateral / 10)\n );\n }\n\n (IRedemptionStrategy[] memory strategies, bytes[] memory strategiesData) = liquidatorsRegistry\n .getRedemptionStrategies(weth, usdc);\n\n uint256 seizedAmount = liquidator.safeLiquidateToTokensWithFlashLoan(\n ILiquidator.LiquidateToTokensWithFlashSwapVars({\n borrower: address(this),\n repayAmount: 10e6,\n cErc20: usdcMarket,\n cTokenCollateral: wethMarket,\n flashSwapContract: contractForFlashSwap,\n minProfitAmount: 6,\n redemptionStrategies: strategies,\n strategyData: strategiesData,\n debtFundingStrategies: new IFundsConversionStrategy[](0),\n debtFundingStrategiesData: new bytes[](0)\n })\n );\n\n emit log_named_uint(\"seized amount\", seizedAmount);\n require(seizedAmount > 0, \"didn't seize any assets\");\n }\n}\n" + }, + "contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { IonicUniV3Liquidator, IUniswapV3Pool, ILiquidator } from \"../../IonicUniV3Liquidator.sol\";\nimport \"../../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol\";\nimport { IRedemptionStrategy } from \"../../liquidators/IRedemptionStrategy.sol\";\nimport { ILiquidatorsRegistry } from \"../../liquidators/registry/ILiquidatorsRegistry.sol\";\nimport { IUniswapV2Router02 } from \"../../external/uniswap/IUniswapV2Router02.sol\";\nimport { IUniswapV3Factory } from \"../../external/uniswap/IUniswapV3Factory.sol\";\nimport { UniswapV2LiquidatorFunder } from \"../../liquidators/UniswapV2LiquidatorFunder.sol\";\nimport { UniswapV3LiquidatorFunder } from \"../../liquidators/UniswapV3LiquidatorFunder.sol\";\nimport { KimUniV2Liquidator } from \"../../liquidators/KimUniV2Liquidator.sol\";\n\nimport { IFundsConversionStrategy } from \"../../liquidators/IFundsConversionStrategy.sol\";\nimport { ICErc20 } from \"../../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../../compound/ComptrollerInterface.sol\";\nimport { AuthoritiesRegistry } from \"../../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../../ionic/PoolRolesAuthority.sol\";\n\nimport { BaseTest } from \"../config/BaseTest.t.sol\";\nimport \"./IonicLiquidatorTest.sol\";\n\ncontract UniswapV3LiquidatorTest is IonicLiquidatorTest {\n function testPolygonUniV3LiquidatorLiquidate() public fork(POLYGON_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeUniV3LiquidatorLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n IonicUniV3Liquidator _liquidator = new IonicUniV3Liquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), address(quoter));\n liquidator = _liquidator;\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = new UniswapV3LiquidatorFunder();\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n vm.prank(OwnableUpgradeable(address(liquidator)).owner());\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testModeKimUniV2Liquidator() public fork(MODE_MAINNET) {\n IonicLiquidator _liquidator = new IonicLiquidator();\n _liquidator.initialize(ap.getAddress(\"wtoken\"), ap.getAddress(\"IUniswapV2Router02\"), 30);\n liquidator = _liquidator;\n liquidator.setPoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n liquidator.setHealthFactorThreshold(1e18);\n\n IonicComptroller pool = IonicComptroller(poolAddress);\n {\n ICErc20[] memory markets = pool.getAllMarkets();\n\n ICErc20 usdcMarket = markets[usdcMarketIndex];\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcMarket.underlying());\n ICErc20 wethMarket = markets[wethMarketIndex];\n IERC20Upgradeable weth = IERC20Upgradeable(wethMarket.underlying());\n {\n emit log_named_address(\"usdc market\", address(usdcMarket));\n emit log_named_address(\"weth market\", address(wethMarket));\n emit log_named_address(\"usdc underlying\", usdcMarket.underlying());\n emit log_named_address(\"weth underlying\", wethMarket.underlying());\n vm.startPrank(liquidatorsRegistry.owner());\n IRedemptionStrategy strategy = KimUniV2Liquidator(0x6aC17D406a820fa464fFdc0940FCa7E60b3b36B7);\n liquidatorsRegistry._setRedemptionStrategy(strategy, weth, usdc);\n vm.stopPrank();\n liquidator._whitelistRedemptionStrategy(strategy, true);\n }\n }\n\n _testLiquidatorLiquidate(uniV3PooForFlash);\n }\n\n function testUniV3PoolForFee() public debuggingOnly fork(MODE_MAINNET) {\n address wethAddr = 0x4200000000000000000000000000000000000006;\n address usdcAddr = 0xd988097fb8612cc24eeC14542bC03424c656005f;\n IERC20Upgradeable usdc = IERC20Upgradeable(usdcAddr);\n IERC20Upgradeable weth = IERC20Upgradeable(wethAddr);\n\n IUniswapV2Router02 kimRouter = IUniswapV2Router02(0x5D61c537393cf21893BE619E36fC94cd73C77DD3);\n address factoryAddress;\n //factory = kimRouter.factory();\n factoryAddress = 0xC33Ce0058004d44E7e1F366E5797A578fDF38584;\n IUniswapV3Factory factory = IUniswapV3Factory(factoryAddress);\n address pool;\n\n uint256 feeConfig = liquidatorsRegistry.uniswapV3Fees(usdc, weth);\n emit log_named_uint(\"feeConfig\", feeConfig);\n\n if (feeConfig == 0) {\n pool = factory.getPool(wethAddr, usdcAddr, uint24(feeConfig));\n emit log_named_address(\"Pool at fee 0\", pool);\n }\n\n pool = factory.getPool(wethAddr, usdcAddr, 500);\n emit log_named_address(\"Pool at fee 500\", pool);\n }\n}\n" + }, + "contracts/test/LiquidityMining.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"forge-std/Vm.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { Auth, Authority } from \"solmate/auth/Auth.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { FlywheelStaticRewards } from \"../ionic/strategies/flywheel/rewards/FlywheelStaticRewards.sol\";\nimport { IFlywheelBooster } from \"../ionic/strategies/flywheel/IFlywheelBooster.sol\";\nimport { IFlywheelRewards } from \"../ionic/strategies/flywheel/rewards/IFlywheelRewards.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20 } from \"../compound/CToken.sol\";\nimport { JumpRateModel } from \"../compound/JumpRateModel.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { AuthoritiesRegistry } from \"../ionic/AuthoritiesRegistry.sol\";\nimport { PoolRolesAuthority } from \"../ionic/PoolRolesAuthority.sol\";\n\nimport { MockPriceOracle } from \"../oracles/1337/MockPriceOracle.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { IonicFlywheelLensRouter } from \"../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol\";\nimport { IonicFlywheel } from \"../ionic/strategies/flywheel/IonicFlywheel.sol\";\nimport { IonicFlywheelCore } from \"../ionic/strategies/flywheel/IonicFlywheelCore.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\ncontract LiquidityMiningTest is BaseTest {\n MockERC20 underlyingToken;\n MockERC20 rewardToken;\n\n JumpRateModel interestModel;\n IonicComptroller comptroller;\n CErc20Delegate cErc20Delegate;\n ICErc20 cErc20;\n FeeDistributor ionicAdmin;\n PoolDirectory poolDirectory;\n\n IonicFlywheel flywheel;\n FlywheelStaticRewards rewards;\n IonicFlywheelLensRouter flywheelClaimer;\n\n address user = address(1337);\n\n uint8 baseDecimal;\n uint8 rewardDecimal;\n\n address[] markets;\n IonicFlywheelCore[] flywheelsToClaim;\n\n function setUpBaseContracts(uint8 _baseDecimal, uint8 _rewardDecimal) public {\n baseDecimal = _baseDecimal;\n rewardDecimal = _rewardDecimal;\n underlyingToken = new MockERC20(\"UnderlyingToken\", \"UT\", baseDecimal);\n rewardToken = new MockERC20(\"RewardToken\", \"RT\", rewardDecimal);\n interestModel = new JumpRateModel(2343665, 1 * 10**baseDecimal, 1 * 10**baseDecimal, 4 * 10**baseDecimal, 0.8e18);\n ionicAdmin = new FeeDistributor();\n ionicAdmin.initialize(1 * 10**(baseDecimal - 2));\n poolDirectory = new PoolDirectory();\n poolDirectory.initialize(false, new address[](0));\n cErc20Delegate = new CErc20Delegate();\n // set the new delegate as the latest\n ionicAdmin._setLatestCErc20Delegate(cErc20Delegate.delegateType(), address(cErc20Delegate), abi.encode(address(0)));\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = new CTokenFirstExtension();\n cErc20DelegateExtensions[1] = cErc20Delegate;\n ionicAdmin._setCErc20DelegateExtensions(address(cErc20Delegate), cErc20DelegateExtensions);\n }\n\n function setUpPoolAndMarket() public {\n MockPriceOracle priceOracle = new MockPriceOracle(10);\n Comptroller tempComptroller = new Comptroller();\n ionicAdmin._setLatestComptrollerImplementation(address(0), address(tempComptroller));\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = new ComptrollerFirstExtension();\n extensions[1] = tempComptroller;\n ionicAdmin._setComptrollerExtensions(address(tempComptroller), extensions);\n (, address comptrollerAddress) = poolDirectory.deployPool(\n \"TestPool\",\n address(tempComptroller),\n abi.encode(payable(address(ionicAdmin))),\n false,\n 0.1e18,\n 1.1e18,\n address(priceOracle)\n );\n\n Unitroller(payable(comptrollerAddress))._acceptAdmin();\n comptroller = IonicComptroller(comptrollerAddress);\n\n AuthoritiesRegistry impl = new AuthoritiesRegistry();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(1), \"\");\n AuthoritiesRegistry newAr = AuthoritiesRegistry(address(proxy));\n newAr.initialize(address(321));\n ionicAdmin.reinitialize(newAr);\n PoolRolesAuthority poolAuth = newAr.createPoolAuthority(comptrollerAddress);\n newAr.setUserRole(comptrollerAddress, user, poolAuth.BORROWER_ROLE(), true);\n\n vm.roll(1);\n comptroller._deployMarket(\n cErc20Delegate.delegateType(),\n abi.encode(\n address(underlyingToken),\n comptroller,\n payable(address(ionicAdmin)),\n InterestRateModel(address(interestModel)),\n \"CUnderlyingToken\",\n \"CUT\",\n uint256(1),\n uint256(0)\n ),\n \"\",\n 0.9e18\n );\n\n ICErc20[] memory allMarkets = comptroller.getAllMarkets();\n cErc20 = allMarkets[allMarkets.length - 1];\n }\n\n function setUpFlywheel() public {\n IonicFlywheel impl = new IonicFlywheel();\n TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), address(dpa), \"\");\n flywheel = IonicFlywheel(address(proxy));\n flywheel.initialize(rewardToken, FlywheelStaticRewards(address(0)), IFlywheelBooster(address(0)), address(this));\n rewards = new FlywheelStaticRewards(IonicFlywheelCore(address(flywheel)), address(this), Authority(address(0)));\n flywheel.setFlywheelRewards(rewards);\n\n flywheelClaimer = new IonicFlywheelLensRouter(poolDirectory);\n\n flywheel.addStrategyForRewards(ERC20(address(cErc20)));\n\n // add flywheel as rewardsDistributor to call flywheelPreBorrowAction / flywheelPreSupplyAction\n require(comptroller._addRewardsDistributor(address(flywheel)) == 0);\n\n // seed rewards to flywheel\n rewardToken.mint(address(rewards), 100 * 10**rewardDecimal);\n\n // Start reward distribution at 1 token per second\n rewards.setRewardsInfo(\n ERC20(address(cErc20)),\n FlywheelStaticRewards.RewardsInfo({ rewardsPerSecond: uint224(1 * 10**rewardDecimal), rewardsEndTimestamp: 0 })\n );\n\n // preparation for a later call\n flywheelsToClaim.push(IonicFlywheelCore(address(flywheel)));\n }\n\n function _initialize(uint8 _baseDecimal, uint8 _rewardDecimal) internal {\n setUpBaseContracts(_baseDecimal, _rewardDecimal);\n setUpPoolAndMarket();\n setUpFlywheel();\n deposit(1 * 10**_baseDecimal);\n vm.warp(block.timestamp + 1);\n }\n\n function deposit(uint256 _amount) public {\n underlyingToken.mint(user, _amount);\n vm.startPrank(user);\n underlyingToken.approve(address(cErc20), _amount);\n comptroller.enterMarkets(markets);\n cErc20.mint(_amount);\n vm.stopPrank();\n }\n\n function _testIntegration() internal {\n uint256 percentFee = flywheel.performanceFee();\n uint224 percent100 = 100e16; //flywheel.ONE();\n\n // store expected rewards per token (1 token per second over total supply)\n uint256 rewardsPerTokenPlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerTokenForFee = (rewardsPerTokenPlusFee * percentFee) / percent100;\n uint256 rewardsPerToken = rewardsPerTokenPlusFee - rewardsPerTokenForFee;\n\n // store expected user rewards (user balance times reward per second over 1 token)\n uint256 userRewards = (rewardsPerToken * cErc20.balanceOf(user)) / (1 * 10**baseDecimal);\n\n ERC20 asErc20 = ERC20(address(cErc20));\n // accrue rewards and check against expected\n assertEq(flywheel.accrue(asErc20, user), userRewards, \"!accrue amount\");\n\n // check market index\n (uint224 index, ) = flywheel.strategyState(asErc20);\n assertEq(index, 10**rewardDecimal + rewardsPerToken, \"!index\");\n\n // claim and check user balance\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n assertEq(rewardToken.balanceOf(user), userRewards, \"!user rewards\");\n\n // mint more tokens by user and rerun test\n deposit(1 * 10**baseDecimal);\n\n // for next test, advance 10 seconds instead of 1 (multiply expectations by 10)\n vm.warp(block.timestamp + 10);\n\n uint256 rewardsPerToken2PlusFee = (1 * 10**rewardDecimal * 1 * 10**baseDecimal) / cErc20.totalSupply();\n uint256 rewardsPerToken2ForFee = (rewardsPerToken2PlusFee * percentFee) / percent100;\n uint256 rewardsPerToken2 = rewardsPerToken2PlusFee - rewardsPerToken2ForFee;\n\n uint256 userRewards2 = (10 * (rewardsPerToken2 * cErc20.balanceOf(user))) / (1 * 10**baseDecimal);\n\n // accrue all unclaimed rewards and claim them\n flywheelClaimer.claimRewardsForMarket(user, asErc20, flywheelsToClaim, asArray(true));\n\n emit log_named_uint(\"userRewards\", userRewards);\n emit log_named_uint(\"userRewards2\", userRewards2);\n // user balance should accumulate from both rewards\n assertEq(rewardToken.balanceOf(user), userRewards + userRewards2, \"balance mismatch\");\n }\n\n function testIntegrationRewardStandard(uint8 i, uint8 j) public {\n vm.assume(i > 1);\n vm.assume(j > 1);\n vm.assume(i < 19);\n vm.assume(j < 19);\n\n _initialize(i, j);\n _testIntegration();\n }\n}\n" + }, + "contracts/test/MaxBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./helpers/WithPool.sol\";\n\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { MockERC20 } from \"solmate/test/utils/mocks/MockERC20.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\nimport { PoolLensSecondary } from \"../PoolLensSecondary.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract MockAsset is MockERC20 {\n constructor() MockERC20(\"test\", \"test\", 8) {}\n\n function deposit() external payable {}\n}\n\ncontract MaxBorrowTest is WithPool {\n address usdcWhale = 0x625E7708f30cA75bfd92586e17077590C60eb4cD;\n address daiWhale = 0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B;\n\n struct LiquidationData {\n address[] cTokens;\n ICErc20[] allMarkets;\n MockAsset usdc;\n MockAsset dai;\n }\n\n function afterForkSetUp() internal override {\n super.setUpWithPool(\n MasterPriceOracle(ap.getAddress(\"MasterPriceOracle\")),\n ERC20Upgradeable(ap.getAddress(\"wtoken\"))\n );\n\n if (block.chainid == POLYGON_MAINNET) {\n vm.prank(0x369582d2010B6eD950B571F4101e3bB9b554876F); // SAND/WMATIC\n MockERC20(address(underlyingToken)).transfer(address(this), 100e18);\n setUpPool(\"polygon-test\", false, 0.1e18, 1.1e18);\n } else if (block.chainid == BSC_MAINNET) {\n deal(address(underlyingToken), address(this), 100e18);\n setUpPool(\"bsc-test\", false, 0.1e18, 1.1e18);\n }\n }\n\n // TODO redeploy to polygon to fix\n function testMaxBorrow() public fork(POLYGON_MAINNET) {\n PoolLensSecondary poolLensSecondary = new PoolLensSecondary();\n poolLensSecondary.initialize(poolDirectory);\n\n LiquidationData memory vars;\n vm.roll(1);\n vars.usdc = MockAsset(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n vars.dai = MockAsset(0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063);\n\n deployCErc20Delegate(address(vars.usdc), \"USDC\", \"usdc\", 0.9e18);\n deployCErc20Delegate(address(vars.dai), \"DAI\", \"dai\", 0.9e18);\n\n vars.allMarkets = comptroller.getAllMarkets();\n\n CErc20Delegate cToken = CErc20Delegate(address(vars.allMarkets[0]));\n\n CErc20Delegate cDaiToken = CErc20Delegate(address(vars.allMarkets[1]));\n\n vars.cTokens = new address[](1);\n\n address accountOne = address(1);\n PoolRolesAuthority pra = ionicAdmin.authoritiesRegistry().poolsAuthorities(address(comptroller));\n\n vm.startPrank(pra.owner());\n pra.setUserRole(accountOne, pra.BORROWER_ROLE(), true);\n vm.stopPrank();\n\n vm.prank(usdcWhale);\n MockERC20(address(vars.usdc)).transfer(accountOne, 10000e6);\n\n vm.prank(daiWhale);\n MockERC20(address(vars.dai)).transfer(accountOne, 10000e18);\n\n // Account One Supply\n {\n emit log(\"Account One Supply\");\n vm.startPrank(accountOne);\n vars.usdc.approve(address(cToken), 1e36);\n cToken.mint(1e6);\n vars.cTokens[0] = address(cToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vars.dai.approve(address(cDaiToken), 1e36);\n cDaiToken.mint(1e18);\n vars.cTokens[0] = address(cDaiToken);\n comptroller.enterMarkets(vars.cTokens);\n\n vm.stopPrank();\n assertEq(cToken.totalSupply(), 1e6 * 5);\n assertEq(cDaiToken.totalSupply(), 1e18 * 5);\n\n uint256 maxBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n uint256 maxDaiBorrow = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cDaiToken)));\n assertApproxEqAbs((maxBorrow * 1e18) / 10**cToken.decimals(), maxDaiBorrow, uint256(1e16), \"!max borrow\");\n }\n\n // borrow cap for collateral test\n {\n vm.prank(comptroller.admin());\n comptroller._setBorrowCapForCollateral(address(cToken), address(cDaiToken), 0.5e6);\n }\n\n uint256 maxBorrowAfterBorrowCap = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertApproxEqAbs(maxBorrowAfterBorrowCap, 0.5e6, uint256(1e5), \"!max borrow\");\n\n // blacklist\n {\n vm.prank(comptroller.admin());\n comptroller._blacklistBorrowingAgainstCollateral(address(cToken), address(cDaiToken), true);\n }\n\n uint256 maxBorrowAfterBlacklist = poolLensSecondary.getMaxBorrow(accountOne, ICErc20(address(cToken)));\n assertEq(maxBorrowAfterBlacklist, 0, \"!blacklist\");\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapPerCollateral() public debuggingOnly forkAtBlock(BSC_MAINNET, 23761190) {\n address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);\n\n address poolAddress = jFiatPoolAddress;\n Comptroller pool = Comptroller(poolAddress);\n\n ComptrollerFirstExtension asExtension = ComptrollerFirstExtension(poolAddress);\n address[] memory borrowers = asExtension.getAllBorrowers();\n address someBorrower = borrowers[1];\n\n ICErc20[] memory markets = asExtension.getAllMarkets();\n for (uint256 i = 0; i < markets.length; i++) {\n ICErc20 market = markets[i];\n uint256 borrowed = market.borrowBalanceCurrent(someBorrower);\n if (borrowed > 0) {\n emit log(\"borrower has borrowed\");\n emit log_uint(borrowed);\n emit log(\"from market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n\n uint256 collateral = market.balanceOf(someBorrower);\n if (collateral > 0) {\n emit log(\"has collateral\");\n emit log_uint(collateral);\n emit log(\"in market\");\n emit log_address(address(market));\n emit log_uint(i);\n emit log(\"\");\n }\n }\n\n ICErc20 marketToBorrow = markets[0];\n ICErc20 cappedCollateralMarket = markets[6];\n uint256 borrowAmount = marketToBorrow.borrowBalanceCurrent(someBorrower);\n\n {\n (uint256 errBefore, , uint256 liquidityBefore, uint256 shortfallBefore) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errBefore\");\n emit log_uint(errBefore);\n emit log(\"liquidityBefore\");\n emit log_uint(liquidityBefore);\n emit log(\"shortfallBefore\");\n emit log_uint(shortfallBefore);\n\n assertGt(liquidityBefore, 0, \"expected positive liquidity\");\n }\n\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(marketToBorrow), address(cappedCollateralMarket), 1);\n emit log(\"\");\n\n (uint256 errAfter, , uint256 liquidityAfter, uint256 shortfallAfter) = pool.getHypotheticalAccountLiquidity(\n someBorrower,\n address(marketToBorrow),\n 0,\n borrowAmount,\n 0\n );\n emit log(\"errAfter\");\n emit log_uint(errAfter);\n emit log(\"liquidityAfter\");\n emit log_uint(liquidityAfter);\n emit log(\"shortfallAfter\");\n emit log_uint(shortfallAfter);\n\n assertGt(shortfallAfter, 0, \"expected some shortfall\");\n }\n}\n" + }, + "contracts/test/MinBorrowTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { MasterPriceOracle } from \"../oracles/MasterPriceOracle.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\ncontract MinBorrowTest is BaseTest {\n FeeDistributor ffd;\n\n function afterForkSetUp() internal override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n }\n\n function testMinBorrow() public fork(BSC_MAINNET) {\n IERC20Upgradeable usdc = IERC20Upgradeable(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d);\n IERC20Upgradeable busd = IERC20Upgradeable(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);\n\n ICErc20 usdcMarket = ICErc20(0x16B8da195CdC7F380B333bf6cF2f0f33c1061755);\n ICErc20 busdMarket = ICErc20(0x3BCb7dbBe729B24bE6c660B3e8ADD1Cb352e371D);\n IonicComptroller comptroller = usdcMarket.comptroller();\n deal(address(usdc), address(this), 10000e18);\n deal(address(busd), address(1), 10000e18);\n\n usdc.approve(address(usdcMarket), 1e36);\n usdcMarket.mint(1000e18);\n\n vm.startPrank(address(1));\n busd.approve(address(busdMarket), 1e36);\n busdMarket.mint(1000e18);\n vm.stopPrank();\n\n // the 0 liquidity base min borrow amount\n uint256 baseMinBorrowEth = ffd.minBorrowEth();\n\n address[] memory cTokens = new address[](2);\n cTokens[0] = address(usdcMarket);\n cTokens[1] = address(busdMarket);\n comptroller.enterMarkets(cTokens);\n\n uint256 minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, baseMinBorrowEth, \"!minBorrowEth for default min borrow eth\");\n\n busdMarket.borrow(300e18);\n\n minBorrowEth = ffd.getMinBorrowEth(busdMarket);\n assertEq(minBorrowEth, 0, \"!minBorrowEth after borrowing less amount than min amount\");\n }\n}\n" + }, + "contracts/test/OracleProtectedTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol\";\n\nimport { UpgradesBaseTest } from \"./UpgradesBaseTest.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { CTokenFirstExtension, DiamondExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { InterestRateModel } from \"../compound/InterestRateModel.sol\";\nimport { IHypernativeOracle } from \"../external/hypernative/interfaces/IHypernativeOracle.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\ncontract MockOraclePasses is IHypernativeOracle {\n function register(address account, bool isStrictMode) external pure {}\n\n function validateForbiddenAccountInteraction(address sender) external pure {}\n\n function validateForbiddenContextInteraction(address origin, address sender) external pure {}\n\n function validateBlacklistedAccountInteraction(address sender) external pure {}\n}\n\ncontract MockOracleFails is IHypernativeOracle {\n error InteractionNotAllowed();\n function register(address account, bool isStrictMode) external pure {}\n\n function validateForbiddenAccountInteraction(address sender) external pure {\n revert InteractionNotAllowed();\n }\n\n function validateForbiddenContextInteraction(address origin, address sender) external pure {\n revert InteractionNotAllowed(); \n }\n\n function validateBlacklistedAccountInteraction(address sender) external pure {\n revert InteractionNotAllowed();\n }\n}\n\ncontract OracleProtectedTest is UpgradesBaseTest {\n error InteractionNotAllowed();\n ICErc20 market = ICErc20(0x49420311B518f3d0c94e897592014de53831cfA3);\n address admin = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;\n IHypernativeOracle oraclePasses;\n IHypernativeOracle oracleFails;\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n _upgradeMarketWithExtension(market);\n oraclePasses = new MockOraclePasses();\n oracleFails = new MockOracleFails();\n }\n\n function test_mint_failsForBlacklisted() public debuggingOnly forkAtBlock(BASE_MAINNET, 20538729) {\n CTokenFirstExtension asExt = CTokenFirstExtension(address(market)); \n // Set up the oracle\n vm.startPrank(admin);\n ap.setAddress(\"HYPERNATIVE_ORACLE\", address(oracleFails));\n vm.stopPrank();\n \n // Try to mint\n address user = address(0x1234);\n uint256 mintAmount = 1e18;\n deal(asExt.underlying(), user, mintAmount);\n \n vm.startPrank(user);\n ICErc20(asExt.underlying()).approve(address(asExt), mintAmount);\n \n vm.expectRevert(InteractionNotAllowed.selector);\n market.mint(mintAmount);\n vm.stopPrank();\n\n // Set up the oracle to pass\n vm.prank(admin);\n ap.setAddress(\"HYPERNATIVE_ORACLE\", address(oraclePasses));\n\n vm.startPrank(user);\n market.mint(mintAmount);\n vm.stopPrank();\n\n // check balances\n assertGt(market.balanceOf(user), 0);\n }\n}\n" + }, + "contracts/test/PermissionedLiquidationsMarketTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport { MarketsTest } from \"./config/MarketsTest.t.sol\";\n\nimport { DiamondExtension, DiamondBase } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { PoolDirectory } from \"../PoolDirectory.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { ComptrollerV3Storage } from \"../compound/ComptrollerStorage.sol\";\nimport { IonicComptroller } from \"../compound/ComptrollerInterface.sol\";\nimport { ILiquidator } from \"../ILiquidator.sol\";\n\nimport { IERC20Upgradeable } from \"openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport { PoolLens } from \"../PoolLens.sol\";\nimport { AddressesProvider } from \"../ionic/AddressesProvider.sol\";\nimport { IonicUniV3Liquidator } from \"../IonicUniV3Liquidator.sol\";\nimport { ERC20 } from \"solmate/tokens/ERC20.sol\";\nimport { IRedemptionStrategy } from \"../liquidators/IRedemptionStrategy.sol\";\nimport { IFundsConversionStrategy } from \"../liquidators/IFundsConversionStrategy.sol\";\n\ncontract PermissionedLiquidationsMarketTest is MarketsTest {\n ICErc20 wethMarket;\n ICErc20 usdtMarket;\n\n ICErc20 wethNativeMarket;\n ICErc20 usdcNativeMarket;\n ICErc20 usdtNativeMarket;\n ICErc20 modeNativeMarket;\n\n IonicComptroller pool;\n PoolLens lens;\n address borrower;\n address liquidator;\n IonicUniV3Liquidator uniV3liquidator;\n\n function afterForkSetUp() internal virtual override {\n super.afterForkSetUp();\n\n wethMarket = ICErc20(0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2);\n usdtMarket = ICErc20(0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3);\n\n wethNativeMarket = ICErc20(0xDb8eE6D1114021A94A045956BBeeCF35d13a30F2);\n usdcNativeMarket = ICErc20(0xc53edEafb6D502DAEC5A7015D67936CEa0cD0F52);\n usdtNativeMarket = ICErc20(0x3120B4907851cc9D780eef9aF88ae4d5360175Fd);\n modeNativeMarket = ICErc20(0x4341620757Bee7EB4553912FaFC963e59C949147);\n\n pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);\n lens = PoolLens(0x70BB19a56BfAEc65aE861E6275A90163AbDF36a6);\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n borrower = 0xcE6cEFa163468F730206688665516952bcf83B74;\n liquidator = 0xE000008459b74a91e306a47C808061DFA372000E;\n uniV3liquidator = IonicUniV3Liquidator(payable(ap.getAddress(\"IonicUniV3Liquidator\")));\n\n vm.prank(ap.owner());\n ap.setAddress(\"PoolLens\", address(lens));\n }\n\n function testLiquidateNoThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateThresholdActive() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n vm.expectRevert(\"Health factor not low enough for non-permissioned liquidations\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n vm.stopPrank();\n }\n\n function testLiquidateHealthFactorLowerThanThreshold() public debuggingOnly forkAtBlock(MODE_MAINNET, 10455052) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(usdtMarket.ionicAdmin());\n CTokenFirstExtension(address(usdtMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n // fast forward until position unhealthy enough\n vm.roll(block.number + 10000000);\n\n address targetContract = 0x927ae5509688eA6B992ba41Ecd1d49a6e7d69109;\n bytes\n memory data = hex\"a9059cbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000002dd0b94812f2eea03a49869f95e1b5868c6f3206ee3d3002417bfdfbc000000000000000000000000ce6cefa163468f730206688665516952bcf83b740001000000000000000000000000000000000000000000000000000000006d3171ea02000000000000000000000000000000000000000000000000000000003698b8f5f0f161fda2712db8b566946122a5af183995e2ed02b702ce183b4e1faa574834715e5d4a6378d0eed3092be717340023c9e14c1bb12cb3ecbcfd3c3fb038000004a6afed9507f0f161fda2712db8b566946122a5af183995e2ed06000000000000000000000000000000000000000000000000000000003698b8f50109f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000000000000009f0f161fda2712db8b566946122a5af183995e2ed000044095ea7b300000000000000000000000094812f2eea03a49869f95e1b5868c6f3206ee3d3000000000000000000000000000000000000000000000000000000003698b8f50a94812f2eea03a49869f95e1b5868c6f3206ee3d3000024f5e3c462000000000000000000000000ce6cefa163468f730206688665516952bcf83b74002000000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d20771ef7eda2be775e5a7aa8afd02c45f059833e9d20a71ef7eda2be775e5a7aa8afd02c45f059833e9d2000004db006a7500000742000000000000000000000000000000000000060100468cc91df6f669cae6cdce766995bd7874052fbc0000000000000000000000000000000000000000000000000000000000000000010107d988097fb8612cc24eec14542bc03424c656005f0100ee8291dd97611a064a7db0e8c9252d851674e20100000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000009a07f0f161fda2712db8b566946122a5af183995e2ed0100a1c6800788482ba0eeb85f47322bb789986ee2f30000000000000000000000000000000000000000000000000000000000000000000107d988097fb8612cc24eec14542bc03424c656005f0100468cc91df6f669cae6cdce766995bd7874052fbc00000000000000000000000000000000000000000000000000000000000000000001000000000000\";\n\n vm.startPrank(liquidator);\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPythShouldRevert() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testLiquidateFromPyth() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n vm.prank(uniV3liquidator.owner());\n uniV3liquidator.setHealthFactorThreshold(.98 * 1e18);\n\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n emit log_named_uint(\"hf\", lens.getHealthFactor(0x0Ff7F5043DD39186c2DF04F81cfa95672B8A3994, pool));\n\n address targetContract = 0xa12c1E460c06B1745EFcbfC9A1f666a8749B0e3A;\n bytes\n memory data = hex\"55e9e8fe00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000ff7f5043dd39186c2df04f81cfa95672b8a39940000000000000000000000000000000000000000000000000002fb8c3841c79600000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d200000000000000000000000071ef7eda2be775e5a7aa8afd02c45f059833e9d2000000000000000000000000468cc91df6f669cae6cdce766995bd7874052fbc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";\n\n vm.mockCall(\n address(uniV3liquidator.expressRelay()),\n abi.encodeWithSelector(\n bytes4(keccak256(\"isPermissioned(address,bytes)\")),\n address(uniV3liquidator),\n abi.encode(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6)\n ),\n abi.encode(false)\n );\n\n vm.startPrank(0x1110DECC92083fbcae218a8478F75B2Ad1b9AEe6);\n vm.expectRevert(\"invalid liquidation\");\n (bool success, bytes memory returnData) = targetContract.call(data);\n require(success, \"Transaction failed\");\n vm.stopPrank();\n }\n\n function testPostUpgradeLiquidate() public debuggingOnly fork(MODE_MAINNET) {\n address borrower = 0xE10B38bbe359656066b3c4648DfEa7018711c35f;\n PoolLens.PoolAsset[] memory assets = lens.getPoolAssetsByUser(pool, borrower);\n\n for (uint i; i < assets.length; i++) {\n emit log_named_string(\"Asset Named\", assets[i].underlyingName);\n emit log_named_uint(\"Supply Balance\", assets[i].supplyBalance);\n emit log_named_uint(\"Borrow Balance\", assets[i].borrowBalance);\n emit log_named_uint(\"Liquidity\", assets[i].liquidity);\n emit log(\"----------------------------------------------------\");\n }\n\n emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n\n // vm.startPrank(0x344d9C4f488bb5519D390304457D64034618145C);\n\n // ERC20(0xd988097fb8612cc24eeC14542bC03424c656005f).approve(address(uniV3liquidator), 4000);\n\n // // ILiquidator.LiquidateToTokensWithFlashSwapVars memory vars = ILiquidator.LiquidateToTokensWithFlashSwapVars({\n // // borrower: borrower,\n // // repayAmount: 4000,\n // // cErc20: ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038),\n // // cTokenCollateral: wethMarket,\n // // flashSwapContract: 0x468cC91dF6F669CaE6cdCE766995Bd7874052FBc,\n // // minProfitAmount: 0,\n // // redemptionStrategies: new IRedemptionStrategy[](0),\n // // strategyData: new bytes[](0),\n // // debtFundingStrategies: new IFundsConversionStrategy[](0),\n // // debtFundingStrategiesData: new bytes[](0)\n // // });\n // // uniV3liquidator.safeLiquidateToTokensWithFlashLoan(vars);\n\n // uniV3liquidator.safeLiquidate(borrower, 4000, ICErc20(0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038), wethMarket, 0);\n\n // vm.stopPrank();\n\n // emit log_named_uint(\"HF\", lens.getHealthFactor(borrower, pool));\n }\n\n function testUpgradeNativeMarket() public debuggingOnly fork(MODE_MAINNET) {\n _upgradeMarket(wethNativeMarket);\n _upgradeMarket(usdcNativeMarket);\n _upgradeMarket(usdtNativeMarket);\n _upgradeMarket(modeNativeMarket);\n _upgradeMarket(wethMarket);\n _upgradeMarket(usdtMarket);\n }\n\n struct CErc20StorageStruct {\n address ionicAdmin;\n string name;\n string symbol;\n uint8 decimals;\n address comptroller;\n address interestRateModel;\n uint256 adminFeeMantissa;\n uint256 ionicFeeMantissa;\n uint256 reserveFactorMantissa;\n uint256 accrualBlockNumber;\n uint256 borrowIndex;\n uint256 totalBorrows;\n uint256 totalReserves;\n uint256 totalAdminFees;\n uint256 totalIonicFees;\n uint256 totalSupply;\n uint256 protocolSeizeShareMantissa;\n uint256 feeSeizeShareMantissa;\n address underlying;\n address ap;\n uint256 cash;\n uint256 totalBorrowsCurrent;\n uint256 balanceOfUnderlying;\n uint256 borrowBalanceCurrent;\n uint256 supplyRatePerBlock;\n uint256 borrowRatePerBlock;\n uint256 exchangeRateCurrent;\n uint256 totalUnderlyingSupplied;\n uint256 allowance;\n uint256 balanceOf;\n }\n\n function testStorageLayoutSafe() public debuggingOnly forkAtBlock(MODE_MAINNET, 10352583) {\n // Capture storage layout before upgrade\n CErc20StorageStruct memory storageDataBefore;\n CErc20StorageStruct memory storageDataAfter;\n\n address owner = 0xbF86588d7e20502f1b250561da775343Dfdb3250; // Use a valid spender address as needed\n\n storageDataBefore.ionicAdmin = wethMarket.ionicAdmin();\n storageDataBefore.name = wethMarket.name();\n storageDataBefore.symbol = wethMarket.symbol();\n storageDataBefore.decimals = wethMarket.decimals();\n storageDataBefore.comptroller = address(wethMarket.comptroller());\n storageDataBefore.interestRateModel = address(wethMarket.interestRateModel());\n storageDataBefore.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataBefore.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataBefore.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataBefore.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataBefore.borrowIndex = wethMarket.borrowIndex();\n storageDataBefore.totalBorrows = wethMarket.totalBorrows();\n storageDataBefore.totalReserves = wethMarket.totalReserves();\n storageDataBefore.totalAdminFees = wethMarket.totalAdminFees();\n storageDataBefore.totalIonicFees = wethMarket.totalIonicFees();\n storageDataBefore.totalSupply = wethMarket.totalSupply();\n storageDataBefore.underlying = wethMarket.underlying();\n storageDataBefore.cash = wethMarket.getCash();\n storageDataBefore.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataBefore.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataBefore.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataBefore.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataBefore.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataBefore.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataBefore.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataBefore.balanceOf = wethMarket.balanceOf(owner);\n storageDataBefore.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataBefore.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n // Upgrade the market\n _upgradeMarket(wethMarket);\n\n vm.prank(wethMarket.ionicAdmin());\n CTokenFirstExtension(address(wethMarket))._setAddressesProvider(0xb0033576a9E444Dd801d5B69e1b63DBC459A6115);\n\n storageDataAfter.ionicAdmin = wethMarket.ionicAdmin();\n storageDataAfter.name = wethMarket.name();\n storageDataAfter.symbol = wethMarket.symbol();\n storageDataAfter.decimals = wethMarket.decimals();\n storageDataAfter.comptroller = address(wethMarket.comptroller());\n storageDataAfter.interestRateModel = address(wethMarket.interestRateModel());\n storageDataAfter.adminFeeMantissa = wethMarket.adminFeeMantissa();\n storageDataAfter.ionicFeeMantissa = wethMarket.ionicFeeMantissa();\n storageDataAfter.reserveFactorMantissa = wethMarket.reserveFactorMantissa();\n storageDataAfter.accrualBlockNumber = wethMarket.accrualBlockNumber();\n storageDataAfter.borrowIndex = wethMarket.borrowIndex();\n storageDataAfter.totalBorrows = wethMarket.totalBorrows();\n storageDataAfter.totalReserves = wethMarket.totalReserves();\n storageDataAfter.totalAdminFees = wethMarket.totalAdminFees();\n storageDataAfter.totalIonicFees = wethMarket.totalIonicFees();\n storageDataAfter.totalSupply = wethMarket.totalSupply();\n storageDataAfter.underlying = wethMarket.underlying();\n storageDataAfter.cash = wethMarket.getCash();\n storageDataAfter.totalBorrowsCurrent = wethMarket.totalBorrowsCurrent();\n storageDataAfter.balanceOfUnderlying = wethMarket.balanceOfUnderlying(owner);\n storageDataAfter.borrowBalanceCurrent = wethMarket.borrowBalanceCurrent(owner);\n storageDataAfter.supplyRatePerBlock = wethMarket.supplyRatePerBlock();\n storageDataAfter.borrowRatePerBlock = wethMarket.borrowRatePerBlock();\n storageDataAfter.exchangeRateCurrent = wethMarket.exchangeRateCurrent();\n storageDataAfter.totalUnderlyingSupplied = wethMarket.getTotalUnderlyingSupplied();\n storageDataAfter.balanceOf = wethMarket.balanceOf(owner);\n storageDataAfter.protocolSeizeShareMantissa = wethMarket.protocolSeizeShareMantissa();\n storageDataAfter.feeSeizeShareMantissa = wethMarket.feeSeizeShareMantissa();\n\n emit log_named_address(\"Storage ionicAdmin (before)\", storageDataBefore.ionicAdmin);\n emit log_named_address(\"Storage ionicAdmin (after)\", storageDataAfter.ionicAdmin);\n\n emit log_named_string(\"Storage name (before)\", storageDataBefore.name);\n emit log_named_string(\"Storage name (after)\", storageDataAfter.name);\n\n emit log_named_string(\"Storage symbol (before)\", storageDataBefore.symbol);\n emit log_named_string(\"Storage symbol (after)\", storageDataAfter.symbol);\n\n emit log_named_uint(\"Storage decimals (before)\", storageDataBefore.decimals);\n emit log_named_uint(\"Storage decimals (after)\", storageDataAfter.decimals);\n\n emit log_named_address(\"Storage comptroller (before)\", storageDataBefore.comptroller);\n emit log_named_address(\"Storage comptroller (after)\", storageDataAfter.comptroller);\n\n emit log_named_address(\"Storage interestRateModel (before)\", storageDataBefore.interestRateModel);\n emit log_named_address(\"Storage interestRateModel (after)\", storageDataAfter.interestRateModel);\n\n emit log_named_uint(\"Storage adminFeeMantissa (before)\", storageDataBefore.adminFeeMantissa);\n emit log_named_uint(\"Storage adminFeeMantissa (after)\", storageDataAfter.adminFeeMantissa);\n\n emit log_named_uint(\"Storage ionicFeeMantissa (before)\", storageDataBefore.ionicFeeMantissa);\n emit log_named_uint(\"Storage ionicFeeMantissa (after)\", storageDataAfter.ionicFeeMantissa);\n\n emit log_named_uint(\"Storage reserveFactorMantissa (before)\", storageDataBefore.reserveFactorMantissa);\n emit log_named_uint(\"Storage reserveFactorMantissa (after)\", storageDataAfter.reserveFactorMantissa);\n\n emit log_named_uint(\"Storage accrualBlockNumber (before)\", storageDataBefore.accrualBlockNumber);\n emit log_named_uint(\"Storage accrualBlockNumber (after)\", storageDataAfter.accrualBlockNumber);\n\n emit log_named_uint(\"Storage borrowIndex (before)\", storageDataBefore.borrowIndex);\n emit log_named_uint(\"Storage borrowIndex (after)\", storageDataAfter.borrowIndex);\n\n emit log_named_uint(\"Storage totalBorrows (before)\", storageDataBefore.totalBorrows);\n emit log_named_uint(\"Storage totalBorrows (after)\", storageDataAfter.totalBorrows);\n\n emit log_named_uint(\"Storage totalReserves (before)\", storageDataBefore.totalReserves);\n emit log_named_uint(\"Storage totalReserves (after)\", storageDataAfter.totalReserves);\n\n emit log_named_uint(\"Storage totalAdminFees (before)\", storageDataBefore.totalAdminFees);\n emit log_named_uint(\"Storage totalAdminFees (after)\", storageDataAfter.totalAdminFees);\n\n emit log_named_uint(\"Storage totalIonicFees (before)\", storageDataBefore.totalIonicFees);\n emit log_named_uint(\"Storage totalIonicFees (after)\", storageDataAfter.totalIonicFees);\n\n emit log_named_uint(\"Storage totalSupply (before)\", storageDataBefore.totalSupply);\n emit log_named_uint(\"Storage totalSupply (after)\", storageDataAfter.totalSupply);\n\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (before)\", storageDataBefore.protocolSeizeShareMantissa);\n emit log_named_uint(\"Storage protocolSeizeShareMantissa (after)\", storageDataAfter.protocolSeizeShareMantissa);\n\n emit log_named_uint(\"Storage feeSeizeShareMantissa (before)\", storageDataBefore.feeSeizeShareMantissa);\n emit log_named_uint(\"Storage feeSeizeShareMantissa (after)\", storageDataAfter.feeSeizeShareMantissa);\n\n emit log_named_address(\"Storage underlying (before)\", storageDataBefore.underlying);\n emit log_named_address(\"Storage underlying (after)\", storageDataAfter.underlying);\n\n emit log_named_uint(\"Storage cash (before)\", storageDataBefore.cash);\n emit log_named_uint(\"Storage cash (after)\", storageDataAfter.cash);\n\n emit log_named_uint(\"Storage totalBorrowsCurrent (before)\", storageDataBefore.totalBorrowsCurrent);\n emit log_named_uint(\"Storage totalBorrowsCurrent (after)\", storageDataAfter.totalBorrowsCurrent);\n\n emit log_named_uint(\"Storage balanceOfUnderlying (before)\", storageDataBefore.balanceOfUnderlying);\n emit log_named_uint(\"Storage balanceOfUnderlying (after)\", storageDataAfter.balanceOfUnderlying);\n\n emit log_named_uint(\"Storage borrowBalanceCurrent (before)\", storageDataBefore.borrowBalanceCurrent);\n emit log_named_uint(\"Storage borrowBalanceCurrent (after)\", storageDataAfter.borrowBalanceCurrent);\n\n emit log_named_uint(\"Storage supplyRatePerBlock (before)\", storageDataBefore.supplyRatePerBlock);\n emit log_named_uint(\"Storage supplyRatePerBlock (after)\", storageDataAfter.supplyRatePerBlock);\n\n emit log_named_uint(\"Storage borrowRatePerBlock (before)\", storageDataBefore.borrowRatePerBlock);\n emit log_named_uint(\"Storage borrowRatePerBlock (after)\", storageDataAfter.borrowRatePerBlock);\n\n emit log_named_uint(\"Storage exchangeRateCurrent (before)\", storageDataBefore.exchangeRateCurrent);\n emit log_named_uint(\"Storage exchangeRateCurrent (after)\", storageDataAfter.exchangeRateCurrent);\n\n emit log_named_uint(\"Storage totalUnderlyingSupplied (before)\", storageDataBefore.totalUnderlyingSupplied);\n emit log_named_uint(\"Storage totalUnderlyingSupplied (after)\", storageDataAfter.totalUnderlyingSupplied);\n\n emit log_named_uint(\"Storage allowance (before)\", storageDataBefore.allowance);\n emit log_named_uint(\"Storage allowance (after)\", storageDataAfter.allowance);\n\n emit log_named_uint(\"Storage balanceOf (before)\", storageDataBefore.balanceOf);\n emit log_named_uint(\"Storage balanceOf (after)\", storageDataAfter.balanceOf);\n\n emit log_named_address(\"Storage ap (before)\", storageDataBefore.ap);\n emit log_named_address(\"Storage ap (after)\", storageDataAfter.ap);\n\n assertEq(storageDataBefore.ionicAdmin, storageDataAfter.ionicAdmin, \"Mismatch in ionicAdmin\");\n assertEq(storageDataBefore.name, storageDataAfter.name, \"Mismatch in name\");\n assertEq(storageDataBefore.symbol, storageDataAfter.symbol, \"Mismatch in symbol\");\n assertEq(storageDataBefore.decimals, storageDataAfter.decimals, \"Mismatch in decimals\");\n assertEq(storageDataBefore.comptroller, storageDataAfter.comptroller, \"Mismatch in comptroller\");\n assertEq(storageDataBefore.interestRateModel, storageDataAfter.interestRateModel, \"Mismatch in interestRateModel\");\n assertEq(storageDataBefore.adminFeeMantissa, storageDataAfter.adminFeeMantissa, \"Mismatch in adminFeeMantissa\");\n assertEq(storageDataBefore.ionicFeeMantissa, storageDataAfter.ionicFeeMantissa, \"Mismatch in ionicFeeMantissa\");\n assertEq(\n storageDataBefore.reserveFactorMantissa,\n storageDataAfter.reserveFactorMantissa,\n \"Mismatch in reserveFactorMantissa\"\n );\n assertEq(\n storageDataBefore.accrualBlockNumber,\n storageDataAfter.accrualBlockNumber,\n \"Mismatch in accrualBlockNumber\"\n );\n assertEq(storageDataBefore.borrowIndex, storageDataAfter.borrowIndex, \"Mismatch in borrowIndex\");\n assertEq(storageDataBefore.totalBorrows, storageDataAfter.totalBorrows, \"Mismatch in totalBorrows\");\n assertEq(storageDataBefore.totalReserves, storageDataAfter.totalReserves, \"Mismatch in totalReserves\");\n assertEq(storageDataBefore.totalAdminFees, storageDataAfter.totalAdminFees, \"Mismatch in totalAdminFees\");\n assertEq(storageDataBefore.totalIonicFees, storageDataAfter.totalIonicFees, \"Mismatch in totalIonicFees\");\n assertEq(storageDataBefore.totalSupply, storageDataAfter.totalSupply, \"Mismatch in totalSupply\");\n assertEq(storageDataBefore.underlying, storageDataAfter.underlying, \"Mismatch in underlying\");\n assertEq(storageDataBefore.cash, storageDataAfter.cash, \"Mismatch in cash\");\n assertEq(\n storageDataBefore.totalBorrowsCurrent,\n storageDataAfter.totalBorrowsCurrent,\n \"Mismatch in totalBorrowsCurrent\"\n );\n assertEq(\n storageDataBefore.balanceOfUnderlying,\n storageDataAfter.balanceOfUnderlying,\n \"Mismatch in balanceOfUnderlying\"\n );\n assertEq(\n storageDataBefore.borrowBalanceCurrent,\n storageDataAfter.borrowBalanceCurrent,\n \"Mismatch in borrowBalanceCurrent\"\n );\n assertEq(\n storageDataBefore.supplyRatePerBlock,\n storageDataAfter.supplyRatePerBlock,\n \"Mismatch in supplyRatePerBlock\"\n );\n assertEq(\n storageDataBefore.borrowRatePerBlock,\n storageDataAfter.borrowRatePerBlock,\n \"Mismatch in borrowRatePerBlock\"\n );\n assertEq(\n storageDataBefore.exchangeRateCurrent,\n storageDataAfter.exchangeRateCurrent,\n \"Mismatch in exchangeRateCurrent\"\n );\n assertEq(\n storageDataBefore.totalUnderlyingSupplied,\n storageDataAfter.totalUnderlyingSupplied,\n \"Mismatch in totalUnderlyingSupplied\"\n );\n assertEq(storageDataBefore.balanceOf, storageDataAfter.balanceOf, \"Mismatch in balanceOf\");\n assertEq(\n storageDataBefore.protocolSeizeShareMantissa,\n storageDataAfter.protocolSeizeShareMantissa,\n \"Mismatch in protocolSeizeShareMantissa\"\n );\n assertEq(\n storageDataBefore.feeSeizeShareMantissa,\n storageDataAfter.feeSeizeShareMantissa,\n \"Mismatch in feeSeizeShareMantissa\"\n );\n }\n\n function testCurrentMarkets() public debuggingOnly forkAtBlock(MODE_MAINNET, 10785800) {\n address[] memory ionAddresses = new address[](10);\n\n _upgradeMarket(wethMarket);\n\n ionAddresses[0] = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;\n ionAddresses[1] = 0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038;\n ionAddresses[2] = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;\n ionAddresses[3] = 0xd70254C3baD29504789714A7c69d60Ec1127375C;\n ionAddresses[4] = 0x59e710215d45F584f44c0FEe83DA6d43D762D857;\n ionAddresses[5] = 0x959FA710CCBb22c7Ce1e59Da82A247e686629310;\n ionAddresses[6] = 0x49950319aBE7CE5c3A6C90698381b45989C99b46;\n ionAddresses[7] = 0xA0D844742B4abbbc43d8931a6Edb00C56325aA18;\n ionAddresses[8] = 0x9a9072302B775FfBd3Db79a7766E75Cf82bcaC0A;\n ionAddresses[9] = 0x19F245782b1258cf3e11Eda25784A378cC18c108;\n\n address ap;\n for (uint i = 0; i < ionAddresses.length; i++) {\n // ap = address(CTokenFirstExtension(ionAddresses[i]).ap());\n ap = address(CTokenFirstExtension(address(wethMarket)).ap());\n emit log_named_address(\"ap\", ap);\n }\n }\n}\n" + }, + "contracts/test/PoolCapsAndBlacklistsTest.t.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >=0.8.0;\n\nimport \"./config/MarketsTest.t.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\ncontract PoolCapsAndBlacklistsTest is MarketsTest {\n Comptroller pool;\n ComptrollerFirstExtension asExtension;\n address borrower = 0x28C0208b7144B511C73586Bb07dE2100495e92f3; // ANKR account\n address otherSupplier = 0x2924973E3366690eA7aE3FCdcb2b4e136Cf7f8Cc; // Supplier of ankrBNBAnkrMkt\n ICErc20 ankrBNBAnkrMkt = ICErc20(0x71693C84486B37096192c9942852f542543639Bf);\n ICErc20 ankrBNBMkt = ICErc20(0xb2b01D6f953A28ba6C8f9E22986f5bDDb7653aEa);\n\n function afterForkSetUp() internal override {\n super.afterForkSetUp();\n\n // ankr pool\n pool = Comptroller(payable(0x1851e32F34565cb95754310b031C5a2Fc0a8a905));\n asExtension = ComptrollerFirstExtension(address(pool));\n _upgradeExistingPool(address(pool));\n\n _upgradeMarket(ankrBNBMkt);\n _upgradeMarket(ankrBNBAnkrMkt);\n\n // just some logging\n {\n uint256 borrowedAnkr = ankrBNBMkt.borrowBalanceCurrent(borrower);\n emit log_named_uint(\"ankrBnb borrow balance\", borrowedAnkr);\n uint256 collateralAnkr = ankrBNBAnkrMkt.balanceOf(borrower);\n emit log_named_uint(\"ankrBnb collateral balance of ankrBNB-ANKR\", collateralAnkr);\n\n uint256 borrowedOther = ankrBNBMkt.borrowBalanceCurrent(otherSupplier);\n emit log_named_uint(\"Other supplier borrower balance\", borrowedOther);\n uint256 collateralOther = ankrBNBAnkrMkt.balanceOf(otherSupplier);\n emit log_named_uint(\"Other supplier collateral balance of ankrBNB-ANKR\", collateralOther);\n\n emit log(\"\");\n emit log(\"Before collateral caps\");\n {\n (, , uint256 liq, uint256 sf) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 before setting BC\", liq); // 1366119859198693075092\n emit log_named_uint(\"Shortfall for account 1 before setting BC\", sf); // 0\n emit log(\"\");\n (, , uint256 liq1, uint256 sf1) = pool.getAccountLiquidity(otherSupplier);\n emit log_named_uint(\"Liq for account 2 before setting BC\", liq1); // 24108891649595017\n emit log_named_uint(\"Shortfall for account 2 before setting BC\", sf1); // 0\n\n assertGt(liq, 0, \"expected positive liquidity\");\n assertGt(liq1, 0, \"expected positive liquidity\");\n emit log(\"\");\n }\n }\n }\n\n // TODO test with the latest block and contracts and/or without the FSL\n function testBorrowCapForCollateralWhitelist() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n emit log(\"\");\n emit log(\"Borrow Caps Set\");\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), 1);\n (, , uint256 liqAfter, uint256 sfAfter) = pool.getAccountLiquidity(borrower);\n emit log_named_uint(\"Liq for account 1 after setting BC\", liqAfter);\n emit log_named_uint(\"Shortfall for account 1 after setting BC\", sfAfter);\n (, , uint256 liq1After, uint256 sf1After) = pool.getAccountLiquidity(otherSupplier);\n emit log(\"\");\n emit log_named_uint(\"Liq for account 2 after setting BC\", liq1After);\n emit log_named_uint(\"Shortfall for account 2 after setting BC\", sf1After);\n emit log(\"\");\n\n assertGt(sfAfter, 0, \"expected some shortfall for ankr\");\n assertEq(liq1After, 24108891649595017, \"expected liquidity for account 2 to decrease\");\n }\n\n {\n vm.prank(pool.admin());\n asExtension._setBorrowCapForCollateralWhitelist(address(ankrBNBMkt), address(ankrBNBAnkrMkt), borrower, true);\n\n emit log(\"\");\n (, , uint256 liqAfterWl, uint256 sfAfterWl) = pool.getAccountLiquidity(borrower);\n (, , uint256 liq1AfterWl, uint256 sf1AfterWl) = pool.getAccountLiquidity(otherSupplier);\n assertEq(sfAfterWl, 0, \"expected shortfall to go back to 0\");\n assertEq(liqAfterWl, 1366119859198693075092, \"expected liq to go back to original\");\n\n // expect liq for second (not whitelisted) account to stay reduced\n assertEq(liq1AfterWl, 24108891649595017, \"expected liq to go back to prev value\");\n }\n }\n\n function testBlacklistBorrowingAgainstCollateralWhitelist() public debuggingOnly fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateral(address(ankrBNBMkt), address(ankrBNBAnkrMkt), true);\n\n (, , uint256 liquidityAfterBlacklist, uint256 shortFallAfterBlacklist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertGt(liquidityBefore - liquidityAfterBlacklist, 0, \"should have lower liquidity after bl\");\n\n vm.prank(pool.admin());\n asExtension._blacklistBorrowingAgainstCollateralWhitelist(\n address(ankrBNBMkt),\n address(ankrBNBAnkrMkt),\n borrower,\n true\n );\n\n (, , uint256 liquidityAfterWhitelist, uint256 shortFallWhitelist) = pool.getHypotheticalAccountLiquidity(\n borrower,\n address(ankrBNBMkt),\n 0,\n 0,\n 0\n );\n assertEq(shortFallWhitelist, shortFallBefore, \"should have the same sf after wl\");\n assertEq(liquidityAfterWhitelist, liquidityBefore, \"should have the same liquidity after wl\");\n }\n\n function testSupplyCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.startPrank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n asExtension._setMintPaused(ankrBNBMkt, false);\n asExtension._setMintPaused(ankrBNBAnkrMkt, false);\n vm.stopPrank();\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!supply cap\");\n pool.mintAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.mintAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"mint not allowed after cap whitelist\");\n }\n\n function testBorrowCapWhitelist() public fork(BSC_MAINNET) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketBorrowCaps(markets, asArray(1, 1));\n\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityBefore, liquidityAfterCap, \"should have the same liquidity after cap\");\n assertEq(shortFallBefore, shortFallAfterCap, \"should have the same shortfall after cap\");\n\n vm.expectRevert(\"!borrow:cap\");\n pool.borrowAllowed(address(ankrBNBMkt), borrower, 2);\n\n vm.prank(pool.admin());\n asExtension._borrowCapWhitelist(address(ankrBNBMkt), borrower, true);\n\n require(pool.borrowAllowed(address(ankrBNBMkt), borrower, 2) == 0, \"borrow not allowed after cap whitelist\");\n }\n\n function testSupplyCapValue() public debuggingOnly forkAtBlock(BSC_MAINNET, 27827185) {\n (, , uint256 liquidityBefore, uint256 shortFallBefore) = pool.getAccountLiquidity(borrower);\n assertEq(shortFallBefore, 0, \"should have no shortfall before\");\n assertGt(liquidityBefore, 0, \"should have positive liquidity before\");\n\n ICErc20[] memory markets = new ICErc20[](2);\n markets[0] = ankrBNBMkt;\n markets[1] = ankrBNBAnkrMkt;\n\n vm.prank(pool.admin());\n asExtension._setMarketSupplyCaps(markets, asArray(1, 1));\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, 0, \"should have no liquidity after\");\n assertGt(shortFallAfterCap, 0, \"should have positive shortfall after\");\n }\n\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[0]), borrower, true);\n vm.prank(pool.admin());\n asExtension._supplyCapWhitelist(address(markets[1]), borrower, true);\n\n {\n (, , uint256 liquidityAfterCap, uint256 shortFallAfterCap) = pool.getAccountLiquidity(borrower);\n assertEq(liquidityAfterCap, liquidityBefore, \"liquidity after whitelist should match before\");\n assertEq(shortFallAfterCap, shortFallBefore, \"shortfall after whitelist should match before\");\n }\n }\n}\n" + }, + "contracts/test/UpgradesBaseTest.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport { FeeDistributor } from \"../FeeDistributor.sol\";\nimport { Comptroller } from \"../compound/Comptroller.sol\";\nimport { DiamondExtension } from \"../ionic/DiamondExtension.sol\";\nimport { ComptrollerFirstExtension } from \"../compound/ComptrollerFirstExtension.sol\";\nimport { CTokenFirstExtension } from \"../compound/CTokenFirstExtension.sol\";\nimport { Unitroller } from \"../compound/Unitroller.sol\";\nimport { CErc20Delegate } from \"../compound/CErc20Delegate.sol\";\nimport { CErc20Delegator } from \"../compound/CErc20Delegator.sol\";\nimport { CErc20PluginDelegate } from \"../compound/CErc20PluginDelegate.sol\";\nimport { CErc20PluginRewardsDelegate } from \"../compound/CErc20PluginRewardsDelegate.sol\";\nimport { CErc20RewardsDelegate } from \"../compound/CErc20RewardsDelegate.sol\";\nimport { ICErc20 } from \"../compound/CTokenInterfaces.sol\";\n\nimport { BaseTest } from \"./config/BaseTest.t.sol\";\n\nimport { TransparentUpgradeableProxy } from \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n\nabstract contract UpgradesBaseTest is BaseTest {\n FeeDistributor internal ffd;\n ComptrollerFirstExtension internal poolExt;\n CTokenFirstExtension internal marketExt;\n\n function afterForkSetUp() internal virtual override {\n ffd = FeeDistributor(payable(ap.getAddress(\"FeeDistributor\")));\n poolExt = new ComptrollerFirstExtension();\n marketExt = new CTokenFirstExtension();\n }\n\n function _upgradePoolWithExtension(Unitroller asUnitroller) internal {\n address oldComptrollerImplementation = asUnitroller.comptrollerImplementation();\n\n // instantiate the new implementation\n Comptroller newComptrollerImplementation = new Comptroller();\n vm.startPrank(ffd.owner());\n address comptrollerImplementationAddress = address(newComptrollerImplementation);\n ffd._setLatestComptrollerImplementation(address(0), comptrollerImplementationAddress);\n // add the extension to the auto upgrade config\n DiamondExtension[] memory extensions = new DiamondExtension[](2);\n extensions[0] = poolExt;\n extensions[1] = newComptrollerImplementation;\n ffd._setComptrollerExtensions(comptrollerImplementationAddress, extensions);\n vm.stopPrank();\n\n // upgrade to the new comptroller\n vm.startPrank(asUnitroller.admin());\n asUnitroller._registerExtension(\n DiamondExtension(comptrollerImplementationAddress),\n DiamondExtension(asUnitroller.comptrollerImplementation())\n );\n asUnitroller._upgrade();\n vm.stopPrank();\n }\n\n function _upgradeMarketWithExtension(ICErc20 market) internal {\n // instantiate the new implementation\n CErc20Delegate newImpl;\n bytes memory becomeImplData = \"\";\n if (compareStrings(\"CErc20Delegate\", market.contractType())) {\n newImpl = new CErc20Delegate();\n } else if (compareStrings(\"CErc20PluginDelegate\", market.contractType())) {\n newImpl = new CErc20PluginDelegate();\n becomeImplData = abi.encode(address(0));\n } else if (compareStrings(\"CErc20RewardsDelegate\", market.contractType())) {\n newImpl = new CErc20RewardsDelegate();\n becomeImplData = abi.encode(address(0));\n } else {\n newImpl = new CErc20PluginRewardsDelegate();\n becomeImplData = abi.encode(address(0));\n }\n\n // set the new delegate as the latest\n vm.startPrank(ffd.owner());\n ffd._setLatestCErc20Delegate(newImpl.delegateType(), address(newImpl), abi.encode(address(0)));\n\n // add the extension to the auto upgrade config\n DiamondExtension[] memory cErc20DelegateExtensions = new DiamondExtension[](2);\n cErc20DelegateExtensions[0] = marketExt;\n cErc20DelegateExtensions[1] = newImpl;\n ffd._setCErc20DelegateExtensions(address(newImpl), cErc20DelegateExtensions);\n vm.stopPrank();\n\n vm.stopPrank();\n // upgrade to the new delegate\n vm.prank(address(ffd));\n market._setImplementationSafe(address(newImpl), becomeImplData);\n }\n}\n" + }, + "contracts/utils/IMulticall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\n/// @title Multicall interface\n/// @notice Enables calling multiple methods in a single call to the contract\ninterface IMulticall {\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n /// @param data The encoded function data for each of the calls to make to this contract\n /// @return results The results from each of the calls passed in via data\n function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n}\n" + }, + "contracts/utils/IW_NATIVE.sol": { + "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity >=0.8.0;\n\ninterface IW_NATIVE {\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n\n function approve(address spender, uint256 amount) external returns (bool);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n function balanceOf(address) external view returns (uint256);\n}\n" + }, + "contracts/utils/Multicall.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.8.0;\n\nimport \"./IMulticall.sol\";\n\n/// @title Multicall\n/// @notice Enables calling multiple methods in a single call to the contract\nabstract contract Multicall is IMulticall {\n /// @inheritdoc IMulticall\n function multicall(bytes[] calldata data) public payable virtual override returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n if (!success) {\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n if (result.length < 68) revert();\n assembly {\n result := add(result, 0x04)\n }\n revert(abi.decode(result, (string)));\n }\n\n results[i] = result;\n }\n }\n}\n" + }, + "ds-test/test.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity >=0.5.0;\n\ncontract DSTest {\n event log (string);\n event logs (bytes);\n\n event log_address (address);\n event log_bytes32 (bytes32);\n event log_int (int);\n event log_uint (uint);\n event log_bytes (bytes);\n event log_string (string);\n\n event log_named_address (string key, address val);\n event log_named_bytes32 (string key, bytes32 val);\n event log_named_decimal_int (string key, int val, uint decimals);\n event log_named_decimal_uint (string key, uint val, uint decimals);\n event log_named_int (string key, int val);\n event log_named_uint (string key, uint val);\n event log_named_bytes (string key, bytes val);\n event log_named_string (string key, string val);\n\n bool public IS_TEST = true;\n bool private _failed;\n\n address constant HEVM_ADDRESS =\n address(bytes20(uint160(uint256(keccak256('hevm cheat code')))));\n\n modifier mayRevert() { _; }\n modifier testopts(string memory) { _; }\n\n function failed() public returns (bool) {\n if (_failed) {\n return _failed;\n } else {\n bool globalFailed = false;\n if (hasHEVMContext()) {\n (, bytes memory retdata) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"load(address,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"))\n )\n );\n globalFailed = abi.decode(retdata, (bool));\n }\n return globalFailed;\n }\n }\n\n function fail() internal virtual {\n if (hasHEVMContext()) {\n (bool status, ) = HEVM_ADDRESS.call(\n abi.encodePacked(\n bytes4(keccak256(\"store(address,bytes32,bytes32)\")),\n abi.encode(HEVM_ADDRESS, bytes32(\"failed\"), bytes32(uint256(0x01)))\n )\n );\n status; // Silence compiler warnings\n }\n _failed = true;\n }\n\n function hasHEVMContext() internal view returns (bool) {\n uint256 hevmCodeSize = 0;\n assembly {\n hevmCodeSize := extcodesize(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D)\n }\n return hevmCodeSize > 0;\n }\n\n modifier logs_gas() {\n uint startGas = gasleft();\n _;\n uint endGas = gasleft();\n emit log_named_uint(\"gas\", startGas - endGas);\n }\n\n function assertTrue(bool condition) internal {\n if (!condition) {\n emit log(\"Error: Assertion Failed\");\n fail();\n }\n }\n\n function assertTrue(bool condition, string memory err) internal {\n if (!condition) {\n emit log_named_string(\"Error\", err);\n assertTrue(condition);\n }\n }\n\n function assertEq(address a, address b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [address]\");\n emit log_named_address(\" Left\", a);\n emit log_named_address(\" Right\", b);\n fail();\n }\n }\n function assertEq(address a, address b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes32 a, bytes32 b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bytes32]\");\n emit log_named_bytes32(\" Left\", a);\n emit log_named_bytes32(\" Right\", b);\n fail();\n }\n }\n function assertEq(bytes32 a, bytes32 b, string memory err) internal {\n if (a != b) {\n emit log_named_string (\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq32(bytes32 a, bytes32 b) internal {\n assertEq(a, b);\n }\n function assertEq32(bytes32 a, bytes32 b, string memory err) internal {\n assertEq(a, b, err);\n }\n\n function assertEq(int a, int b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n fail();\n }\n }\n function assertEq(int a, int b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEq(uint a, uint b) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n fail();\n }\n }\n function assertEq(uint a, uint b, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n function assertEqDecimal(int a, int b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals) internal {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n fail();\n }\n }\n function assertEqDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEqDecimal(a, b, decimals);\n }\n }\n\n function assertGt(uint a, uint b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGt(uint a, uint b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGt(int a, int b) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGt(int a, int b, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGt(a, b);\n }\n }\n function assertGtDecimal(int a, int b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals) internal {\n if (a <= b) {\n emit log(\"Error: a > b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a <= b) {\n emit log_named_string(\"Error\", err);\n assertGtDecimal(a, b, decimals);\n }\n }\n\n function assertGe(uint a, uint b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertGe(uint a, uint b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGe(int a, int b) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertGe(int a, int b, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGe(a, b);\n }\n }\n function assertGeDecimal(int a, int b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals) internal {\n if (a < b) {\n emit log(\"Error: a >= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertGeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a < b) {\n emit log_named_string(\"Error\", err);\n assertGeDecimal(a, b, decimals);\n }\n }\n\n function assertLt(uint a, uint b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLt(uint a, uint b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLt(int a, int b) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLt(int a, int b, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLt(a, b);\n }\n }\n function assertLtDecimal(int a, int b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals) internal {\n if (a >= b) {\n emit log(\"Error: a < b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLtDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a >= b) {\n emit log_named_string(\"Error\", err);\n assertLtDecimal(a, b, decimals);\n }\n }\n\n function assertLe(uint a, uint b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [uint]\");\n emit log_named_uint(\" Value a\", a);\n emit log_named_uint(\" Value b\", b);\n fail();\n }\n }\n function assertLe(uint a, uint b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLe(int a, int b) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [int]\");\n emit log_named_int(\" Value a\", a);\n emit log_named_int(\" Value b\", b);\n fail();\n }\n }\n function assertLe(int a, int b, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLe(a, b);\n }\n }\n function assertLeDecimal(int a, int b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal int]\");\n emit log_named_decimal_int(\" Value a\", a, decimals);\n emit log_named_decimal_int(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(int a, int b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals) internal {\n if (a > b) {\n emit log(\"Error: a <= b not satisfied [decimal uint]\");\n emit log_named_decimal_uint(\" Value a\", a, decimals);\n emit log_named_decimal_uint(\" Value b\", b, decimals);\n fail();\n }\n }\n function assertLeDecimal(uint a, uint b, uint decimals, string memory err) internal {\n if (a > b) {\n emit log_named_string(\"Error\", err);\n assertLeDecimal(a, b, decimals);\n }\n }\n\n function assertEq(string memory a, string memory b) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log(\"Error: a == b not satisfied [string]\");\n emit log_named_string(\" Left\", a);\n emit log_named_string(\" Right\", b);\n fail();\n }\n }\n function assertEq(string memory a, string memory b, string memory err) internal {\n if (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function checkEq0(bytes memory a, bytes memory b) internal pure returns (bool ok) {\n ok = true;\n if (a.length == b.length) {\n for (uint i = 0; i < a.length; i++) {\n if (a[i] != b[i]) {\n ok = false;\n }\n }\n } else {\n ok = false;\n }\n }\n function assertEq0(bytes memory a, bytes memory b) internal {\n if (!checkEq0(a, b)) {\n emit log(\"Error: a == b not satisfied [bytes]\");\n emit log_named_bytes(\" Left\", a);\n emit log_named_bytes(\" Right\", b);\n fail();\n }\n }\n function assertEq0(bytes memory a, bytes memory b, string memory err) internal {\n if (!checkEq0(a, b)) {\n emit log_named_string(\"Error\", err);\n assertEq0(a, b);\n }\n }\n}\n" + }, + "forge-std/Base.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {StdStorage} from \"./StdStorage.sol\";\nimport {Vm, VmSafe} from \"./Vm.sol\";\n\nabstract contract CommonBase {\n // Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.\n address internal constant VM_ADDRESS = address(uint160(uint256(keccak256(\"hevm cheat code\"))));\n // console.sol and console2.sol work by executing a staticcall to this address.\n address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;\n // Default address for tx.origin and msg.sender, 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38.\n address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256(\"foundry default caller\"))));\n // Address of the test contract, deployed by the DEFAULT_SENDER.\n address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;\n // Deterministic deployment address of the Multicall3 contract.\n address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;\n\n uint256 internal constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n Vm internal constant vm = Vm(VM_ADDRESS);\n StdStorage internal stdstore;\n}\n\nabstract contract TestBase is CommonBase {}\n\nabstract contract ScriptBase is CommonBase {\n // Used when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);\n}\n" + }, + "forge-std/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nlibrary console {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n }\n\n function logUint(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n }\n\n function log(uint p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n }\n\n function log(uint p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n }\n\n function log(uint p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n }\n\n function log(string memory p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n }\n\n function log(uint p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/console2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\n/// @dev The original console.sol uses `int` and `uint` for computing function selectors, but it should\n/// use `int256` and `uint256`. This modified version fixes that. This version is recommended\n/// over `console.sol` if you don't need compatibility with Hardhat as the logs will show up in\n/// forge stack traces. If you do need compatibility with Hardhat, you must use `console.sol`.\n/// Reference: https://github.com/NomicFoundation/hardhat/issues/2178\nlibrary console2 {\n address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n function _sendLogPayload(bytes memory payload) private view {\n uint256 payloadLength = payload.length;\n address consoleAddress = CONSOLE_ADDRESS;\n /// @solidity memory-safe-assembly\n assembly {\n let payloadStart := add(payload, 32)\n let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n }\n }\n\n function log() internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log()\"));\n }\n\n function logInt(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function logUint(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function logString(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function logBool(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function logAddress(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function logBytes(bytes memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n }\n\n function logBytes1(bytes1 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n }\n\n function logBytes2(bytes2 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n }\n\n function logBytes3(bytes3 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n }\n\n function logBytes4(bytes4 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n }\n\n function logBytes5(bytes5 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n }\n\n function logBytes6(bytes6 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n }\n\n function logBytes7(bytes7 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n }\n\n function logBytes8(bytes8 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n }\n\n function logBytes9(bytes9 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n }\n\n function logBytes10(bytes10 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n }\n\n function logBytes11(bytes11 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n }\n\n function logBytes12(bytes12 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n }\n\n function logBytes13(bytes13 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n }\n\n function logBytes14(bytes14 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n }\n\n function logBytes15(bytes15 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n }\n\n function logBytes16(bytes16 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n }\n\n function logBytes17(bytes17 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n }\n\n function logBytes18(bytes18 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n }\n\n function logBytes19(bytes19 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n }\n\n function logBytes20(bytes20 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n }\n\n function logBytes21(bytes21 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n }\n\n function logBytes22(bytes22 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n }\n\n function logBytes23(bytes23 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n }\n\n function logBytes24(bytes24 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n }\n\n function logBytes25(bytes25 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n }\n\n function logBytes26(bytes26 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n }\n\n function logBytes27(bytes27 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n }\n\n function logBytes28(bytes28 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n }\n\n function logBytes29(bytes29 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n }\n\n function logBytes30(bytes30 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n }\n\n function logBytes31(bytes31 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n }\n\n function logBytes32(bytes32 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n }\n\n function log(uint256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n }\n\n function log(int256 p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n }\n\n function log(string memory p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n }\n\n function log(bool p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n }\n\n function log(address p0) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n }\n\n function log(uint256 p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n }\n\n function log(uint256 p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n }\n\n function log(uint256 p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n }\n\n function log(uint256 p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n }\n\n function log(string memory p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n }\n\n function log(string memory p0, int256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,int256)\", p0, p1));\n }\n\n function log(string memory p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n }\n\n function log(string memory p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n }\n\n function log(string memory p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n }\n\n function log(bool p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n }\n\n function log(bool p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n }\n\n function log(bool p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n }\n\n function log(bool p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n }\n\n function log(address p0, uint256 p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n }\n\n function log(address p0, string memory p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n }\n\n function log(address p0, bool p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n }\n\n function log(address p0, address p1) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n }\n\n function log(uint256 p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n }\n\n function log(string memory p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n }\n\n function log(bool p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n }\n\n function log(address p0, uint256 p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n }\n\n function log(address p0, string memory p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n }\n\n function log(address p0, bool p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, uint256 p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, string memory p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, bool p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n }\n\n function log(address p0, address p1, address p2) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(uint256 p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(string memory p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(bool p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, uint256 p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, string memory p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, bool p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, uint256 p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, string memory p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, bool p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, uint256 p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, string memory p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, bool p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n }\n\n function log(address p0, address p1, address p2, address p3) internal view {\n _sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n }\n\n}" + }, + "forge-std/interfaces/IMulticall3.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ninterface IMulticall3 {\n struct Call {\n address target;\n bytes callData;\n }\n\n struct Call3 {\n address target;\n bool allowFailure;\n bytes callData;\n }\n\n struct Call3Value {\n address target;\n bool allowFailure;\n uint256 value;\n bytes callData;\n }\n\n struct Result {\n bool success;\n bytes returnData;\n }\n\n function aggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes[] memory returnData);\n\n function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);\n\n function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);\n\n function blockAndAggregate(Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n\n function getBasefee() external view returns (uint256 basefee);\n\n function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);\n\n function getBlockNumber() external view returns (uint256 blockNumber);\n\n function getChainId() external view returns (uint256 chainid);\n\n function getCurrentBlockCoinbase() external view returns (address coinbase);\n\n function getCurrentBlockDifficulty() external view returns (uint256 difficulty);\n\n function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);\n\n function getCurrentBlockTimestamp() external view returns (uint256 timestamp);\n\n function getEthBalance(address addr) external view returns (uint256 balance);\n\n function getLastBlockHash() external view returns (bytes32 blockHash);\n\n function tryAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (Result[] memory returnData);\n\n function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)\n external\n payable\n returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);\n}\n" + }, + "forge-std/StdAssertions.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {DSTest} from \"ds-test/test.sol\";\nimport {stdMath} from \"./StdMath.sol\";\n\nabstract contract StdAssertions is DSTest {\n event log_array(uint256[] val);\n event log_array(int256[] val);\n event log_array(address[] val);\n event log_named_array(string key, uint256[] val);\n event log_named_array(string key, int256[] val);\n event log_named_array(string key, address[] val);\n\n function fail(string memory err) internal virtual {\n emit log_named_string(\"Error\", err);\n fail();\n }\n\n function assertFalse(bool data) internal virtual {\n assertTrue(!data);\n }\n\n function assertFalse(bool data, string memory err) internal virtual {\n assertTrue(!data, err);\n }\n\n function assertEq(bool a, bool b) internal virtual {\n if (a != b) {\n emit log(\"Error: a == b not satisfied [bool]\");\n emit log_named_string(\" Left\", a ? \"true\" : \"false\");\n emit log_named_string(\" Right\", b ? \"true\" : \"false\");\n fail();\n }\n }\n\n function assertEq(bool a, bool b, string memory err) internal virtual {\n if (a != b) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(bytes memory a, bytes memory b) internal virtual {\n assertEq0(a, b);\n }\n\n function assertEq(bytes memory a, bytes memory b, string memory err) internal virtual {\n assertEq0(a, b, err);\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [uint[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [int[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(address[] memory a, address[] memory b) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log(\"Error: a == b not satisfied [address[]]\");\n emit log_named_array(\" Left\", a);\n emit log_named_array(\" Right\", b);\n fail();\n }\n }\n\n function assertEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(int256[] memory a, int256[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n function assertEq(address[] memory a, address[] memory b, string memory err) internal virtual {\n if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) {\n emit log_named_string(\"Error\", err);\n assertEq(a, b);\n }\n }\n\n // Legacy helper\n function assertEqUint(uint256 a, uint256 b) internal virtual {\n assertEq(uint256(a), uint256(b));\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(uint256 a, uint256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(uint256 a, uint256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_uint(\" Max Delta\", maxDelta);\n emit log_named_uint(\" Delta\", delta);\n fail();\n }\n }\n\n function assertApproxEqAbs(int256 a, int256 b, uint256 maxDelta, string memory err) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbs(a, b, maxDelta);\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals) internal virtual {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max Delta\", maxDelta, decimals);\n emit log_named_decimal_uint(\" Delta\", delta, decimals);\n fail();\n }\n }\n\n function assertApproxEqAbsDecimal(int256 a, int256 b, uint256 maxDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n uint256 delta = stdMath.delta(a, b);\n\n if (delta > maxDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqAbsDecimal(a, b, maxDelta, decimals);\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100%\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_uint(\" Left\", a);\n emit log_named_uint(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals\n ) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [uint]\");\n emit log_named_decimal_uint(\" Left\", a, decimals);\n emit log_named_decimal_uint(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(\n uint256 a,\n uint256 b,\n uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%\n uint256 decimals,\n string memory err\n ) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_int(\" Left\", a);\n emit log_named_int(\" Right\", b);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRel(int256 a, int256 b, uint256 maxPercentDelta, string memory err) internal virtual {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRel(a, b, maxPercentDelta);\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals) internal virtual {\n if (b == 0) return assertEq(a, b); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log(\"Error: a ~= b not satisfied [int]\");\n emit log_named_decimal_int(\" Left\", a, decimals);\n emit log_named_decimal_int(\" Right\", b, decimals);\n emit log_named_decimal_uint(\" Max % Delta\", maxPercentDelta, 18);\n emit log_named_decimal_uint(\" % Delta\", percentDelta, 18);\n fail();\n }\n }\n\n function assertApproxEqRelDecimal(int256 a, int256 b, uint256 maxPercentDelta, uint256 decimals, string memory err)\n internal\n virtual\n {\n if (b == 0) return assertEq(a, b, err); // If the left is 0, right must be too.\n\n uint256 percentDelta = stdMath.percentDelta(a, b);\n\n if (percentDelta > maxPercentDelta) {\n emit log_named_string(\"Error\", err);\n assertApproxEqRelDecimal(a, b, maxPercentDelta, decimals);\n }\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual {\n assertEqCall(target, callDataA, target, callDataB, true);\n }\n\n function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)\n internal\n virtual\n {\n assertEqCall(targetA, callDataA, targetB, callDataB, true);\n }\n\n function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)\n internal\n virtual\n {\n assertEqCall(target, callDataA, target, callDataB, strictRevertData);\n }\n\n function assertEqCall(\n address targetA,\n bytes memory callDataA,\n address targetB,\n bytes memory callDataB,\n bool strictRevertData\n ) internal virtual {\n (bool successA, bytes memory returnDataA) = address(targetA).call(callDataA);\n (bool successB, bytes memory returnDataB) = address(targetB).call(callDataB);\n\n if (successA && successB) {\n assertEq(returnDataA, returnDataB, \"Call return data does not match\");\n }\n\n if (!successA && !successB && strictRevertData) {\n assertEq(returnDataA, returnDataB, \"Call revert data does not match\");\n }\n\n if (!successA && successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call revert data\", returnDataA);\n emit log_named_bytes(\" Right call return data\", returnDataB);\n fail();\n }\n\n if (successA && !successB) {\n emit log(\"Error: Calls were not equal\");\n emit log_named_bytes(\" Left call return data\", returnDataA);\n emit log_named_bytes(\" Right call revert data\", returnDataB);\n fail();\n }\n }\n}\n" + }, + "forge-std/StdChains.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n/**\n * StdChains provides information about EVM compatible chains that can be used in scripts/tests.\n * For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are\n * identified by their alias, which is the same as the alias in the `[rpc_endpoints]` section of\n * the `foundry.toml` file. For best UX, ensure the alias in the `foundry.toml` file match the\n * alias used in this contract, which can be found as the first argument to the\n * `setChainWithDefaultRpcUrl` call in the `initialize` function.\n *\n * There are two main ways to use this contract:\n * 1. Set a chain with `setChain(string memory chainAlias, ChainData memory chain)` or\n * `setChain(string memory chainAlias, Chain memory chain)`\n * 2. Get a chain with `getChain(string memory chainAlias)` or `getChain(uint256 chainId)`.\n *\n * The first time either of those are used, chains are initialized with the default set of RPC URLs.\n * This is done in `initialize`, which uses `setChainWithDefaultRpcUrl`. Defaults are recorded in\n * `defaultRpcUrls`.\n *\n * The `setChain` function is straightforward, and it simply saves off the given chain data.\n *\n * The `getChain` methods use `getChainWithUpdatedRpcUrl` to return a chain. For example, let's say\n * we want to retrieve `mainnet`'s RPC URL:\n * - If you haven't set any mainnet chain info with `setChain`, you haven't specified that\n * chain in `foundry.toml` and no env var is set, the default data and RPC URL will be returned.\n * - If you have set a mainnet RPC URL in `foundry.toml` it will return that, if valid (e.g. if\n * a URL is given or if an environment variable is given and that environment variable exists).\n * Otherwise, the default data is returned.\n * - If you specified data with `setChain` it will return that.\n *\n * Summarizing the above, the prioritization hierarchy is `setChain` -> `foundry.toml` -> environment variable -> defaults.\n */\nabstract contract StdChains {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private initialized;\n\n struct ChainData {\n string name;\n uint256 chainId;\n string rpcUrl;\n }\n\n struct Chain {\n // The chain name.\n string name;\n // The chain's Chain ID.\n uint256 chainId;\n // The chain's alias. (i.e. what gets specified in `foundry.toml`).\n string chainAlias;\n // A default RPC endpoint for this chain.\n // NOTE: This default RPC URL is included for convenience to facilitate quick tests and\n // experimentation. Do not use this RPC URL for production test suites, CI, or other heavy\n // usage as you will be throttled and this is a disservice to others who need this endpoint.\n string rpcUrl;\n }\n\n // Maps from the chain's alias (matching the alias in the `foundry.toml` file) to chain data.\n mapping(string => Chain) private chains;\n // Maps from the chain's alias to it's default RPC URL.\n mapping(string => string) private defaultRpcUrls;\n // Maps from a chain ID to it's alias.\n mapping(uint256 => string) private idToAlias;\n\n bool private fallbackToDefaultRpcUrls = true;\n\n // The RPC URL will be fetched from config or defaultRpcUrls if possible.\n function getChain(string memory chainAlias) internal virtual returns (Chain memory chain) {\n require(bytes(chainAlias).length != 0, \"StdChains getChain(string): Chain alias cannot be the empty string.\");\n\n initialize();\n chain = chains[chainAlias];\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(string): Chain with alias \\\"\", chainAlias, \"\\\" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n function getChain(uint256 chainId) internal virtual returns (Chain memory chain) {\n require(chainId != 0, \"StdChains getChain(uint256): Chain ID cannot be 0.\");\n initialize();\n string memory chainAlias = idToAlias[chainId];\n\n chain = chains[chainAlias];\n\n require(\n chain.chainId != 0,\n string(abi.encodePacked(\"StdChains getChain(uint256): Chain with ID \", vm.toString(chainId), \" not found.\"))\n );\n\n chain = getChainWithUpdatedRpcUrl(chainAlias, chain);\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, ChainData memory chain) internal virtual {\n require(\n bytes(chainAlias).length != 0,\n \"StdChains setChain(string,ChainData): Chain alias cannot be the empty string.\"\n );\n\n require(chain.chainId != 0, \"StdChains setChain(string,ChainData): Chain ID cannot be 0.\");\n\n initialize();\n string memory foundAlias = idToAlias[chain.chainId];\n\n require(\n bytes(foundAlias).length == 0 || keccak256(bytes(foundAlias)) == keccak256(bytes(chainAlias)),\n string(\n abi.encodePacked(\n \"StdChains setChain(string,ChainData): Chain ID \",\n vm.toString(chain.chainId),\n \" already used by \\\"\",\n foundAlias,\n \"\\\".\"\n )\n )\n );\n\n uint256 oldChainId = chains[chainAlias].chainId;\n delete idToAlias[oldChainId];\n\n chains[chainAlias] =\n Chain({name: chain.name, chainId: chain.chainId, chainAlias: chainAlias, rpcUrl: chain.rpcUrl});\n idToAlias[chain.chainId] = chainAlias;\n }\n\n // set chain info, with priority to argument's rpcUrl field.\n function setChain(string memory chainAlias, Chain memory chain) internal virtual {\n setChain(chainAlias, ChainData({name: chain.name, chainId: chain.chainId, rpcUrl: chain.rpcUrl}));\n }\n\n function _toUpper(string memory str) private pure returns (string memory) {\n bytes memory strb = bytes(str);\n bytes memory copy = new bytes(strb.length);\n for (uint256 i = 0; i < strb.length; i++) {\n bytes1 b = strb[i];\n if (b >= 0x61 && b <= 0x7A) {\n copy[i] = bytes1(uint8(b) - 32);\n } else {\n copy[i] = b;\n }\n }\n return string(copy);\n }\n\n // lookup rpcUrl, in descending order of priority:\n // current -> config (foundry.toml) -> environment variable -> default\n function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private returns (Chain memory) {\n if (bytes(chain.rpcUrl).length == 0) {\n try vm.rpcUrl(chainAlias) returns (string memory configRpcUrl) {\n chain.rpcUrl = configRpcUrl;\n } catch (bytes memory err) {\n string memory envName = string(abi.encodePacked(_toUpper(chainAlias), \"_RPC_URL\"));\n if (fallbackToDefaultRpcUrls) {\n chain.rpcUrl = vm.envOr(envName, defaultRpcUrls[chainAlias]);\n } else {\n chain.rpcUrl = vm.envString(envName);\n }\n // distinguish 'not found' from 'cannot read'\n bytes memory notFoundError =\n abi.encodeWithSignature(\"CheatCodeError\", string(abi.encodePacked(\"invalid rpc url \", chainAlias)));\n if (keccak256(notFoundError) != keccak256(err) || bytes(chain.rpcUrl).length == 0) {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, err), mload(err))\n }\n }\n }\n }\n return chain;\n }\n\n function setFallbackToDefaultRpcUrls(bool useDefault) internal {\n fallbackToDefaultRpcUrls = useDefault;\n }\n\n function initialize() private {\n if (initialized) return;\n\n initialized = true;\n\n // If adding an RPC here, make sure to test the default RPC URL in `testRpcs`\n setChainWithDefaultRpcUrl(\"anvil\", ChainData(\"Anvil\", 31337, \"http://127.0.0.1:8545\"));\n setChainWithDefaultRpcUrl(\n \"mainnet\", ChainData(\"Mainnet\", 1, \"https://mainnet.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"goerli\", ChainData(\"Goerli\", 5, \"https://goerli.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\n \"sepolia\", ChainData(\"Sepolia\", 11155111, \"https://sepolia.infura.io/v3/f4a0bdad42674adab5fc0ac077ffab2b\")\n );\n setChainWithDefaultRpcUrl(\"optimism\", ChainData(\"Optimism\", 10, \"https://mainnet.optimism.io\"));\n setChainWithDefaultRpcUrl(\"optimism_goerli\", ChainData(\"Optimism Goerli\", 420, \"https://goerli.optimism.io\"));\n setChainWithDefaultRpcUrl(\"arbitrum_one\", ChainData(\"Arbitrum One\", 42161, \"https://arb1.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\n \"arbitrum_one_goerli\", ChainData(\"Arbitrum One Goerli\", 421613, \"https://goerli-rollup.arbitrum.io/rpc\")\n );\n setChainWithDefaultRpcUrl(\"arbitrum_nova\", ChainData(\"Arbitrum Nova\", 42170, \"https://nova.arbitrum.io/rpc\"));\n setChainWithDefaultRpcUrl(\"polygon\", ChainData(\"Polygon\", 137, \"https://polygon-rpc.com\"));\n setChainWithDefaultRpcUrl(\n \"polygon_mumbai\", ChainData(\"Polygon Mumbai\", 80001, \"https://rpc-mumbai.maticvigil.com\")\n );\n setChainWithDefaultRpcUrl(\"avalanche\", ChainData(\"Avalanche\", 43114, \"https://api.avax.network/ext/bc/C/rpc\"));\n setChainWithDefaultRpcUrl(\n \"avalanche_fuji\", ChainData(\"Avalanche Fuji\", 43113, \"https://api.avax-test.network/ext/bc/C/rpc\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain\", ChainData(\"BNB Smart Chain\", 56, \"https://bsc-dataseed1.binance.org\")\n );\n setChainWithDefaultRpcUrl(\n \"bnb_smart_chain_testnet\",\n ChainData(\"BNB Smart Chain Testnet\", 97, \"https://rpc.ankr.com/bsc_testnet_chapel\")\n );\n setChainWithDefaultRpcUrl(\"gnosis_chain\", ChainData(\"Gnosis Chain\", 100, \"https://rpc.gnosischain.com\"));\n }\n\n // set chain info, with priority to chainAlias' rpc url in foundry.toml\n function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private {\n string memory rpcUrl = chain.rpcUrl;\n defaultRpcUrls[chainAlias] = rpcUrl;\n chain.rpcUrl = \"\";\n setChain(chainAlias, chain);\n chain.rpcUrl = rpcUrl; // restore argument\n }\n}\n" + }, + "forge-std/StdCheats.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {Vm} from \"./Vm.sol\";\n\nabstract contract StdCheatsSafe {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n bool private gasMeteringOff;\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawTx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n // json value name = function\n string functionSig;\n bytes32 hash;\n // json value name = tx\n RawTx1559Detail txDetail;\n // json value name = type\n string opcode;\n }\n\n struct RawTx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n bytes gas;\n bytes nonce;\n address to;\n bytes txType;\n bytes value;\n }\n\n struct Tx1559 {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n bytes32 hash;\n Tx1559Detail txDetail;\n string opcode;\n }\n\n struct Tx1559Detail {\n AccessList[] accessList;\n bytes data;\n address from;\n uint256 gas;\n uint256 nonce;\n address to;\n uint256 txType;\n uint256 value;\n }\n\n // Data structures to parse Transaction objects from the broadcast artifact\n // that DO NOT conform to EIP1559. The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct TxLegacy {\n string[] arguments;\n address contractAddress;\n string contractName;\n string functionSig;\n string hash;\n string opcode;\n TxDetailLegacy transaction;\n }\n\n struct TxDetailLegacy {\n AccessList[] accessList;\n uint256 chainId;\n bytes data;\n address from;\n uint256 gas;\n uint256 gasPrice;\n bytes32 hash;\n uint256 nonce;\n bytes1 opcode;\n bytes32 r;\n bytes32 s;\n uint256 txType;\n address to;\n uint8 v;\n uint256 value;\n }\n\n struct AccessList {\n address accessAddress;\n bytes32[] storageKeys;\n }\n\n // Data structures to parse Receipt objects from the broadcast artifact.\n // The Raw structs is what is parsed from the JSON\n // and then converted to the one that is used by the user for better UX.\n\n struct RawReceipt {\n bytes32 blockHash;\n bytes blockNumber;\n address contractAddress;\n bytes cumulativeGasUsed;\n bytes effectiveGasPrice;\n address from;\n bytes gasUsed;\n RawReceiptLog[] logs;\n bytes logsBloom;\n bytes status;\n address to;\n bytes32 transactionHash;\n bytes transactionIndex;\n }\n\n struct Receipt {\n bytes32 blockHash;\n uint256 blockNumber;\n address contractAddress;\n uint256 cumulativeGasUsed;\n uint256 effectiveGasPrice;\n address from;\n uint256 gasUsed;\n ReceiptLog[] logs;\n bytes logsBloom;\n uint256 status;\n address to;\n bytes32 transactionHash;\n uint256 transactionIndex;\n }\n\n // Data structures to parse the entire broadcast artifact, assuming the\n // transactions conform to EIP1559.\n\n struct EIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n Receipt[] receipts;\n uint256 timestamp;\n Tx1559[] transactions;\n TxReturn[] txReturns;\n }\n\n struct RawEIP1559ScriptArtifact {\n string[] libraries;\n string path;\n string[] pending;\n RawReceipt[] receipts;\n TxReturn[] txReturns;\n uint256 timestamp;\n RawTx1559[] transactions;\n }\n\n struct RawReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n bytes blockNumber;\n bytes data;\n bytes logIndex;\n bool removed;\n bytes32[] topics;\n bytes32 transactionHash;\n bytes transactionIndex;\n bytes transactionLogIndex;\n }\n\n struct ReceiptLog {\n // json value = address\n address logAddress;\n bytes32 blockHash;\n uint256 blockNumber;\n bytes data;\n uint256 logIndex;\n bytes32[] topics;\n uint256 transactionIndex;\n uint256 transactionLogIndex;\n bool removed;\n }\n\n struct TxReturn {\n string internalType;\n string value;\n }\n\n function assumeNoPrecompiles(address addr) internal virtual {\n // Assembly required since `block.chainid` was introduced in 0.8.0.\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n assumeNoPrecompiles(addr, chainId);\n }\n\n function assumeNoPrecompiles(address addr, uint256 chainId) internal pure virtual {\n // Note: For some chains like Optimism these are technically predeploys (i.e. bytecode placed at a specific\n // address), but the same rationale for excluding them applies so we include those too.\n\n // These should be present on all EVM-compatible chains.\n vm.assume(addr < address(0x1) || addr > address(0x9));\n\n // forgefmt: disable-start\n if (chainId == 10 || chainId == 420) {\n // https://github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.go#L6-L21\n vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));\n } else if (chainId == 42161 || chainId == 421613) {\n // https://developer.arbitrum.io/useful-addresses#arbitrum-precompiles-l2-same-on-all-arb-chains\n vm.assume(addr < address(0x0000000000000000000000000000000000000064) || addr > address(0x0000000000000000000000000000000000000068));\n } else if (chainId == 43114 || chainId == 43113) {\n // https://github.com/ava-labs/subnet-evm/blob/47c03fd007ecaa6de2c52ea081596e0a88401f58/precompile/params.go#L18-L59\n vm.assume(addr < address(0x0100000000000000000000000000000000000000) || addr > address(0x01000000000000000000000000000000000000ff));\n vm.assume(addr < address(0x0200000000000000000000000000000000000000) || addr > address(0x02000000000000000000000000000000000000FF));\n vm.assume(addr < address(0x0300000000000000000000000000000000000000) || addr > address(0x03000000000000000000000000000000000000Ff));\n }\n // forgefmt: disable-end\n }\n\n function readEIP1559ScriptArtifact(string memory path)\n internal\n view\n virtual\n returns (EIP1559ScriptArtifact memory)\n {\n string memory data = vm.readFile(path);\n bytes memory parsedData = vm.parseJson(data);\n RawEIP1559ScriptArtifact memory rawArtifact = abi.decode(parsedData, (RawEIP1559ScriptArtifact));\n EIP1559ScriptArtifact memory artifact;\n artifact.libraries = rawArtifact.libraries;\n artifact.path = rawArtifact.path;\n artifact.timestamp = rawArtifact.timestamp;\n artifact.pending = rawArtifact.pending;\n artifact.txReturns = rawArtifact.txReturns;\n artifact.receipts = rawToConvertedReceipts(rawArtifact.receipts);\n artifact.transactions = rawToConvertedEIPTx1559s(rawArtifact.transactions);\n return artifact;\n }\n\n function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory) {\n Tx1559[] memory txs = new Tx1559[](rawTxs.length);\n for (uint256 i; i < rawTxs.length; i++) {\n txs[i] = rawToConvertedEIPTx1559(rawTxs[i]);\n }\n return txs;\n }\n\n function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory) {\n Tx1559 memory transaction;\n transaction.arguments = rawTx.arguments;\n transaction.contractName = rawTx.contractName;\n transaction.functionSig = rawTx.functionSig;\n transaction.hash = rawTx.hash;\n transaction.txDetail = rawToConvertedEIP1559Detail(rawTx.txDetail);\n transaction.opcode = rawTx.opcode;\n return transaction;\n }\n\n function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)\n internal\n pure\n virtual\n returns (Tx1559Detail memory)\n {\n Tx1559Detail memory txDetail;\n txDetail.data = rawDetail.data;\n txDetail.from = rawDetail.from;\n txDetail.to = rawDetail.to;\n txDetail.nonce = _bytesToUint(rawDetail.nonce);\n txDetail.txType = _bytesToUint(rawDetail.txType);\n txDetail.value = _bytesToUint(rawDetail.value);\n txDetail.gas = _bytesToUint(rawDetail.gas);\n txDetail.accessList = rawDetail.accessList;\n return txDetail;\n }\n\n function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".transactions\");\n RawTx1559[] memory rawTxs = abi.decode(parsedDeployData, (RawTx1559[]));\n return rawToConvertedEIPTx1559s(rawTxs);\n }\n\n function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".transactions[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawTx1559 memory rawTx = abi.decode(parsedDeployData, (RawTx1559));\n return rawToConvertedEIPTx1559(rawTx);\n }\n\n // Analogous to readTransactions, but for receipts.\n function readReceipts(string memory path) internal view virtual returns (Receipt[] memory) {\n string memory deployData = vm.readFile(path);\n bytes memory parsedDeployData = vm.parseJson(deployData, \".receipts\");\n RawReceipt[] memory rawReceipts = abi.decode(parsedDeployData, (RawReceipt[]));\n return rawToConvertedReceipts(rawReceipts);\n }\n\n function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory) {\n string memory deployData = vm.readFile(path);\n string memory key = string(abi.encodePacked(\".receipts[\", vm.toString(index), \"]\"));\n bytes memory parsedDeployData = vm.parseJson(deployData, key);\n RawReceipt memory rawReceipt = abi.decode(parsedDeployData, (RawReceipt));\n return rawToConvertedReceipt(rawReceipt);\n }\n\n function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory) {\n Receipt[] memory receipts = new Receipt[](rawReceipts.length);\n for (uint256 i; i < rawReceipts.length; i++) {\n receipts[i] = rawToConvertedReceipt(rawReceipts[i]);\n }\n return receipts;\n }\n\n function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory) {\n Receipt memory receipt;\n receipt.blockHash = rawReceipt.blockHash;\n receipt.to = rawReceipt.to;\n receipt.from = rawReceipt.from;\n receipt.contractAddress = rawReceipt.contractAddress;\n receipt.effectiveGasPrice = _bytesToUint(rawReceipt.effectiveGasPrice);\n receipt.cumulativeGasUsed = _bytesToUint(rawReceipt.cumulativeGasUsed);\n receipt.gasUsed = _bytesToUint(rawReceipt.gasUsed);\n receipt.status = _bytesToUint(rawReceipt.status);\n receipt.transactionIndex = _bytesToUint(rawReceipt.transactionIndex);\n receipt.blockNumber = _bytesToUint(rawReceipt.blockNumber);\n receipt.logs = rawToConvertedReceiptLogs(rawReceipt.logs);\n receipt.logsBloom = rawReceipt.logsBloom;\n receipt.transactionHash = rawReceipt.transactionHash;\n return receipt;\n }\n\n function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)\n internal\n pure\n virtual\n returns (ReceiptLog[] memory)\n {\n ReceiptLog[] memory logs = new ReceiptLog[](rawLogs.length);\n for (uint256 i; i < rawLogs.length; i++) {\n logs[i].logAddress = rawLogs[i].logAddress;\n logs[i].blockHash = rawLogs[i].blockHash;\n logs[i].blockNumber = _bytesToUint(rawLogs[i].blockNumber);\n logs[i].data = rawLogs[i].data;\n logs[i].logIndex = _bytesToUint(rawLogs[i].logIndex);\n logs[i].topics = rawLogs[i].topics;\n logs[i].transactionIndex = _bytesToUint(rawLogs[i].transactionIndex);\n logs[i].transactionLogIndex = _bytesToUint(rawLogs[i].transactionLogIndex);\n logs[i].removed = rawLogs[i].removed;\n }\n return logs;\n }\n\n // Deploy a contract by fetching the contract bytecode from\n // the artifacts directory\n // e.g. `deployCode(code, abi.encode(arg1,arg2,arg3))`\n function deployCode(string memory what, bytes memory args) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes): Deployment failed.\");\n }\n\n function deployCode(string memory what) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(0, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string): Deployment failed.\");\n }\n\n /// @dev deploy contract with value on construction\n function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = abi.encodePacked(vm.getCode(what), args);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,bytes,uint256): Deployment failed.\");\n }\n\n function deployCode(string memory what, uint256 val) internal virtual returns (address addr) {\n bytes memory bytecode = vm.getCode(what);\n /// @solidity memory-safe-assembly\n assembly {\n addr := create(val, add(bytecode, 0x20), mload(bytecode))\n }\n\n require(addr != address(0), \"StdCheats deployCode(string,uint256): Deployment failed.\");\n }\n\n // creates a labeled address and the corresponding private key\n function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey) {\n privateKey = uint256(keccak256(abi.encodePacked(name)));\n addr = vm.addr(privateKey);\n vm.label(addr, name);\n }\n\n // creates a labeled address\n function makeAddr(string memory name) internal virtual returns (address addr) {\n (addr,) = makeAddrAndKey(name);\n }\n\n function deriveRememberKey(string memory mnemonic, uint32 index)\n internal\n virtual\n returns (address who, uint256 privateKey)\n {\n privateKey = vm.deriveKey(mnemonic, index);\n who = vm.rememberKey(privateKey);\n }\n\n function _bytesToUint(bytes memory b) private pure returns (uint256) {\n require(b.length <= 32, \"StdCheats _bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n function isFork() internal view virtual returns (bool status) {\n try vm.activeFork() {\n status = true;\n } catch (bytes memory) {}\n }\n\n modifier skipWhenForking() {\n if (!isFork()) {\n _;\n }\n }\n\n modifier skipWhenNotForking() {\n if (isFork()) {\n _;\n }\n }\n\n modifier noGasMetering() {\n vm.pauseGasMetering();\n // To prevent turning gas monitoring back on with nested functions that use this modifier,\n // we check if gasMetering started in the off position. If it did, we don't want to turn\n // it back on until we exit the top level function that used the modifier\n //\n // i.e. funcA() noGasMetering { funcB() }, where funcB has noGasMetering as well.\n // funcA will have `gasStartedOff` as false, funcB will have it as true,\n // so we only turn metering back on at the end of the funcA\n bool gasStartedOff = gasMeteringOff;\n gasMeteringOff = true;\n\n _;\n\n // if gas metering was on when this modifier was called, turn it back on at the end\n if (!gasStartedOff) {\n gasMeteringOff = false;\n vm.resumeGasMetering();\n }\n }\n\n // a cheat for fuzzing addresses that are payable only\n // see https://github.com/foundry-rs/foundry/issues/3631\n function assumePayable(address addr) internal virtual {\n (bool success,) = payable(addr).call{value: 0}(\"\");\n vm.assume(success);\n }\n}\n\n// Wrappers around cheatcodes to avoid footguns\nabstract contract StdCheats is StdCheatsSafe {\n using stdStorage for StdStorage;\n\n StdStorage private stdstore;\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n // Skip forward or rewind time by the specified number of seconds\n function skip(uint256 time) internal virtual {\n vm.warp(block.timestamp + time);\n }\n\n function rewind(uint256 time) internal virtual {\n vm.warp(block.timestamp - time);\n }\n\n // Setup a prank from an address that has some ether\n function hoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender);\n }\n\n function hoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.prank(msgSender, origin);\n }\n\n function hoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.prank(msgSender, origin);\n }\n\n // Start perpetual prank from an address that has some ether\n function startHoax(address msgSender) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender);\n }\n\n function startHoax(address msgSender, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender);\n }\n\n // Start perpetual prank from an address that has some ether\n // tx.origin is set to the origin parameter\n function startHoax(address msgSender, address origin) internal virtual {\n vm.deal(msgSender, 1 << 128);\n vm.startPrank(msgSender, origin);\n }\n\n function startHoax(address msgSender, address origin, uint256 give) internal virtual {\n vm.deal(msgSender, give);\n vm.startPrank(msgSender, origin);\n }\n\n function changePrank(address msgSender) internal virtual {\n vm.stopPrank();\n vm.startPrank(msgSender);\n }\n\n // The same as Vm's `deal`\n // Use the alternative signature for ERC20 tokens\n function deal(address to, uint256 give) internal virtual {\n vm.deal(to, give);\n }\n\n // Set the balance of an account for any ERC20 token\n // Use the alternative signature to update `totalSupply`\n function deal(address token, address to, uint256 give) internal virtual {\n deal(token, to, give, false);\n }\n\n // Set the balance of an account for any ERC1155 token\n // Use the alternative signature to update `totalSupply`\n function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual {\n dealERC1155(token, to, id, give, false);\n }\n\n function deal(address token, address to, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0x18160ddd));\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0x18160ddd).checked_write(totSup);\n }\n }\n\n function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual {\n // get current balance\n (, bytes memory balData) = token.call(abi.encodeWithSelector(0x00fdd58e, to, id));\n uint256 prevBal = abi.decode(balData, (uint256));\n\n // update balance\n stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);\n\n // update total supply\n if (adjust) {\n (, bytes memory totSupData) = token.call(abi.encodeWithSelector(0xbd85b039, id));\n require(\n totSupData.length != 0,\n \"StdCheats deal(address,address,uint,uint,bool): target contract is not ERC1155Supply.\"\n );\n uint256 totSup = abi.decode(totSupData, (uint256));\n if (give < prevBal) {\n totSup -= (prevBal - give);\n } else {\n totSup += (give - prevBal);\n }\n stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);\n }\n }\n\n function dealERC721(address token, address to, uint256 id) internal virtual {\n // check if token id is already minted and the actual owner.\n (bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id));\n require(successMinted, \"StdCheats deal(address,address,uint,bool): id not minted.\");\n\n // get owner current balance\n (, bytes memory fromBalData) = token.call(abi.encodeWithSelector(0x70a08231, abi.decode(ownerData, (address))));\n uint256 fromPrevBal = abi.decode(fromBalData, (uint256));\n\n // get new user current balance\n (, bytes memory toBalData) = token.call(abi.encodeWithSelector(0x70a08231, to));\n uint256 toPrevBal = abi.decode(toBalData, (uint256));\n\n // update balances\n stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);\n stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);\n\n // update owner\n stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);\n }\n}\n" + }, + "forge-std/StdError.sol": { + "content": "// SPDX-License-Identifier: MIT\n// Panics work for versions >=0.8.0, but we lowered the pragma to make this compatible with Test\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdError {\n bytes public constant assertionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x01);\n bytes public constant arithmeticError = abi.encodeWithSignature(\"Panic(uint256)\", 0x11);\n bytes public constant divisionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x12);\n bytes public constant enumConversionError = abi.encodeWithSignature(\"Panic(uint256)\", 0x21);\n bytes public constant encodeStorageError = abi.encodeWithSignature(\"Panic(uint256)\", 0x22);\n bytes public constant popError = abi.encodeWithSignature(\"Panic(uint256)\", 0x31);\n bytes public constant indexOOBError = abi.encodeWithSignature(\"Panic(uint256)\", 0x32);\n bytes public constant memOverflowError = abi.encodeWithSignature(\"Panic(uint256)\", 0x41);\n bytes public constant zeroVarError = abi.encodeWithSignature(\"Panic(uint256)\", 0x51);\n}\n" + }, + "forge-std/StdInvariant.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\ncontract StdInvariant {\n struct FuzzSelector {\n address addr;\n bytes4[] selectors;\n }\n\n address[] private _excludedContracts;\n address[] private _excludedSenders;\n address[] private _targetedContracts;\n address[] private _targetedSenders;\n\n string[] private _excludedArtifacts;\n string[] private _targetedArtifacts;\n\n FuzzSelector[] private _targetedArtifactSelectors;\n FuzzSelector[] private _targetedSelectors;\n\n // Functions for users:\n // These are intended to be called in tests.\n\n function excludeContract(address newExcludedContract_) internal {\n _excludedContracts.push(newExcludedContract_);\n }\n\n function excludeSender(address newExcludedSender_) internal {\n _excludedSenders.push(newExcludedSender_);\n }\n\n function excludeArtifact(string memory newExcludedArtifact_) internal {\n _excludedArtifacts.push(newExcludedArtifact_);\n }\n\n function targetArtifact(string memory newTargetedArtifact_) internal {\n _targetedArtifacts.push(newTargetedArtifact_);\n }\n\n function targetArtifactSelector(FuzzSelector memory newTargetedArtifactSelector_) internal {\n _targetedArtifactSelectors.push(newTargetedArtifactSelector_);\n }\n\n function targetContract(address newTargetedContract_) internal {\n _targetedContracts.push(newTargetedContract_);\n }\n\n function targetSelector(FuzzSelector memory newTargetedSelector_) internal {\n _targetedSelectors.push(newTargetedSelector_);\n }\n\n function targetSender(address newTargetedSender_) internal {\n _targetedSenders.push(newTargetedSender_);\n }\n\n // Functions for forge:\n // These are called by forge to run invariant tests and don't need to be called in tests.\n\n function excludeArtifacts() public view returns (string[] memory excludedArtifacts_) {\n excludedArtifacts_ = _excludedArtifacts;\n }\n\n function excludeContracts() public view returns (address[] memory excludedContracts_) {\n excludedContracts_ = _excludedContracts;\n }\n\n function excludeSenders() public view returns (address[] memory excludedSenders_) {\n excludedSenders_ = _excludedSenders;\n }\n\n function targetArtifacts() public view returns (string[] memory targetedArtifacts_) {\n targetedArtifacts_ = _targetedArtifacts;\n }\n\n function targetArtifactSelectors() public view returns (FuzzSelector[] memory targetedArtifactSelectors_) {\n targetedArtifactSelectors_ = _targetedArtifactSelectors;\n }\n\n function targetContracts() public view returns (address[] memory targetedContracts_) {\n targetedContracts_ = _targetedContracts;\n }\n\n function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_) {\n targetedSelectors_ = _targetedSelectors;\n }\n\n function targetSenders() public view returns (address[] memory targetedSenders_) {\n targetedSenders_ = _targetedSenders;\n }\n}\n" + }, + "forge-std/StdJson.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {VmSafe} from \"./Vm.sol\";\n\n// Helpers for parsing and writing JSON files\n// To parse:\n// ```\n// using stdJson for string;\n// string memory json = vm.readFile(\"some_peth\");\n// json.parseUint(\"\");\n// ```\n// To write:\n// ```\n// using stdJson for string;\n// string memory json = \"deploymentArtifact\";\n// Contract contract = new Contract();\n// json.serialize(\"contractAddress\", address(contract));\n// json = json.serialize(\"deploymentTimes\", uint(1));\n// // store the stringified JSON to the 'json' variable we have been using as a key\n// // as we won't need it any longer\n// string memory json2 = \"finalArtifact\";\n// string memory final = json2.serialize(\"depArtifact\", json);\n// final.write(\"\");\n// ```\n\nlibrary stdJson {\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {\n return vm.parseJson(json, key);\n }\n\n function readUint(string memory json, string memory key) internal returns (uint256) {\n return vm.parseJsonUint(json, key);\n }\n\n function readUintArray(string memory json, string memory key) internal returns (uint256[] memory) {\n return vm.parseJsonUintArray(json, key);\n }\n\n function readInt(string memory json, string memory key) internal returns (int256) {\n return vm.parseJsonInt(json, key);\n }\n\n function readIntArray(string memory json, string memory key) internal returns (int256[] memory) {\n return vm.parseJsonIntArray(json, key);\n }\n\n function readBytes32(string memory json, string memory key) internal returns (bytes32) {\n return vm.parseJsonBytes32(json, key);\n }\n\n function readBytes32Array(string memory json, string memory key) internal returns (bytes32[] memory) {\n return vm.parseJsonBytes32Array(json, key);\n }\n\n function readString(string memory json, string memory key) internal returns (string memory) {\n return vm.parseJsonString(json, key);\n }\n\n function readStringArray(string memory json, string memory key) internal returns (string[] memory) {\n return vm.parseJsonStringArray(json, key);\n }\n\n function readAddress(string memory json, string memory key) internal returns (address) {\n return vm.parseJsonAddress(json, key);\n }\n\n function readAddressArray(string memory json, string memory key) internal returns (address[] memory) {\n return vm.parseJsonAddressArray(json, key);\n }\n\n function readBool(string memory json, string memory key) internal returns (bool) {\n return vm.parseJsonBool(json, key);\n }\n\n function readBoolArray(string memory json, string memory key) internal returns (bool[] memory) {\n return vm.parseJsonBoolArray(json, key);\n }\n\n function readBytes(string memory json, string memory key) internal returns (bytes memory) {\n return vm.parseJsonBytes(json, key);\n }\n\n function readBytesArray(string memory json, string memory key) internal returns (bytes[] memory) {\n return vm.parseJsonBytesArray(json, key);\n }\n\n function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory) {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bool[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBool(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory) {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, uint256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeUint(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory) {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, int256[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeInt(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory) {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, address[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeAddress(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory) {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes32[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes32(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory) {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, bytes[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeBytes(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function serialize(string memory jsonKey, string memory key, string[] memory value)\n internal\n returns (string memory)\n {\n return vm.serializeString(jsonKey, key, value);\n }\n\n function write(string memory jsonKey, string memory path) internal {\n vm.writeJson(jsonKey, path);\n }\n\n function write(string memory jsonKey, string memory path, string memory valueKey) internal {\n vm.writeJson(jsonKey, path, valueKey);\n }\n}\n" + }, + "forge-std/StdMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nlibrary stdMath {\n int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;\n\n function abs(int256 a) internal pure returns (uint256) {\n // Required or it will fail when `a = type(int256).min`\n if (a == INT256_MIN) {\n return 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n }\n\n return uint256(a > 0 ? a : -a);\n }\n\n function delta(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a - b : b - a;\n }\n\n function delta(int256 a, int256 b) internal pure returns (uint256) {\n // a and b are of the same sign\n // this works thanks to two's complement, the left-most bit is the sign bit\n if ((a ^ b) > -1) {\n return delta(abs(a), abs(b));\n }\n\n // a and b are of opposite signs\n return abs(a) + abs(b);\n }\n\n function percentDelta(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n\n return absDelta * 1e18 / b;\n }\n\n function percentDelta(int256 a, int256 b) internal pure returns (uint256) {\n uint256 absDelta = delta(a, b);\n uint256 absB = abs(b);\n\n return absDelta * 1e18 / absB;\n }\n}\n" + }, + "forge-std/StdStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nstruct StdStorage {\n mapping(address => mapping(bytes4 => mapping(bytes32 => uint256))) slots;\n mapping(address => mapping(bytes4 => mapping(bytes32 => bool))) finds;\n bytes32[] _keys;\n bytes4 _sig;\n uint256 _depth;\n address _target;\n bytes32 _set;\n}\n\nlibrary stdStorageSafe {\n event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);\n event WARNING_UninitedSlot(address who, uint256 slot);\n\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return bytes4(keccak256(bytes(sigStr)));\n }\n\n /// @notice find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against\n // slot complexity:\n // if flat, will be bytes32(uint256(uint));\n // if map, will be keccak256(abi.encode(key, uint(slot)));\n // if deep map, will be keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))));\n // if map struct, will be bytes32(uint256(keccak256(abi.encode(key1, keccak256(abi.encode(key0, uint(slot)))))) + structFieldDepth);\n function find(StdStorage storage self) internal returns (uint256) {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n // calldata to test against\n if (self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n vm.record();\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n (bytes32[] memory reads,) = vm.accesses(address(who));\n if (reads.length == 1) {\n bytes32 curr = vm.load(who, reads[0]);\n if (curr == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[0]));\n }\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[0]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[0]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n } else if (reads.length > 1) {\n for (uint256 i = 0; i < reads.length; i++) {\n bytes32 prev = vm.load(who, reads[i]);\n if (prev == bytes32(0)) {\n emit WARNING_UninitedSlot(who, uint256(reads[i]));\n }\n // store\n vm.store(who, reads[i], bytes32(hex\"1337\"));\n bool success;\n bytes memory rdat;\n {\n (success, rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n\n if (success && fdat == bytes32(hex\"1337\")) {\n // we found which of the slots is the actual one\n emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[i]));\n self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[i]);\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;\n vm.store(who, reads[i], prev);\n break;\n }\n vm.store(who, reads[i], prev);\n }\n } else {\n revert(\"stdStorage find(StdStorage): No storage use detected for target.\");\n }\n\n require(\n self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))],\n \"stdStorage find(StdStorage): Slot(s) not found.\"\n );\n\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n\n return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n self._target = _target;\n return self;\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n self._sig = _sig;\n return self;\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n self._sig = sigs(_sig);\n return self;\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n self._keys.push(bytes32(uint256(uint160(who))));\n return self;\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n self._keys.push(bytes32(amt));\n return self;\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n self._keys.push(key);\n return self;\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n self._depth = _depth;\n return self;\n }\n\n function read(StdStorage storage self) private returns (bytes memory) {\n address t = self._target;\n uint256 s = find(self);\n return abi.encode(vm.load(t, bytes32(s)));\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return abi.decode(read(self), (bytes32));\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n int256 v = read_int(self);\n if (v == 0) return false;\n if (v == 1) return true;\n revert(\"stdStorage read_bool(StdStorage): Cannot decode. Make sure you are reading a bool.\");\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return abi.decode(read(self), (address));\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return abi.decode(read(self), (uint256));\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return abi.decode(read(self), (int256));\n }\n\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n\nlibrary stdStorage {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n function sigs(string memory sigStr) internal pure returns (bytes4) {\n return stdStorageSafe.sigs(sigStr);\n }\n\n function find(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.find(self);\n }\n\n function target(StdStorage storage self, address _target) internal returns (StdStorage storage) {\n return stdStorageSafe.target(self, _target);\n }\n\n function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage) {\n return stdStorageSafe.sig(self, _sig);\n }\n\n function with_key(StdStorage storage self, address who) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, who);\n }\n\n function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, amt);\n }\n\n function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage) {\n return stdStorageSafe.with_key(self, key);\n }\n\n function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage) {\n return stdStorageSafe.depth(self, _depth);\n }\n\n function checked_write(StdStorage storage self, address who) internal {\n checked_write(self, bytes32(uint256(uint160(who))));\n }\n\n function checked_write(StdStorage storage self, uint256 amt) internal {\n checked_write(self, bytes32(amt));\n }\n\n function checked_write(StdStorage storage self, bool write) internal {\n bytes32 t;\n /// @solidity memory-safe-assembly\n assembly {\n t := write\n }\n checked_write(self, t);\n }\n\n function checked_write(StdStorage storage self, bytes32 set) internal {\n address who = self._target;\n bytes4 fsig = self._sig;\n uint256 field_depth = self._depth;\n bytes32[] memory ins = self._keys;\n\n bytes memory cald = abi.encodePacked(fsig, flatten(ins));\n if (!self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]) {\n find(self);\n }\n bytes32 slot = bytes32(self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))]);\n\n bytes32 fdat;\n {\n (, bytes memory rdat) = who.staticcall(cald);\n fdat = bytesToBytes32(rdat, 32 * field_depth);\n }\n bytes32 curr = vm.load(who, slot);\n\n if (fdat != curr) {\n require(\n false,\n \"stdStorage find(StdStorage): Packed slot. This would cause dangerous overwriting and currently isn't supported.\"\n );\n }\n vm.store(who, slot, set);\n delete self._target;\n delete self._sig;\n delete self._keys;\n delete self._depth;\n }\n\n function read_bytes32(StdStorage storage self) internal returns (bytes32) {\n return stdStorageSafe.read_bytes32(self);\n }\n\n function read_bool(StdStorage storage self) internal returns (bool) {\n return stdStorageSafe.read_bool(self);\n }\n\n function read_address(StdStorage storage self) internal returns (address) {\n return stdStorageSafe.read_address(self);\n }\n\n function read_uint(StdStorage storage self) internal returns (uint256) {\n return stdStorageSafe.read_uint(self);\n }\n\n function read_int(StdStorage storage self) internal returns (int256) {\n return stdStorageSafe.read_int(self);\n }\n\n // Private function so needs to be copied over\n function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {\n bytes32 out;\n\n uint256 max = b.length > 32 ? 32 : b.length;\n for (uint256 i = 0; i < max; i++) {\n out |= bytes32(b[offset + i] & 0xFF) >> (i * 8);\n }\n return out;\n }\n\n // Private function so needs to be copied over\n function flatten(bytes32[] memory b) private pure returns (bytes memory) {\n bytes memory result = new bytes(b.length * 32);\n for (uint256 i = 0; i < b.length; i++) {\n bytes32 k = b[i];\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(result, add(32, mul(32, i))), k)\n }\n }\n\n return result;\n }\n}\n" + }, + "forge-std/StdStyle.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.22 <0.9.0;\n\nimport {Vm} from \"./Vm.sol\";\n\nlibrary StdStyle {\n Vm private constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n\n string constant RED = \"\\u001b[91m\";\n string constant GREEN = \"\\u001b[92m\";\n string constant YELLOW = \"\\u001b[93m\";\n string constant BLUE = \"\\u001b[94m\";\n string constant MAGENTA = \"\\u001b[95m\";\n string constant CYAN = \"\\u001b[96m\";\n string constant BOLD = \"\\u001b[1m\";\n string constant DIM = \"\\u001b[2m\";\n string constant ITALIC = \"\\u001b[3m\";\n string constant UNDERLINE = \"\\u001b[4m\";\n string constant INVERSE = \"\\u001b[7m\";\n string constant RESET = \"\\u001b[0m\";\n\n function styleConcat(string memory style, string memory self) private pure returns (string memory) {\n return string(abi.encodePacked(style, self, RESET));\n }\n\n function red(string memory self) internal pure returns (string memory) {\n return styleConcat(RED, self);\n }\n\n function red(uint256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(int256 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(address self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function red(bool self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes(bytes memory self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function redBytes32(bytes32 self) internal pure returns (string memory) {\n return red(vm.toString(self));\n }\n\n function green(string memory self) internal pure returns (string memory) {\n return styleConcat(GREEN, self);\n }\n\n function green(uint256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(int256 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(address self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function green(bool self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes(bytes memory self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function greenBytes32(bytes32 self) internal pure returns (string memory) {\n return green(vm.toString(self));\n }\n\n function yellow(string memory self) internal pure returns (string memory) {\n return styleConcat(YELLOW, self);\n }\n\n function yellow(uint256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(int256 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(address self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellow(bool self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes(bytes memory self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function yellowBytes32(bytes32 self) internal pure returns (string memory) {\n return yellow(vm.toString(self));\n }\n\n function blue(string memory self) internal pure returns (string memory) {\n return styleConcat(BLUE, self);\n }\n\n function blue(uint256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(int256 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(address self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blue(bool self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes(bytes memory self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function blueBytes32(bytes32 self) internal pure returns (string memory) {\n return blue(vm.toString(self));\n }\n\n function magenta(string memory self) internal pure returns (string memory) {\n return styleConcat(MAGENTA, self);\n }\n\n function magenta(uint256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(int256 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(address self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magenta(bool self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes(bytes memory self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function magentaBytes32(bytes32 self) internal pure returns (string memory) {\n return magenta(vm.toString(self));\n }\n\n function cyan(string memory self) internal pure returns (string memory) {\n return styleConcat(CYAN, self);\n }\n\n function cyan(uint256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(int256 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(address self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyan(bool self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes(bytes memory self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function cyanBytes32(bytes32 self) internal pure returns (string memory) {\n return cyan(vm.toString(self));\n }\n\n function bold(string memory self) internal pure returns (string memory) {\n return styleConcat(BOLD, self);\n }\n\n function bold(uint256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(int256 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(address self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function bold(bool self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes(bytes memory self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function boldBytes32(bytes32 self) internal pure returns (string memory) {\n return bold(vm.toString(self));\n }\n\n function dim(string memory self) internal pure returns (string memory) {\n return styleConcat(DIM, self);\n }\n\n function dim(uint256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(int256 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(address self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dim(bool self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes(bytes memory self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function dimBytes32(bytes32 self) internal pure returns (string memory) {\n return dim(vm.toString(self));\n }\n\n function italic(string memory self) internal pure returns (string memory) {\n return styleConcat(ITALIC, self);\n }\n\n function italic(uint256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(int256 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(address self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italic(bool self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes(bytes memory self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function italicBytes32(bytes32 self) internal pure returns (string memory) {\n return italic(vm.toString(self));\n }\n\n function underline(string memory self) internal pure returns (string memory) {\n return styleConcat(UNDERLINE, self);\n }\n\n function underline(uint256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(int256 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(address self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underline(bool self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes(bytes memory self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function underlineBytes32(bytes32 self) internal pure returns (string memory) {\n return underline(vm.toString(self));\n }\n\n function inverse(string memory self) internal pure returns (string memory) {\n return styleConcat(INVERSE, self);\n }\n\n function inverse(uint256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(int256 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(address self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverse(bool self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes(bytes memory self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n\n function inverseBytes32(bytes32 self) internal pure returns (string memory) {\n return inverse(vm.toString(self));\n }\n}\n" + }, + "forge-std/StdUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\nimport {IMulticall3} from \"./interfaces/IMulticall3.sol\";\n// TODO Remove import.\nimport {VmSafe} from \"./Vm.sol\";\n\nabstract contract StdUtils {\n /*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n //////////////////////////////////////////////////////////////////////////*/\n\n IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);\n VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;\n uint256 private constant INT256_MIN_ABS =\n 57896044618658097711785492504343953926634992332820282019728792003956564819968;\n uint256 private constant UINT256_MAX =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n\n // Used by default when deploying with create2, https://github.com/Arachnid/deterministic-deployment-proxy.\n address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n /*//////////////////////////////////////////////////////////////////////////\n INTERNAL FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result) {\n require(min <= max, \"StdUtils bound(uint256,uint256,uint256): Max is less than min.\");\n // If x is between min and max, return x directly. This is to ensure that dictionary values\n // do not get shifted if the min is nonzero. More info: https://github.com/foundry-rs/forge-std/issues/188\n if (x >= min && x <= max) return x;\n\n uint256 size = max - min + 1;\n\n // If the value is 0, 1, 2, 3, warp that to min, min+1, min+2, min+3. Similarly for the UINT256_MAX side.\n // This helps ensure coverage of the min/max values.\n if (x <= 3 && size > x) return min + x;\n if (x >= UINT256_MAX - 3 && size > UINT256_MAX - x) return max - (UINT256_MAX - x);\n\n // Otherwise, wrap x into the range [min, max], i.e. the range is inclusive.\n if (x > max) {\n uint256 diff = x - max;\n uint256 rem = diff % size;\n if (rem == 0) return max;\n result = min + rem - 1;\n } else if (x < min) {\n uint256 diff = min - x;\n uint256 rem = diff % size;\n if (rem == 0) return min;\n result = max - rem + 1;\n }\n }\n\n function bound(uint256 x, uint256 min, uint256 max) internal view virtual returns (uint256 result) {\n result = _bound(x, min, max);\n console2_log(\"Bound Result\", result);\n }\n\n function bound(int256 x, int256 min, int256 max) internal view virtual returns (int256 result) {\n require(min <= max, \"StdUtils bound(int256,int256,int256): Max is less than min.\");\n\n // Shifting all int256 values to uint256 to use _bound function. The range of two types are:\n // int256 : -(2**255) ~ (2**255 - 1)\n // uint256: 0 ~ (2**256 - 1)\n // So, add 2**255, INT256_MIN_ABS to the integer values.\n //\n // If the given integer value is -2**255, we cannot use `-uint256(-x)` because of the overflow.\n // So, use `~uint256(x) + 1` instead.\n uint256 _x = x < 0 ? (INT256_MIN_ABS - ~uint256(x) - 1) : (uint256(x) + INT256_MIN_ABS);\n uint256 _min = min < 0 ? (INT256_MIN_ABS - ~uint256(min) - 1) : (uint256(min) + INT256_MIN_ABS);\n uint256 _max = max < 0 ? (INT256_MIN_ABS - ~uint256(max) - 1) : (uint256(max) + INT256_MIN_ABS);\n\n uint256 y = _bound(_x, _min, _max);\n\n // To move it back to int256 value, subtract INT256_MIN_ABS at here.\n result = y < INT256_MIN_ABS ? int256(~(INT256_MIN_ABS - y) + 1) : int256(y - INT256_MIN_ABS);\n console2_log(\"Bound result\", vm.toString(result));\n }\n\n function bytesToUint(bytes memory b) internal pure virtual returns (uint256) {\n require(b.length <= 32, \"StdUtils bytesToUint(bytes): Bytes length exceeds 32.\");\n return abi.decode(abi.encodePacked(new bytes(32 - b.length), b), (uint256));\n }\n\n /// @dev Compute the address a contract will be deployed at for a given deployer address and nonce\n /// @notice adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)\n function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address) {\n // forgefmt: disable-start\n // The integer zero is treated as an empty byte string, and as a result it only has a length prefix, 0x80, computed via 0x80 + 0.\n // A one byte integer uses its own value as its length prefix, there is no additional \"0x80 + length\" prefix that comes before it.\n if (nonce == 0x00) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, bytes1(0x80))));\n if (nonce <= 0x7f) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd6), bytes1(0x94), deployer, uint8(nonce))));\n\n // Nonces greater than 1 byte all follow a consistent encoding scheme, where each value is preceded by a prefix of 0x80 + length.\n if (nonce <= 2**8 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd7), bytes1(0x94), deployer, bytes1(0x81), uint8(nonce))));\n if (nonce <= 2**16 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd8), bytes1(0x94), deployer, bytes1(0x82), uint16(nonce))));\n if (nonce <= 2**24 - 1) return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xd9), bytes1(0x94), deployer, bytes1(0x83), uint24(nonce))));\n // forgefmt: disable-end\n\n // More details about RLP encoding can be found here: https://eth.wiki/fundamentals/rlp\n // 0xda = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x84 ++ nonce)\n // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex)\n // 0x84 = 0x80 + 0x04 (0x04 = the bytes length of the nonce, 4 bytes, in hex)\n // We assume nobody can have a nonce large enough to require more than 32 bytes.\n return addressFromLast20Bytes(\n keccak256(abi.encodePacked(bytes1(0xda), bytes1(0x94), deployer, bytes1(0x84), uint32(nonce)))\n );\n }\n\n function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)\n internal\n pure\n virtual\n returns (address)\n {\n return addressFromLast20Bytes(keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, initcodeHash)));\n }\n\n /// @dev returns the address of a contract created with CREATE2 using the default CREATE2 deployer\n function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address) {\n return computeCreate2Address(salt, initCodeHash, CREATE2_FACTORY);\n }\n\n /// @dev returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n function hashInitCode(bytes memory creationCode) internal pure returns (bytes32) {\n return hashInitCode(creationCode, \"\");\n }\n\n /// @dev returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2\n /// @param creationCode the creation code of a contract C, as returned by type(C).creationCode\n /// @param args the ABI-encoded arguments to the constructor of C\n function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(creationCode, args));\n }\n\n // Performs a single call with Multicall3 to query the ERC-20 token balances of the given addresses.\n function getTokenBalances(address token, address[] memory addresses)\n internal\n virtual\n returns (uint256[] memory balances)\n {\n uint256 tokenCodeSize;\n assembly {\n tokenCodeSize := extcodesize(token)\n }\n require(tokenCodeSize > 0, \"StdUtils getTokenBalances(address,address[]): Token address is not a contract.\");\n\n // ABI encode the aggregate call to Multicall3.\n uint256 length = addresses.length;\n IMulticall3.Call[] memory calls = new IMulticall3.Call[](length);\n for (uint256 i = 0; i < length; ++i) {\n // 0x70a08231 = bytes4(\"balanceOf(address)\"))\n calls[i] = IMulticall3.Call({target: token, callData: abi.encodeWithSelector(0x70a08231, (addresses[i]))});\n }\n\n // Make the aggregate call.\n (, bytes[] memory returnData) = multicall.aggregate(calls);\n\n // ABI decode the return data and return the balances.\n balances = new uint256[](length);\n for (uint256 i = 0; i < length; ++i) {\n balances[i] = abi.decode(returnData[i], (uint256));\n }\n }\n\n /*//////////////////////////////////////////////////////////////////////////\n PRIVATE FUNCTIONS\n //////////////////////////////////////////////////////////////////////////*/\n\n function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address) {\n return address(uint160(uint256(bytesValue)));\n }\n\n // Used to prevent the compilation of console, which shortens the compilation time when console is not used elsewhere.\n\n function console2_log(string memory p0, uint256 p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n status;\n }\n\n function console2_log(string memory p0, string memory p1) private view {\n (bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n status;\n }\n}\n" + }, + "forge-std/Test.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// 💬 ABOUT\n// Standard Library's default Test\n\n// 🧩 MODULES\nimport {console} from \"./console.sol\";\nimport {console2} from \"./console2.sol\";\nimport {StdAssertions} from \"./StdAssertions.sol\";\nimport {StdChains} from \"./StdChains.sol\";\nimport {StdCheats} from \"./StdCheats.sol\";\nimport {stdError} from \"./StdError.sol\";\nimport {StdInvariant} from \"./StdInvariant.sol\";\nimport {stdJson} from \"./StdJson.sol\";\nimport {stdMath} from \"./StdMath.sol\";\nimport {StdStorage, stdStorage} from \"./StdStorage.sol\";\nimport {StdUtils} from \"./StdUtils.sol\";\nimport {Vm} from \"./Vm.sol\";\nimport {StdStyle} from \"./StdStyle.sol\";\n\n// 📦 BOILERPLATE\nimport {TestBase} from \"./Base.sol\";\nimport {DSTest} from \"ds-test/test.sol\";\n\n// ⭐️ TEST\nabstract contract Test is DSTest, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils, TestBase {\n// Note: IS_TEST() must return true.\n// Note: Must have failure system, https://github.com/dapphub/ds-test/blob/cd98eff28324bfac652e63a239a60632a761790b/src/test.sol#L39-L76.\n}\n" + }, + "forge-std/Vm.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.2 <0.9.0;\n\npragma experimental ABIEncoderV2;\n\n// Cheatcodes are marked as view/pure/none using the following rules:\n// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,\n// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure (you are modifying some state be it the EVM, interpreter, filesystem, etc),\n// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,\n// 3. Otherwise you're `pure`.\n\ninterface VmSafe {\n struct Log {\n bytes32[] topics;\n bytes data;\n address emitter;\n }\n\n struct Rpc {\n string key;\n string url;\n }\n\n struct FsMetadata {\n bool isDir;\n bool isSymlink;\n uint256 length;\n bool readOnly;\n uint256 modified;\n uint256 accessed;\n uint256 created;\n }\n\n // Loads a storage slot from an address\n function load(address target, bytes32 slot) external view returns (bytes32 data);\n // Signs data\n function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);\n // Gets the address for a given private key\n function addr(uint256 privateKey) external pure returns (address keyAddr);\n // Gets the nonce of an account\n function getNonce(address account) external view returns (uint64 nonce);\n // Performs a foreign function call via the terminal\n function ffi(string[] calldata commandInput) external returns (bytes memory result);\n // Sets environment variables\n function setEnv(string calldata name, string calldata value) external;\n // Reads environment variables, (name) => (value)\n function envBool(string calldata name) external view returns (bool value);\n function envUint(string calldata name) external view returns (uint256 value);\n function envInt(string calldata name) external view returns (int256 value);\n function envAddress(string calldata name) external view returns (address value);\n function envBytes32(string calldata name) external view returns (bytes32 value);\n function envString(string calldata name) external view returns (string memory value);\n function envBytes(string calldata name) external view returns (bytes memory value);\n // Reads environment variables as arrays\n function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);\n function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);\n function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);\n function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);\n function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);\n function envString(string calldata name, string calldata delim) external view returns (string[] memory value);\n function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);\n // Read environment variables with default value\n function envOr(string calldata name, bool defaultValue) external returns (bool value);\n function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);\n function envOr(string calldata name, int256 defaultValue) external returns (int256 value);\n function envOr(string calldata name, address defaultValue) external returns (address value);\n function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);\n function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);\n function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);\n // Read environment variables as arrays with default value\n function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)\n external\n returns (bool[] memory value);\n function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)\n external\n returns (uint256[] memory value);\n function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)\n external\n returns (int256[] memory value);\n function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)\n external\n returns (address[] memory value);\n function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)\n external\n returns (bytes32[] memory value);\n function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)\n external\n returns (string[] memory value);\n function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)\n external\n returns (bytes[] memory value);\n // Records all storage reads and writes\n function record() external;\n // Gets all accessed reads and write slot from a recording session, for a given address\n function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);\n // Gets the _creation_ bytecode from an artifact file. Takes in the relative path to the json file\n function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);\n // Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file\n function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);\n // Labels an address in call traces\n function label(address account, string calldata newLabel) external;\n // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain\n function broadcast() external;\n // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain\n function broadcast(address signer) external;\n // Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain\n function broadcast(uint256 privateKey) external;\n // Using the address that calls the test contract, has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain\n function startBroadcast() external;\n // Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain\n function startBroadcast(address signer) external;\n // Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain\n function startBroadcast(uint256 privateKey) external;\n // Stops collecting onchain transactions\n function stopBroadcast() external;\n // Reads the entire content of file to string\n function readFile(string calldata path) external view returns (string memory data);\n // Reads the entire content of file as binary. Path is relative to the project root.\n function readFileBinary(string calldata path) external view returns (bytes memory data);\n // Get the path of the current project root\n function projectRoot() external view returns (string memory path);\n // Get the metadata for a file/directory\n function fsMetadata(string calldata fileOrDir) external returns (FsMetadata memory metadata);\n // Reads next line of file to string\n function readLine(string calldata path) external view returns (string memory line);\n // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n function writeFile(string calldata path, string calldata data) external;\n // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n // Path is relative to the project root.\n function writeFileBinary(string calldata path, bytes calldata data) external;\n // Writes line to file, creating a file if it does not exist.\n function writeLine(string calldata path, string calldata data) external;\n // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n function closeFile(string calldata path) external;\n // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases:\n // - Path points to a directory.\n // - The file doesn't exist.\n // - The user lacks permissions to remove the file.\n function removeFile(string calldata path) external;\n // Convert values to a string\n function toString(address value) external pure returns (string memory stringifiedValue);\n function toString(bytes calldata value) external pure returns (string memory stringifiedValue);\n function toString(bytes32 value) external pure returns (string memory stringifiedValue);\n function toString(bool value) external pure returns (string memory stringifiedValue);\n function toString(uint256 value) external pure returns (string memory stringifiedValue);\n function toString(int256 value) external pure returns (string memory stringifiedValue);\n // Convert values from a string\n function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);\n function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);\n function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);\n function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);\n function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);\n function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);\n // Record all the transaction logs\n function recordLogs() external;\n // Gets all the recorded logs\n function getRecordedLogs() external returns (Log[] memory logs);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation path m/44'/60'/0'/0/{index}\n function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);\n // Derive a private key from a provided mnenomic string (or mnenomic file path) at {derivationPath}{index}\n function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)\n external\n pure\n returns (uint256 privateKey);\n // Adds a private key to the local forge wallet and returns the address\n function rememberKey(uint256 privateKey) external returns (address keyAddr);\n //\n // parseJson\n //\n // ----\n // In case the returned value is a JSON object, it's encoded as a ABI-encoded tuple. As JSON objects\n // don't have the notion of ordered, but tuples do, they JSON object is encoded with it's fields ordered in\n // ALPHABETICAL order. That means that in order to successfully decode the tuple, we need to define a tuple that\n // encodes the fields in the same order, which is alphabetical. In the case of Solidity structs, they are encoded\n // as tuples, with the attributes in the order in which they are defined.\n // For example: json = { 'a': 1, 'b': 0xa4tb......3xs}\n // a: uint256\n // b: address\n // To decode that json, we need to define a struct or a tuple as follows:\n // struct json = { uint256 a; address b; }\n // If we defined a json struct with the opposite order, meaning placing the address b first, it would try to\n // decode the tuple in that order, and thus fail.\n // ----\n // Given a string of JSON, return it as ABI-encoded\n function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);\n function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);\n\n // The following parseJson cheatcodes will do type coercion, for the type that they indicate.\n // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12'\n // and hex numbers '0xEF'.\n // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not\n // a JSON object.\n function parseJsonUint(string calldata, string calldata) external returns (uint256);\n function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);\n function parseJsonInt(string calldata, string calldata) external returns (int256);\n function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);\n function parseJsonBool(string calldata, string calldata) external returns (bool);\n function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);\n function parseJsonAddress(string calldata, string calldata) external returns (address);\n function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);\n function parseJsonString(string calldata, string calldata) external returns (string memory);\n function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);\n function parseJsonBytes(string calldata, string calldata) external returns (bytes memory);\n function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory);\n function parseJsonBytes32(string calldata, string calldata) external returns (bytes32);\n function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory);\n\n // Serialize a key and value to a JSON object stored in-memory that can be later written to a file\n // It returns the stringified version of the specific JSON file up to that moment.\n function serializeBool(string calldata objectKey, string calldata valueKey, bool value)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address value)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)\n external\n returns (string memory json);\n\n function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)\n external\n returns (string memory json);\n function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)\n external\n returns (string memory json);\n function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)\n external\n returns (string memory json);\n function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)\n external\n returns (string memory json);\n function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)\n external\n returns (string memory json);\n function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)\n external\n returns (string memory json);\n function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)\n external\n returns (string memory json);\n\n //\n // writeJson\n //\n // ----\n // Write a serialized JSON object to a file. If the file exists, it will be overwritten.\n // Let's assume we want to write the following JSON to a file:\n //\n // { \"boolean\": true, \"number\": 342, \"object\": { \"title\": \"finally json serialization\" } }\n //\n // ```\n // string memory json1 = \"some key\";\n // vm.serializeBool(json1, \"boolean\", true);\n // vm.serializeBool(json1, \"number\", uint256(342));\n // json2 = \"some other key\";\n // string memory output = vm.serializeString(json2, \"title\", \"finally json serialization\");\n // string memory finalJson = vm.serialize(json1, \"object\", output);\n // vm.writeJson(finalJson, \"./output/example.json\");\n // ```\n // The critical insight is that every invocation of serialization will return the stringified version of the JSON\n // up to that point. That means we can construct arbitrary JSON objects and then use the return stringified version\n // to serialize them as values to another JSON object.\n //\n // json1 and json2 are simply keys used by the backend to keep track of the objects. So vm.serializeJson(json1,..)\n // will find the object in-memory that is keyed by \"some key\".\n function writeJson(string calldata json, string calldata path) external;\n // Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \n // This is useful to replace a specific value of a JSON file, without having to parse the entire thing\n function writeJson(string calldata json, string calldata path, string calldata valueKey) external;\n // Returns the RPC url for the given alias\n function rpcUrl(string calldata rpcAlias) external view returns (string memory json);\n // Returns all rpc urls and their aliases `[alias, url][]`\n function rpcUrls() external view returns (string[2][] memory urls);\n // Returns all rpc urls and their aliases as structs.\n function rpcUrlStructs() external view returns (Rpc[] memory urls);\n // If the condition is false, discard this run's fuzz inputs and generate new ones.\n function assume(bool condition) external pure;\n // Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.\n function pauseGasMetering() external;\n // Resumes gas metering (i.e. gas usage is counted again). Noop if already on.\n function resumeGasMetering() external;\n}\n\ninterface Vm is VmSafe {\n // Sets block.timestamp\n function warp(uint256 newTimestamp) external;\n // Sets block.height\n function roll(uint256 newHeight) external;\n // Sets block.basefee\n function fee(uint256 newBasefee) external;\n // Sets block.difficulty\n function difficulty(uint256 newDifficulty) external;\n // Sets block.chainid\n function chainId(uint256 newChainId) external;\n // Stores a value to an address' storage slot.\n function store(address target, bytes32 slot, bytes32 value) external;\n // Sets the nonce of an account; must be higher than the current nonce of the account\n function setNonce(address account, uint64 newNonce) external;\n // Sets the *next* call's msg.sender to be the input address\n function prank(address msgSender) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called\n function startPrank(address msgSender) external;\n // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input\n function prank(address msgSender, address txOrigin) external;\n // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input\n function startPrank(address msgSender, address txOrigin) external;\n // Resets subsequent calls' msg.sender to be `address(this)`\n function stopPrank() external;\n // Sets an address' balance\n function deal(address account, uint256 newBalance) external;\n // Sets an address' code\n function etch(address target, bytes calldata newRuntimeBytecode) external;\n // Expects an error on next call\n function expectRevert(bytes calldata revertData) external;\n function expectRevert(bytes4 revertData) external;\n function expectRevert() external;\n // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData).\n // Call this function, then emit an event, then call a function. Internally after the call, we check if\n // logs were emitted in the expected order with the expected topics and data (as specified by the booleans)\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;\n function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)\n external;\n // Mocks a call to an address, returning specified data.\n // Calldata can either be strict or a partial match, e.g. if you only\n // pass a Solidity selector to the expected calldata, then the entire Solidity\n // function will be mocked.\n function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;\n // Mocks a call to an address with a specific msg.value, returning specified data.\n // Calldata match takes precedence over msg.value in case of ambiguity.\n function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;\n // Clears all mocked calls\n function clearMockedCalls() external;\n // Expects a call to an address with the specified calldata.\n // Calldata can either be a strict or a partial match\n function expectCall(address callee, bytes calldata data) external;\n // Expects a call to an address with the specified msg.value and calldata\n function expectCall(address callee, uint256 msgValue, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value, gas, and calldata.\n function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;\n // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas.\n function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;\n // Sets block.coinbase\n function coinbase(address newCoinbase) external;\n // Snapshot the current state of the evm.\n // Returns the id of the snapshot that was created.\n // To revert a snapshot use `revertTo`\n function snapshot() external returns (uint256 snapshotId);\n // Revert the state of the EVM to a previous snapshot\n // Takes the snapshot id to revert to.\n // This deletes the snapshot and all snapshots taken after the given snapshot id.\n function revertTo(uint256 snapshotId) external returns (bool success);\n // Creates a new fork with the given endpoint and block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork\n function createFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction,\n // and returns the identifier of the fork\n function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);\n // Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before\n // the transaction, returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);\n // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork\n function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);\n // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.\n function selectFork(uint256 forkId) external;\n /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.\n function activeFork() external view returns (uint256 forkId);\n // Updates the currently active fork to given block number\n // This is similar to `roll` but for the currently active fork\n function rollFork(uint256 blockNumber) external;\n // Updates the currently active fork to given transaction\n // this will `rollFork` with the number of the block the transaction was mined in and replays all transaction mined before it in the block\n function rollFork(bytes32 txHash) external;\n // Updates the given fork to given block number\n function rollFork(uint256 forkId, uint256 blockNumber) external;\n // Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block\n function rollFork(uint256 forkId, bytes32 txHash) external;\n // Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\n // Meaning, changes made to the state of this account will be kept when switching forks\n function makePersistent(address account) external;\n function makePersistent(address account0, address account1) external;\n function makePersistent(address account0, address account1, address account2) external;\n function makePersistent(address[] calldata accounts) external;\n // Revokes persistent status from the address, previously added via `makePersistent`\n function revokePersistent(address account) external;\n function revokePersistent(address[] calldata accounts) external;\n // Returns true if the account is marked as persistent\n function isPersistent(address account) external view returns (bool persistent);\n // In forking mode, explicitly grant the given address cheatcode access\n function allowCheatcodes(address account) external;\n // Fetches the given transaction from the active fork and executes it on the current state\n function transact(bytes32 txHash) external;\n // Fetches the given transaction from the given fork and executes it on the current state\n function transact(uint256 forkId, bytes32 txHash) external;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/interfaces/IERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20Upgradeable.sol\";\nimport \"../token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable {\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed sender,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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/contracts/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract 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 // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\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/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../utils/SafeERC20Upgradeable.sol\";\nimport \"../../../interfaces/IERC4626Upgradeable.sol\";\nimport \"../../../utils/math/MathUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of\n * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable {\n using MathUpgradeable for uint256;\n\n IERC20Upgradeable private _asset;\n uint8 private _decimals;\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n function __ERC4626_init(IERC20Upgradeable asset_) internal onlyInitializing {\n __ERC4626_init_unchained(asset_);\n }\n\n function __ERC4626_init_unchained(IERC20Upgradeable asset_) internal onlyInitializing {\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n _decimals = success ? assetDecimals : super.decimals();\n _asset = asset_;\n }\n\n /**\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n */\n function _tryGetAssetDecimals(IERC20Upgradeable asset_) private returns (bool, uint8) {\n (bool success, bytes memory encodedDecimals) = address(asset_).call(\n abi.encodeWithSelector(IERC20MetadataUpgradeable.decimals.selector)\n );\n if (success && encodedDecimals.length >= 32) {\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n if (returnedDecimals <= type(uint8).max) {\n return (true, uint8(returnedDecimals));\n }\n }\n return (false, 0);\n }\n\n /**\n * @dev Decimals are read from the underlying asset in the constructor and cached. If this fails (e.g., the asset\n * has not been created yet), the cached value is set to a default obtained by `super.decimals()` (which depends on\n * inheritance but is most likely 18). Override this function in order to set a guaranteed hardcoded value.\n * See {IERC20Metadata-decimals}.\n */\n function decimals() public view virtual override(IERC20MetadataUpgradeable, ERC20Upgradeable) returns (uint8) {\n return _decimals;\n }\n\n /** @dev See {IERC4626-asset}. */\n function asset() public view virtual override returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4626-totalAssets}. */\n function totalAssets() public view virtual override returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4626-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxDeposit}. */\n function maxDeposit(address) public view virtual override returns (uint256) {\n return _isVaultCollateralized() ? type(uint256).max : 0;\n }\n\n /** @dev See {IERC4626-maxMint}. */\n function maxMint(address) public view virtual override returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual override returns (uint256) {\n return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-maxRedeem}. */\n function maxRedeem(address owner) public view virtual override returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4626-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-previewMint}. */\n function previewMint(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, MathUpgradeable.Rounding.Up);\n }\n\n /** @dev See {IERC4626-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, MathUpgradeable.Rounding.Down);\n }\n\n /** @dev See {IERC4626-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-mint}. */\n function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4626-withdraw}. */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-redeem}. */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n *\n * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset\n * would represent an infinite amount of shares.\n */\n function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) {\n uint256 supply = totalSupply();\n return\n (assets == 0 || supply == 0)\n ? _initialConvertToShares(assets, rounding)\n : assets.mulDiv(supply, totalAssets(), rounding);\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToAssets} when overriding it.\n */\n function _initialConvertToShares(\n uint256 assets,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 shares) {\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 assets) {\n uint256 supply = totalSupply();\n return\n (supply == 0) ? _initialConvertToAssets(shares, rounding) : shares.mulDiv(totalAssets(), supply, rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) to apply when the vault is empty.\n *\n * NOTE: Make sure to keep this function consistent with {_initialConvertToShares} when overriding it.\n */\n function _initialConvertToAssets(\n uint256 shares,\n MathUpgradeable.Rounding /*rounding*/\n ) internal view virtual returns (uint256 assets) {\n return shares;\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transferred and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transferred, which is a valid state.\n _burn(owner, shares);\n SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _isVaultCollateralized() private view returns (bool) {\n return totalAssets() > 0 || totalSupply() == 0;\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/contracts/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/contracts/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/contracts/token/ERC20/utils/SafeERC20Upgradeable.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 \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/Create2Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2Upgradeable {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(\n uint256 amount,\n bytes32 salt,\n bytes memory bytecode\n ) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(\n bytes32 salt,\n bytes32 bytecodeHash,\n address deployer\n ) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n" + }, + "openzeppelin-contracts-upgradeable/contracts/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n" + }, + "solmate/auth/Auth.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\nabstract contract Auth {\n event OwnerUpdated(address indexed user, address indexed newOwner);\n\n event AuthorityUpdated(address indexed user, Authority indexed newAuthority);\n\n address public owner;\n\n Authority public authority;\n\n constructor(address _owner, Authority _authority) {\n owner = _owner;\n authority = _authority;\n\n emit OwnerUpdated(msg.sender, _owner);\n emit AuthorityUpdated(msg.sender, _authority);\n }\n\n modifier requiresAuth() virtual {\n require(isAuthorized(msg.sender, msg.sig), \"UNAUTHORIZED\");\n\n _;\n }\n\n function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {\n Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.\n\n // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be\n // aware that this makes protected functions uncallable even to the owner if the authority is out of order.\n return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;\n }\n\n function setAuthority(Authority newAuthority) public virtual {\n // We check if the caller is the owner first because we want to ensure they can\n // always swap out the authority even if it's reverting or using up a lot of gas.\n require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));\n\n authority = newAuthority;\n\n emit AuthorityUpdated(msg.sender, newAuthority);\n }\n\n function setOwner(address newOwner) public virtual requiresAuth {\n owner = newOwner;\n\n emit OwnerUpdated(msg.sender, newOwner);\n }\n}\n\n/// @notice A generic interface for a contract which provides authorization data to an Auth instance.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)\ninterface Authority {\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) external view returns (bool);\n}\n" + }, + "solmate/auth/authorities/RolesAuthority.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {Auth, Authority} from \"../Auth.sol\";\n\n/// @notice Role based Authority that supports up to 256 roles.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)\n/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)\ncontract RolesAuthority is Auth, Authority {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);\n\n event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);\n\n event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}\n\n /*//////////////////////////////////////////////////////////////\n ROLE/USER STORAGE\n //////////////////////////////////////////////////////////////*/\n\n mapping(address => bytes32) public getUserRoles;\n\n mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;\n\n mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;\n\n function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {\n return (uint256(getUserRoles[user]) >> role) & 1 != 0;\n }\n\n function doesRoleHaveCapability(\n uint8 role,\n address target,\n bytes4 functionSig\n ) public view virtual returns (bool) {\n return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;\n }\n\n /*//////////////////////////////////////////////////////////////\n AUTHORIZATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function canCall(\n address user,\n address target,\n bytes4 functionSig\n ) public view virtual override returns (bool) {\n return\n isCapabilityPublic[target][functionSig] ||\n bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];\n }\n\n /*//////////////////////////////////////////////////////////////\n ROLE CAPABILITY CONFIGURATION LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setPublicCapability(\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n isCapabilityPublic[target][functionSig] = enabled;\n\n emit PublicCapabilityUpdated(target, functionSig, enabled);\n }\n\n function setRoleCapability(\n uint8 role,\n address target,\n bytes4 functionSig,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getRolesWithCapability[target][functionSig] |= bytes32(1 << role);\n } else {\n getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);\n }\n\n emit RoleCapabilityUpdated(role, target, functionSig, enabled);\n }\n\n /*//////////////////////////////////////////////////////////////\n USER ROLE ASSIGNMENT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function setUserRole(\n address user,\n uint8 role,\n bool enabled\n ) public virtual requiresAuth {\n if (enabled) {\n getUserRoles[user] |= bytes32(1 << role);\n } else {\n getUserRoles[user] &= ~bytes32(1 << role);\n }\n\n emit UserRoleUpdated(user, role, enabled);\n }\n}\n" + }, + "solmate/mixins/ERC4626.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\nimport {FixedPointMathLib} from \"../utils/FixedPointMathLib.sol\";\n\n/// @notice Minimal ERC4626 tokenized Vault implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/mixins/ERC4626.sol)\nabstract contract ERC4626 is ERC20 {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /*//////////////////////////////////////////////////////////////\n IMMUTABLES\n //////////////////////////////////////////////////////////////*/\n\n ERC20 public immutable asset;\n\n constructor(\n ERC20 _asset,\n string memory _name,\n string memory _symbol\n ) ERC20(_name, _symbol, _asset.decimals()) {\n asset = _asset;\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\n // Check for rounding error since we round down in previewDeposit.\n require((shares = previewDeposit(assets)) != 0, \"ZERO_SHARES\");\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\n\n // Need to transfer before minting or ERC777s could reenter.\n asset.safeTransferFrom(msg.sender, address(this), assets);\n\n _mint(receiver, shares);\n\n emit Deposit(msg.sender, receiver, assets, shares);\n\n afterDeposit(assets, shares);\n }\n\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual returns (uint256 shares) {\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\n\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual returns (uint256 assets) {\n if (msg.sender != owner) {\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\n }\n\n // Check for rounding error since we round down in previewRedeem.\n require((assets = previewRedeem(shares)) != 0, \"ZERO_ASSETS\");\n\n beforeWithdraw(assets, shares);\n\n _burn(owner, shares);\n\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\n\n asset.safeTransfer(receiver, assets);\n }\n\n /*//////////////////////////////////////////////////////////////\n ACCOUNTING LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function totalAssets() public view virtual returns (uint256);\n\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\n }\n\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\n }\n\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\n return convertToShares(assets);\n }\n\n function previewMint(uint256 shares) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\n }\n\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\n\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\n }\n\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\n return convertToAssets(shares);\n }\n\n /*//////////////////////////////////////////////////////////////\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function maxDeposit(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxMint(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n function maxWithdraw(address owner) public view virtual returns (uint256) {\n return convertToAssets(balanceOf[owner]);\n }\n\n function maxRedeem(address owner) public view virtual returns (uint256) {\n return balanceOf[owner];\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL HOOKS LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\n\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\n}\n" + }, + "solmate/test/utils/mocks/MockERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../../../tokens/ERC20.sol\";\n\ncontract MockERC20 is ERC20 {\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) ERC20(_name, _symbol, _decimals) {}\n\n function mint(address to, uint256 value) public virtual {\n _mint(to, value);\n }\n\n function burn(address from, uint256 value) public virtual {\n _burn(from, value);\n }\n}\n" + }, + "solmate/tokens/ERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" + }, + "solmate/tokens/WETH.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"./ERC20.sol\";\n\nimport {SafeTransferLib} from \"../utils/SafeTransferLib.sol\";\n\n/// @notice Minimalist and modern Wrapped Ether implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)\n/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)\ncontract WETH is ERC20(\"Wrapped Ether\", \"WETH\", 18) {\n using SafeTransferLib for address;\n\n event Deposit(address indexed from, uint256 amount);\n\n event Withdrawal(address indexed to, uint256 amount);\n\n function deposit() public payable virtual {\n _mint(msg.sender, msg.value);\n\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 amount) public virtual {\n _burn(msg.sender, amount);\n\n emit Withdrawal(msg.sender, amount);\n\n msg.sender.safeTransferETH(amount);\n }\n\n receive() external payable virtual {\n deposit();\n }\n}\n" + }, + "solmate/utils/FixedPointMathLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // Divide z by the denominator.\n z := div(z, denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n assembly {\n // Store x * y in z for now.\n z := mul(x, y)\n\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n revert(0, 0)\n }\n\n // First, divide z - 1 by the denominator and add 1.\n // We allow z - 1 to underflow if z is 0, because we multiply the\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n assembly {\n let y := x // We start y at x, which will help us make our initial estimate.\n\n z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n // We check y >= 2^(k + 8) but shift right by k bits\n // each branch to ensure that if x >= 256, then y >= 256.\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n y := shr(128, y)\n z := shl(64, z)\n }\n if iszero(lt(y, 0x1000000000000000000)) {\n y := shr(64, y)\n z := shl(32, z)\n }\n if iszero(lt(y, 0x10000000000)) {\n y := shr(32, y)\n z := shl(16, z)\n }\n if iszero(lt(y, 0x1000000)) {\n y := shr(16, y)\n z := shl(8, z)\n }\n\n // Goal was to get z*z*y within a small factor of x. More iterations could\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n // There is no overflow risk here since y < 2^136 after the first branch above.\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // If x+1 is a perfect square, the Babylonian method cycles between\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n z := sub(z, lt(div(x, z), z))\n }\n }\n\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Mod x by y. Note this will return\n // 0 instead of reverting if y is zero.\n z := mod(x, y)\n }\n }\n\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\n assembly {\n // Divide x by y. Note this will return\n // 0 instead of reverting if y is zero.\n r := div(x, y)\n }\n }\n\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n assembly {\n // Add 1 to x * y if x % y > 0. Note this will\n // return 0 instead of reverting if y is zero.\n z := add(gt(mod(x, y), 0), div(x, y))\n }\n }\n}\n" + }, + "solmate/utils/SafeCastLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Safe unsigned integer casting library that reverts on overflow.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeCastLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol)\nlibrary SafeCastLib {\n function safeCastTo248(uint256 x) internal pure returns (uint248 y) {\n require(x < 1 << 248);\n\n y = uint248(x);\n }\n\n function safeCastTo224(uint256 x) internal pure returns (uint224 y) {\n require(x < 1 << 224);\n\n y = uint224(x);\n }\n\n function safeCastTo192(uint256 x) internal pure returns (uint192 y) {\n require(x < 1 << 192);\n\n y = uint192(x);\n }\n\n function safeCastTo160(uint256 x) internal pure returns (uint160 y) {\n require(x < 1 << 160);\n\n y = uint160(x);\n }\n\n function safeCastTo128(uint256 x) internal pure returns (uint128 y) {\n require(x < 1 << 128);\n\n y = uint128(x);\n }\n\n function safeCastTo96(uint256 x) internal pure returns (uint96 y) {\n require(x < 1 << 96);\n\n y = uint96(x);\n }\n\n function safeCastTo64(uint256 x) internal pure returns (uint64 y) {\n require(x < 1 << 64);\n\n y = uint64(x);\n }\n\n function safeCastTo32(uint256 x) internal pure returns (uint32 y) {\n require(x < 1 << 32);\n\n y = uint32(x);\n }\n\n function safeCastTo24(uint256 x) internal pure returns (uint24 y) {\n require(x < 1 << 24);\n\n y = uint24(x);\n }\n\n function safeCastTo16(uint256 x) internal pure returns (uint16 y) {\n require(x < 1 << 16);\n\n y = uint16(x);\n }\n\n function safeCastTo8(uint256 x) internal pure returns (uint8 y) {\n require(x < 1 << 8);\n\n y = uint8(x);\n }\n}\n" + }, + "solmate/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index 3bd0f1f65c..9cc0f298a3 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -6,7 +6,7 @@ import { HardhatUserConfig } from "hardhat/config"; import { config as dotenv } from "dotenv"; import "./tasks"; -import { base, fraxtal, mode } from "viem/chains"; +import { base, fraxtal, mode, superseed } from "viem/chains"; dotenv(); @@ -24,7 +24,8 @@ const config: HardhatUserConfig = { multisig: { [mode.id]: "0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2", [base.id]: "0x9eC25b8063De13d478Ba8121b964A339A1BB0ebB", - [fraxtal.id]: "0xf8Ec79Ac74b16242d17cC7258250fA3317E3C1b2" + [fraxtal.id]: "0xf8Ec79Ac74b16242d17cC7258250fA3317E3C1b2", + [superseed.id]: "0x1155b614971f16758C92c4890eD338C9e3ede6b7" } }, solidity: { @@ -106,13 +107,24 @@ const config: HardhatUserConfig = { apiKey: "empty" } } + }, + superseed: { + url: process.env.OVERRIDE_RPC_URL_SUPERSEED ?? "https://rpc-superseed-mainnet-0.t.conduit.xyz", + accounts, + verify: { + etherscan: { + apiUrl: "https://explorer-superseed-mainnet-0.t.conduit.xyz/api", + apiKey: "empty" + } + } } }, etherscan: { apiKey: { base: process.env.ETHERSCAN_API_KEY_BASE!, optimisticEthereum: process.env.ETHERSCAN_API_KEY_OPTIMISM!, - lisk: "empty" + lisk: "empty", + superseed: "empty" }, customChains: [ { @@ -122,6 +134,14 @@ const config: HardhatUserConfig = { apiURL: "https://blockscout.lisk.com/api", browserURL: "https://blockscout.lisk.com" } + }, + { + network: "superseed", + chainId: 5330, + urls: { + apiURL: "https://explorer-superseed-mainnet-0.t.conduit.xyz/api", + browserURL: "https://explorer-superseed-mainnet-0.t.conduit.xyz" + } } ] }, diff --git a/packages/contracts/package.json b/packages/contracts/package.json index eee864d4d4..6f4d57bf69 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -10,13 +10,14 @@ "forge:build": "forge build", "prettier": "prettier --write --plugin=prettier-plugin-solidity 'contracts/**/*.sol' --config .prettierrc", "lint": "prettier --list-different 'contracts/**/*.sol'", - "export:all": "yarn export:mode && yarn export:base && yarn export:bob && yarn export:optimism && yarn export:fraxtal && yarn export:lisk", + "export:all": "yarn export:mode && yarn export:base && yarn export:bob && yarn export:optimism && yarn export:fraxtal && yarn export:lisk && yarn export:superseed", "export:mode": "hardhat export --network mode --export ../sdk/deployments/mode.json && node ./scripts/prune.js ../sdk/deployments/mode.json", "export:base": "hardhat export --network base --export ../sdk/deployments/base.json && node ./scripts/prune.js ../sdk/deployments/base.json", "export:bob": "hardhat export --network bob --export ../sdk/deployments/bob.json && node ./scripts/prune.js ../sdk/deployments/bob.json", "export:optimism": "hardhat export --network optimism --export ../sdk/deployments/optimism.json && node ./scripts/prune.js ../sdk/deployments/optimism.json", "export:fraxtal": "hardhat export --network fraxtal --export ../sdk/deployments/fraxtal.json && node ./scripts/prune.js ../sdk/deployments/fraxtal.json", "export:lisk": "hardhat export --network lisk --export ../sdk/deployments/lisk.json && node ./scripts/prune.js ../sdk/deployments/lisk.json", + "export:superseed": "hardhat export --network superseed --export ../sdk/deployments/superseed.json && node ./scripts/prune.js ../sdk/deployments/superseed.json", "prune": "node ./scripts/prune.js ../sdk/deployments/*.json", "generate": "yarn forge:build && wagmi generate" }, @@ -54,6 +55,6 @@ "solidity-coverage": "^0.8.13", "ts-node": "^10.9.2", "typescript": "^5.5.3", - "viem": "^2.21.12" + "viem": "^2.21.55" } } diff --git a/packages/contracts/tasks/chain-specific/index.ts b/packages/contracts/tasks/chain-specific/index.ts index 2e8a6d9bb5..cf8fa29c37 100644 --- a/packages/contracts/tasks/chain-specific/index.ts +++ b/packages/contracts/tasks/chain-specific/index.ts @@ -5,6 +5,7 @@ import "./fraxtal"; import "./optimism"; import "./lisk"; import "./virtual-base"; +import "./superseed"; export const SUPPLY_DURATION = 29 * (24 * 60 * 60) + 1 * (23 * 60 * 60); // 29 days 23 hours export const BORROW_DURATION = 30 * (24 * 60 * 60); // 30 days \ No newline at end of file diff --git a/packages/contracts/tasks/chain-specific/superseed/index.ts b/packages/contracts/tasks/chain-specific/superseed/index.ts new file mode 100644 index 0000000000..a2fa630e2b --- /dev/null +++ b/packages/contracts/tasks/chain-specific/superseed/index.ts @@ -0,0 +1,3 @@ +import "./market"; + +export const COMPTROLLER_MAIN = "0x6C855402d39AFb6B3EB81844dcFC7Bb0cD742D4e"; diff --git a/packages/contracts/tasks/chain-specific/superseed/market.ts b/packages/contracts/tasks/chain-specific/superseed/market.ts new file mode 100644 index 0000000000..af6b6b3d99 --- /dev/null +++ b/packages/contracts/tasks/chain-specific/superseed/market.ts @@ -0,0 +1,100 @@ +import { task } from "hardhat/config"; +import { Address, formatUnits, parseEther, zeroAddress } from "viem"; +import { assetSymbols } from "@ionicprotocol/types"; + +import { prepareAndLogTransaction } from "../../../chainDeploy/helpers/logging"; +import { COMPTROLLER_MAIN } from "."; +import { getMarketInfo } from "../../market"; +import { superseed } from "@ionicprotocol/chains"; + +const superseedAssets = superseed.assets; + +task("markets:deploy:superseed:new", "deploy new superseed assets").setAction(async (_, { viem, run }) => { + const assetsToDeploy: string[] = [assetSymbols.WETH]; + for (const asset of superseedAssets.filter((asset) => assetsToDeploy.includes(asset.symbol))) { + if (!asset.name || !asset.symbol || !asset.underlying) { + throw new Error(`Asset ${asset.symbol} has no name, symbol or underlying`); + } + const name = `Ionic ${asset.name}`; + const symbol = "ion" + asset.symbol; + console.log(`Deploying ctoken ${name} with symbol ${symbol}`); + await run("market:deploy", { + signer: "deployer", + cf: "0", + underlying: asset.underlying, + comptroller: COMPTROLLER_MAIN, + symbol, + name + }); + const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER_MAIN); + const cToken = await pool.read.cTokensByUnderlying([asset.underlying]); + console.log(`Deployed ${asset.symbol} at ${cToken}`); + + if (cToken !== zeroAddress) { + await run("market:set-supply-cap", { + market: cToken, + maxSupply: asset.initialSupplyCap + }); + + await run("market:set-borrow-cap", { + market: cToken, + maxBorrow: asset.initialBorrowCap + }); + } + } +}); + +task("superseed:set-caps:new", "one time setup").setAction(async (_, { viem, run, getNamedAccounts, deployments }) => { + const { deployer } = await getNamedAccounts(); + const assetsToDeploy: string[] = [assetSymbols.WETH]; + for (const asset of superseed.assets.filter((asset) => assetsToDeploy.includes(asset.symbol))) { + const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER_MAIN); + const cToken = await pool.read.cTokensByUnderlying([asset.underlying]); + const asExt = await viem.getContractAt("CTokenFirstExtension", cToken); + const admin = await pool.read.admin(); + const ap = await deployments.get("AddressesProvider"); + if (admin.toLowerCase() !== deployer.toLowerCase()) { + await prepareAndLogTransaction({ + contractInstance: asExt, + functionName: "_setAddressesProvider", + args: [ap.address as Address], + description: "Set Addresses Provider", + inputs: [ + { + internalType: "address", + name: "_ap", + type: "address" + } + ] + }); + } else { + const tx = await asExt.write._setAddressesProvider([ap.address as Address]); + console.log("set addresses provider", tx); + } + + await run("market:set-borrow-cap", { + market: cToken, + maxBorrow: asset.initialBorrowCap + }); + + await run("market:set-supply-cap", { + market: cToken, + maxSupply: asset.initialSupplyCap + }); + } +}); + +task("market:set-cf:superseed:new", "Sets CF on a market").setAction(async (_, { viem, run }) => { + for (const asset of superseed.assets.filter((asset) => asset.symbol === assetSymbols.WETH)) { + const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER_MAIN); + const cToken = await pool.read.cTokensByUnderlying([asset.underlying]); + console.log("cToken: ", cToken, asset.symbol); + + if (asset.initialCf) { + await run("market:set:ltv", { + marketAddress: cToken, + ltv: asset.initialCf + }); + } + } +}); \ No newline at end of file diff --git a/packages/contracts/tasks/market/deploy.ts b/packages/contracts/tasks/market/deploy.ts index a5ced026a7..78f2e975cc 100644 --- a/packages/contracts/tasks/market/deploy.ts +++ b/packages/contracts/tasks/market/deploy.ts @@ -39,6 +39,16 @@ task("market:deploy", "deploy market") const collateralFactorBN = parseEther((config.collateralFactor / 100).toString()); console.log("collateralFactorBN", collateralFactorBN.toString()); + console.log("constructor params: ", [ + config.underlying, + config.comptroller, + config.feeDistributor, + config.interestRateModel, + config.name, + config.symbol, + reserveFactorBN, + adminFeeBN + ]); const constructorData = encodeAbiParameters( parseAbiParameters("address,address,address,address,string,string,uint256,uint256"), [ @@ -52,6 +62,7 @@ task("market:deploy", "deploy market") adminFeeBN ] ); + console.log("constructorData", constructorData); const owner = (await comptroller.read.admin()) as Address; // Test Transaction diff --git a/packages/contracts/tasks/pool/admin/create.ts b/packages/contracts/tasks/pool/admin/create.ts index 544623f738..c61aaacb6b 100644 --- a/packages/contracts/tasks/pool/admin/create.ts +++ b/packages/contracts/tasks/pool/admin/create.ts @@ -70,6 +70,18 @@ task("pool:create:bob:main").setAction(async ({}, { run, deployments }) => { }); }); +task("pool:create:superseed").setAction(async ({}, { run, deployments }) => { + const mpo = await deployments.get("MasterPriceOracle"); + await run("pool:create", { + name: "Superseed Main Market", + creator: "deployer", + priceOracle: mpo.address, // MPO + closeFactor: "50", + liquidationIncentive: "8", + enforceWhitelist: "false" + }); +}); + task("pool:create", "Create pool if does not exist") .addParam("name", "Name of the pool to be created", undefined, types.string) .addParam("creator", "Named account from which to create the pool", "deployer", types.string) @@ -110,7 +122,7 @@ task("pool:create", "Create pool if does not exist") ]); const receipt = await publicClient.waitForTransactionReceipt({ hash: deployTx }); const [event] = await poolDirectory.getEvents.PoolRegistered({ blockHash: receipt.blockHash }); - console.log(`Pool registered: ${event}`); + console.log(`Pool registered: ${JSON.stringify(event, null, 2)}`); if (!event) { throw "Pool not found"; } diff --git a/packages/monitors/oracle/package.json b/packages/monitors/oracle/package.json index d27dfb718d..3265806c21 100644 --- a/packages/monitors/oracle/package.json +++ b/packages/monitors/oracle/package.json @@ -48,6 +48,6 @@ "dotenv": "^16.0.0", "pino": "^8.0.0", "pino-pretty": "^9.1.1", - "viem": "^2.21.12" + "viem": "^2.21.55" } } diff --git a/packages/sdk/deployments/superseed.json b/packages/sdk/deployments/superseed.json new file mode 100644 index 0000000000..09a705ee39 --- /dev/null +++ b/packages/sdk/deployments/superseed.json @@ -0,0 +1,150 @@ +{ + "name": "superseed", + "chainId": "5330", + "contracts": { + "AddressesProvider": { + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea" + }, + "AddressesProvider_Implementation": { + "address": "0x7Ea7BB80F3bBEE9b52e6Ed3775bA06C9C80D4154" + }, + "AddressesProvider_Proxy": { + "address": "0xBbDcA7858ac2417b06636F7BA35e7d9EA39402ea" + }, + "AuthoritiesRegistry": { + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE" + }, + "AuthoritiesRegistry_Implementation": { + "address": "0x522E808b99a89F0587906eB0A913675D35a936f6" + }, + "AuthoritiesRegistry_Proxy": { + "address": "0x49fC77CaC3066BDE8EfFb717E43aA31b112A0ECE" + }, + "CErc20Delegate": { + "address": "0xE1A3006be645a80F206311d9f18C866c204bA02f" + }, + "CErc20PluginDelegate": { + "address": "0x8C58ECb9C0050824177f4e1Cd71C335421d4aeA2" + }, + "CErc20RewardsDelegate": { + "address": "0xb3788b3C421348E43beEa88551acC16d2f6a6332" + }, + "CTokenFirstExtension": { + "address": "0x8b2B6a9dC8Cd73309Cef8d64920831d4C73F43a7" + }, + "Comptroller": { + "address": "0x8ea3fc79D9E463464C5159578d38870b770f6E57" + }, + "ComptrollerFirstExtension": { + "address": "0x284bb7298F3d7B99CA105a468c4E696D11150E6E" + }, + "ComptrollerPrudentiaCapsExt": { + "address": "0xA7B9F9B18587A3854aE41C80a08291eca149bCB7" + }, + "DefaultProxyAdmin": { + "address": "0x04C21Db52CcA974dF3Dc019C92E52e522ce57156" + }, + "FeeDistributor": { + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6" + }, + "FeeDistributor_Implementation": { + "address": "0x985a323A1CccA8Cd5fb8935590EE33FbcFE849d0" + }, + "FeeDistributor_Proxy": { + "address": "0x9BAD1f7685f33ad855AE81089dFe79040864E2F6" + }, + "FixedNativePriceOracle": { + "address": "0x431C87E08e2636733a945D742d25Ba77577ED480" + }, + "GlobalPauser": { + "address": "0x02140fd77e463137D41b35aec304178DbdbFA8D9" + }, + "IonicFlywheelLensRouter": { + "address": "0x7AABEfD7d8d2576Dc932EbE97bE8Ba90299a4ee4" + }, + "IonicLiquidator_Implementation": { + "address": "0xeC7D0330E86485474C13A2152Fa867ddd41Bb12B" + }, + "IonicUniV3Liquidator": { + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a" + }, + "IonicUniV3Liquidator_Implementation": { + "address": "0xb0033576a9E444Dd801d5B69e1b63DBC459A6115" + }, + "IonicUniV3Liquidator_Proxy": { + "address": "0x48bf6bd4B3d8b4E75863B5340b977E888BacE19a" + }, + "JumpRateModel": { + "address": "0xa6BA5F1164dc66F9C5bDCE33A6d2fC70bE8Da108" + }, + "LeveredPositionFactory": { + "address": "0x5d74800e977bFc8E14Eca28C9405BacbD091738E" + }, + "LeveredPositionFactoryFirstExtension": { + "address": "0xC3cEc17c135d3C5d6BadC284AFF08f396447DaaC" + }, + "LeveredPositionFactorySecondExtension": { + "address": "0x7DFDd5B55Fe37602B355F7a9Ed0fe00e30C163cb" + }, + "LeveredPositionsLens": { + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF" + }, + "LeveredPositionsLens_Implementation": { + "address": "0x948BB10123B349F0c9f358Fe36735C260DF0B4cC" + }, + "LeveredPositionsLens_Proxy": { + "address": "0xcA0aE3039B8825Cd7A968ceda6D99a49458722aF" + }, + "LiquidatorsRegistry": { + "address": "0x2DDF3DdFE856D1A4E5DBcb324194E2a622AeD83C" + }, + "LiquidatorsRegistryExtension": { + "address": "0xA90f1c28F8Bc9C92113e54d0b7d007647Ee216a4" + }, + "LiquidatorsRegistrySecondExtension": { + "address": "0xc71B968C6C23e2723Bae32957D815C9bE3ca1b34" + }, + "LooplessFlywheelBooster": { + "address": "0x1E2812B4dEcA77B5dD7Af9f2D6ec40102bcffD02" + }, + "MasterPriceOracle": { + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c" + }, + "MasterPriceOracle_Implementation": { + "address": "0xBc97F93657186ad3614D05AaB83ee744Fc8CEf48" + }, + "MasterPriceOracle_Proxy": { + "address": "0x987F3103c976CAF5087087bbF99A7E389F22311c" + }, + "OracleRegistry": { + "address": "0x8Da0b2ca671F32afF847A61F845f1e99a152BDA9" + }, + "PoolDirectory": { + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd" + }, + "PoolDirectory_Implementation": { + "address": "0xAeE8AA2c69CaA9F6D2C6a78198243C348d0C07D2" + }, + "PoolDirectory_Proxy": { + "address": "0xe451047f3A6C8Dc595Cf305DC21F32adD5fF42Fd" + }, + "PoolLens": { + "address": "0x1D7669b6BDfdb83066dd7C0aDa4B630b25cBc28a" + }, + "PoolLensSecondary": { + "address": "0x5f0369AA93f36cA6a8B5ed7aAc47bf9e76086D03" + }, + "SimplePriceOracle": { + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b" + }, + "SimplePriceOracle_Implementation": { + "address": "0xd8d2D1195a548FE2ff69C31c4C90e54b263771c7" + }, + "SimplePriceOracle_Proxy": { + "address": "0x239C8E4792F4D5A9bDD7769bA84A0E8dB1756c9b" + }, + "UniswapV3LiquidatorFunder": { + "address": "0x1D89E5ba287E67AC0046D2218Be5fE1382cE47b4" + } + } +} \ No newline at end of file diff --git a/packages/sdk/package.json b/packages/sdk/package.json index f45aa11c8d..b2d4d293db 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -66,6 +66,6 @@ "bufferutil": "^4.0.8", "perf_hooks": "^0.0.1", "utf-8-validate": "^6.0.4", - "viem": "^2.21.12" + "viem": "^2.21.55" } } diff --git a/packages/sdk/src/IonicSdk/index.ts b/packages/sdk/src/IonicSdk/index.ts index 3870b4d0d6..3e1c6415cc 100644 --- a/packages/sdk/src/IonicSdk/index.ts +++ b/packages/sdk/src/IonicSdk/index.ts @@ -128,17 +128,11 @@ export class IonicBase { IonicLiquidator: this.chainId === bob.id || this.chainId === lisk.id ? ({} as any) - : this.chainId === mode.id - ? getContract({ - abi: ionicUniV3LiquidatorAbi, - address: this.chainDeployment.IonicUniV3Liquidator.address as Address, - client: this.walletClient! - }) - : getContract({ - abi: ionicLiquidatorAbi, - address: this.chainDeployment.IonicLiquidator.address as Address, - client: this.walletClient! - }), + : getContract({ + abi: ionicUniV3LiquidatorAbi, + address: this.chainDeployment.IonicUniV3Liquidator.address as Address, + client: this.walletClient! + }), FeeDistributor: getContract({ abi: feeDistributorAbi, address: this.chainDeployment.FeeDistributor.address as Address, diff --git a/packages/sdk/src/modules/Pools.ts b/packages/sdk/src/modules/Pools.ts index 8124a073f0..1411a24f78 100644 --- a/packages/sdk/src/modules/Pools.ts +++ b/packages/sdk/src/modules/Pools.ts @@ -1,4 +1,4 @@ -import { base, bob, mode, optimism, fraxtal, lisk } from "@ionicprotocol/chains"; +import { base, bob, mode, optimism, fraxtal, lisk, superseed } from "@ionicprotocol/chains"; import { ChainSupportedAssets as ChainSupportedAssetsType, IonicPoolData, @@ -39,7 +39,8 @@ export const ChainSupportedAssets: ChainSupportedAssetsType = { [SupportedChains.optimism]: optimism.assets, [SupportedChains.bob]: bob.assets, [SupportedChains.fraxtal]: fraxtal.assets, - [SupportedChains.lisk]: lisk.assets + [SupportedChains.lisk]: lisk.assets, + [SupportedChains.superseed]: superseed.assets }; export interface IIonicPools { diff --git a/packages/sdk/tests-mocha/IonicSdk/index.spec.ts b/packages/sdk/tests-mocha/IonicSdk/index.spec.ts index 8fcef49b48..212fe82fe5 100644 --- a/packages/sdk/tests-mocha/IonicSdk/index.spec.ts +++ b/packages/sdk/tests-mocha/IonicSdk/index.spec.ts @@ -95,7 +95,7 @@ describe("Ionic Index", () => { restore(); }); - it("should deploy a pool when comptroller is already deployed and enforce whitelist is false", async () => { + it.skip("should deploy a pool when comptroller is already deployed and enforce whitelist is false", async () => { ionicBase.chainDeployment.Comptroller = { abi: [], address: mkAddress("0xccc") }; await ionicBase.deployPool("Test", false, 1n, 1n, mkAddress("0xa"), [mkAddress("0xbbb")]); expect(ionicBase.contracts.PoolDirectory.write.deployPool).to.be.calledOnceWith([ diff --git a/packages/security/package.json b/packages/security/package.json index 50769d21e7..bfdc5e4fbc 100644 --- a/packages/security/package.json +++ b/packages/security/package.json @@ -52,6 +52,6 @@ "decimal.js": "^10.4.0", "node-cache": "^5.1.2", "utf-8-validate": "^5.0.9", - "viem": "^2.21.12" + "viem": "^2.21.55" } } diff --git a/packages/types/package.json b/packages/types/package.json index 8f0d933cef..5017cd5450 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -34,6 +34,6 @@ }, "dependencies": { "utf-8-validate": "^6.0.4", - "viem": "^2.21.12" + "viem": "^2.21.55" } } diff --git a/packages/types/src/enums.ts b/packages/types/src/enums.ts index 285f2c39f2..235f2a6c56 100644 --- a/packages/types/src/enums.ts +++ b/packages/types/src/enums.ts @@ -4,7 +4,8 @@ export enum SupportedChains { optimism = 10, bob = 60808, fraxtal = 252, - lisk = 1135 + lisk = 1135, + superseed = 5330 } export const SupportedChainsArray = Object.entries(SupportedChains) diff --git a/packages/ui/app/_components/markets/NetworkSelector.tsx b/packages/ui/app/_components/markets/NetworkSelector.tsx index 5c6da0c54b..89fb8f1f4c 100644 --- a/packages/ui/app/_components/markets/NetworkSelector.tsx +++ b/packages/ui/app/_components/markets/NetworkSelector.tsx @@ -21,7 +21,15 @@ interface INetworkSelector { upcomingChains?: string[]; } -const NETWORK_ORDER = ['Mode', 'Base', 'Optimism', 'Fraxtal', 'Lisk', 'BoB']; +const NETWORK_ORDER = [ + 'Mode', + 'Base', + 'Optimism', + 'Fraxtal', + 'Lisk', + 'BoB', + 'Superseed' +]; function NetworkSelector({ dropdownSelectedChain, diff --git a/packages/ui/app/_components/xION/TxPopup.tsx b/packages/ui/app/_components/xION/TxPopup.tsx index 10c450ab1b..ab6f493b20 100644 --- a/packages/ui/app/_components/xION/TxPopup.tsx +++ b/packages/ui/app/_components/xION/TxPopup.tsx @@ -57,18 +57,6 @@ function TxPopup({ // 'completed' | 'error' | 'pending' | 'unknown' // >('unknown'); - const temp = { - hasHistory: false, - amount: BigInt(0), - hash: '0x1234567890abcdef1234567890abcdef12345678', - fromChain: '34443', - toChain: '8453', - approvalHash: '0x123456789', - bridgeStatus: 'unknown', - status: false, - bridgingBlock: '21212' - }; - //-------------------------- for future use // const [mock] = useLocalStorage('bridgeTx', ''); // console.log(mock); @@ -118,9 +106,7 @@ function TxPopup({ Amount
- {Number( - formatEther(mock?.amount ?? temp.amount) - ).toLocaleString('en-US', { + {Number(formatEther(mock.amount)).toLocaleString('en-US', { maximumFractionDigits: 6 })} @@ -137,8 +123,8 @@ function TxPopup({
{( - Number(formatEther(mock?.amount ?? temp.amount)) - - Number(formatEther(mock?.amount ?? temp.amount)) * 0.01 + Number(formatEther(mock.amount)) - + Number(formatEther(mock.amount)) * 0.01 ).toLocaleString('en-US', { maximumFractionDigits: 3 })} @@ -155,11 +141,11 @@ function TxPopup({ Networks
- {chainsArr[+mock?.fromChain ?? temp.fromChain]} + {chainsArr[+mock.fromChain]} {'->'} - {chainsArr[+mock?.toChain ?? temp.toChain]} + {chainsArr[+mock.toChain]}
@@ -168,10 +154,10 @@ function TxPopup({
@@ -180,10 +166,10 @@ function TxPopup({ @@ -202,7 +188,7 @@ function TxPopup({ TRACK diff --git a/packages/ui/app/layout.tsx b/packages/ui/app/layout.tsx index 7d4e1742dd..3ea666b4b4 100644 --- a/packages/ui/app/layout.tsx +++ b/packages/ui/app/layout.tsx @@ -14,7 +14,8 @@ import { mode, bob, fraxtal, - lisk + lisk, + superseed } from '@reown/appkit/networks'; import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; @@ -35,7 +36,7 @@ const metadata = { url: 'https://app.ionic.money' }; -export const networks = [base, mode, optimism, bob, fraxtal, lisk]; +export const networks = [base, mode, optimism, bob, fraxtal, lisk, superseed]; export const projectId = '923645e96d6f05f650d266a32ea7295f'; @@ -59,7 +60,8 @@ createAppKit({ chainImages: { [mode.id]: 'https://icons.llamao.fi/icons/chains/rsz_mode.jpg', [bob.id]: 'https://icons.llamao.fi/icons/chains/rsz_bob.jpg', - [fraxtal.id]: 'https://icons.llamao.fi/icons/chains/rsz_fraxtal.jpg' + [fraxtal.id]: 'https://icons.llamao.fi/icons/chains/rsz_fraxtal.jpg', + [superseed.id]: 'https://icons.llamao.fi/icons/chains/rsz_superseed.jpg' } }); @@ -102,7 +104,7 @@ export default function RootLayout({ `} - + diff --git a/packages/ui/config/index.ts b/packages/ui/config/index.ts index b017f71c2f..7328520c42 100644 --- a/packages/ui/config/index.ts +++ b/packages/ui/config/index.ts @@ -9,6 +9,7 @@ type CONFIG = { isBobEnabled: boolean; isFraxtalEnabled: boolean; isLiskEnabled: boolean; + isSuperseedEnabled: boolean; isTestnetEnabled: boolean; productDomain: string | undefined; productUrl: string | undefined; @@ -36,6 +37,7 @@ const config: CONFIG = { isBobEnabled: true, isLiskEnabled: true, isFraxtalEnabled: true, + isSuperseedEnabled: true, isTestnetEnabled: process.env.NEXT_PUBLIC_SHOW_TESTNETS === 'true', productDomain: process.env.PRODUCT_DOMAIN, productUrl: process.env.PRODUCT_URL, diff --git a/packages/ui/constants/index.ts b/packages/ui/constants/index.ts index 82f73ccb80..e550eb92ab 100644 --- a/packages/ui/constants/index.ts +++ b/packages/ui/constants/index.ts @@ -1,4 +1,12 @@ -import { base, bob, fraxtal, lisk, mode, optimism } from 'viem/chains'; +import { + base, + bob, + fraxtal, + lisk, + mode, + optimism, + superseed +} from 'viem/chains'; import type { TxStep } from '@ui/types/ComponentPropsType'; @@ -333,6 +341,21 @@ export const pools: Record = { assets: ['WETH', 'USDC', 'USDT', 'WBTC', 'LSK'] } ] + }, + [superseed.id]: { + name: 'Superseed', + arrow: 'ffffff', + bg: 'bg-fraxtal', + text: 'text-white', + border: 'border-fraxtal', + logo: '/img/logo/SUPERSEED.png', + pools: [ + { + id: '0', + name: 'Main Pool', + assets: ['WETH'] + } + ] } }; diff --git a/packages/ui/hooks/market/useMarketData.ts b/packages/ui/hooks/market/useMarketData.ts index d6c353115f..f87ca6a8cc 100644 --- a/packages/ui/hooks/market/useMarketData.ts +++ b/packages/ui/hooks/market/useMarketData.ts @@ -276,8 +276,8 @@ export const useMarketData = ( if (!marketData.length) return []; const featuredSymbols = [ - shouldGetFeatured.featuredSupply[+chain][selectedPool]?.toLowerCase(), - shouldGetFeatured.featuredSupply2[+chain][selectedPool]?.toLowerCase() + shouldGetFeatured.featuredSupply[+chain]?.[selectedPool]?.toLowerCase(), + shouldGetFeatured.featuredSupply2[+chain]?.[selectedPool]?.toLowerCase() ]; return marketData.filter((market) => diff --git a/packages/ui/hooks/useFusePoolData.ts b/packages/ui/hooks/useFusePoolData.ts index 0734f577e0..55c13dea60 100644 --- a/packages/ui/hooks/useFusePoolData.ts +++ b/packages/ui/hooks/useFusePoolData.ts @@ -34,7 +34,7 @@ export const useFusePoolData = ( ], queryFn: async () => { - if (usdPrice && sdk?.chainId && poolId) { + if (usdPrice && sdk?.chainId && typeof poolId !== 'undefined') { const response = await sdk.fetchPoolData(poolId, address).catch((e) => { console.warn( `Getting fuse pool data error: `, diff --git a/packages/ui/package.json b/packages/ui/package.json index 003030a447..9aba521e27 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -33,8 +33,8 @@ "@radix-ui/react-tabs": "^1.1.1", "@radix-ui/react-toast": "^1.2.2", "@radix-ui/react-tooltip": "^1.1.3", - "@reown/appkit": "^1.2.0", - "@reown/appkit-adapter-wagmi": "^1.2.0", + "@reown/appkit": "^1.6.1", + "@reown/appkit-adapter-wagmi": "^1.6.1", "@sentry/nextjs": "^8.35.0", "@supabase/supabase-js": "^2.45.6", "@tanstack/react-query": "^5.59.16", diff --git a/packages/ui/public/img/logo/SUPERSEED.png b/packages/ui/public/img/logo/SUPERSEED.png new file mode 100644 index 0000000000..a303c33762 Binary files /dev/null and b/packages/ui/public/img/logo/SUPERSEED.png differ diff --git a/packages/ui/types/ChainMetaData.ts b/packages/ui/types/ChainMetaData.ts index 0eba5e5b0f..0da2a66b7a 100644 --- a/packages/ui/types/ChainMetaData.ts +++ b/packages/ui/types/ChainMetaData.ts @@ -6,7 +6,8 @@ import { mode, optimism, fraxtal, - lisk + lisk, + superseed } from '@ionicprotocol/chains'; import type { IonicPoolData } from '@ionicprotocol/types'; @@ -36,6 +37,10 @@ export const supportedChainIdToConfig: { [lisk.chainId]: { enabled: config.isLiskEnabled, supported: config.isLiskEnabled + }, + [superseed.chainId]: { + enabled: config.isSuperseedEnabled, + supported: config.isSuperseedEnabled } }; diff --git a/packages/ui/utils/networkData.ts b/packages/ui/utils/networkData.ts index e267db0b97..dc93f96b69 100644 --- a/packages/ui/utils/networkData.ts +++ b/packages/ui/utils/networkData.ts @@ -4,7 +4,8 @@ import { optimism as vOptimism, bob as vBob, fraxtal as vFraxtal, - lisk as vLisk + lisk as vLisk, + superseed as vSuperseed } from 'viem/chains'; import { config } from '@ui/config/index'; @@ -18,7 +19,8 @@ import { optimism, bob, fraxtal, - lisk + lisk, + superseed } from '@ionicprotocol/chains'; import { SupportedChains } from '@ionicprotocol/types'; import type { @@ -95,6 +97,10 @@ export function getEnabledChains() { enabledChains.push(vLisk); } + if (config.isSuperseedEnabled) { + enabledChains.push(vSuperseed); + } + return enabledChains; } @@ -104,7 +110,8 @@ export const ChainSupportedAssets: ChainSupportedAssetsType = { [SupportedChains.optimism]: optimism.assets, [SupportedChains.bob]: bob.assets, [SupportedChains.fraxtal]: fraxtal.assets, - [SupportedChains.lisk]: lisk.assets + [SupportedChains.lisk]: lisk.assets, + [SupportedChains.superseed]: superseed.assets }; export const deployedPlugins: { [chainId: string]: DeployedPluginsType } = { @@ -113,5 +120,6 @@ export const deployedPlugins: { [chainId: string]: DeployedPluginsType } = { [SupportedChains.optimism]: optimism.deployedPlugins, [SupportedChains.bob]: bob.deployedPlugins, [SupportedChains.fraxtal]: fraxtal.deployedPlugins, - [SupportedChains.lisk]: lisk.deployedPlugins + [SupportedChains.lisk]: lisk.deployedPlugins, + [SupportedChains.superseed]: superseed.deployedPlugins }; diff --git a/yarn.lock b/yarn.lock index ec39d97d24..ec51e175c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,13 +5,6 @@ __metadata: version: 8 cacheKey: 10 -"@adraffy/ens-normalize@npm:1.10.0": - version: 1.10.0 - resolution: "@adraffy/ens-normalize@npm:1.10.0" - checksum: 10/5cdb5d2a9c9f8c0a71a7bb830967da0069cae1f1235cd41ae11147e4000f368f6958386e622cd4d52bf45c1ed3f8275056b387cba28902b83354e40ff323ecde - languageName: node - linkType: hard - "@adraffy/ens-normalize@npm:1.10.1": version: 1.10.1 resolution: "@adraffy/ens-normalize@npm:1.10.1" @@ -19,6 +12,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:^1.10.1": + version: 1.11.0 + resolution: "@adraffy/ens-normalize@npm:1.11.0" + checksum: 10/abef75f21470ea43dd6071168e092d2d13e38067e349e76186c78838ae174a46c3e18ca50921d05bea6ec3203074147c9e271f8cb6531d1c2c0e146f3199ddcb + languageName: node + linkType: hard + "@alloc/quick-lru@npm:^5.2.0": version: 5.2.0 resolution: "@alloc/quick-lru@npm:5.2.0" @@ -2166,7 +2166,7 @@ __metadata: typescript: "npm:^5.5.3" typescript-eslint: "npm:^7.14.1" utf-8-validate: "npm:^6.0.4" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2200,7 +2200,7 @@ __metadata: solidity-coverage: "npm:^0.8.13" ts-node: "npm:^10.9.2" typescript: "npm:^5.5.3" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2242,7 +2242,7 @@ __metadata: rimraf: "npm:^5.0.7" ts-node: "npm:^10.9.2" typescript: "npm:^5.5.3" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2275,7 +2275,7 @@ __metadata: rimraf: "npm:^5.0.7" sinon: "npm:^14.0.0" typescript: "npm:^5.5.3" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2300,7 +2300,7 @@ __metadata: rimraf: "npm:^5.0.7" ts-node-dev: "npm:^2.0.0" typescript: "npm:^5.5.3" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2339,7 +2339,7 @@ __metadata: ts-node: "npm:^10.9.2" typescript: "npm:^5.5.3" utf-8-validate: "npm:^6.0.4" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2370,7 +2370,7 @@ __metadata: ts-mocha: "npm:^10.0.0" typescript: "npm:^5.5.3" utf-8-validate: "npm:^5.0.9" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2386,7 +2386,7 @@ __metadata: tsup: "npm:^8.1.0" typescript: "npm:^5.5.3" utf-8-validate: "npm:^6.0.4" - viem: "npm:^2.21.12" + viem: "npm:^2.21.55" languageName: unknown linkType: soft @@ -2418,8 +2418,8 @@ __metadata: "@radix-ui/react-tabs": "npm:^1.1.1" "@radix-ui/react-toast": "npm:^1.2.2" "@radix-ui/react-tooltip": "npm:^1.1.3" - "@reown/appkit": "npm:^1.2.0" - "@reown/appkit-adapter-wagmi": "npm:^1.2.0" + "@reown/appkit": "npm:^1.6.1" + "@reown/appkit-adapter-wagmi": "npm:^1.6.1" "@sentry/nextjs": "npm:^8.35.0" "@supabase/supabase-js": "npm:^2.45.6" "@tanstack/react-query": "npm:^5.59.16" @@ -4092,15 +4092,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.4.0": - version: 1.4.0 - resolution: "@noble/curves@npm:1.4.0" - dependencies: - "@noble/hashes": "npm:1.4.0" - checksum: 10/b21b30a36ff02bfcc0f5e6163d245cdbaf7f640511fff97ccf83fc207ee79cfd91584b4d97977374de04cb118a55eb63a7964c82596a64162bbc42bc685ae6d9 - languageName: node - linkType: hard - "@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": version: 1.4.2 resolution: "@noble/curves@npm:1.4.2" @@ -4110,6 +4101,15 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:1.7.0, @noble/curves@npm:~1.7.0": + version: 1.7.0 + resolution: "@noble/curves@npm:1.7.0" + dependencies: + "@noble/hashes": "npm:1.6.0" + checksum: 10/2a11ef4895907d0b241bd3b72f9e6ebe56f0e705949bfd5efe003f25233549f620d287550df2d24ad56a1f953b82ec5f7cf4bd7cb78b1b2e76eb6dd516d44cf8 + languageName: node + linkType: hard + "@noble/curves@npm:^1.1.0, @noble/curves@npm:^1.4.0, @noble/curves@npm:^1.4.2": version: 1.5.0 resolution: "@noble/curves@npm:1.5.0" @@ -4149,13 +4149,27 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.5.0, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.5.0, @noble/hashes@npm:~1.5.0": +"@noble/hashes@npm:1.5.0, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.5.0": version: 1.5.0 resolution: "@noble/hashes@npm:1.5.0" checksum: 10/da7fc7af52af7afcf59810a7eea6155075464ff462ffda2572dc6d57d53e2669b1ea2ec774e814f6273f1697e567f28d36823776c9bf7068cba2a2855140f26e languageName: node linkType: hard +"@noble/hashes@npm:1.6.0": + version: 1.6.0 + resolution: "@noble/hashes@npm:1.6.0" + checksum: 10/b44b043b02adbecd33596adeed97d9f9864c24a2410f7ac3b847986c2ecf1f6f0df76024b3f1b14d6ea954932960d88898fe551fb9d39844a8b870e9f9044ea1 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.6.1, @noble/hashes@npm:~1.6.0": + version: 1.6.1 + resolution: "@noble/hashes@npm:1.6.1" + checksum: 10/74d9ad7b1437a22ba3b877584add3367587fbf818113152f293025d20d425aa74c191d18d434797312f2270458bc9ab3241c34d14ec6115fb16438b3248f631f + languageName: node + linkType: hard + "@noble/secp256k1@npm:1.7.1, @noble/secp256k1@npm:~1.7.0": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" @@ -6457,174 +6471,153 @@ __metadata: languageName: node linkType: hard -"@reown/appkit-adapter-wagmi@npm:^1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-adapter-wagmi@npm:1.2.0" - dependencies: - "@reown/appkit": "npm:1.2.0" - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-core": "npm:1.2.0" - "@reown/appkit-polyfills": "npm:1.2.0" - "@reown/appkit-scaffold-ui": "npm:1.2.0" - "@reown/appkit-siwe": "npm:1.2.0" - "@reown/appkit-ui": "npm:1.2.0" - "@reown/appkit-utils": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" - "@walletconnect/universal-provider": "npm:2.17.0" - "@walletconnect/utils": "npm:2.17.0" +"@reown/appkit-adapter-wagmi@npm:^1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-adapter-wagmi@npm:1.6.1" + dependencies: + "@reown/appkit": "npm:1.6.1" + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-core": "npm:1.6.1" + "@reown/appkit-polyfills": "npm:1.6.1" + "@reown/appkit-scaffold-ui": "npm:1.6.1" + "@reown/appkit-ui": "npm:1.6.1" + "@reown/appkit-utils": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" + "@walletconnect/universal-provider": "npm:2.17.2" + "@walletconnect/utils": "npm:2.17.2" valtio: "npm:1.11.2" peerDependencies: - "@coinbase/wallet-sdk": 4.0.3 + "@coinbase/wallet-sdk": 4.2.4 "@wagmi/connectors": ">=5.1" "@wagmi/core": ">=2.13" viem: 2.x wagmi: ">=2.12" - checksum: 10/2df4539223690e3c504887ea0e9088d2e74afed212cb324d4191478cd53b3d4ac8f4368fb2d6f123211ba6001913b891f28c33eb6cba84d7abcf55499ea3efd7 - languageName: node - linkType: hard - -"@reown/appkit-common@npm:1.1.8": - version: 1.1.8 - resolution: "@reown/appkit-common@npm:1.1.8" - dependencies: - bignumber.js: "npm:9.1.2" - dayjs: "npm:1.11.10" - viem: "npm:2.x" - checksum: 10/482c1223d926ccb769c6559f8911f6f3becb0e945f39dbeaa3dd12c747ce3462607b1d3ccb4792e136f07615963dfa56a9bccd93467f48ad62570a5cdccf0077 + checksum: 10/6d3813a447547c8995b6b919b69a49305ae2dc943974cf1528a75fc30285b2a9739dba0e346f3bcd884565408d8d820f190694761963c58551b095eef04d3c60 languageName: node linkType: hard -"@reown/appkit-common@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-common@npm:1.2.0" +"@reown/appkit-common@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-common@npm:1.6.1" dependencies: bignumber.js: "npm:9.1.2" dayjs: "npm:1.11.10" viem: "npm:2.x" - checksum: 10/f16e628d4c0ea43ebdf526165f8ca8299f51018c78184a03de1585ca90a0040c0ef9102b5b719422574621fb404137933fbad2f8f94273910a1834ae0ff0e161 + checksum: 10/c6f83484bf524406c47f900c513840223b4cf0da64939b756e2f3db9ab9728e601ec79c0f383cadc790edd4059a2eb32395049c15be2e48fb59259c4f4ff7e16 languageName: node linkType: hard -"@reown/appkit-core@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-core@npm:1.2.0" +"@reown/appkit-core@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-core@npm:1.6.1" dependencies: - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" - "@walletconnect/universal-provider": "npm:2.17.0" + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" + "@walletconnect/universal-provider": "npm:2.17.2" valtio: "npm:1.11.2" viem: "npm:2.x" - checksum: 10/efce69be7aa0bb2c77e84740ed1ddf81ca78a60572785f0c213b2d70d9c0ba2fb80024ee86cefdd38291e5a067498facb97ba05ebc4388b8f7ea6eda73e1c47e + checksum: 10/2556d6eb55099d84b303f7b883a8e37e35cb48814d469e44c507158adb463833b2f3518da29e278d0b4fcf760bcd33d402d018e706b3f4dfab92461b34fdba3c languageName: node linkType: hard -"@reown/appkit-polyfills@npm:1.1.8": - version: 1.1.8 - resolution: "@reown/appkit-polyfills@npm:1.1.8" +"@reown/appkit-polyfills@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-polyfills@npm:1.6.1" dependencies: buffer: "npm:6.0.3" - checksum: 10/877a07261e9296a5f52895f8e7b7298c63e5fe42e57f38454b34567a57166c2a81205806e17b1939082205d317c5cafe1b3f1c19b89a3c39fd376c82cc202bd1 + checksum: 10/c34edcb19c9658bf7401370961a90c1c2afd2644870e75cce11fbdc72910a33f9313425322834cec9ad4d96495d8f42c28e5cb267b7375ce5d165f6c99bf657d languageName: node linkType: hard -"@reown/appkit-polyfills@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-polyfills@npm:1.2.0" +"@reown/appkit-scaffold-ui@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-scaffold-ui@npm:1.6.1" dependencies: - buffer: "npm:6.0.3" - checksum: 10/2388f777b006977f9450380b76778f5111878bc298ff75ef8748932161053b1ff62b17c131c938df3f6c8eacb71fc146fdc088b25ef3a8f9dbeb5b723c593aba - languageName: node - linkType: hard - -"@reown/appkit-scaffold-ui@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-scaffold-ui@npm:1.2.0" - dependencies: - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-core": "npm:1.2.0" - "@reown/appkit-siwe": "npm:1.2.0" - "@reown/appkit-ui": "npm:1.2.0" - "@reown/appkit-utils": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-core": "npm:1.6.1" + "@reown/appkit-ui": "npm:1.6.1" + "@reown/appkit-utils": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" lit: "npm:3.1.0" - checksum: 10/497ebf3586715e5a796e3a1c44e178e04530197953482e0676193b42527ace889f33ef0b3e1b9d0e1cfdeebf531e0c5884e4aaebe0dece6851453a3d80e9056c + checksum: 10/d416e510512c4022c17d13966865591c98f091b4ff8eafe4ec7b34d5a18cf5374b3b9be8d4ec31a7b4dbadddf8cc605bd5f2b242647524a8c976e53965ae760c languageName: node linkType: hard -"@reown/appkit-siwe@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-siwe@npm:1.2.0" - dependencies: - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-core": "npm:1.2.0" - "@reown/appkit-ui": "npm:1.2.0" - "@reown/appkit-utils": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" - "@walletconnect/utils": "npm:2.17.0" +"@reown/appkit-siwe@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-siwe@npm:1.6.1" + dependencies: + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-core": "npm:1.6.1" + "@reown/appkit-ui": "npm:1.6.1" + "@reown/appkit-utils": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" + "@walletconnect/utils": "npm:2.17.2" lit: "npm:3.1.0" valtio: "npm:1.11.2" - checksum: 10/6bdb5b8a3a2035e275a35b03e58a4c458fb7fdb7ba3f2a6755041a68b8a4e6f1e635c1ceb8207cae99755b8e7dd7b63d1d4bce9d2b809187071ecbf654e34550 + checksum: 10/cae917a5618505f629c5b79aeca9a42b2beee1c710d85cd70d4a83b65fbdc52b6c50902e982c649e6e54b2272c9c40f3a1a5cbb8c57877a272e8b2d579c821e5 languageName: node linkType: hard -"@reown/appkit-ui@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-ui@npm:1.2.0" +"@reown/appkit-ui@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-ui@npm:1.6.1" dependencies: lit: "npm:3.1.0" qrcode: "npm:1.5.3" - checksum: 10/8c27d57b73be8866c3ccd222204c14ec5f50b609f516fa7460c91d4e050ae9dc6bba9b65c219eb09ba1a9850c0eb11b408ba7079f788ebeee68c2741ae865014 + checksum: 10/7ce3e547ac666e7563fbf9c0f016ce3500d91aa15ec0d43b5284f9dac46dc0177c5908f5556acade49cf57d9c0fa4787149371463aa49f1c0d9aacfc5a54c6d5 languageName: node linkType: hard -"@reown/appkit-utils@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-utils@npm:1.2.0" +"@reown/appkit-utils@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-utils@npm:1.6.1" dependencies: - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-core": "npm:1.2.0" - "@reown/appkit-polyfills": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-core": "npm:1.6.1" + "@reown/appkit-polyfills": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" "@walletconnect/logger": "npm:2.1.2" - "@walletconnect/universal-provider": "npm:2.17.0" + "@walletconnect/universal-provider": "npm:2.17.2" valtio: "npm:1.11.2" viem: "npm:2.x" peerDependencies: valtio: 1.11.2 - checksum: 10/0bb7585aab476e98e450fbea17b8393dee4986bf33964c88d391fd576758ea603b9e15ac7f5ddae261c05df7d07738df0856b9e85ba99389dc8e208fadb4f044 + checksum: 10/668f9eaaecebf6d6512a045d1d8b64748a773d5a394862f2a10bf6a2fcf8480eab536b493134ece43987fd0c1946d0bdff376fd3f2934d199a47695bcbd7094d languageName: node linkType: hard -"@reown/appkit-wallet@npm:1.2.0": - version: 1.2.0 - resolution: "@reown/appkit-wallet@npm:1.2.0" +"@reown/appkit-wallet@npm:1.6.1": + version: 1.6.1 + resolution: "@reown/appkit-wallet@npm:1.6.1" dependencies: - "@reown/appkit-common": "npm:1.1.8" - "@reown/appkit-polyfills": "npm:1.1.8" + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-polyfills": "npm:1.6.1" "@walletconnect/logger": "npm:2.1.2" zod: "npm:3.22.4" - checksum: 10/70ec42cdad2b0130c3ee717985ebeb985f6c74c2b8213878d4affcd88e319e74892ab47678e6939921cb83b3f426c151160fc4d228bec1b516148349824899c4 + checksum: 10/d7c4b3f298a0549303a4012b7359f9eafbd0ae94cc5094bf87d853ae2d2a963568d5871979acaa2d69540e06bbdd1ae89181cb498a02c450afdffdbec3a1b9be languageName: node linkType: hard -"@reown/appkit@npm:1.2.0, @reown/appkit@npm:^1.2.0": - version: 1.2.0 - resolution: "@reown/appkit@npm:1.2.0" - dependencies: - "@reown/appkit-common": "npm:1.2.0" - "@reown/appkit-core": "npm:1.2.0" - "@reown/appkit-polyfills": "npm:1.2.0" - "@reown/appkit-scaffold-ui": "npm:1.2.0" - "@reown/appkit-siwe": "npm:1.2.0" - "@reown/appkit-ui": "npm:1.2.0" - "@reown/appkit-utils": "npm:1.2.0" - "@reown/appkit-wallet": "npm:1.2.0" - "@walletconnect/types": "npm:2.17.0" - "@walletconnect/universal-provider": "npm:2.17.0" - "@walletconnect/utils": "npm:2.17.0" +"@reown/appkit@npm:1.6.1, @reown/appkit@npm:^1.6.1": + version: 1.6.1 + resolution: "@reown/appkit@npm:1.6.1" + dependencies: + "@reown/appkit-common": "npm:1.6.1" + "@reown/appkit-core": "npm:1.6.1" + "@reown/appkit-polyfills": "npm:1.6.1" + "@reown/appkit-scaffold-ui": "npm:1.6.1" + "@reown/appkit-siwe": "npm:1.6.1" + "@reown/appkit-ui": "npm:1.6.1" + "@reown/appkit-utils": "npm:1.6.1" + "@reown/appkit-wallet": "npm:1.6.1" + "@walletconnect/types": "npm:2.17.2" + "@walletconnect/universal-provider": "npm:2.17.2" + "@walletconnect/utils": "npm:2.17.2" + bs58: "npm:6.0.0" valtio: "npm:1.11.2" viem: "npm:2.x" - checksum: 10/44737dd4a3351c5350ba716b48608c24de24e78be118ee12b4d7df81a978f968722763b6744661564532b6d24029bb8cb0a19d5fed46ddd10f5872240ce40e42 + checksum: 10/324b72e570a1d5a9d1358fb8571deefc060497f395a77ae69da1c545ec6b76dab77ce25dfe16e743807224e08bed48e8f26a7af0f3d9b4b1695c842096a26c4f languageName: node linkType: hard @@ -6844,10 +6837,10 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.8": - version: 1.1.9 - resolution: "@scure/base@npm:1.1.9" - checksum: 10/f0ab7f687bbcdee2a01377fe3cd808bf63977999672751295b6a92625d5322f4754a96d40f6bd579bc367aad48ecf8a4e6d0390e70296e6ded1076f52adb16bb +"@scure/base@npm:~1.2.1": + version: 1.2.1 + resolution: "@scure/base@npm:1.2.1" + checksum: 10/f7bdd17618ccae7a74c8cbe410a235e4adbe54aa8afe4e2fb1294338aa92f6fd04b1f1f5dea60552f638b5f5e3e74902b7baf59d3954e5e42c0a36c6baa2ebe0 languageName: node linkType: hard @@ -6873,6 +6866,17 @@ __metadata: languageName: node linkType: hard +"@scure/bip32@npm:1.6.0, @scure/bip32@npm:^1.5.0": + version: 1.6.0 + resolution: "@scure/bip32@npm:1.6.0" + dependencies: + "@noble/curves": "npm:~1.7.0" + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/2efb81ed9a7b8d5d35233e10abebc114544a3783a2a32b9fb60e1e9a67965b272c9d17910e1649083b69c8ceb80241b05b59dbeb7a5b18ea34e497aed3f16709 + languageName: node + linkType: hard + "@scure/bip39@npm:1.1.1": version: 1.1.1 resolution: "@scure/bip39@npm:1.1.1" @@ -6893,13 +6897,13 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.4.0": - version: 1.4.0 - resolution: "@scure/bip39@npm:1.4.0" +"@scure/bip39@npm:1.5.0, @scure/bip39@npm:^1.4.0": + version: 1.5.0 + resolution: "@scure/bip39@npm:1.5.0" dependencies: - "@noble/hashes": "npm:~1.5.0" - "@scure/base": "npm:~1.1.8" - checksum: 10/f86e0e79768c95bc684ed6de92892b1a6f228db0f8fab836f091c0ec0f6d1e291b8c4391cfbeaa9ea83f41045613535b1940cd10e7d780a5b73db163b1e7f151 + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/b795ee31ac4c10603bf3b726cc0e5cf43834a68f05a535e0baf2162772bac100de470b4c6cf7ddbecb95d7a3fb82b8a959badced406c329ab696cd89104194bc languageName: node linkType: hard @@ -9374,6 +9378,31 @@ __metadata: languageName: node linkType: hard +"@walletconnect/core@npm:2.17.2": + version: 2.17.2 + resolution: "@walletconnect/core@npm:2.17.2" + dependencies: + "@walletconnect/heartbeat": "npm:1.2.2" + "@walletconnect/jsonrpc-provider": "npm:1.0.14" + "@walletconnect/jsonrpc-types": "npm:1.0.4" + "@walletconnect/jsonrpc-utils": "npm:1.0.8" + "@walletconnect/jsonrpc-ws-connection": "npm:1.0.14" + "@walletconnect/keyvaluestorage": "npm:1.1.1" + "@walletconnect/logger": "npm:2.1.2" + "@walletconnect/relay-api": "npm:1.0.11" + "@walletconnect/relay-auth": "npm:1.0.4" + "@walletconnect/safe-json": "npm:1.0.2" + "@walletconnect/time": "npm:1.0.2" + "@walletconnect/types": "npm:2.17.2" + "@walletconnect/utils": "npm:2.17.2" + "@walletconnect/window-getters": "npm:1.0.1" + events: "npm:3.3.0" + lodash.isequal: "npm:4.5.0" + uint8arrays: "npm:3.1.0" + checksum: 10/331417457e17e0b0dc4bd805ecd450407ecd50b8c79609b43c7f664a7f9024d490e9d75ed52fb717a44ebc1a12721cc6cfa11d6cfe698af1439755224e225b11 + languageName: node + linkType: hard + "@walletconnect/environment@npm:^1.0.1": version: 1.0.1 resolution: "@walletconnect/environment@npm:1.0.1" @@ -9584,6 +9613,23 @@ __metadata: languageName: node linkType: hard +"@walletconnect/sign-client@npm:2.17.2": + version: 2.17.2 + resolution: "@walletconnect/sign-client@npm:2.17.2" + dependencies: + "@walletconnect/core": "npm:2.17.2" + "@walletconnect/events": "npm:1.0.1" + "@walletconnect/heartbeat": "npm:1.2.2" + "@walletconnect/jsonrpc-utils": "npm:1.0.8" + "@walletconnect/logger": "npm:2.1.2" + "@walletconnect/time": "npm:1.0.2" + "@walletconnect/types": "npm:2.17.2" + "@walletconnect/utils": "npm:2.17.2" + events: "npm:3.3.0" + checksum: 10/8612aaf1f527d652649babf55e7b735b61cbfc2160f56093f81f7903b5443a22f4ee7a063d2545835a9e869c1bc82034236e221124e3a816858a102275c2fb2d + languageName: node + linkType: hard + "@walletconnect/time@npm:1.0.2, @walletconnect/time@npm:^1.0.2": version: 1.0.2 resolution: "@walletconnect/time@npm:1.0.2" @@ -9607,6 +9653,20 @@ __metadata: languageName: node linkType: hard +"@walletconnect/types@npm:2.17.2": + version: 2.17.2 + resolution: "@walletconnect/types@npm:2.17.2" + dependencies: + "@walletconnect/events": "npm:1.0.1" + "@walletconnect/heartbeat": "npm:1.2.2" + "@walletconnect/jsonrpc-types": "npm:1.0.4" + "@walletconnect/keyvaluestorage": "npm:1.1.1" + "@walletconnect/logger": "npm:2.1.2" + events: "npm:3.3.0" + checksum: 10/a668ab7a88b9f5904833f9e0b1bc5ac7501a5bdfdd1c84774464e399f337e31e61da90982bb9bf022ef91398b5e15d74ef368625cce38902c6a7cffb255d46fd + languageName: node + linkType: hard + "@walletconnect/universal-provider@npm:2.17.0": version: 2.17.0 resolution: "@walletconnect/universal-provider@npm:2.17.0" @@ -9624,6 +9684,26 @@ __metadata: languageName: node linkType: hard +"@walletconnect/universal-provider@npm:2.17.2": + version: 2.17.2 + resolution: "@walletconnect/universal-provider@npm:2.17.2" + dependencies: + "@walletconnect/events": "npm:1.0.1" + "@walletconnect/jsonrpc-http-connection": "npm:1.0.8" + "@walletconnect/jsonrpc-provider": "npm:1.0.14" + "@walletconnect/jsonrpc-types": "npm:1.0.4" + "@walletconnect/jsonrpc-utils": "npm:1.0.8" + "@walletconnect/keyvaluestorage": "npm:1.1.1" + "@walletconnect/logger": "npm:2.1.2" + "@walletconnect/sign-client": "npm:2.17.2" + "@walletconnect/types": "npm:2.17.2" + "@walletconnect/utils": "npm:2.17.2" + events: "npm:3.3.0" + lodash: "npm:4.17.21" + checksum: 10/7081d7927df86bea80e056c497db468668369dc2020735da8ff5e687f95504e2b26e667d46bc39617db5141d42279b85a27deee699b046ab634e0f4cfd89e821 + languageName: node + linkType: hard + "@walletconnect/utils@npm:2.17.0": version: 2.17.0 resolution: "@walletconnect/utils@npm:2.17.0" @@ -9648,6 +9728,34 @@ __metadata: languageName: node linkType: hard +"@walletconnect/utils@npm:2.17.2": + version: 2.17.2 + resolution: "@walletconnect/utils@npm:2.17.2" + dependencies: + "@ethersproject/hash": "npm:5.7.0" + "@ethersproject/transactions": "npm:5.7.0" + "@stablelib/chacha20poly1305": "npm:1.0.1" + "@stablelib/hkdf": "npm:1.0.1" + "@stablelib/random": "npm:1.0.2" + "@stablelib/sha256": "npm:1.0.1" + "@stablelib/x25519": "npm:1.0.3" + "@walletconnect/jsonrpc-utils": "npm:1.0.8" + "@walletconnect/keyvaluestorage": "npm:1.1.1" + "@walletconnect/relay-api": "npm:1.0.11" + "@walletconnect/relay-auth": "npm:1.0.4" + "@walletconnect/safe-json": "npm:1.0.2" + "@walletconnect/time": "npm:1.0.2" + "@walletconnect/types": "npm:2.17.2" + "@walletconnect/window-getters": "npm:1.0.1" + "@walletconnect/window-metadata": "npm:1.0.1" + detect-browser: "npm:5.3.0" + elliptic: "npm:6.6.0" + query-string: "npm:7.1.3" + uint8arrays: "npm:3.1.0" + checksum: 10/4d43adf7c5d21cc3916a797ff704fa348c7ef9d54184e16f6a9ee8b7d3aa3e58861b1c3a8c6c7bdc5137de67da822689f0035838a4d57d50a03834920cada4b4 + languageName: node + linkType: hard + "@walletconnect/window-getters@npm:1.0.1, @walletconnect/window-getters@npm:^1.0.1": version: 1.0.1 resolution: "@walletconnect/window-getters@npm:1.0.1" @@ -9788,9 +9896,9 @@ __metadata: languageName: node linkType: hard -"abitype@npm:1.0.5": - version: 1.0.5 - resolution: "abitype@npm:1.0.5" +"abitype@npm:1.0.7, abitype@npm:^1.0.6": + version: 1.0.7 + resolution: "abitype@npm:1.0.7" peerDependencies: typescript: ">=5.0.4" zod: ^3 >=3.22.0 @@ -9799,7 +9907,7 @@ __metadata: optional: true zod: optional: true - checksum: 10/1acd0d9687945dd78442b71bd84ff3b9dceae27d15f0d8b14b16554a0c8c9518eeb971ff8e94d507f4d9f05a8a8b91eb8fafd735eaecebac37d5c5a4aac06d8e + checksum: 10/6c2c3390a2f90186bf0df73f20cf257dfd9b62d1eb266de6ddf362030dcbd79cd113b4110e52f7802d7b042ea8fdb7ee2f113751b883787c2d9589d56fb4273b languageName: node linkType: hard @@ -11134,6 +11242,15 @@ __metadata: languageName: node linkType: hard +"bs58@npm:6.0.0, bs58@npm:^6.0.0": + version: 6.0.0 + resolution: "bs58@npm:6.0.0" + dependencies: + base-x: "npm:^5.0.0" + checksum: 10/7c9bb2b2d93d997a8c652de3510d89772007ac64ee913dc4e16ba7ff47624caad3128dcc7f360763eb6308760c300b3e9fd91b8bcbd489acd1a13278e7949c4e + languageName: node + linkType: hard + "bs58@npm:^4.0.0, bs58@npm:^4.0.1": version: 4.0.1 resolution: "bs58@npm:4.0.1" @@ -11152,15 +11269,6 @@ __metadata: languageName: node linkType: hard -"bs58@npm:^6.0.0": - version: 6.0.0 - resolution: "bs58@npm:6.0.0" - dependencies: - base-x: "npm:^5.0.0" - checksum: 10/7c9bb2b2d93d997a8c652de3510d89772007ac64ee913dc4e16ba7ff47624caad3128dcc7f360763eb6308760c300b3e9fd91b8bcbd489acd1a13278e7949c4e - languageName: node - linkType: hard - "bs58check@npm:^2.1.2": version: 2.1.2 resolution: "bs58check@npm:2.1.2" @@ -13312,6 +13420,21 @@ __metadata: languageName: node linkType: hard +"elliptic@npm:6.6.0": + version: 6.6.0 + resolution: "elliptic@npm:6.6.0" + dependencies: + bn.js: "npm:^4.11.9" + brorand: "npm:^1.1.0" + hash.js: "npm:^1.0.0" + hmac-drbg: "npm:^1.0.1" + inherits: "npm:^2.0.4" + minimalistic-assert: "npm:^1.0.1" + minimalistic-crypto-utils: "npm:^1.0.1" + checksum: 10/27575b0403e010e5d7e7a131fcadce6a7dd1ae82ccb24cc7c20b275d32ab1cb7ecb6a070225795df08407441dc8c7a32efd986596d48d1d6846f64ff8f094af7 + languageName: node + linkType: hard + "elliptic@npm:^6.5.2, elliptic@npm:^6.5.4, elliptic@npm:^6.5.7": version: 6.5.7 resolution: "elliptic@npm:6.5.7" @@ -17946,12 +18069,12 @@ __metadata: languageName: node linkType: hard -"isows@npm:1.0.4": - version: 1.0.4 - resolution: "isows@npm:1.0.4" +"isows@npm:1.0.6": + version: 1.0.6 + resolution: "isows@npm:1.0.6" peerDependencies: ws: "*" - checksum: 10/a3ee62e3d6216abb3adeeb2a551fe2e7835eac87b05a6ecc3e7739259bf5f8e83290501f49e26137390c8093f207fc3378d4a7653aab76ad7bbab4b2dba9c5b9 + checksum: 10/ab9e85b50bcc3d70aa5ec875aa2746c5daf9321cb376ed4e5434d3c2643c5d62b1f466d93a05cd2ad0ead5297224922748c31707cb4fbd68f5d05d0479dce99c languageName: node linkType: hard @@ -21187,6 +21310,26 @@ __metadata: languageName: node linkType: hard +"ox@npm:0.1.2": + version: 0.1.2 + resolution: "ox@npm:0.1.2" + dependencies: + "@adraffy/ens-normalize": "npm:^1.10.1" + "@noble/curves": "npm:^1.6.0" + "@noble/hashes": "npm:^1.5.0" + "@scure/bip32": "npm:^1.5.0" + "@scure/bip39": "npm:^1.4.0" + abitype: "npm:^1.0.6" + eventemitter3: "npm:5.0.1" + peerDependencies: + typescript: ">=5.4.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/cba00f13289599ff03cee3dbc19167c1d0f01829379d119f962b4e951ee2bf0d14491c7a45974e6a2a745117b13b22e9e4131d285e1f5247ea4e1cbc43c5c3d8 + languageName: node + linkType: hard + "p-cancelable@npm:^3.0.0": version: 3.0.0 resolution: "p-cancelable@npm:3.0.0" @@ -26697,25 +26840,25 @@ __metadata: languageName: node linkType: hard -"viem@npm:^2.21.12": - version: 2.21.12 - resolution: "viem@npm:2.21.12" +"viem@npm:^2.21.55": + version: 2.21.55 + resolution: "viem@npm:2.21.55" dependencies: - "@adraffy/ens-normalize": "npm:1.10.0" - "@noble/curves": "npm:1.4.0" - "@noble/hashes": "npm:1.4.0" - "@scure/bip32": "npm:1.4.0" - "@scure/bip39": "npm:1.4.0" - abitype: "npm:1.0.5" - isows: "npm:1.0.4" - webauthn-p256: "npm:0.0.5" - ws: "npm:8.17.1" + "@noble/curves": "npm:1.7.0" + "@noble/hashes": "npm:1.6.1" + "@scure/bip32": "npm:1.6.0" + "@scure/bip39": "npm:1.5.0" + abitype: "npm:1.0.7" + isows: "npm:1.0.6" + ox: "npm:0.1.2" + webauthn-p256: "npm:0.0.10" + ws: "npm:8.18.0" peerDependencies: typescript: ">=5.0.4" peerDependenciesMeta: typescript: optional: true - checksum: 10/01caf655cb906ab040b0aa7acd88050d5447bcd3e7cdb167aa8f9212620890d4ce9ffe72254268887f60dc3670c1225d7a8b7466b0e72ed97cdbb93034d8b43f + checksum: 10/4fbcac7d9c909b3807a49a271343f60d70f0f5c42dabc7971de3bed3f619a7bdfe6e9820457477131b0c4c59e4c8de8f36d562b0642534bb35fd1b4961ba5775 languageName: node linkType: hard @@ -26790,13 +26933,13 @@ __metadata: languageName: node linkType: hard -"webauthn-p256@npm:0.0.5": - version: 0.0.5 - resolution: "webauthn-p256@npm:0.0.5" +"webauthn-p256@npm:0.0.10": + version: 0.0.10 + resolution: "webauthn-p256@npm:0.0.10" dependencies: "@noble/curves": "npm:^1.4.0" "@noble/hashes": "npm:^1.4.0" - checksum: 10/6bf5d1857dfb99ecb3b318af06eddea874c10135e6ebb9f046270f5cbb162933bc6caf77aedb033e14c09971dda544a5fb367ac545e4ec8001b309ba517555cf + checksum: 10/dde2b6313b6a0f20996f7ee90181258fc7685bfff401df7d904578da75b374f25d5b9c1189cd2fcec30625b1f276b393188d156d49783f0611623cd713bb5b09 languageName: node linkType: hard @@ -27182,33 +27325,33 @@ __metadata: languageName: node linkType: hard -"ws@npm:^7.4.6, ws@npm:^7.5.1, ws@npm:^7.5.10": - version: 7.5.10 - resolution: "ws@npm:7.5.10" +"ws@npm:8.18.0, ws@npm:^8.14.2, ws@npm:^8.16.0, ws@npm:^8.5.0, ws@npm:^8.6.0": + version: 8.18.0 + resolution: "ws@npm:8.18.0" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 + utf-8-validate: ">=5.0.2" peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 + checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 languageName: node linkType: hard -"ws@npm:^8.14.2, ws@npm:^8.16.0, ws@npm:^8.5.0, ws@npm:^8.6.0": - version: 8.18.0 - resolution: "ws@npm:8.18.0" +"ws@npm:^7.4.6, ws@npm:^7.5.1, ws@npm:^7.5.10": + version: 7.5.10 + resolution: "ws@npm:7.5.10" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" + utf-8-validate: ^5.0.2 peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 + checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 languageName: node linkType: hard